@kushagradhawan/kookie-ui 0.1.52 → 0.1.54
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/components.css +72 -72
- package/dist/cjs/components/_internal/shell-bottom.js.map +2 -2
- package/dist/cjs/components/_internal/shell-handles.js +1 -1
- package/dist/cjs/components/_internal/shell-handles.js.map +3 -3
- package/dist/cjs/components/_internal/shell-inspector.js.map +2 -2
- package/dist/cjs/components/_internal/shell-sidebar.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-sidebar.js +1 -1
- package/dist/cjs/components/_internal/shell-sidebar.js.map +2 -2
- package/dist/cjs/components/chatbar.d.ts.map +1 -1
- package/dist/cjs/components/chatbar.js +1 -1
- package/dist/cjs/components/chatbar.js.map +3 -3
- package/dist/cjs/components/shell.hooks.js +1 -1
- package/dist/cjs/components/shell.hooks.js.map +2 -2
- package/dist/cjs/components/shell.js +1 -1
- package/dist/cjs/components/shell.js.map +3 -3
- package/dist/cjs/components/shell.types.d.ts +2 -2
- package/dist/cjs/components/shell.types.d.ts.map +1 -1
- package/dist/cjs/components/shell.types.js +1 -1
- package/dist/cjs/components/shell.types.js.map +3 -3
- package/dist/esm/components/_internal/shell-bottom.js.map +2 -2
- package/dist/esm/components/_internal/shell-handles.js +1 -1
- package/dist/esm/components/_internal/shell-handles.js.map +3 -3
- package/dist/esm/components/_internal/shell-inspector.js.map +2 -2
- package/dist/esm/components/_internal/shell-sidebar.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-sidebar.js +1 -1
- package/dist/esm/components/_internal/shell-sidebar.js.map +2 -2
- package/dist/esm/components/chatbar.d.ts.map +1 -1
- package/dist/esm/components/chatbar.js +1 -1
- package/dist/esm/components/chatbar.js.map +3 -3
- package/dist/esm/components/shell.hooks.js +1 -1
- package/dist/esm/components/shell.hooks.js.map +3 -3
- package/dist/esm/components/shell.js +1 -1
- package/dist/esm/components/shell.js.map +3 -3
- package/dist/esm/components/shell.types.d.ts +2 -2
- package/dist/esm/components/shell.types.d.ts.map +1 -1
- package/dist/esm/components/shell.types.js +1 -1
- package/dist/esm/components/shell.types.js.map +3 -3
- package/package.json +1 -1
- package/schemas/base-button.json +1 -1
- package/schemas/button.json +1 -1
- package/schemas/icon-button.json +1 -1
- package/schemas/index.json +6 -6
- package/schemas/toggle-button.json +1 -1
- package/schemas/toggle-icon-button.json +1 -1
- package/src/components/_internal/shell-bottom.tsx +1 -1
- package/src/components/_internal/shell-handles.tsx +1 -1
- package/src/components/_internal/shell-inspector.tsx +1 -1
- package/src/components/_internal/shell-sidebar.tsx +2 -2
- package/src/components/chatbar.css +15 -12
- package/src/components/chatbar.tsx +7 -5
- package/src/components/shell.hooks.ts +3 -3
- package/src/components/shell.tsx +14 -14
- package/src/components/shell.types.ts +2 -2
- package/styles.css +72 -72
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as i from"react";import B from"classnames";import{usePaneResize as X}from"./shell-resize.js";const P=i.forwardRef(({className:c,children:d,...I},W)=>{const{containerRef:R,cssVarName:u,minSize:x,maxSize:H,defaultSize:C,orientation:y,edge:T,computeNext:F,onResize:h,onResizeStart:M,onResizeEnd:
|
|
1
|
+
import*as i from"react";import B from"classnames";import{usePaneResize as X}from"./shell-resize.js";const P=i.forwardRef(({className:c,children:d,...I},W)=>{const{containerRef:R,cssVarName:u,minSize:x,maxSize:H,defaultSize:C,orientation:y,edge:T,computeNext:F,onResize:h,onResizeStart:M,onResizeEnd:g,snapPoints:D,snapTolerance:K,collapseThreshold:z,collapsible:A,target:G,requestCollapse:V,requestToggle:U}=X(),S=i.useRef(null);i.useEffect(()=>()=>{try{S.current?.()}catch{}S.current=null},[]);const q=y;return i.createElement("div",{...I,ref:W,className:B("rt-ShellResizer",c),"data-orientation":y,"data-edge":T,role:"slider","aria-orientation":q,"aria-valuemin":x,"aria-valuemax":H,"aria-valuenow":C,tabIndex:0,onPointerDown:e=>{if(!R.current)return;e.preventDefault();const n=R.current,l=e.currentTarget,b=e.pointerId;try{S.current?.()}catch{}n.setAttribute("data-resizing","");try{l.setPointerCapture(b)}catch{}const w=y==="vertical"?e.clientX:e.clientY,p=parseFloat(getComputedStyle(n).getPropertyValue(u)||`${C}`),m=s=>Math.min(Math.max(s,x),H),r=document.body,t=r.style.cursor,v=r.style.userSelect;r.style.cursor=y==="vertical"?"col-resize":"row-resize",r.style.userSelect="none",M?.(p);const a=s=>{const f=y==="vertical"?s.clientX:s.clientY,L=m(F(f,w,p));n.style.setProperty(u,`${L}px`),l.setAttribute("aria-valuenow",String(L)),h?.(L)},E=()=>{try{l.releasePointerCapture(b)}catch{}window.removeEventListener("pointermove",a),document.removeEventListener("pointermove",a),window.removeEventListener("mousemove",a),document.removeEventListener("mousemove",a),l.removeEventListener("pointermove",a),window.removeEventListener("pointerup",o),document.removeEventListener("pointerup",o),window.removeEventListener("mouseup",o),document.removeEventListener("mouseup",o),window.removeEventListener("pointercancel",o),document.removeEventListener("pointercancel",o),window.removeEventListener("keydown",N),l.removeEventListener("lostpointercapture",o),n.removeAttribute("data-resizing"),r.style.cursor=t,r.style.userSelect=v,S.current=null},o=()=>{const s=parseFloat(getComputedStyle(n).getPropertyValue(u)||`${C}`);let f=s;if(D&&D.length){const L=D.reduce((k,$)=>Math.abs($-s)<Math.abs(k-s)?$:k,D[0]);Math.abs(L-s)<=(K??8)&&(f=L,n.style.setProperty(u,`${f}px`),l.setAttribute("aria-valuenow",String(f)),h?.(f))}A&&typeof z=="number"&&s<=z&&V?.(),g?.(f),E()},N=s=>{s.key==="Escape"&&(n.style.setProperty(u,`${p}px`),l.setAttribute("aria-valuenow",String(p)),g?.(p),E())};window.addEventListener("pointermove",a),document.addEventListener("pointermove",a),window.addEventListener("mousemove",a),document.addEventListener("mousemove",a),l.addEventListener("pointermove",a),window.addEventListener("pointerup",o),document.addEventListener("pointerup",o),window.addEventListener("mouseup",o),document.addEventListener("mouseup",o),window.addEventListener("pointercancel",o),document.addEventListener("pointercancel",o),window.addEventListener("keydown",N),l.addEventListener("lostpointercapture",o),S.current=E},onDoubleClick:()=>{A&&U?.()},onKeyDown:e=>{if(!R.current)return;const n=R.current,l=getComputedStyle(n).getPropertyValue(u),b=Number.parseFloat(l.trim()),w=Number.isFinite(b)?b:C,p=t=>Math.min(Math.max(t,x),H),m=e.shiftKey?32:8;let r=0;if(y==="vertical"){const t=typeof document<"u"?document.dir:void 0,v=getComputedStyle(n).direction,a=!!(n.closest&&n.closest('[dir="rtl"]')),E=t==="rtl"||v==="rtl"||a;e.key==="ArrowRight"?r=E?-m:m:e.key==="ArrowLeft"&&(r=E?m:-m)}else e.key==="ArrowDown"?r=m:e.key==="ArrowUp"&&(r=-m);if(e.key==="Home"){e.preventDefault(),M?.(w);const t=p(x);n.style.setProperty(u,`${t}px`),e.currentTarget.setAttribute("aria-valuenow",String(t)),h?.(t),g?.(t);return}if(e.key==="End"){e.preventDefault(),M?.(w);const t=p(H);n.style.setProperty(u,`${t}px`),e.currentTarget.setAttribute("aria-valuenow",String(t)),h?.(t),g?.(t);return}if(r!==0){e.preventDefault(),M?.(w);const t=y==="vertical"&&T==="start"?-r:r,v=p(w+t);n.style.setProperty(u,`${v}px`),e.currentTarget.setAttribute("aria-valuenow",String(v)),h?.(v),g?.(v)}}},d)});P.displayName="Shell.Handle";const Y=i.forwardRef((c,d)=>i.createElement(P,{...c,ref:d}));Y.displayName="Shell.Panel.Handle";const O=i.forwardRef((c,d)=>i.createElement(P,{...c,ref:d}));O.displayName="Shell.Sidebar.Handle";const _=i.forwardRef((c,d)=>i.createElement(P,{...c,ref:d}));_.displayName="Shell.Inspector.Handle";const j=i.forwardRef((c,d)=>i.createElement(P,{...c,ref:d}));j.displayName="Shell.Bottom.Handle";export{j as BottomHandle,_ as InspectorHandle,P as PaneHandle,Y as PanelHandle,O as SidebarHandle};
|
|
2
2
|
//# sourceMappingURL=shell-handles.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/_internal/shell-handles.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport { usePaneResize } from './shell-resize.js';\n\nexport const PaneHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>(({ className, children, ...props }, ref) => {\n const {\n containerRef,\n cssVarName,\n minSize,\n maxSize,\n defaultSize,\n orientation,\n edge,\n computeNext,\n onResize,\n onResizeStart,\n onResizeEnd,\n snapPoints,\n snapTolerance,\n collapseThreshold,\n collapsible,\n target,\n requestCollapse,\n requestToggle,\n } = usePaneResize();\n\n const activeCleanupRef = React.useRef<(() => void) | null>(null);\n React.useEffect(\n () => () => {\n try {\n activeCleanupRef.current?.();\n } catch {}\n activeCleanupRef.current = null;\n },\n [],\n );\n\n const ariaOrientation = orientation;\n\n return (\n <div\n {...props}\n ref={ref}\n className={classNames('rt-ShellResizer', className)}\n data-orientation={orientation}\n data-edge={edge}\n role=\"slider\"\n aria-orientation={ariaOrientation}\n aria-valuemin={minSize}\n aria-valuemax={maxSize}\n aria-valuenow={defaultSize}\n tabIndex={0}\n onPointerDown={(e) => {\n if (!containerRef.current) return;\n e.preventDefault();\n const container = containerRef.current;\n const handleEl = e.currentTarget as HTMLElement;\n const pointerId = e.pointerId;\n try {\n activeCleanupRef.current?.();\n } catch {}\n container.setAttribute('data-resizing', '');\n try {\n handleEl.setPointerCapture(pointerId);\n } catch {}\n const startClient = orientation === 'vertical' ? e.clientX : e.clientY;\n const startSize = parseFloat(getComputedStyle(container).getPropertyValue(cssVarName) || `${defaultSize}`);\n const clamp = (v: number) => Math.min(Math.max(v, minSize), maxSize);\n const body = document.body;\n const prevCursor = body.style.cursor;\n const prevUserSelect = body.style.userSelect;\n body.style.cursor = orientation === 'vertical' ? 'col-resize' : 'row-resize';\n body.style.userSelect = 'none';\n onResizeStart?.(startSize);\n const handleMove = (ev: PointerEvent) => {\n const client = orientation === 'vertical' ? ev.clientX : ev.clientY;\n const next = clamp(computeNext(client, startClient, startSize));\n container.style.setProperty(cssVarName, `${next}px`);\n handleEl.setAttribute('aria-valuenow', String(next));\n onResize?.(next);\n };\n const cleanup = () => {\n try {\n handleEl.releasePointerCapture(pointerId);\n } catch {}\n window.removeEventListener('pointermove', handleMove as any);\n document.removeEventListener('pointermove', handleMove as any);\n window.removeEventListener('mousemove', handleMove as any);\n document.removeEventListener('mousemove', handleMove as any);\n handleEl.removeEventListener('pointermove', handleMove as any);\n window.removeEventListener('pointerup', handleUp as any);\n document.removeEventListener('pointerup', handleUp as any);\n window.removeEventListener('mouseup', handleUp as any);\n document.removeEventListener('mouseup', handleUp as any);\n window.removeEventListener('pointercancel', handleUp as any);\n document.removeEventListener('pointercancel', handleUp as any);\n window.removeEventListener('keydown', handleKey as any);\n handleEl.removeEventListener('lostpointercapture', handleUp as any);\n container.removeAttribute('data-resizing');\n body.style.cursor = prevCursor;\n body.style.userSelect = prevUserSelect;\n activeCleanupRef.current = null;\n };\n const handleUp = () => {\n const finalSize = parseFloat(getComputedStyle(container).getPropertyValue(cssVarName) || `${defaultSize}`);\n let snapped = finalSize;\n if (snapPoints && snapPoints.length) {\n const nearest = snapPoints.reduce((acc, p) => (Math.abs(p - finalSize) < Math.abs(acc - finalSize) ? p : acc), snapPoints[0]);\n if (Math.abs(nearest - finalSize) <= (snapTolerance ?? 8)) {\n snapped = nearest;\n container.style.setProperty(cssVarName, `${snapped}px`);\n handleEl.setAttribute('aria-valuenow', String(snapped));\n onResize?.(snapped);\n }\n }\n if (collapsible && typeof collapseThreshold === 'number' && finalSize <= collapseThreshold) {\n requestCollapse?.();\n }\n onResizeEnd?.(snapped);\n cleanup();\n };\n const handleKey = (kev: KeyboardEvent) => {\n if (kev.key === 'Escape') {\n container.style.setProperty(cssVarName, `${startSize}px`);\n handleEl.setAttribute('aria-valuenow', String(startSize));\n onResizeEnd?.(startSize);\n cleanup();\n }\n };\n window.addEventListener('pointermove', handleMove as any);\n document.addEventListener('pointermove', handleMove as any);\n // Fallbacks for environments that don't fully support PointerEvent on window\n window.addEventListener('mousemove', handleMove as any);\n document.addEventListener('mousemove', handleMove as any);\n handleEl.addEventListener('pointermove', handleMove as any);\n window.addEventListener('pointerup', handleUp as any);\n document.addEventListener('pointerup', handleUp as any);\n window.addEventListener('mouseup', handleUp as any);\n document.addEventListener('mouseup', handleUp as any);\n window.addEventListener('pointercancel', handleUp as any);\n document.addEventListener('pointercancel', handleUp as any);\n window.addEventListener('keydown', handleKey as any);\n handleEl.addEventListener('lostpointercapture', handleUp as any);\n activeCleanupRef.current = cleanup;\n }}\n onDoubleClick={() => {\n if (collapsible) requestToggle?.();\n }}\n onKeyDown={(e) => {\n if (!containerRef.current) return;\n const container = containerRef.current;\n const rawCurrent = getComputedStyle(container).getPropertyValue(cssVarName);\n const parsedCurrent = Number.parseFloat(rawCurrent.trim());\n const current = Number.isFinite(parsedCurrent) ? parsedCurrent : defaultSize;\n const clamp = (v: number) => Math.min(Math.max(v, minSize), maxSize);\n const step = e.shiftKey ? 32 : 8;\n let delta = 0;\n if (orientation === 'vertical') {\n const docDir = typeof document !== 'undefined' ? document.dir : undefined;\n const cssDir = getComputedStyle(container).direction;\n const hasRtlAncestor = !!(container.closest && container.closest('[dir=\"rtl\"]'));\n const isRtl = docDir === 'rtl' || cssDir === 'rtl' || hasRtlAncestor;\n if (e.key === 'ArrowRight')\n delta = isRtl ? -step : step; // inline-end\n else if (e.key === 'ArrowLeft') delta = isRtl ? step : -step; // inline-start\n } else {\n if (e.key === 'ArrowDown') delta = step;\n else if (e.key === 'ArrowUp') delta = -step;\n }\n if (e.key === 'Home') {\n e.preventDefault();\n onResizeStart?.(current);\n const next = clamp(minSize);\n container.style.setProperty(cssVarName, `${next}px`);\n (e.currentTarget as HTMLElement).setAttribute('aria-valuenow', String(next));\n onResize?.(next);\n onResizeEnd?.(next);\n return;\n }\n if (e.key === 'End') {\n e.preventDefault();\n onResizeStart?.(current);\n const next = clamp(maxSize);\n container.style.setProperty(cssVarName, `${next}px`);\n (e.currentTarget as HTMLElement).setAttribute('aria-valuenow', String(next));\n onResize?.(next);\n onResizeEnd?.(next);\n return;\n }\n if (delta !== 0) {\n e.preventDefault();\n onResizeStart?.(current);\n const signedDelta = orientation === 'vertical' ? (edge === 'start' ? -delta : delta) : delta;\n const next = clamp(current + signedDelta);\n container.style.setProperty(cssVarName, `${next}px`);\n (e.currentTarget as HTMLElement).setAttribute('aria-valuenow', String(next));\n onResize?.(next);\n onResizeEnd?.(next);\n }\n }}\n >\n {children}\n </div>\n );\n});\nPaneHandle.displayName = 'Shell.Handle';\n\nexport const PanelHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>((props, ref) => <PaneHandle {...props} ref={ref} />);\nPanelHandle.displayName = 'Shell.Panel.Handle';\n\nexport const SidebarHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>((props, ref) => <PaneHandle {...props} ref={ref} />);\nSidebarHandle.displayName = 'Shell.Sidebar.Handle';\n\nexport const InspectorHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>((props, ref) => <PaneHandle {...props} ref={ref} />);\nInspectorHandle.displayName = 'Shell.Inspector.Handle';\n\nexport const BottomHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>((props, ref) => <PaneHandle {...props} ref={ref} />);\nBottomHandle.displayName = 'Shell.Bottom.Handle';\n"],
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aACvB,OAAS,iBAAAC,MAAqB,oBAEvB,MAAMC,EAAaH,EAAM,WAAkE,CAAC,CAAE,UAAAI,EAAW,SAAAC,EAAU,GAAGC,CAAM,EAAGC,IAAQ,CAC5I,KAAM,CACJ,aAAAC,EACA,WAAAC,EACA,QAAAC,EACA,QAAAC,EACA,YAAAC,EACA,YAAAC,EACA,KAAAC,EACA,YAAAC,EACA,SAAAC,EACA,cAAAC,EACA,YAAAC,EACA,WAAAC,EACA,cAAAC,EACA,kBAAAC,EACA,YAAAC,EACA,
|
|
6
|
-
"names": ["React", "classNames", "usePaneResize", "PaneHandle", "className", "children", "props", "ref", "containerRef", "cssVarName", "minSize", "maxSize", "defaultSize", "orientation", "edge", "computeNext", "onResize", "onResizeStart", "onResizeEnd", "snapPoints", "snapTolerance", "collapseThreshold", "collapsible", "
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport { usePaneResize } from './shell-resize.js';\n\nexport const PaneHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>(({ className, children, ...props }, ref) => {\n const {\n containerRef,\n cssVarName,\n minSize,\n maxSize,\n defaultSize,\n orientation,\n edge,\n computeNext,\n onResize,\n onResizeStart,\n onResizeEnd,\n snapPoints,\n snapTolerance,\n collapseThreshold,\n collapsible,\n target: _target,\n requestCollapse,\n requestToggle,\n } = usePaneResize();\n\n const activeCleanupRef = React.useRef<(() => void) | null>(null);\n React.useEffect(\n () => () => {\n try {\n activeCleanupRef.current?.();\n } catch {}\n activeCleanupRef.current = null;\n },\n [],\n );\n\n const ariaOrientation = orientation;\n\n return (\n <div\n {...props}\n ref={ref}\n className={classNames('rt-ShellResizer', className)}\n data-orientation={orientation}\n data-edge={edge}\n role=\"slider\"\n aria-orientation={ariaOrientation}\n aria-valuemin={minSize}\n aria-valuemax={maxSize}\n aria-valuenow={defaultSize}\n tabIndex={0}\n onPointerDown={(e) => {\n if (!containerRef.current) return;\n e.preventDefault();\n const container = containerRef.current;\n const handleEl = e.currentTarget as HTMLElement;\n const pointerId = e.pointerId;\n try {\n activeCleanupRef.current?.();\n } catch {}\n container.setAttribute('data-resizing', '');\n try {\n handleEl.setPointerCapture(pointerId);\n } catch {}\n const startClient = orientation === 'vertical' ? e.clientX : e.clientY;\n const startSize = parseFloat(getComputedStyle(container).getPropertyValue(cssVarName) || `${defaultSize}`);\n const clamp = (v: number) => Math.min(Math.max(v, minSize), maxSize);\n const body = document.body;\n const prevCursor = body.style.cursor;\n const prevUserSelect = body.style.userSelect;\n body.style.cursor = orientation === 'vertical' ? 'col-resize' : 'row-resize';\n body.style.userSelect = 'none';\n onResizeStart?.(startSize);\n const handleMove = (ev: PointerEvent) => {\n const client = orientation === 'vertical' ? ev.clientX : ev.clientY;\n const next = clamp(computeNext(client, startClient, startSize));\n container.style.setProperty(cssVarName, `${next}px`);\n handleEl.setAttribute('aria-valuenow', String(next));\n onResize?.(next);\n };\n const cleanup = () => {\n try {\n handleEl.releasePointerCapture(pointerId);\n } catch {}\n window.removeEventListener('pointermove', handleMove as any);\n document.removeEventListener('pointermove', handleMove as any);\n window.removeEventListener('mousemove', handleMove as any);\n document.removeEventListener('mousemove', handleMove as any);\n handleEl.removeEventListener('pointermove', handleMove as any);\n window.removeEventListener('pointerup', handleUp as any);\n document.removeEventListener('pointerup', handleUp as any);\n window.removeEventListener('mouseup', handleUp as any);\n document.removeEventListener('mouseup', handleUp as any);\n window.removeEventListener('pointercancel', handleUp as any);\n document.removeEventListener('pointercancel', handleUp as any);\n window.removeEventListener('keydown', handleKey as any);\n handleEl.removeEventListener('lostpointercapture', handleUp as any);\n container.removeAttribute('data-resizing');\n body.style.cursor = prevCursor;\n body.style.userSelect = prevUserSelect;\n activeCleanupRef.current = null;\n };\n const handleUp = () => {\n const finalSize = parseFloat(getComputedStyle(container).getPropertyValue(cssVarName) || `${defaultSize}`);\n let snapped = finalSize;\n if (snapPoints && snapPoints.length) {\n const nearest = snapPoints.reduce((acc, p) => (Math.abs(p - finalSize) < Math.abs(acc - finalSize) ? p : acc), snapPoints[0]);\n if (Math.abs(nearest - finalSize) <= (snapTolerance ?? 8)) {\n snapped = nearest;\n container.style.setProperty(cssVarName, `${snapped}px`);\n handleEl.setAttribute('aria-valuenow', String(snapped));\n onResize?.(snapped);\n }\n }\n if (collapsible && typeof collapseThreshold === 'number' && finalSize <= collapseThreshold) {\n requestCollapse?.();\n }\n onResizeEnd?.(snapped);\n cleanup();\n };\n const handleKey = (kev: KeyboardEvent) => {\n if (kev.key === 'Escape') {\n container.style.setProperty(cssVarName, `${startSize}px`);\n handleEl.setAttribute('aria-valuenow', String(startSize));\n onResizeEnd?.(startSize);\n cleanup();\n }\n };\n window.addEventListener('pointermove', handleMove as any);\n document.addEventListener('pointermove', handleMove as any);\n // Fallbacks for environments that don't fully support PointerEvent on window\n window.addEventListener('mousemove', handleMove as any);\n document.addEventListener('mousemove', handleMove as any);\n handleEl.addEventListener('pointermove', handleMove as any);\n window.addEventListener('pointerup', handleUp as any);\n document.addEventListener('pointerup', handleUp as any);\n window.addEventListener('mouseup', handleUp as any);\n document.addEventListener('mouseup', handleUp as any);\n window.addEventListener('pointercancel', handleUp as any);\n document.addEventListener('pointercancel', handleUp as any);\n window.addEventListener('keydown', handleKey as any);\n handleEl.addEventListener('lostpointercapture', handleUp as any);\n activeCleanupRef.current = cleanup;\n }}\n onDoubleClick={() => {\n if (collapsible) requestToggle?.();\n }}\n onKeyDown={(e) => {\n if (!containerRef.current) return;\n const container = containerRef.current;\n const rawCurrent = getComputedStyle(container).getPropertyValue(cssVarName);\n const parsedCurrent = Number.parseFloat(rawCurrent.trim());\n const current = Number.isFinite(parsedCurrent) ? parsedCurrent : defaultSize;\n const clamp = (v: number) => Math.min(Math.max(v, minSize), maxSize);\n const step = e.shiftKey ? 32 : 8;\n let delta = 0;\n if (orientation === 'vertical') {\n const docDir = typeof document !== 'undefined' ? document.dir : undefined;\n const cssDir = getComputedStyle(container).direction;\n const hasRtlAncestor = !!(container.closest && container.closest('[dir=\"rtl\"]'));\n const isRtl = docDir === 'rtl' || cssDir === 'rtl' || hasRtlAncestor;\n if (e.key === 'ArrowRight')\n delta = isRtl ? -step : step; // inline-end\n else if (e.key === 'ArrowLeft') delta = isRtl ? step : -step; // inline-start\n } else {\n if (e.key === 'ArrowDown') delta = step;\n else if (e.key === 'ArrowUp') delta = -step;\n }\n if (e.key === 'Home') {\n e.preventDefault();\n onResizeStart?.(current);\n const next = clamp(minSize);\n container.style.setProperty(cssVarName, `${next}px`);\n (e.currentTarget as HTMLElement).setAttribute('aria-valuenow', String(next));\n onResize?.(next);\n onResizeEnd?.(next);\n return;\n }\n if (e.key === 'End') {\n e.preventDefault();\n onResizeStart?.(current);\n const next = clamp(maxSize);\n container.style.setProperty(cssVarName, `${next}px`);\n (e.currentTarget as HTMLElement).setAttribute('aria-valuenow', String(next));\n onResize?.(next);\n onResizeEnd?.(next);\n return;\n }\n if (delta !== 0) {\n e.preventDefault();\n onResizeStart?.(current);\n const signedDelta = orientation === 'vertical' ? (edge === 'start' ? -delta : delta) : delta;\n const next = clamp(current + signedDelta);\n container.style.setProperty(cssVarName, `${next}px`);\n (e.currentTarget as HTMLElement).setAttribute('aria-valuenow', String(next));\n onResize?.(next);\n onResizeEnd?.(next);\n }\n }}\n >\n {children}\n </div>\n );\n});\nPaneHandle.displayName = 'Shell.Handle';\n\nexport const PanelHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>((props, ref) => <PaneHandle {...props} ref={ref} />);\nPanelHandle.displayName = 'Shell.Panel.Handle';\n\nexport const SidebarHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>((props, ref) => <PaneHandle {...props} ref={ref} />);\nSidebarHandle.displayName = 'Shell.Sidebar.Handle';\n\nexport const InspectorHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>((props, ref) => <PaneHandle {...props} ref={ref} />);\nInspectorHandle.displayName = 'Shell.Inspector.Handle';\n\nexport const BottomHandle = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<'div'>>((props, ref) => <PaneHandle {...props} ref={ref} />);\nBottomHandle.displayName = 'Shell.Bottom.Handle';\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aACvB,OAAS,iBAAAC,MAAqB,oBAEvB,MAAMC,EAAaH,EAAM,WAAkE,CAAC,CAAE,UAAAI,EAAW,SAAAC,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AAE,eAAe,EACjBtC,IAAgBoC,CAAO,EACvB,MAAMO,EAAc/C,IAAgB,YAAcC,IAAS,QAAU,CAACyC,EAAiBA,EACjFd,EAAOR,EAAMoB,EAAUO,CAAW,EACxChC,EAAU,MAAM,YAAYnB,EAAY,GAAGgC,CAAI,IAAI,EAClD,EAAE,cAA8B,aAAa,gBAAiB,OAAOA,CAAI,CAAC,EAC3EzB,IAAWyB,CAAI,EACfvB,IAAcuB,CAAI,CACpB,CACF,GAECpC,CACH,CAEJ,CAAC,EACDF,EAAW,YAAc,eAElB,MAAM0D,EAAc7D,EAAM,WAAkE,CAACM,EAAOC,IAAQP,EAAA,cAACG,EAAA,CAAY,GAAGG,EAAO,IAAKC,EAAK,CAAE,EACtJsD,EAAY,YAAc,qBAEnB,MAAMC,EAAgB9D,EAAM,WAAkE,CAACM,EAAOC,IAAQP,EAAA,cAACG,EAAA,CAAY,GAAGG,EAAO,IAAKC,EAAK,CAAE,EACxJuD,EAAc,YAAc,uBAErB,MAAMC,EAAkB/D,EAAM,WAAkE,CAACM,EAAOC,IAAQP,EAAA,cAACG,EAAA,CAAY,GAAGG,EAAO,IAAKC,EAAK,CAAE,EAC1JwD,EAAgB,YAAc,yBAEvB,MAAMC,EAAehE,EAAM,WAAkE,CAACM,EAAOC,IAAQP,EAAA,cAACG,EAAA,CAAY,GAAGG,EAAO,IAAKC,EAAK,CAAE,EACvJyD,EAAa,YAAc",
|
|
6
|
+
"names": ["React", "classNames", "usePaneResize", "PaneHandle", "className", "children", "props", "ref", "containerRef", "cssVarName", "minSize", "maxSize", "defaultSize", "orientation", "edge", "computeNext", "onResize", "onResizeStart", "onResizeEnd", "snapPoints", "snapTolerance", "collapseThreshold", "collapsible", "_target", "requestCollapse", "requestToggle", "activeCleanupRef", "ariaOrientation", "container", "handleEl", "pointerId", "startClient", "startSize", "clamp", "v", "body", "prevCursor", "prevUserSelect", "handleMove", "ev", "client", "next", "cleanup", "handleUp", "handleKey", "finalSize", "snapped", "nearest", "acc", "p", "kev", "rawCurrent", "parsedCurrent", "current", "step", "delta", "docDir", "cssDir", "hasRtlAncestor", "isRtl", "signedDelta", "PanelHandle", "SidebarHandle", "InspectorHandle", "BottomHandle"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/_internal/shell-inspector.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport * as Sheet from '../sheet.js';\nimport { VisuallyHidden } from '../visually-hidden.js';\nimport { useShell } from '../shell.context.js';\nimport { useResponsivePresentation, useResponsiveValue } from '../shell.hooks.js';\nimport { PaneResizeContext } from './shell-resize.js';\nimport { InspectorHandle, PaneHandle } from './shell-handles.js';\nimport { BREAKPOINTS } from '../shell.types.js';\nimport type { Breakpoint, PaneMode, PaneSizePersistence, ResponsivePresentation } from '../shell.types.js';\n\ninterface PaneProps extends React.ComponentPropsWithoutRef<'div'> {\n presentation?: ResponsivePresentation;\n // legacy mode removed\n expandedSize?: number;\n minSize?: number;\n maxSize?: number;\n resizable?: boolean;\n collapsible?: boolean;\n onExpand?: () => void;\n onCollapse?: () => void;\n onResize?: (size: number) => void;\n resizer?: React.ReactNode;\n onResizeStart?: (size: number) => void;\n onResizeEnd?: (size: number) => void;\n snapPoints?: number[];\n snapTolerance?: number;\n collapseThreshold?: number;\n paneId?: string;\n persistence?: PaneSizePersistence;\n}\n\ntype InspectorOpenChangeMeta = { reason: 'init' | 'toggle' | 'responsive' };\ntype InspectorControlledProps = { open: boolean | Partial<Record<Breakpoint, boolean>>; onOpenChange?: (open: boolean, meta: InspectorOpenChangeMeta) => void; defaultOpen?: never };\ntype InspectorUncontrolledProps = { defaultOpen?: boolean | Partial<Record<Breakpoint, boolean>>; onOpenChange?: (open: boolean, meta: InspectorOpenChangeMeta) => void; open?: never };\ntype InspectorSizeChangeMeta = { reason: 'init' | 'resize' | 'controlled' };\ntype InspectorPublicProps = PaneProps &\n (InspectorControlledProps | InspectorUncontrolledProps) & {\n onSizeChange?: (size: number, meta: InspectorSizeChangeMeta) => void;\n sizeUpdate?: 'throttle' | 'debounce';\n sizeUpdateMs?: number;\n };\n\ntype InspectorComponent = React.ForwardRefExoticComponent<InspectorPublicProps & React.RefAttributes<HTMLDivElement>> & { Handle: typeof InspectorHandle };\n\nexport const Inspector = React.forwardRef<HTMLDivElement, InspectorPublicProps>(\n (\n {\n className,\n presentation = { initial: 'overlay', lg: 'fixed' },\n // removed legacy props\n // new API\n defaultOpen,\n open,\n onOpenChange,\n expandedSize = 320,\n minSize = 200,\n maxSize = 500,\n resizable = false,\n collapsible = true,\n onExpand,\n onCollapse,\n onResize,\n onResizeStart,\n onResizeEnd,\n snapPoints,\n snapTolerance,\n collapseThreshold,\n paneId,\n persistence,\n children,\n style,\n ...props\n },\n ref,\n ) => {\n const shell = useShell();\n const resolvedPresentation = useResponsivePresentation(presentation);\n const isOverlay = resolvedPresentation === 'overlay';\n const isStacked = resolvedPresentation === 'stacked';\n const localRef = React.useRef<HTMLDivElement | null>(null);\n const setRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n localRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n },\n [ref],\n );\n const childArray = React.Children.toArray(children) as React.ReactElement[];\n const handleChildren = childArray.filter((el: React.ReactElement) => React.isValidElement(el) && el.type === InspectorHandle);\n const contentChildren = childArray.filter((el: React.ReactElement) => !(React.isValidElement(el) && el.type === InspectorHandle));\n\n // Throttled/debounced emitter for onSizeChange\n const emitSizeChange = React.useMemo(() => {\n const cb = (props as any).onSizeChange as undefined | ((s: number, meta: InspectorSizeChangeMeta) => void);\n const strategy = (props as any).sizeUpdate as undefined | 'throttle' | 'debounce';\n const ms = (props as any).sizeUpdateMs ?? 50;\n if (!cb) return () => {};\n if (strategy === 'debounce') {\n let t: any = null;\n return (s: number, meta: InspectorSizeChangeMeta) => {\n if (t) clearTimeout(t);\n t = setTimeout(() => {\n cb(s, meta);\n }, ms);\n };\n }\n if (strategy === 'throttle') {\n let last = 0;\n return (s: number, meta: InspectorSizeChangeMeta) => {\n const now = Date.now();\n if (now - last >= ms) {\n last = now;\n cb(s, meta);\n }\n };\n }\n return (s: number, meta: InspectorSizeChangeMeta) => cb(s, meta);\n }, [(props as any).onSizeChange, (props as any).sizeUpdate, (props as any).sizeUpdateMs]);\n\n // Dev guards\n const wasControlledRef = React.useRef<boolean | null>(null);\n if (process.env.NODE_ENV !== 'production') {\n if (typeof open !== 'undefined' && typeof defaultOpen !== 'undefined') {\n // eslint-disable-next-line no-console\n console.error('Shell.Inspector: Do not pass both `open` and `defaultOpen`. Choose one.');\n }\n }\n\n // Warn on controlled/uncontrolled mode switch\n React.useEffect(() => {\n const isControlled = typeof open !== 'undefined';\n if (wasControlledRef.current === null) {\n wasControlledRef.current = isControlled;\n return;\n }\n if (wasControlledRef.current !== isControlled) {\n // eslint-disable-next-line no-console\n console.warn('Shell.Inspector: Switching between controlled and uncontrolled `open` is not supported.');\n wasControlledRef.current = isControlled;\n }\n }, [open]);\n\n const responsiveNotifiedRef = React.useRef(false);\n const didInitFromDefaultOpenRef = React.useRef(false);\n const resolvedDefaultOpen = useResponsiveValue(defaultOpen);\n React.useEffect(() => {\n if (!shell.currentBreakpointReady) return;\n if (didInitFromDefaultOpenRef.current) return;\n if (typeof open !== 'undefined') return; // controlled ignores default\n if (typeof defaultOpen === 'undefined') return;\n const initialOpen = Boolean(resolvedDefaultOpen);\n shell.setInspectorMode(initialOpen ? 'expanded' : 'collapsed');\n if (initialOpen) onOpenChange?.(true, { reason: 'init' });\n didInitFromDefaultOpenRef.current = true;\n }, [shell.currentBreakpointReady, resolvedDefaultOpen, defaultOpen, open, onOpenChange]);\n\n // Controlled responsive open\n const resolvedOpen = useResponsiveValue(open);\n React.useEffect(() => {\n if (typeof resolvedOpen === 'undefined') return;\n const shouldExpand = Boolean(resolvedOpen);\n if (shouldExpand && shell.inspectorMode !== 'expanded') shell.setInspectorMode('expanded');\n if (!shouldExpand && shell.inspectorMode !== 'collapsed') shell.setInspectorMode('collapsed');\n }, [resolvedOpen, shell.inspectorMode]);\n\n // Removed boolean-only mount init; handled in responsive init effect above\n\n // Removed: boolean-only controlled sync. Use responsive-resolved effect below instead.\n\n const initNotifiedRef = React.useRef(false);\n const lastInspectorModeRef = React.useRef<PaneMode | null>(null);\n React.useEffect(() => {\n // Notify init open\n if (!initNotifiedRef.current && typeof open === 'undefined' && defaultOpen && shell.inspectorMode === 'expanded') {\n onOpenChange?.(true, { reason: 'init' });\n initNotifiedRef.current = true;\n }\n\n // Notify toggles when uncontrolled (avoid double-notify after responsive change)\n if (typeof open === 'undefined') {\n if (lastInspectorModeRef.current !== null && lastInspectorModeRef.current !== shell.inspectorMode) {\n if (!responsiveNotifiedRef.current) {\n onOpenChange?.(shell.inspectorMode === 'expanded', { reason: 'toggle' });\n }\n responsiveNotifiedRef.current = false;\n }\n lastInspectorModeRef.current = shell.inspectorMode;\n }\n }, [shell.inspectorMode, open, defaultOpen, onOpenChange]);\n\n React.useEffect(() => {\n if (shell.inspectorMode === 'expanded') {\n onExpand?.();\n } else {\n onCollapse?.();\n }\n }, [shell.inspectorMode, onExpand, onCollapse]);\n\n const isExpanded = shell.inspectorMode === 'expanded';\n\n const persistenceAdapter = React.useMemo(() => {\n if (!paneId || persistence) return persistence;\n const key = `kookie-ui:shell:inspector:${paneId}`;\n const adapter: PaneSizePersistence = {\n load: () => {\n if (typeof window === 'undefined') return undefined;\n const v = window.localStorage.getItem(key);\n return v ? Number(v) : undefined;\n },\n save: (size: number) => {\n if (typeof window === 'undefined') return;\n window.localStorage.setItem(key, String(size));\n },\n };\n return adapter;\n }, [paneId, persistence]);\n\n React.useEffect(() => {\n let mounted = true;\n (async () => {\n if (!resizable || !persistenceAdapter?.load || isOverlay) return;\n const loaded = await persistenceAdapter.load();\n if (mounted && typeof loaded === 'number' && localRef.current) {\n localRef.current.style.setProperty('--inspector-size', `${loaded}px`);\n onResize?.(loaded);\n }\n })();\n return () => {\n mounted = false;\n };\n }, [resizable, persistenceAdapter, onResize, isOverlay]);\n\n const handleEl =\n resizable && !isOverlay && isExpanded ? (\n <PaneResizeContext.Provider\n value={{\n containerRef: localRef,\n cssVarName: '--inspector-size',\n minSize,\n maxSize,\n defaultSize: expandedSize,\n orientation: 'vertical',\n edge: 'start',\n computeNext: (client, startClient, startSize) => {\n const isRtl = getComputedStyle(localRef.current!).direction === 'rtl';\n const delta = client - startClient;\n return startSize + (isRtl ? delta : -delta);\n },\n onResize,\n onResizeStart,\n onResizeEnd: (size) => {\n onResizeEnd?.(size);\n emitSizeChange(size, { reason: 'resize' });\n persistenceAdapter?.save?.(size);\n },\n target: 'inspector',\n collapsible,\n snapPoints,\n snapTolerance: snapTolerance ?? 8,\n collapseThreshold,\n requestCollapse: () => shell.setInspectorMode('collapsed'),\n requestToggle: () => shell.togglePane('inspector'),\n }}\n >\n {handleChildren.length > 0 ? handleChildren.map((el, i) => React.cloneElement(el, { key: el.key ?? i })) : <PaneHandle />}\n </PaneResizeContext.Provider>\n ) : null;\n\n // Normalize CSS lengths to px\n const normalizeToPx = React.useCallback((value: number | string | undefined): number | undefined => {\n if (value == null) return undefined;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n const str = String(value).trim();\n if (!str) return undefined;\n if (str.endsWith('px')) return Number.parseFloat(str);\n if (str.endsWith('rem')) {\n const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize || '16') || 16;\n return Number.parseFloat(str) * rem;\n }\n if (str.endsWith('%')) {\n const pct = Number.parseFloat(str);\n const base = document.documentElement.clientWidth || window.innerWidth || 0;\n return (pct / 100) * base;\n }\n const n = Number.parseFloat(str);\n return Number.isFinite(n) ? n : undefined;\n }, []);\n\n // Apply defaultSize on mount when uncontrolled\n React.useEffect(() => {\n if (!localRef.current) return;\n if (typeof (props as any).size === 'undefined' && typeof (props as any).defaultSize !== 'undefined') {\n const px = normalizeToPx((props as any).defaultSize);\n if (typeof px === 'number' && Number.isFinite(px)) {\n const minPx = typeof minSize === 'number' ? minSize : undefined;\n const maxPx = typeof maxSize === 'number' ? maxSize : undefined;\n const clamped = Math.min(maxPx ?? px, Math.max(minPx ?? px, px));\n localRef.current.style.setProperty('--inspector-size', `${clamped}px`);\n emitSizeChange(clamped, { reason: 'init' });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Controlled size sync\n React.useEffect(() => {\n if (!localRef.current) return;\n if (typeof (props as any).size === 'undefined') return;\n const px = normalizeToPx((props as any).size);\n if (typeof px === 'number' && Number.isFinite(px)) {\n const minPx = typeof minSize === 'number' ? minSize : undefined;\n const maxPx = typeof maxSize === 'number' ? maxSize : undefined;\n const clamped = Math.min(maxPx ?? px, Math.max(minPx ?? px, px));\n localRef.current.style.setProperty('--inspector-size', `${clamped}px`);\n emitSizeChange(clamped, { reason: 'controlled' });\n }\n }, [(props as any).size, minSize, maxSize, normalizeToPx, emitSizeChange]);\n\n if (isOverlay) {\n const open = shell.inspectorMode === 'expanded';\n return (\n <Sheet.Root open={open} onOpenChange={(o) => shell.setInspectorMode(o ? 'expanded' : 'collapsed')}>\n <Sheet.Content side=\"end\" style={{ padding: 0 }} width={{ initial: `${expandedSize}px` }}>\n <VisuallyHidden>\n <Sheet.Title>Inspector</Sheet.Title>\n </VisuallyHidden>\n {contentChildren}\n </Sheet.Content>\n </Sheet.Root>\n );\n }\n\n // Strip control/size props from DOM spread\n const {\n defaultOpen: _inspectorDefaultOpenIgnored,\n open: _inspectorOpenIgnored,\n onOpenChange: _inspectorOnOpenChangeIgnored,\n size: _sz,\n defaultSize: _dsz,\n onSizeChange: _osc,\n sizeUpdate: _szu,\n sizeUpdateMs: _szums,\n ...inspectorDomProps\n } = props as any;\n\n return (\n <div\n {...inspectorDomProps}\n ref={setRef}\n className={classNames('rt-ShellInspector', className)}\n data-mode={shell.inspectorMode}\n data-peek={shell.peekTarget === 'inspector' || undefined}\n data-presentation={shell.currentBreakpointReady ? resolvedPresentation : undefined}\n data-open={(shell.currentBreakpointReady && isStacked && isExpanded) || undefined}\n style={{\n ...style,\n ['--inspector-size' as any]: `${expandedSize}px`,\n ['--inspector-min-size' as any]: `${minSize}px`,\n ['--inspector-max-size' as any]: `${maxSize}px`,\n }}\n >\n <div className=\"rt-ShellInspectorContent\" data-visible={isExpanded || undefined}>\n {contentChildren}\n </div>\n {handleEl}\n </div>\n );\n },\n) as InspectorComponent;\n\nInspector.displayName = 'Shell.Inspector';\nInspector.Handle = InspectorHandle;\n"],
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,OAAgB,aACvB,UAAYC,MAAW,cACvB,OAAS,kBAAAC,OAAsB,wBAC/B,OAAS,YAAAC,OAAgB,sBACzB,OAAS,6BAAAC,GAA2B,sBAAAC,MAA0B,oBAC9D,OAAS,qBAAAC,OAAyB,oBAClC,OAAS,mBAAAC,EAAiB,cAAAC,OAAkB,qBAC5C,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport * as Sheet from '../sheet.js';\nimport { VisuallyHidden } from '../visually-hidden.js';\nimport { useShell } from '../shell.context.js';\nimport { useResponsivePresentation, useResponsiveValue } from '../shell.hooks.js';\nimport { PaneResizeContext } from './shell-resize.js';\nimport { InspectorHandle, PaneHandle } from './shell-handles.js';\nimport { _BREAKPOINTS } from '../shell.types.js';\nimport type { Breakpoint, PaneMode, PaneSizePersistence, ResponsivePresentation } from '../shell.types.js';\n\ninterface PaneProps extends React.ComponentPropsWithoutRef<'div'> {\n presentation?: ResponsivePresentation;\n // legacy mode removed\n expandedSize?: number;\n minSize?: number;\n maxSize?: number;\n resizable?: boolean;\n collapsible?: boolean;\n onExpand?: () => void;\n onCollapse?: () => void;\n onResize?: (size: number) => void;\n resizer?: React.ReactNode;\n onResizeStart?: (size: number) => void;\n onResizeEnd?: (size: number) => void;\n snapPoints?: number[];\n snapTolerance?: number;\n collapseThreshold?: number;\n paneId?: string;\n persistence?: PaneSizePersistence;\n}\n\ntype InspectorOpenChangeMeta = { reason: 'init' | 'toggle' | 'responsive' };\ntype InspectorControlledProps = { open: boolean | Partial<Record<Breakpoint, boolean>>; onOpenChange?: (open: boolean, meta: InspectorOpenChangeMeta) => void; defaultOpen?: never };\ntype InspectorUncontrolledProps = { defaultOpen?: boolean | Partial<Record<Breakpoint, boolean>>; onOpenChange?: (open: boolean, meta: InspectorOpenChangeMeta) => void; open?: never };\ntype InspectorSizeChangeMeta = { reason: 'init' | 'resize' | 'controlled' };\ntype InspectorPublicProps = PaneProps &\n (InspectorControlledProps | InspectorUncontrolledProps) & {\n onSizeChange?: (size: number, meta: InspectorSizeChangeMeta) => void;\n sizeUpdate?: 'throttle' | 'debounce';\n sizeUpdateMs?: number;\n };\n\ntype InspectorComponent = React.ForwardRefExoticComponent<InspectorPublicProps & React.RefAttributes<HTMLDivElement>> & { Handle: typeof InspectorHandle };\n\nexport const Inspector = React.forwardRef<HTMLDivElement, InspectorPublicProps>(\n (\n {\n className,\n presentation = { initial: 'overlay', lg: 'fixed' },\n // removed legacy props\n // new API\n defaultOpen,\n open,\n onOpenChange,\n expandedSize = 320,\n minSize = 200,\n maxSize = 500,\n resizable = false,\n collapsible = true,\n onExpand,\n onCollapse,\n onResize,\n onResizeStart,\n onResizeEnd,\n snapPoints,\n snapTolerance,\n collapseThreshold,\n paneId,\n persistence,\n children,\n style,\n ...props\n },\n ref,\n ) => {\n const shell = useShell();\n const resolvedPresentation = useResponsivePresentation(presentation);\n const isOverlay = resolvedPresentation === 'overlay';\n const isStacked = resolvedPresentation === 'stacked';\n const localRef = React.useRef<HTMLDivElement | null>(null);\n const setRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n localRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n },\n [ref],\n );\n const childArray = React.Children.toArray(children) as React.ReactElement[];\n const handleChildren = childArray.filter((el: React.ReactElement) => React.isValidElement(el) && el.type === InspectorHandle);\n const contentChildren = childArray.filter((el: React.ReactElement) => !(React.isValidElement(el) && el.type === InspectorHandle));\n\n // Throttled/debounced emitter for onSizeChange\n const emitSizeChange = React.useMemo(() => {\n const cb = (props as any).onSizeChange as undefined | ((s: number, meta: InspectorSizeChangeMeta) => void);\n const strategy = (props as any).sizeUpdate as undefined | 'throttle' | 'debounce';\n const ms = (props as any).sizeUpdateMs ?? 50;\n if (!cb) return () => {};\n if (strategy === 'debounce') {\n let t: any = null;\n return (s: number, meta: InspectorSizeChangeMeta) => {\n if (t) clearTimeout(t);\n t = setTimeout(() => {\n cb(s, meta);\n }, ms);\n };\n }\n if (strategy === 'throttle') {\n let last = 0;\n return (s: number, meta: InspectorSizeChangeMeta) => {\n const now = Date.now();\n if (now - last >= ms) {\n last = now;\n cb(s, meta);\n }\n };\n }\n return (s: number, meta: InspectorSizeChangeMeta) => cb(s, meta);\n }, [(props as any).onSizeChange, (props as any).sizeUpdate, (props as any).sizeUpdateMs]);\n\n // Dev guards\n const wasControlledRef = React.useRef<boolean | null>(null);\n if (process.env.NODE_ENV !== 'production') {\n if (typeof open !== 'undefined' && typeof defaultOpen !== 'undefined') {\n // eslint-disable-next-line no-console\n console.error('Shell.Inspector: Do not pass both `open` and `defaultOpen`. Choose one.');\n }\n }\n\n // Warn on controlled/uncontrolled mode switch\n React.useEffect(() => {\n const isControlled = typeof open !== 'undefined';\n if (wasControlledRef.current === null) {\n wasControlledRef.current = isControlled;\n return;\n }\n if (wasControlledRef.current !== isControlled) {\n // eslint-disable-next-line no-console\n console.warn('Shell.Inspector: Switching between controlled and uncontrolled `open` is not supported.');\n wasControlledRef.current = isControlled;\n }\n }, [open]);\n\n const responsiveNotifiedRef = React.useRef(false);\n const didInitFromDefaultOpenRef = React.useRef(false);\n const resolvedDefaultOpen = useResponsiveValue(defaultOpen);\n React.useEffect(() => {\n if (!shell.currentBreakpointReady) return;\n if (didInitFromDefaultOpenRef.current) return;\n if (typeof open !== 'undefined') return; // controlled ignores default\n if (typeof defaultOpen === 'undefined') return;\n const initialOpen = Boolean(resolvedDefaultOpen);\n shell.setInspectorMode(initialOpen ? 'expanded' : 'collapsed');\n if (initialOpen) onOpenChange?.(true, { reason: 'init' });\n didInitFromDefaultOpenRef.current = true;\n }, [shell.currentBreakpointReady, resolvedDefaultOpen, defaultOpen, open, onOpenChange]);\n\n // Controlled responsive open\n const resolvedOpen = useResponsiveValue(open);\n React.useEffect(() => {\n if (typeof resolvedOpen === 'undefined') return;\n const shouldExpand = Boolean(resolvedOpen);\n if (shouldExpand && shell.inspectorMode !== 'expanded') shell.setInspectorMode('expanded');\n if (!shouldExpand && shell.inspectorMode !== 'collapsed') shell.setInspectorMode('collapsed');\n }, [resolvedOpen, shell.inspectorMode]);\n\n // Removed boolean-only mount init; handled in responsive init effect above\n\n // Removed: boolean-only controlled sync. Use responsive-resolved effect below instead.\n\n const initNotifiedRef = React.useRef(false);\n const lastInspectorModeRef = React.useRef<PaneMode | null>(null);\n React.useEffect(() => {\n // Notify init open\n if (!initNotifiedRef.current && typeof open === 'undefined' && defaultOpen && shell.inspectorMode === 'expanded') {\n onOpenChange?.(true, { reason: 'init' });\n initNotifiedRef.current = true;\n }\n\n // Notify toggles when uncontrolled (avoid double-notify after responsive change)\n if (typeof open === 'undefined') {\n if (lastInspectorModeRef.current !== null && lastInspectorModeRef.current !== shell.inspectorMode) {\n if (!responsiveNotifiedRef.current) {\n onOpenChange?.(shell.inspectorMode === 'expanded', { reason: 'toggle' });\n }\n responsiveNotifiedRef.current = false;\n }\n lastInspectorModeRef.current = shell.inspectorMode;\n }\n }, [shell.inspectorMode, open, defaultOpen, onOpenChange]);\n\n React.useEffect(() => {\n if (shell.inspectorMode === 'expanded') {\n onExpand?.();\n } else {\n onCollapse?.();\n }\n }, [shell.inspectorMode, onExpand, onCollapse]);\n\n const isExpanded = shell.inspectorMode === 'expanded';\n\n const persistenceAdapter = React.useMemo(() => {\n if (!paneId || persistence) return persistence;\n const key = `kookie-ui:shell:inspector:${paneId}`;\n const adapter: PaneSizePersistence = {\n load: () => {\n if (typeof window === 'undefined') return undefined;\n const v = window.localStorage.getItem(key);\n return v ? Number(v) : undefined;\n },\n save: (size: number) => {\n if (typeof window === 'undefined') return;\n window.localStorage.setItem(key, String(size));\n },\n };\n return adapter;\n }, [paneId, persistence]);\n\n React.useEffect(() => {\n let mounted = true;\n (async () => {\n if (!resizable || !persistenceAdapter?.load || isOverlay) return;\n const loaded = await persistenceAdapter.load();\n if (mounted && typeof loaded === 'number' && localRef.current) {\n localRef.current.style.setProperty('--inspector-size', `${loaded}px`);\n onResize?.(loaded);\n }\n })();\n return () => {\n mounted = false;\n };\n }, [resizable, persistenceAdapter, onResize, isOverlay]);\n\n const handleEl =\n resizable && !isOverlay && isExpanded ? (\n <PaneResizeContext.Provider\n value={{\n containerRef: localRef,\n cssVarName: '--inspector-size',\n minSize,\n maxSize,\n defaultSize: expandedSize,\n orientation: 'vertical',\n edge: 'start',\n computeNext: (client, startClient, startSize) => {\n const isRtl = getComputedStyle(localRef.current!).direction === 'rtl';\n const delta = client - startClient;\n return startSize + (isRtl ? delta : -delta);\n },\n onResize,\n onResizeStart,\n onResizeEnd: (size) => {\n onResizeEnd?.(size);\n emitSizeChange(size, { reason: 'resize' });\n persistenceAdapter?.save?.(size);\n },\n target: 'inspector',\n collapsible,\n snapPoints,\n snapTolerance: snapTolerance ?? 8,\n collapseThreshold,\n requestCollapse: () => shell.setInspectorMode('collapsed'),\n requestToggle: () => shell.togglePane('inspector'),\n }}\n >\n {handleChildren.length > 0 ? handleChildren.map((el, i) => React.cloneElement(el, { key: el.key ?? i })) : <PaneHandle />}\n </PaneResizeContext.Provider>\n ) : null;\n\n // Normalize CSS lengths to px\n const normalizeToPx = React.useCallback((value: number | string | undefined): number | undefined => {\n if (value == null) return undefined;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n const str = String(value).trim();\n if (!str) return undefined;\n if (str.endsWith('px')) return Number.parseFloat(str);\n if (str.endsWith('rem')) {\n const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize || '16') || 16;\n return Number.parseFloat(str) * rem;\n }\n if (str.endsWith('%')) {\n const pct = Number.parseFloat(str);\n const base = document.documentElement.clientWidth || window.innerWidth || 0;\n return (pct / 100) * base;\n }\n const n = Number.parseFloat(str);\n return Number.isFinite(n) ? n : undefined;\n }, []);\n\n // Apply defaultSize on mount when uncontrolled\n React.useEffect(() => {\n if (!localRef.current) return;\n if (typeof (props as any).size === 'undefined' && typeof (props as any).defaultSize !== 'undefined') {\n const px = normalizeToPx((props as any).defaultSize);\n if (typeof px === 'number' && Number.isFinite(px)) {\n const minPx = typeof minSize === 'number' ? minSize : undefined;\n const maxPx = typeof maxSize === 'number' ? maxSize : undefined;\n const clamped = Math.min(maxPx ?? px, Math.max(minPx ?? px, px));\n localRef.current.style.setProperty('--inspector-size', `${clamped}px`);\n emitSizeChange(clamped, { reason: 'init' });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Controlled size sync\n React.useEffect(() => {\n if (!localRef.current) return;\n if (typeof (props as any).size === 'undefined') return;\n const px = normalizeToPx((props as any).size);\n if (typeof px === 'number' && Number.isFinite(px)) {\n const minPx = typeof minSize === 'number' ? minSize : undefined;\n const maxPx = typeof maxSize === 'number' ? maxSize : undefined;\n const clamped = Math.min(maxPx ?? px, Math.max(minPx ?? px, px));\n localRef.current.style.setProperty('--inspector-size', `${clamped}px`);\n emitSizeChange(clamped, { reason: 'controlled' });\n }\n }, [(props as any).size, minSize, maxSize, normalizeToPx, emitSizeChange]);\n\n if (isOverlay) {\n const open = shell.inspectorMode === 'expanded';\n return (\n <Sheet.Root open={open} onOpenChange={(o) => shell.setInspectorMode(o ? 'expanded' : 'collapsed')}>\n <Sheet.Content side=\"end\" style={{ padding: 0 }} width={{ initial: `${expandedSize}px` }}>\n <VisuallyHidden>\n <Sheet.Title>Inspector</Sheet.Title>\n </VisuallyHidden>\n {contentChildren}\n </Sheet.Content>\n </Sheet.Root>\n );\n }\n\n // Strip control/size props from DOM spread\n const {\n defaultOpen: _inspectorDefaultOpenIgnored,\n open: _inspectorOpenIgnored,\n onOpenChange: _inspectorOnOpenChangeIgnored,\n size: _sz,\n defaultSize: _dsz,\n onSizeChange: _osc,\n sizeUpdate: _szu,\n sizeUpdateMs: _szums,\n ...inspectorDomProps\n } = props as any;\n\n return (\n <div\n {...inspectorDomProps}\n ref={setRef}\n className={classNames('rt-ShellInspector', className)}\n data-mode={shell.inspectorMode}\n data-peek={shell.peekTarget === 'inspector' || undefined}\n data-presentation={shell.currentBreakpointReady ? resolvedPresentation : undefined}\n data-open={(shell.currentBreakpointReady && isStacked && isExpanded) || undefined}\n style={{\n ...style,\n ['--inspector-size' as any]: `${expandedSize}px`,\n ['--inspector-min-size' as any]: `${minSize}px`,\n ['--inspector-max-size' as any]: `${maxSize}px`,\n }}\n >\n <div className=\"rt-ShellInspectorContent\" data-visible={isExpanded || undefined}>\n {contentChildren}\n </div>\n {handleEl}\n </div>\n );\n },\n) as InspectorComponent;\n\nInspector.displayName = 'Shell.Inspector';\nInspector.Handle = InspectorHandle;\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,OAAgB,aACvB,UAAYC,MAAW,cACvB,OAAS,kBAAAC,OAAsB,wBAC/B,OAAS,YAAAC,OAAgB,sBACzB,OAAS,6BAAAC,GAA2B,sBAAAC,MAA0B,oBAC9D,OAAS,qBAAAC,OAAyB,oBAClC,OAAS,mBAAAC,EAAiB,cAAAC,OAAkB,qBAC5C,MAA6B,oBAqCtB,MAAMC,EAAYV,EAAM,WAC7B,CACE,CACE,UAAAW,EACA,aAAAC,EAAe,CAAE,QAAS,UAAW,GAAI,OAAQ,EAGjD,YAAAC,EACA,KAAAC,EACA,aAAAC,EACA,aAAAC,EAAe,IACf,QAAAC,EAAU,IACV,QAAAC,EAAU,IACV,UAAAC,EAAY,GACZ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,EAAS,QAAQ,MAAM,YAAY,mBAAoB,GAAGgD,CAAO,IAAI,EACrEzC,EAAeyC,EAAS,CAAE,OAAQ,YAAa,CAAC,CAClD,CACF,EAAG,CAAEtD,EAAc,KAAMhB,EAASC,EAAS6D,EAAejC,CAAc,CAAC,EAErET,EAAW,CACb,MAAMvB,EAAOqB,EAAM,gBAAkB,WACrC,OACEnC,EAAA,cAACE,EAAM,KAAN,CAAW,KAAMY,EAAM,aAAe,GAAMqB,EAAM,iBAAiB,EAAI,WAAa,WAAW,GAC9FnC,EAAA,cAACE,EAAM,QAAN,CAAc,KAAK,MAAM,MAAO,CAAE,QAAS,CAAE,EAAG,MAAO,CAAE,QAAS,GAAGc,CAAY,IAAK,GACrFhB,EAAA,cAACG,GAAA,KACCH,EAAA,cAACE,EAAM,MAAN,KAAY,WAAS,CACxB,EACC2C,CACH,CACF,CAEJ,CAGA,KAAM,CACJ,YAAa2C,GACb,KAAMC,GACN,aAAcC,GACd,KAAMC,GACN,YAAaC,GACb,aAAcC,GACd,WAAYC,GACZ,aAAcC,GACd,GAAGC,EACL,EAAI/D,EAEJ,OACEjC,EAAA,cAAC,OACE,GAAGgG,GACJ,IAAKxD,GACL,UAAWvC,GAAW,oBAAqBU,CAAS,EACpD,YAAWwB,EAAM,cACjB,YAAWA,EAAM,aAAe,aAAe,OAC/C,oBAAmBA,EAAM,uBAAyBC,EAAuB,OACzE,YAAYD,EAAM,wBAA0BG,IAAa2B,GAAe,OACxE,MAAO,CACL,GAAGjC,EACF,mBAA4B,GAAGhB,CAAY,KAC3C,uBAAgC,GAAGC,CAAO,KAC1C,uBAAgC,GAAGC,CAAO,IAC7C,GAEAlB,EAAA,cAAC,OAAI,UAAU,2BAA2B,eAAciE,GAAc,QACnEpB,CACH,EACC2B,EACH,CAEJ,CACF,EAEA9D,EAAU,YAAc,kBACxBA,EAAU,OAASF",
|
|
6
6
|
"names": ["React", "classNames", "Sheet", "VisuallyHidden", "useShell", "useResponsivePresentation", "useResponsiveValue", "PaneResizeContext", "InspectorHandle", "PaneHandle", "Inspector", "className", "presentation", "defaultOpen", "open", "onOpenChange", "expandedSize", "minSize", "maxSize", "resizable", "collapsible", "onExpand", "onCollapse", "onResize", "onResizeStart", "onResizeEnd", "snapPoints", "snapTolerance", "collapseThreshold", "paneId", "persistence", "children", "style", "props", "ref", "shell", "resolvedPresentation", "isOverlay", "isStacked", "localRef", "setRef", "node", "childArray", "handleChildren", "el", "contentChildren", "emitSizeChange", "cb", "strategy", "ms", "t", "s", "meta", "last", "now", "wasControlledRef", "isControlled", "responsiveNotifiedRef", "didInitFromDefaultOpenRef", "resolvedDefaultOpen", "initialOpen", "resolvedOpen", "shouldExpand", "initNotifiedRef", "lastInspectorModeRef", "isExpanded", "persistenceAdapter", "key", "v", "size", "mounted", "loaded", "handleEl", "client", "startClient", "startSize", "isRtl", "delta", "i", "normalizeToPx", "value", "str", "rem", "pct", "base", "n", "px", "clamped", "_inspectorDefaultOpenIgnored", "_inspectorOpenIgnored", "_inspectorOnOpenChangeIgnored", "_sz", "_dsz", "_osc", "_szu", "_szums", "inspectorDomProps"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-sidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/_internal/shell-sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAE,aAAa,EAAc,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"shell-sidebar.d.ts","sourceRoot":"","sources":["../../../../src/components/_internal/shell-sidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAE,aAAa,EAAc,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE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Hidden as ce}from"../visually-hidden.js";import{useShell as j}from"../shell.context.js";import{useResponsivePresentation as fe,useResponsiveValue as q}from"../shell.hooks.js";import{PaneResizeContext as be}from"./shell-resize.js";import{SidebarHandle as F,PaneHandle as pe}from"./shell-handles.js";import"../shell.types.js";const K=r.forwardRef(({className:G,presentation:J={initial:"overlay",md:"fixed"},expandedSize:u=288,minSize:c=200,maxSize:f=400,resizable:C=!1,collapsible:Q=!0,onExpand:$,onCollapse:U,onResize:z,onResizeStart:X,onResizeEnd:Y,snapPoints:Z,snapTolerance:ee,collapseThreshold:te,paneId:x,persistence:E,children:ne,style:re,thinSize:y=64,toggleModes:w,state:b,defaultState:p,onStateChange:N,...s},S)=>{const t=j(),k=fe(J),M=k==="overlay",oe=k==="stacked",d=r.useRef(null),ae=r.useCallback(e=>{d.current=e,typeof S=="function"?S(e):S&&(S.current=e)},[S]),
|
|
1
|
+
import*as r from"react";import ue from"classnames";import*as D from"../sheet.js";import{VisuallyHidden as ce}from"../visually-hidden.js";import{useShell as j}from"../shell.context.js";import{useResponsivePresentation as fe,useResponsiveValue as q}from"../shell.hooks.js";import{PaneResizeContext as be}from"./shell-resize.js";import{SidebarHandle as F,PaneHandle as pe}from"./shell-handles.js";import"../shell.types.js";const K=r.forwardRef(({className:G,presentation:J={initial:"overlay",md:"fixed"},expandedSize:u=288,minSize:c=200,maxSize:f=400,resizable:C=!1,collapsible:Q=!0,onExpand:$,onCollapse:U,onResize:z,onResizeStart:X,onResizeEnd:Y,snapPoints:Z,snapTolerance:ee,collapseThreshold:te,paneId:x,persistence:E,children:ne,style:re,thinSize:y=64,toggleModes:w,state:b,defaultState:p,onStateChange:N,...s},S)=>{const t=j(),k=fe(J),M=k==="overlay",oe=k==="stacked",d=r.useRef(null),ae=r.useCallback(e=>{d.current=e,typeof S=="function"?S(e):S&&(S.current=e)},[S]),_=r.Children.toArray(ne),O=_.filter(e=>r.isValidElement(e)&&e.type===F),V=_.filter(e=>!(r.isValidElement(e)&&e.type===F)),h=r.useMemo(()=>{const e=s.onSizeChange,n=s.sizeUpdate,o=s.sizeUpdateMs??50;if(!e)return()=>{};if(n==="debounce"){let a=null;return(i,m)=>{a&&clearTimeout(a),a=setTimeout(()=>{e(i,m)},o)}}if(n==="throttle"){let a=0;return(i,m)=>{const L=Date.now();L-a>=o&&(a=L,e(i,m))}}return(a,i)=>e(a,i)},[s.onSizeChange,s.sizeUpdate,s.sizeUpdateMs]),ie=r.useId();r.useEffect(()=>(t.setHasSidebar(!0),()=>{t.setHasSidebar(!1)}),[t,ie]);const g=r.useRef(null);r.useEffect(()=>{const e=typeof b<"u";if(g.current===null){g.current=e;return}g.current!==e&&(console.warn("Shell.Sidebar: Switching between controlled and uncontrolled `state` is not supported."),g.current=e)},[b]);const l=q(b),B=q(p),W=r.useRef(!1);r.useEffect(()=>{if(!W.current&&t.currentBreakpointReady){if(W.current=!0,typeof b<"u"&&l){t.sidebarMode!==l&&t.setSidebarMode(l);return}if(typeof p<"u"){const e=B??p;t.sidebarMode!==e&&t.setSidebarMode(e),N?.(e,{reason:"init"});return}}},[t.currentBreakpointReady,B,l,b,p]),r.useEffect(()=>{l!==void 0&&t.sidebarMode!==l&&t.setSidebarMode(l)},[l,t.sidebarMode]);const P=r.useRef(null);r.useEffect(()=>{typeof b>"u"&&(P.current===null?P.current=t.sidebarMode:P.current!==t.sidebarMode&&(P.current=t.sidebarMode,N?.(t.sidebarMode,{reason:"toggle"})))},[t.sidebarMode,b,N]),r.useEffect(()=>{t.sidebarMode==="expanded"?$?.():U?.()},[t.sidebarMode,$,U]);const A=t.sidebarMode!=="collapsed",v=r.useMemo(()=>{if(!x||E)return E;const e=`kookie-ui:shell:sidebar:${x}`;return{load:()=>{if(typeof window>"u")return;const o=window.localStorage.getItem(e);return o?Number(o):void 0},save:o=>{typeof window>"u"||window.localStorage.setItem(e,String(o))}}},[x,E]);r.useEffect(()=>{let e=!0;return(async()=>{if(!C||!v?.load||M)return;const n=await v.load();e&&typeof n=="number"&&d.current&&(d.current.style.setProperty("--sidebar-size",`${n}px`),z?.(n))})(),()=>{e=!1}},[C,v,z,M]);const R=j(),T=r.useCallback(()=>{const e=p??"expanded";return e==="thin"||e==="expanded"?e:"expanded"},[p]);r.useEffect(()=>{if(!R.setSidebarToggleComputer)return;const e=w??"both",n=o=>{if(e==="both")return o==="collapsed"?"thin":o==="thin"?"expanded":"collapsed";const a=T();return o==="collapsed"?a:o===a?"collapsed":a};return R.setSidebarToggleComputer(n),()=>{R.setSidebarToggleComputer?.(o=>o==="collapsed"?"thin":o==="thin"?"expanded":"collapsed")}},[R,w,T]);const I=r.useRef(u),se=r.useRef("expanded");r.useEffect(()=>{t.sidebarMode!=="collapsed"&&(se.current=t.sidebarMode,I.current=t.sidebarMode==="thin"?y:u)},[t.sidebarMode,y,u]);const de=C&&!M&&t.sidebarMode==="expanded"?r.createElement(be.Provider,{value:{containerRef:d,cssVarName:"--sidebar-size",minSize:c,maxSize:f,defaultSize:u,orientation:"vertical",edge:"end",computeNext:(e,n,o)=>{const a=getComputedStyle(d.current).direction==="rtl",i=e-n;return o+(a?-i:i)},onResize:z,onResizeStart:X,onResizeEnd:e=>{Y?.(e),h(e,{reason:"resize"}),v?.save?.(e)},target:"sidebar",collapsible:Q,snapPoints:Z,snapTolerance:ee??8,collapseThreshold:te,requestCollapse:()=>t.setSidebarMode("collapsed"),requestToggle:()=>t.togglePane("sidebar")}},O.length>0?O.map((e,n)=>r.cloneElement(e,{key:e.key??n})):r.createElement(pe,null)):null,{state:me,defaultState:ye,onStateChange:Se,size:Me,defaultSize:he,onSizeChange:ge,sizeUpdate:Pe,sizeUpdateMs:ve,...le}=s,H=r.useCallback(e=>{if(e==null)return;if(typeof e=="number"&&Number.isFinite(e))return e;const n=String(e).trim();if(!n)return;if(n.endsWith("px"))return Number.parseFloat(n);if(n.endsWith("rem")){const a=Number.parseFloat(getComputedStyle(document.documentElement).fontSize||"16")||16;return Number.parseFloat(n)*a}if(n.endsWith("%")){const a=Number.parseFloat(n),i=document.documentElement.clientWidth||window.innerWidth||0;return a/100*i}const o=Number.parseFloat(n);return Number.isFinite(o)?o:void 0},[]);if(r.useEffect(()=>{if(!d.current)return;const{size:e,defaultSize:n}=s;if(typeof e>"u"&&typeof n<"u"){const o=H(n);if(typeof o=="number"&&Number.isFinite(o)){const m=Math.min((typeof f=="number"?f:void 0)??o,Math.max((typeof c=="number"?c:void 0)??o,o));d.current.style.setProperty("--sidebar-size",`${m}px`),h(m,{reason:"init"})}}},[]),r.useEffect(()=>{if(!d.current)return;const{size:e}=s;if(typeof e>"u")return;const n=H(e);if(typeof n=="number"&&Number.isFinite(n)){const i=Math.min((typeof f=="number"?f:void 0)??n,Math.max((typeof c=="number"?c:void 0)??n,n));d.current.style.setProperty("--sidebar-size",`${i}px`),h(i,{reason:"controlled"})}},[s.size,c,f,H,h]),M){const e=t.sidebarMode!=="collapsed";return r.createElement(D.Root,{open:e,onOpenChange:n=>t.setSidebarMode(n?"expanded":"collapsed")},r.createElement(D.Content,{side:"start",style:{padding:0},width:{initial:`${e?t.sidebarMode==="thin"?y:u:I.current}px`}},r.createElement(ce,null,r.createElement(D.Title,null,"Navigation")),V))}return r.createElement("div",{...le,ref:ae,className:ue("rt-ShellSidebar",G),"data-mode":t.sidebarMode,"data-peek":t.peekTarget==="sidebar"||void 0,"data-presentation":t.currentBreakpointReady?k:void 0,"data-open":t.currentBreakpointReady&&oe&&A||void 0,style:{...re,"--sidebar-size":`${u}px`,"--sidebar-thin-size":`${y}px`,"--sidebar-min-size":`${c}px`,"--sidebar-max-size":`${f}px`,...t.peekTarget==="sidebar"&&t.sidebarMode==="collapsed"&&!M?(()=>{const e=w??"both",n=t.sidebarMode;let o;if(e==="both")o=n==="collapsed"?"thin":n==="thin"?"expanded":"collapsed";else{const a=T();o=n==="collapsed"?a:"collapsed"}return o==="thin"?{"--peek-sidebar-width":`${y}px`}:{"--peek-sidebar-width":`var(--sidebar-size, ${u}px)`}})():{}}},r.createElement("div",{className:"rt-ShellSidebarContent","data-visible":A||void 0},V),de)});K.displayName="Shell.Sidebar",K.Handle=F;export{K as Sidebar};
|
|
2
2
|
//# sourceMappingURL=shell-sidebar.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/_internal/shell-sidebar.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport * as Sheet from '../sheet.js';\nimport { VisuallyHidden } from '../visually-hidden.js';\nimport { useShell } from '../shell.context.js';\nimport { useResponsivePresentation, useResponsiveValue } from '../shell.hooks.js';\nimport { PaneResizeContext } from './shell-resize.js';\nimport { SidebarHandle, PaneHandle } from './shell-handles.js';\nimport type { Breakpoint, PaneMode, PaneSizePersistence, PresentationValue, ResponsivePresentation, ResponsiveSidebarMode, SidebarMode, Responsive } from '../shell.types.js';\nimport { BREAKPOINTS } from '../shell.types.js';\n\ninterface PaneProps extends React.ComponentPropsWithoutRef<'div'> {\n presentation?: ResponsivePresentation;\n mode?: PaneMode;\n defaultMode?: any;\n onModeChange?: (mode: PaneMode | SidebarMode) => void;\n expandedSize?: number;\n minSize?: number;\n maxSize?: number;\n resizable?: boolean;\n collapsible?: boolean;\n onExpand?: () => void;\n onCollapse?: () => void;\n onResize?: (size: number) => void;\n resizer?: React.ReactNode;\n onResizeStart?: (size: number) => void;\n onResizeEnd?: (size: number) => void;\n snapPoints?: number[];\n snapTolerance?: number;\n collapseThreshold?: number;\n paneId?: string;\n persistence?: PaneSizePersistence;\n}\n\ntype SidebarStateChangeMeta = { reason: 'init' | 'toggle' | 'responsive' };\ntype SidebarControlledProps = { state: Responsive<SidebarMode>; onStateChange?: (state: SidebarMode, meta: SidebarStateChangeMeta) => void; defaultState?: never };\ntype SidebarUncontrolledProps = { defaultState?: SidebarMode | Partial<Record<Breakpoint, SidebarMode>>; onStateChange?: (state: SidebarMode, meta: SidebarStateChangeMeta) => void; state?: never };\ntype SidebarPublicProps = Omit<PaneProps, 'mode' | 'defaultMode' | 'onModeChange'> & {\n // removed legacy mode props\n thinSize?: number;\n toggleModes?: 'both' | 'single';\n // size API (width when expanded)\n size?: number | string;\n defaultSize?: number | string;\n onSizeChange?: (size: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => void;\n sizeUpdate?: 'throttle' | 'debounce';\n sizeUpdateMs?: number;\n} & (SidebarControlledProps | SidebarUncontrolledProps);\n\ntype SidebarComponent = React.ForwardRefExoticComponent<SidebarPublicProps & React.RefAttributes<HTMLDivElement>> & { Handle: typeof SidebarHandle };\n\nexport const Sidebar = React.forwardRef<HTMLDivElement, SidebarPublicProps>(\n (\n {\n className,\n presentation = { initial: 'overlay', md: 'fixed' },\n // removed legacy props\n expandedSize = 288,\n minSize = 200,\n maxSize = 400,\n resizable = false,\n collapsible = true,\n onExpand,\n onCollapse,\n onResize,\n onResizeStart,\n onResizeEnd,\n snapPoints,\n snapTolerance,\n collapseThreshold,\n paneId,\n persistence,\n children,\n style,\n thinSize = 64,\n toggleModes,\n // new state props (XOR)\n state,\n defaultState,\n onStateChange,\n ...props\n },\n ref,\n ) => {\n const shell = useShell();\n const resolvedPresentation = useResponsivePresentation(presentation);\n const isOverlay = resolvedPresentation === 'overlay';\n const isStacked = resolvedPresentation === 'stacked';\n // Phase sequencing is now CSS-driven; no JS-managed phase\n const localRef = React.useRef<HTMLDivElement | null>(null);\n const setRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n localRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n },\n [ref],\n );\n const childArray = React.Children.toArray(children) as React.ReactElement[];\n const handleChildren = childArray.filter((el: React.ReactElement) => React.isValidElement(el) && el.type === SidebarHandle);\n const contentChildren = childArray.filter((el: React.ReactElement) => !(React.isValidElement(el) && el.type === SidebarHandle));\n\n // Throttled/debounced emitter for onSizeChange\n const emitSizeChange = React.useMemo(() => {\n const cb = (props as any).onSizeChange as undefined | ((s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => void);\n const strategy = (props as any).sizeUpdate as undefined | 'throttle' | 'debounce';\n const ms = (props as any).sizeUpdateMs ?? 50;\n if (!cb) return () => {};\n if (strategy === 'debounce') {\n let t: any = null;\n return (s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => {\n if (t) clearTimeout(t);\n t = setTimeout(() => {\n cb(s, meta);\n }, ms);\n };\n }\n if (strategy === 'throttle') {\n let last = 0;\n return (s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => {\n const now = Date.now();\n if (now - last >= ms) {\n last = now;\n cb(s, meta);\n }\n };\n }\n return (s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => cb(s, meta);\n }, [(props as any).onSizeChange, (props as any).sizeUpdate, (props as any).sizeUpdateMs]);\n\n // Register with shell\n const sidebarId = React.useId();\n React.useEffect(() => {\n shell.setHasSidebar(true);\n return () => {\n shell.setHasSidebar(false);\n };\n }, [shell, sidebarId]);\n\n // Dev guards\n const wasControlledRef = React.useRef<boolean | null>(null);\n if (process.env.NODE_ENV !== 'production') {\n if (typeof state !== 'undefined' && typeof defaultState !== 'undefined') {\n // eslint-disable-next-line no-console\n console.error('Shell.Sidebar: Do not pass both `state` and `defaultState`. Choose one.');\n }\n if (typeof (props as any).size !== 'undefined' && typeof (props as any).defaultSize !== 'undefined') {\n // eslint-disable-next-line no-console\n console.error('Shell.Sidebar: Do not pass both `size` and `defaultSize`. Choose one.');\n }\n }\n\n // Warn on mode switch between controlled/uncontrolled\n React.useEffect(() => {\n const isControlled = typeof state !== 'undefined';\n if (wasControlledRef.current === null) {\n wasControlledRef.current = isControlled;\n return;\n }\n if (wasControlledRef.current !== isControlled) {\n // eslint-disable-next-line no-console\n console.warn('Shell.Sidebar: Switching between controlled and uncontrolled `state` is not supported.');\n wasControlledRef.current = isControlled;\n }\n }, [state]);\n\n // Resolve responsive controlled state at top level\n const resolvedState = useResponsiveValue(state);\n const resolvedDefaultState = useResponsiveValue(defaultState as any);\n\n // Honor state/defaultState on mount when uncontrolled\n const didInitRef = React.useRef(false);\n React.useEffect(() => {\n if (didInitRef.current) return;\n if (!shell.currentBreakpointReady) return;\n didInitRef.current = true;\n // Controlled state may be responsive; use resolved value\n if (typeof state !== 'undefined' && resolvedState) {\n if (shell.sidebarMode !== resolvedState) shell.setSidebarMode(resolvedState);\n return;\n }\n if (typeof defaultState !== 'undefined') {\n const initialState = (resolvedDefaultState ?? defaultState) as SidebarMode;\n if (shell.sidebarMode !== initialState) {\n shell.setSidebarMode(initialState);\n }\n onStateChange?.(initialState, { reason: 'init' });\n return;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [shell.currentBreakpointReady, resolvedDefaultState, resolvedState, state, defaultState]);\n\n // Sync controlled state (responsive-aware)\n React.useEffect(() => {\n if (resolvedState === undefined) return;\n if (shell.sidebarMode !== resolvedState) shell.setSidebarMode(resolvedState);\n }, [resolvedState, shell.sidebarMode]);\n\n // Emit mode changes\n const lastNotifyModeRef = React.useRef<SidebarMode | null>(null);\n React.useEffect(() => {\n // notify new API when uncontrolled; skip first run to avoid masking init\n if (typeof state === 'undefined') {\n if (lastNotifyModeRef.current === null) {\n lastNotifyModeRef.current = shell.sidebarMode as SidebarMode;\n } else if (lastNotifyModeRef.current !== shell.sidebarMode) {\n lastNotifyModeRef.current = shell.sidebarMode as SidebarMode;\n onStateChange?.(shell.sidebarMode as SidebarMode, { reason: 'toggle' });\n }\n }\n }, [shell.sidebarMode, state, onStateChange]);\n\n // Emit expand/collapse events\n React.useEffect(() => {\n if (shell.sidebarMode === 'expanded') {\n onExpand?.();\n } else {\n onCollapse?.();\n }\n }, [shell.sidebarMode, onExpand, onCollapse]);\n\n // Option A: thin is width-only; content remains visible whenever not collapsed\n const isContentVisible = shell.sidebarMode !== 'collapsed';\n\n // Default persistence if paneId provided and none supplied (fixed only)\n const persistenceAdapter = React.useMemo(() => {\n if (!paneId || persistence) return persistence;\n const key = `kookie-ui:shell:sidebar:${paneId}`;\n const adapter: PaneSizePersistence = {\n load: () => {\n if (typeof window === 'undefined') return undefined;\n const v = window.localStorage.getItem(key);\n return v ? Number(v) : undefined;\n },\n save: (size: number) => {\n if (typeof window === 'undefined') return;\n window.localStorage.setItem(key, String(size));\n },\n };\n return adapter;\n }, [paneId, persistence]);\n\n React.useEffect(() => {\n let mounted = true;\n (async () => {\n if (!resizable || !persistenceAdapter?.load || isOverlay) return;\n const loaded = await persistenceAdapter.load();\n if (mounted && typeof loaded === 'number' && localRef.current) {\n localRef.current.style.setProperty('--sidebar-size', `${loaded}px`);\n onResize?.(loaded);\n }\n })();\n return () => {\n mounted = false;\n };\n }, [resizable, persistenceAdapter, onResize, isOverlay]);\n\n // Register custom toggle behavior based on toggleModes (both|single)\n const shellForToggle = useShell();\n const resolveDefaultSidebarMode = React.useCallback((): SidebarMode => {\n const resolved = defaultState ?? 'expanded';\n return resolved === 'thin' || resolved === 'expanded' ? resolved : 'expanded';\n }, [defaultState]);\n\n React.useEffect(() => {\n if (!shellForToggle.setSidebarToggleComputer) return;\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const compute = (current: SidebarMode): SidebarMode => {\n if (strategy === 'both') {\n if (current === 'collapsed') return 'thin';\n if (current === 'thin') return 'expanded';\n return 'collapsed';\n }\n const target = resolveDefaultSidebarMode();\n if (current === 'collapsed') return target;\n if (current === target) return 'collapsed';\n return target;\n };\n shellForToggle.setSidebarToggleComputer(compute);\n return () => {\n shellForToggle.setSidebarToggleComputer?.((cur) => (cur === 'collapsed' ? 'thin' : cur === 'thin' ? 'expanded' : 'collapsed'));\n };\n }, [shellForToggle, toggleModes, resolveDefaultSidebarMode]);\n\n const lastOverlayWidthRef = React.useRef<number>(expandedSize);\n const lastOverlayModeRef = React.useRef<SidebarMode>('expanded');\n React.useEffect(() => {\n if (shell.sidebarMode !== 'collapsed') {\n lastOverlayModeRef.current = shell.sidebarMode as SidebarMode;\n lastOverlayWidthRef.current = shell.sidebarMode === 'thin' ? thinSize : expandedSize;\n }\n }, [shell.sidebarMode, thinSize, expandedSize]);\n\n // Remove responsive default mode behavior entirely\n\n const handleEl =\n resizable && !isOverlay && shell.sidebarMode === 'expanded' ? (\n <PaneResizeContext.Provider\n value={{\n containerRef: localRef,\n cssVarName: '--sidebar-size',\n minSize,\n maxSize,\n defaultSize: expandedSize,\n orientation: 'vertical',\n edge: 'end',\n computeNext: (client, startClient, startSize) => {\n const isRtl = getComputedStyle(localRef.current!).direction === 'rtl';\n const delta = client - startClient;\n return startSize + (isRtl ? -delta : delta);\n },\n onResize,\n onResizeStart,\n onResizeEnd: (size) => {\n onResizeEnd?.(size);\n emitSizeChange(size, { reason: 'resize' });\n persistenceAdapter?.save?.(size);\n },\n target: 'sidebar',\n collapsible,\n snapPoints,\n snapTolerance: snapTolerance ?? 8,\n collapseThreshold,\n requestCollapse: () => shell.setSidebarMode('collapsed'),\n requestToggle: () => shell.togglePane('sidebar'),\n }}\n >\n {handleChildren.length > 0 ? handleChildren.map((el, i) => React.cloneElement(el, { key: el.key ?? i })) : <PaneHandle />}\n </PaneResizeContext.Provider>\n ) : null;\n\n // Strip new API props from DOM\n const { state: _s, defaultState: _ds, onStateChange: _osc, size: _sz, defaultSize: _dsz, onSizeChange: _onsc, sizeUpdate: _szu, sizeUpdateMs: _szums, ...domProps } = props as any;\n\n // Normalize CSS lengths to px\n const normalizeToPx = React.useCallback((value: number | string | undefined): number | undefined => {\n if (value == null) return undefined;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n const str = String(value).trim();\n if (!str) return undefined;\n if (str.endsWith('px')) return Number.parseFloat(str);\n if (str.endsWith('rem')) {\n const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize || '16') || 16;\n return Number.parseFloat(str) * rem;\n }\n if (str.endsWith('%')) {\n const pct = Number.parseFloat(str);\n const base = document.documentElement.clientWidth || window.innerWidth || 0;\n return (pct / 100) * base;\n }\n const n = Number.parseFloat(str);\n return Number.isFinite(n) ? n : undefined;\n }, []);\n\n // Apply defaultSize on mount when uncontrolled\n React.useEffect(() => {\n if (!localRef.current) return;\n const { size, defaultSize } = props as any;\n if (typeof size === 'undefined' && typeof defaultSize !== 'undefined') {\n const px = normalizeToPx(defaultSize);\n if (typeof px === 'number' && Number.isFinite(px)) {\n const minPx = typeof minSize === 'number' ? minSize : undefined;\n const maxPx = typeof maxSize === 'number' ? maxSize : undefined;\n const clamped = Math.min(maxPx ?? px, Math.max(minPx ?? px, px));\n localRef.current.style.setProperty('--sidebar-size', `${clamped}px`);\n emitSizeChange(clamped, { reason: 'init' });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Controlled size sync\n React.useEffect(() => {\n if (!localRef.current) return;\n const { size } = props as any;\n if (typeof size === 'undefined') return;\n const px = normalizeToPx(size);\n if (typeof px === 'number' && Number.isFinite(px)) {\n const minPx = typeof minSize === 'number' ? minSize : undefined;\n const maxPx = typeof maxSize === 'number' ? maxSize : undefined;\n const clamped = Math.min(maxPx ?? px, Math.max(minPx ?? px, px));\n localRef.current.style.setProperty('--sidebar-size', `${clamped}px`);\n emitSizeChange(clamped, { reason: 'controlled' });\n }\n }, [(props as any).size, minSize, maxSize, normalizeToPx, emitSizeChange]);\n\n if (isOverlay) {\n const open = shell.sidebarMode !== 'collapsed';\n return (\n <Sheet.Root open={open} onOpenChange={(o) => shell.setSidebarMode(o ? 'expanded' : 'collapsed')}>\n <Sheet.Content\n side=\"start\"\n style={{ padding: 0 }}\n width={{\n initial: `${open ? (shell.sidebarMode === 'thin' ? thinSize : expandedSize) : lastOverlayWidthRef.current}px`,\n }}\n >\n <VisuallyHidden>\n <Sheet.Title>Navigation</Sheet.Title>\n </VisuallyHidden>\n {contentChildren}\n </Sheet.Content>\n </Sheet.Root>\n );\n }\n return (\n <div\n {...domProps}\n ref={setRef}\n className={classNames('rt-ShellSidebar', className)}\n data-mode={shell.sidebarMode}\n data-peek={shell.peekTarget === 'sidebar' || undefined}\n data-presentation={shell.currentBreakpointReady ? resolvedPresentation : undefined}\n data-open={(shell.currentBreakpointReady && isStacked && isContentVisible) || undefined}\n style={{\n ...style,\n ['--sidebar-size' as any]: `${expandedSize}px`,\n ['--sidebar-thin-size' as any]: `${thinSize}px`,\n ['--sidebar-min-size' as any]: `${minSize}px`,\n ['--sidebar-max-size' as any]: `${maxSize}px`,\n ...(shell.peekTarget === 'sidebar' && shell.sidebarMode === 'collapsed' && !isOverlay\n ? (() => {\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const current = shell.sidebarMode as SidebarMode;\n let next: SidebarMode;\n if (strategy === 'both') {\n next = current === 'collapsed' ? 'thin' : current === 'thin' ? 'expanded' : 'collapsed';\n } else {\n const target = resolveDefaultSidebarMode();\n next = current === 'collapsed' ? target : 'collapsed';\n }\n if (next === 'thin') {\n return {\n ['--peek-sidebar-width' as any]: `${thinSize}px`,\n } as React.CSSProperties;\n }\n return {\n ['--peek-sidebar-width' as any]: `var(--sidebar-size, ${expandedSize}px)`,\n } as React.CSSProperties;\n })()\n : {}),\n }}\n >\n <div className=\"rt-ShellSidebarContent\" data-visible={isContentVisible || undefined}>\n {contentChildren}\n </div>\n {handleEl}\n </div>\n );\n },\n) as SidebarComponent;\n\nSidebar.displayName = 'Shell.Sidebar';\nSidebar.Handle = SidebarHandle;\n"],
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,OAAgB,aACvB,UAAYC,MAAW,cACvB,OAAS,kBAAAC,OAAsB,wBAC/B,OAAS,YAAAC,MAAgB,sBACzB,OAAS,6BAAAC,GAA2B,sBAAAC,MAA0B,oBAC9D,OAAS,qBAAAC,OAAyB,oBAClC,OAAS,iBAAAC,EAAe,cAAAC,OAAkB,qBAE1C,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\nimport * as Sheet from '../sheet.js';\nimport { VisuallyHidden } from '../visually-hidden.js';\nimport { useShell } from '../shell.context.js';\nimport { useResponsivePresentation, useResponsiveValue } from '../shell.hooks.js';\nimport { PaneResizeContext } from './shell-resize.js';\nimport { SidebarHandle, PaneHandle } from './shell-handles.js';\nimport type { Breakpoint, PaneMode, PaneSizePersistence, ResponsivePresentation, SidebarMode, Responsive } from '../shell.types.js';\nimport { _BREAKPOINTS } from '../shell.types.js';\n\ninterface PaneProps extends React.ComponentPropsWithoutRef<'div'> {\n presentation?: ResponsivePresentation;\n mode?: PaneMode;\n defaultMode?: any;\n onModeChange?: (mode: PaneMode | SidebarMode) => void;\n expandedSize?: number;\n minSize?: number;\n maxSize?: number;\n resizable?: boolean;\n collapsible?: boolean;\n onExpand?: () => void;\n onCollapse?: () => void;\n onResize?: (size: number) => void;\n resizer?: React.ReactNode;\n onResizeStart?: (size: number) => void;\n onResizeEnd?: (size: number) => void;\n snapPoints?: number[];\n snapTolerance?: number;\n collapseThreshold?: number;\n paneId?: string;\n persistence?: PaneSizePersistence;\n}\n\ntype SidebarStateChangeMeta = { reason: 'init' | 'toggle' | 'responsive' };\ntype SidebarControlledProps = { state: Responsive<SidebarMode>; onStateChange?: (state: SidebarMode, meta: SidebarStateChangeMeta) => void; defaultState?: never };\ntype SidebarUncontrolledProps = { defaultState?: SidebarMode | Partial<Record<Breakpoint, SidebarMode>>; onStateChange?: (state: SidebarMode, meta: SidebarStateChangeMeta) => void; state?: never };\ntype SidebarPublicProps = Omit<PaneProps, 'mode' | 'defaultMode' | 'onModeChange'> & {\n // removed legacy mode props\n thinSize?: number;\n toggleModes?: 'both' | 'single';\n // size API (width when expanded)\n size?: number | string;\n defaultSize?: number | string;\n onSizeChange?: (size: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => void;\n sizeUpdate?: 'throttle' | 'debounce';\n sizeUpdateMs?: number;\n} & (SidebarControlledProps | SidebarUncontrolledProps);\n\ntype SidebarComponent = React.ForwardRefExoticComponent<SidebarPublicProps & React.RefAttributes<HTMLDivElement>> & { Handle: typeof SidebarHandle };\n\nexport const Sidebar = React.forwardRef<HTMLDivElement, SidebarPublicProps>(\n (\n {\n className,\n presentation = { initial: 'overlay', md: 'fixed' },\n // removed legacy props\n expandedSize = 288,\n minSize = 200,\n maxSize = 400,\n resizable = false,\n collapsible = true,\n onExpand,\n onCollapse,\n onResize,\n onResizeStart,\n onResizeEnd,\n snapPoints,\n snapTolerance,\n collapseThreshold,\n paneId,\n persistence,\n children,\n style,\n thinSize = 64,\n toggleModes,\n // new state props (XOR)\n state,\n defaultState,\n onStateChange,\n ...props\n },\n ref,\n ) => {\n const shell = useShell();\n const resolvedPresentation = useResponsivePresentation(presentation);\n const isOverlay = resolvedPresentation === 'overlay';\n const isStacked = resolvedPresentation === 'stacked';\n // Phase sequencing is now CSS-driven; no JS-managed phase\n const localRef = React.useRef<HTMLDivElement | null>(null);\n const setRef = React.useCallback(\n (node: HTMLDivElement | null) => {\n localRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;\n },\n [ref],\n );\n const childArray = React.Children.toArray(children) as React.ReactElement[];\n const handleChildren = childArray.filter((el: React.ReactElement) => React.isValidElement(el) && el.type === SidebarHandle);\n const contentChildren = childArray.filter((el: React.ReactElement) => !(React.isValidElement(el) && el.type === SidebarHandle));\n\n // Throttled/debounced emitter for onSizeChange\n const emitSizeChange = React.useMemo(() => {\n const cb = (props as any).onSizeChange as undefined | ((s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => void);\n const strategy = (props as any).sizeUpdate as undefined | 'throttle' | 'debounce';\n const ms = (props as any).sizeUpdateMs ?? 50;\n if (!cb) return () => {};\n if (strategy === 'debounce') {\n let t: any = null;\n return (s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => {\n if (t) clearTimeout(t);\n t = setTimeout(() => {\n cb(s, meta);\n }, ms);\n };\n }\n if (strategy === 'throttle') {\n let last = 0;\n return (s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => {\n const now = Date.now();\n if (now - last >= ms) {\n last = now;\n cb(s, meta);\n }\n };\n }\n return (s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => cb(s, meta);\n }, [(props as any).onSizeChange, (props as any).sizeUpdate, (props as any).sizeUpdateMs]);\n\n // Register with shell\n const sidebarId = React.useId();\n React.useEffect(() => {\n shell.setHasSidebar(true);\n return () => {\n shell.setHasSidebar(false);\n };\n }, [shell, sidebarId]);\n\n // Dev guards\n const wasControlledRef = React.useRef<boolean | null>(null);\n if (process.env.NODE_ENV !== 'production') {\n if (typeof state !== 'undefined' && typeof defaultState !== 'undefined') {\n // eslint-disable-next-line no-console\n console.error('Shell.Sidebar: Do not pass both `state` and `defaultState`. Choose one.');\n }\n if (typeof (props as any).size !== 'undefined' && typeof (props as any).defaultSize !== 'undefined') {\n // eslint-disable-next-line no-console\n console.error('Shell.Sidebar: Do not pass both `size` and `defaultSize`. Choose one.');\n }\n }\n\n // Warn on mode switch between controlled/uncontrolled\n React.useEffect(() => {\n const isControlled = typeof state !== 'undefined';\n if (wasControlledRef.current === null) {\n wasControlledRef.current = isControlled;\n return;\n }\n if (wasControlledRef.current !== isControlled) {\n // eslint-disable-next-line no-console\n console.warn('Shell.Sidebar: Switching between controlled and uncontrolled `state` is not supported.');\n wasControlledRef.current = isControlled;\n }\n }, [state]);\n\n // Resolve responsive controlled state at top level\n const resolvedState = useResponsiveValue(state);\n const resolvedDefaultState = useResponsiveValue(defaultState as any);\n\n // Honor state/defaultState on mount when uncontrolled\n const didInitRef = React.useRef(false);\n React.useEffect(() => {\n if (didInitRef.current) return;\n if (!shell.currentBreakpointReady) return;\n didInitRef.current = true;\n // Controlled state may be responsive; use resolved value\n if (typeof state !== 'undefined' && resolvedState) {\n if (shell.sidebarMode !== resolvedState) shell.setSidebarMode(resolvedState);\n return;\n }\n if (typeof defaultState !== 'undefined') {\n const initialState = (resolvedDefaultState ?? defaultState) as SidebarMode;\n if (shell.sidebarMode !== initialState) {\n shell.setSidebarMode(initialState);\n }\n onStateChange?.(initialState, { reason: 'init' });\n return;\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [shell.currentBreakpointReady, resolvedDefaultState, resolvedState, state, defaultState]);\n\n // Sync controlled state (responsive-aware)\n React.useEffect(() => {\n if (resolvedState === undefined) return;\n if (shell.sidebarMode !== resolvedState) shell.setSidebarMode(resolvedState);\n }, [resolvedState, shell.sidebarMode]);\n\n // Emit mode changes\n const lastNotifyModeRef = React.useRef<SidebarMode | null>(null);\n React.useEffect(() => {\n // notify new API when uncontrolled; skip first run to avoid masking init\n if (typeof state === 'undefined') {\n if (lastNotifyModeRef.current === null) {\n lastNotifyModeRef.current = shell.sidebarMode as SidebarMode;\n } else if (lastNotifyModeRef.current !== shell.sidebarMode) {\n lastNotifyModeRef.current = shell.sidebarMode as SidebarMode;\n onStateChange?.(shell.sidebarMode as SidebarMode, { reason: 'toggle' });\n }\n }\n }, [shell.sidebarMode, state, onStateChange]);\n\n // Emit expand/collapse events\n React.useEffect(() => {\n if (shell.sidebarMode === 'expanded') {\n onExpand?.();\n } else {\n onCollapse?.();\n }\n }, [shell.sidebarMode, onExpand, onCollapse]);\n\n // Option A: thin is width-only; content remains visible whenever not collapsed\n const isContentVisible = shell.sidebarMode !== 'collapsed';\n\n // Default persistence if paneId provided and none supplied (fixed only)\n const persistenceAdapter = React.useMemo(() => {\n if (!paneId || persistence) return persistence;\n const key = `kookie-ui:shell:sidebar:${paneId}`;\n const adapter: PaneSizePersistence = {\n load: () => {\n if (typeof window === 'undefined') return undefined;\n const v = window.localStorage.getItem(key);\n return v ? Number(v) : undefined;\n },\n save: (size: number) => {\n if (typeof window === 'undefined') return;\n window.localStorage.setItem(key, String(size));\n },\n };\n return adapter;\n }, [paneId, persistence]);\n\n React.useEffect(() => {\n let mounted = true;\n (async () => {\n if (!resizable || !persistenceAdapter?.load || isOverlay) return;\n const loaded = await persistenceAdapter.load();\n if (mounted && typeof loaded === 'number' && localRef.current) {\n localRef.current.style.setProperty('--sidebar-size', `${loaded}px`);\n onResize?.(loaded);\n }\n })();\n return () => {\n mounted = false;\n };\n }, [resizable, persistenceAdapter, onResize, isOverlay]);\n\n // Register custom toggle behavior based on toggleModes (both|single)\n const shellForToggle = useShell();\n const resolveDefaultSidebarMode = React.useCallback((): SidebarMode => {\n const resolved = defaultState ?? 'expanded';\n return resolved === 'thin' || resolved === 'expanded' ? resolved : 'expanded';\n }, [defaultState]);\n\n React.useEffect(() => {\n if (!shellForToggle.setSidebarToggleComputer) return;\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const compute = (current: SidebarMode): SidebarMode => {\n if (strategy === 'both') {\n if (current === 'collapsed') return 'thin';\n if (current === 'thin') return 'expanded';\n return 'collapsed';\n }\n const target = resolveDefaultSidebarMode();\n if (current === 'collapsed') return target;\n if (current === target) return 'collapsed';\n return target;\n };\n shellForToggle.setSidebarToggleComputer(compute);\n return () => {\n shellForToggle.setSidebarToggleComputer?.((cur) => (cur === 'collapsed' ? 'thin' : cur === 'thin' ? 'expanded' : 'collapsed'));\n };\n }, [shellForToggle, toggleModes, resolveDefaultSidebarMode]);\n\n const lastOverlayWidthRef = React.useRef<number>(expandedSize);\n const lastOverlayModeRef = React.useRef<SidebarMode>('expanded');\n React.useEffect(() => {\n if (shell.sidebarMode !== 'collapsed') {\n lastOverlayModeRef.current = shell.sidebarMode as SidebarMode;\n lastOverlayWidthRef.current = shell.sidebarMode === 'thin' ? thinSize : expandedSize;\n }\n }, [shell.sidebarMode, thinSize, expandedSize]);\n\n // Remove responsive default mode behavior entirely\n\n const handleEl =\n resizable && !isOverlay && shell.sidebarMode === 'expanded' ? (\n <PaneResizeContext.Provider\n value={{\n containerRef: localRef,\n cssVarName: '--sidebar-size',\n minSize,\n maxSize,\n defaultSize: expandedSize,\n orientation: 'vertical',\n edge: 'end',\n computeNext: (client, startClient, startSize) => {\n const isRtl = getComputedStyle(localRef.current!).direction === 'rtl';\n const delta = client - startClient;\n return startSize + (isRtl ? -delta : delta);\n },\n onResize,\n onResizeStart,\n onResizeEnd: (size) => {\n onResizeEnd?.(size);\n emitSizeChange(size, { reason: 'resize' });\n persistenceAdapter?.save?.(size);\n },\n target: 'sidebar',\n collapsible,\n snapPoints,\n snapTolerance: snapTolerance ?? 8,\n collapseThreshold,\n requestCollapse: () => shell.setSidebarMode('collapsed'),\n requestToggle: () => shell.togglePane('sidebar'),\n }}\n >\n {handleChildren.length > 0 ? handleChildren.map((el, i) => React.cloneElement(el, { key: el.key ?? i })) : <PaneHandle />}\n </PaneResizeContext.Provider>\n ) : null;\n\n // Strip new API props from DOM\n const { state: _s, defaultState: _ds, onStateChange: _osc, size: _sz, defaultSize: _dsz, onSizeChange: _onsc, sizeUpdate: _szu, sizeUpdateMs: _szums, ...domProps } = props as any;\n\n // Normalize CSS lengths to px\n const normalizeToPx = React.useCallback((value: number | string | undefined): number | undefined => {\n if (value == null) return undefined;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n const str = String(value).trim();\n if (!str) return undefined;\n if (str.endsWith('px')) return Number.parseFloat(str);\n if (str.endsWith('rem')) {\n const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize || '16') || 16;\n return Number.parseFloat(str) * rem;\n }\n if (str.endsWith('%')) {\n const pct = Number.parseFloat(str);\n const base = document.documentElement.clientWidth || window.innerWidth || 0;\n return (pct / 100) * base;\n }\n const n = Number.parseFloat(str);\n return Number.isFinite(n) ? n : undefined;\n }, []);\n\n // Apply defaultSize on mount when uncontrolled\n React.useEffect(() => {\n if (!localRef.current) return;\n const { size, defaultSize } = props as any;\n if (typeof size === 'undefined' && typeof defaultSize !== 'undefined') {\n const px = normalizeToPx(defaultSize);\n if (typeof px === 'number' && Number.isFinite(px)) {\n const minPx = typeof minSize === 'number' ? minSize : undefined;\n const maxPx = typeof maxSize === 'number' ? maxSize : undefined;\n const clamped = Math.min(maxPx ?? px, Math.max(minPx ?? px, px));\n localRef.current.style.setProperty('--sidebar-size', `${clamped}px`);\n emitSizeChange(clamped, { reason: 'init' });\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Controlled size sync\n React.useEffect(() => {\n if (!localRef.current) return;\n const { size } = props as any;\n if (typeof size === 'undefined') return;\n const px = normalizeToPx(size);\n if (typeof px === 'number' && Number.isFinite(px)) {\n const minPx = typeof minSize === 'number' ? minSize : undefined;\n const maxPx = typeof maxSize === 'number' ? maxSize : undefined;\n const clamped = Math.min(maxPx ?? px, Math.max(minPx ?? px, px));\n localRef.current.style.setProperty('--sidebar-size', `${clamped}px`);\n emitSizeChange(clamped, { reason: 'controlled' });\n }\n }, [(props as any).size, minSize, maxSize, normalizeToPx, emitSizeChange]);\n\n if (isOverlay) {\n const open = shell.sidebarMode !== 'collapsed';\n return (\n <Sheet.Root open={open} onOpenChange={(o) => shell.setSidebarMode(o ? 'expanded' : 'collapsed')}>\n <Sheet.Content\n side=\"start\"\n style={{ padding: 0 }}\n width={{\n initial: `${open ? (shell.sidebarMode === 'thin' ? thinSize : expandedSize) : lastOverlayWidthRef.current}px`,\n }}\n >\n <VisuallyHidden>\n <Sheet.Title>Navigation</Sheet.Title>\n </VisuallyHidden>\n {contentChildren}\n </Sheet.Content>\n </Sheet.Root>\n );\n }\n return (\n <div\n {...domProps}\n ref={setRef}\n className={classNames('rt-ShellSidebar', className)}\n data-mode={shell.sidebarMode}\n data-peek={shell.peekTarget === 'sidebar' || undefined}\n data-presentation={shell.currentBreakpointReady ? resolvedPresentation : undefined}\n data-open={(shell.currentBreakpointReady && isStacked && isContentVisible) || undefined}\n style={{\n ...style,\n ['--sidebar-size' as any]: `${expandedSize}px`,\n ['--sidebar-thin-size' as any]: `${thinSize}px`,\n ['--sidebar-min-size' as any]: `${minSize}px`,\n ['--sidebar-max-size' as any]: `${maxSize}px`,\n ...(shell.peekTarget === 'sidebar' && shell.sidebarMode === 'collapsed' && !isOverlay\n ? (() => {\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const current = shell.sidebarMode as SidebarMode;\n let next: SidebarMode;\n if (strategy === 'both') {\n next = current === 'collapsed' ? 'thin' : current === 'thin' ? 'expanded' : 'collapsed';\n } else {\n const target = resolveDefaultSidebarMode();\n next = current === 'collapsed' ? target : 'collapsed';\n }\n if (next === 'thin') {\n return {\n ['--peek-sidebar-width' as any]: `${thinSize}px`,\n } as React.CSSProperties;\n }\n return {\n ['--peek-sidebar-width' as any]: `var(--sidebar-size, ${expandedSize}px)`,\n } as React.CSSProperties;\n })()\n : {}),\n }}\n >\n <div className=\"rt-ShellSidebarContent\" data-visible={isContentVisible || undefined}>\n {contentChildren}\n </div>\n {handleEl}\n </div>\n );\n },\n) as SidebarComponent;\n\nSidebar.displayName = 'Shell.Sidebar';\nSidebar.Handle = SidebarHandle;\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,OAAgB,aACvB,UAAYC,MAAW,cACvB,OAAS,kBAAAC,OAAsB,wBAC/B,OAAS,YAAAC,MAAgB,sBACzB,OAAS,6BAAAC,GAA2B,sBAAAC,MAA0B,oBAC9D,OAAS,qBAAAC,OAAyB,oBAClC,OAAS,iBAAAC,EAAe,cAAAC,OAAkB,qBAE1C,MAA6B,oBA0CtB,MAAMC,EAAUV,EAAM,WAC3B,CACE,CACE,UAAAW,EACA,aAAAC,EAAe,CAAE,QAAS,UAAW,GAAI,OAAQ,EAEjD,aAAAC,EAAe,IACf,QAAAC,EAAU,IACV,QAAAC,EAAU,IACV,UAAAC,EAAY,GACZ,YAAAC,EAAc,GACd,SAAAC,EACA,WAAAC,EACA,SAAAC,EACA,cAAAC,EACA,YAAAC,EACA,WAAAC,EACA,cAAAC,GACA,kBAAAC,GACA,OAAAC,EACA,YAAAC,EACA,SAAAC,GACA,MAAAC,GACA,SAAAC,EAAW,GACX,YAAAC,EAEA,MAAAC,EACA,aAAAC,EACA,cAAAC,EACA,GAAGC,CACL,EACAC,IACG,CACH,MAAMC,EAAQjC,EAAS,EACjBkC,EAAuBjC,GAA0BO,CAAY,EAC7D2B,EAAYD,IAAyB,UACrCE,GAAYF,IAAyB,UAErCG,EAAWzC,EAAM,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3G,GAEA/E,EAAA,cAACG,GAAA,KACCH,EAAA,cAACE,EAAM,MAAN,KAAY,YAAU,CACzB,EACC6C,CACH,CACF,CAEJ,CACA,OACE/C,EAAA,cAAC,OACE,GAAGgG,GACJ,IAAKtD,GACL,UAAWzC,GAAW,kBAAmBU,CAAS,EAClD,YAAW0B,EAAM,YACjB,YAAWA,EAAM,aAAe,WAAa,OAC7C,oBAAmBA,EAAM,uBAAyBC,EAAuB,OACzE,YAAYD,EAAM,wBAA0BG,IAAayB,GAAqB,OAC9E,MAAO,CACL,GAAGpC,GACF,iBAA0B,GAAGhB,CAAY,KACzC,sBAA+B,GAAGiB,CAAQ,KAC1C,qBAA8B,GAAGhB,CAAO,KACxC,qBAA8B,GAAGC,CAAO,KACzC,GAAIsB,EAAM,aAAe,WAAaA,EAAM,cAAgB,aAAe,CAACE,GACvE,IAAM,CACL,MAAMW,EAA8BnB,GAAe,OAC7C6C,EAAUvC,EAAM,YACtB,IAAIwE,EACJ,GAAI3D,IAAa,OACf2D,EAAOjC,IAAY,YAAc,OAASA,IAAY,OAAS,WAAa,gBACvE,CACL,MAAMC,EAASJ,EAA0B,EACzCoC,EAAOjC,IAAY,YAAcC,EAAS,WAC5C,CACA,OAAIgC,IAAS,OACJ,CACJ,uBAAgC,GAAG/E,CAAQ,IAC9C,EAEK,CACJ,uBAAgC,uBAAuBjB,CAAY,KACtE,CACF,GAAG,EACH,CAAC,CACP,GAEAb,EAAA,cAAC,OAAI,UAAU,yBAAyB,eAAciE,GAAoB,QACvElB,CACH,EACCkC,EACH,CAEJ,CACF,EAEAvE,EAAQ,YAAc,gBACtBA,EAAQ,OAASF",
|
|
6
6
|
"names": ["React", "classNames", "Sheet", "VisuallyHidden", "useShell", "useResponsivePresentation", "useResponsiveValue", "PaneResizeContext", "SidebarHandle", "PaneHandle", "Sidebar", "className", "presentation", "expandedSize", "minSize", "maxSize", "resizable", "collapsible", "onExpand", "onCollapse", "onResize", "onResizeStart", "onResizeEnd", "snapPoints", "snapTolerance", "collapseThreshold", "paneId", "persistence", "children", "style", "thinSize", "toggleModes", "state", "defaultState", "onStateChange", "props", "ref", "shell", "resolvedPresentation", "isOverlay", "isStacked", "localRef", "setRef", "node", "childArray", "handleChildren", "el", "contentChildren", "emitSizeChange", "cb", "strategy", "ms", "t", "s", "meta", "last", "now", "sidebarId", "wasControlledRef", "isControlled", "resolvedState", "resolvedDefaultState", "didInitRef", "initialState", "lastNotifyModeRef", "isContentVisible", "persistenceAdapter", "key", "v", "size", "mounted", "loaded", "shellForToggle", "resolveDefaultSidebarMode", "resolved", "compute", "current", "target", "cur", "lastOverlayWidthRef", "lastOverlayModeRef", "handleEl", "client", "startClient", "startSize", "isRtl", "delta", "i", "_s", "_ds", "_osc", "_sz", "_dsz", "_onsc", "_szu", "_szums", "domProps", "normalizeToPx", "value", "str", "rem", "pct", "base", "n", "defaultSize", "px", "clamped", "open", "o", "next"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbar.d.ts","sourceRoot":"","sources":["../../../src/components/chatbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"chatbar.d.ts","sourceRoot":"","sources":["../../../src/components/chatbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAKzF,KAAK,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AACvD,KAAK,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAGjD,4CAA4C;AAC5C,KAAK,gBAAgB,GAAG,MAAM,G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AE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as e from"react";import S from"classnames";import{IconButton as Se}from"./icon-button.js";import{CloseIcon as _e,FileTextIcon as Je}from"./icons.js";import{Flex as ce}from"./flex.js";import{ScrollArea as Qe}from"./scroll-area.js";import{Slot as B}from"./slot.js";import{Box as Xe}from"./box.js";import"./card.js";import{Text as ve}from"./text.js";import"./inset.js";import{useDropzone as Ze}from"react-dropzone";const xe=typeof window<"u"?e.useLayoutEffect:e.useEffect,Oe=e.createContext(null),W=()=>{const l=e.useContext(Oe);if(!l)throw new Error("Chatbar context not found. Wrap parts in <Chatbar.Root>.");return l},Me=e.forwardRef((l,i)=>{const{className:s,style:p,children:m,value:b,defaultValue:A="",onValueChange:h,open:r,defaultOpen:a=!1,onOpenChange:R,expandOn:P="both",minLines:T=1,maxLines:u=6,sendMode:C="whenDirty",disabled:F,readOnly:Y,onSubmit:O,size:H="2",variant:V,color:N,radius:U,panelBackground:M,material:D,width:ae,maxWidth:G,asChild:oe,attachments:re,defaultAttachments:ue=[],onAttachmentsChange:K,accept:_,multiple:z=!0,maxAttachments:w,maxFileSize:d,paste:de=!0,pasteAccept:J,clearOnSubmit:me=!0,onAttachmentReject:$,dropzone:k=!0,apiRef:n,...c}=l,f=D||M,v=b!=null,[L,pe]=e.useState(A),Q=v?b:L,I=r!=null,[X,q]=e.useState(a),Z=I?r:X,he=e.useRef(null),se=e.useRef(null),fe=e.useRef(!1),ie="attachments"in l,[Be,Re]=e.useState(ue),j=ie?re??[]:Be,ee=e.useRef(new Set),be=t=>Array.isArray(t)?t:typeof t=="string"?t.split(",").map(o=>o.trim()):[],te=be(_),we=be(J).length>0?be(J):te,Ce=(t,o)=>{if(o.length===0)return!0;const g=t.type.toLowerCase(),E=t.name.toLowerCase();for(const y of o){const x=y.toLowerCase();if(x.includes("/")){const[le,ye]=x.split("/"),[ne,Ge]=g.split("/");if(le==="*"||le===ne&&(ye==="*"||ye===Ge))return!0}else if(x.startsWith(".")&&E.endsWith(x))return!0}return!1},We=t=>{const o=[],g=[],E=typeof w=="number"?Math.max(w-j.length,0):1/0;for(const y of t){if(o.length>=E){g.push({file:y,reason:"count"});continue}if(typeof d=="number"&&y.size>d){g.push({file:y,reason:"size"});continue}if(!Ce(y,te)){g.push({file:y,reason:"type"});continue}const x=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,le=/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(y.name),ne=(y.type||"").toLowerCase().startsWith("image/")||le?URL.createObjectURL(y):void 0;ne&&ee.current.add(ne),o.push({id:x,name:y.name,size:y.size,type:y.type,file:y,url:ne,status:"idle"})}return{accepted:o,rejected:g}},ge=t=>{const{accepted:o,rejected:g}=We(t);if(o.length>0){const E=j.concat(o);ie||Re(E),K?.(E),I||q(!0),R?.(!0)}g.length>0&&$?.(g)},Ve=t=>{const o=x=>we.length===0?Ce(x,te):Ce(x,we),g=[],E=[],y=typeof w=="number"?Math.max(w-j.length,0):1/0;for(const x of t){if(g.length>=y){E.push({file:x,reason:"count"});continue}if(typeof d=="number"&&x.size>d){E.push({file:x,reason:"size"});continue}if(!o(x)){E.push({file:x,reason:"type"});continue}g.push(x)}g.length>0&&ge(g),E.length>0&&$?.(E)};e.useEffect(()=>{const t=new Set(j.map(o=>o.url).filter(Boolean));for(const o of Array.from(ee.current))t.has(o)||(URL.revokeObjectURL(o),ee.current.delete(o))},[j]),e.useEffect(()=>()=>{for(const t of Array.from(ee.current))URL.revokeObjectURL(t);ee.current.clear()},[]);const Ue=oe?B:"div",Ke=e.useCallback(t=>{const o=t.relatedTarget,g=he.current;g&&(o&&g.contains(o)||fe.current||(Q?.trim?.()??"").length===0&&j.length===0&&(I||q(!1),R?.(!1)))},[I,R,Q,j]),{getRootProps:$e,getInputProps:qe,isDragActive:Pe,open:Ee}=Ze({onDrop:(t,o)=>{if(t.length>0&&ge(t),o.length>0&&$){const g=o.map(({file:E,errors:y})=>{const x=y[0]?.code==="file-too-large"?"size":y[0]?.code==="file-invalid-type"?"type":"count";return{file:E,reason:x}});$(g)}},accept:te.length>0?te.reduce((t,o)=>(o.includes("/")?t[o]=[]:o.startsWith(".")&&(t[o]=[]),t),{}):void 0,multiple:z,maxSize:d,noClick:!0,noKeyboard:!0,disabled:!k||F});e.useImperativeHandle(n,()=>({focusTextarea:()=>se.current?.focus({preventScroll:!0}),openFilePicker:()=>{fe.current=!0,Ee()}}),[Ee]);const Te=e.useCallback(t=>{if(!(t instanceof Element))return!1;const o=t;return o.closest(".rt-ChatbarDropOverlay")?!0:!!o.closest('button, [role="button"], a[href], input, textarea, select, [contenteditable], [tabindex]:not([tabindex="-1"])')},[]),Ye=e.useCallback(t=>{F||Te(t.target)||t.pointerType==="mouse"&&t.button!==0||(t.preventDefault(),se.current?.focus({preventScroll:!0}))},[F,Te,se]);return e.createElement(Oe.Provider,{value:{open:Z,setOpen:t=>{I||q(t),R?.(t)},isOpenControlled:I,value:Q,setValue:t=>{v||pe(t),h?.(t)},isValueControlled:v,size:H,expandOn:P,minLines:T,maxLines:u,sendMode:C,disabled:F,readOnly:Y,onSubmit:O,rootRef:he,textareaRef:se,attachments:j,setAttachments:t=>{ie||Re(t),K?.(t)},isAttachmentsControlled:ie,accept:_,multiple:z,maxAttachments:w,maxFileSize:d,paste:de,pasteAccept:J,clearOnSubmit:me,onAttachmentReject:$,dropzone:k,appendFiles:ge,appendFilesFromPaste:Ve,fileDialogOpenRef:fe}},e.createElement(Ue,{...c,ref:t=>{typeof i=="function"?i(t):i&&(i.current=t),he.current=t},className:S("rt-ChatbarRoot",`rt-r-size-${H}`,s),style:{position:"relative",width:ae,maxWidth:G,...p},"data-state":Z?"open":"closed","data-disabled":F?"":void 0,"data-readonly":Y?"":void 0,"data-drop-active":k&&Pe?"":void 0,"data-accent-color":N,"data-radius":U,"data-panel-background":f,"data-material":f,"aria-expanded":Z,onBlurCapture:Ke},k&&e.createElement("input",{...qe()}),e.createElement("div",{...k?$e():{},style:{width:"100%",height:"100%"},onPointerDown:Ye},e.createElement(Xe,{className:S("rt-ChatbarBox",`rt-variant-${V??"surface"}`),style:{position:"relative"},"data-accent-color":N,"data-radius":U,"data-panel-background":f,"data-material":f},e.createElement("div",{className:"rt-ChatbarGrid"},m),k&&Pe&&e.createElement("div",{className:"rt-ChatbarDropOverlay"},e.createElement("div",{className:"rt-ChatbarDropContent"},e.createElement(ve,{color:"gray",size:H,weight:"medium"},"Drop files here to attach")))))))});Me.displayName="Chatbar.Root";const Le=e.forwardRef((l,i)=>{const{className:s,style:p,asChild:m,onFocus:b,onInput:A,onChange:h,onPaste:r,onKeyDown:a,submitOnEnter:R=!1,rows:P,...T}=l,u=W(),{open:C,minLines:F,maxLines:Y,expandOn:O,disabled:H,readOnly:V,setOpen:N,setValue:U,textareaRef:M,value:D,isValueControlled:ae,sendMode:G,paste:oe,appendFilesFromPaste:re,size:ue}=u,K=e.useRef(0),_=e.useRef(0),z=e.useRef(0),w=e.useCallback(()=>{const n=M.current;if(!n)return;const c=window.getComputedStyle(n),f=parseFloat(c.lineHeight)||20,v=parseFloat(c.paddingTop)||0,L=parseFloat(c.paddingBottom)||0;K.current=f,_.current=v+L,z.current=Math.ceil(1*f)+v+L},[M]),d=e.useCallback(n=>{const c=M.current;if(!c)return;c.style.height="auto",K.current===0&&w();const f=K.current,v=_.current,L=n??C,pe=L?F:1,Q=L?Y:1,I=Math.ceil(pe*f)+v,X=Math.ceil(Q*f)+v,q=Math.max(c.scrollHeight,I),Z=Math.min(q,X);c.style.height=`${Z}px`,q>X?(c.style.overflowY="auto",c.style.maxHeight=`${X}px`):(c.style.overflowY="hidden",c.style.maxHeight="none")},[C,F,Y,M,w]);xe(()=>{d()},[d,D,C]),xe(()=>{if(!(O==="overflow"||O==="both")||C)return;const n=M.current;if(!n)return;n.style.height="auto",z.current===0&&w(),n.scrollHeight>z.current+1&&(N(!0),d(!0),requestAnimationFrame(()=>d(!0)))},[D,O,C,N,M,w,d]),xe(()=>{w(),d()},[w,d,ue]),e.useEffect(()=>{const n=M.current;if(!n||typeof ResizeObserver>"u")return;let c=K.current;const f=new ResizeObserver(()=>{const v=window.getComputedStyle(n),L=parseFloat(v.lineHeight)||20;L!==c&&(c=L,w(),requestAnimationFrame(()=>d()))});return f.observe(n),()=>f.disconnect()},[M,w,d]),e.useEffect(()=>{},[]);const de=e.useCallback(n=>{H||V||((O==="focus"||O==="both")&&!C&&N(!0),b?.(n))},[H,V,O,C,N,b]),J=e.useCallback(n=>{const c=n.currentTarget,f=c.value;U(f),(O==="overflow"||O==="both")&&!C&&(c.style.height="auto",z.current===0&&w(),c.scrollHeight>z.current+1&&(N(!0),d(!0),requestAnimationFrame(()=>d(!0)))),requestAnimationFrame(()=>d()),h?.(n)},[O,C,N,U,h,d,w]),me=e.useCallback(n=>{if(oe){const f=Array.from(n.clipboardData?.items??[]).filter(v=>v.kind==="file").map(v=>v.getAsFile()).filter(v=>!!v);f.length>0&&(n.preventDefault(),re(f))}setTimeout(()=>{C?d():d(!0)},0),r?.(n)},[oe,C,d,r,re]),$=e.useCallback(n=>{if(!R){a?.(n);return}if(n.key==="Enter"&&!n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey&&!n.nativeEvent.isComposing){if(H||V){a?.(n);return}if(G==="never"){a?.(n);return}const f=D.trim().length>0||u.attachments.length>0;if(G==="whenDirty"&&!f){a?.(n);return}n.preventDefault(),u.onSubmit?.({value:D,attachments:u.attachments}),u.clearOnSubmit&&(ae||U(""),u.setAttachments([]))}a?.(n)},[R,H,V,G,D,ae,U,u,a]),k=m?B:"textarea";return e.createElement("div",{className:S("rt-ChatbarField","rt-ChatbarTextarea",s)},e.createElement(k,{...T,ref:n=>{typeof i=="function"?i(n):i&&(i.current=n),M.current=n},className:"rt-ChatbarInput",value:D,onInput:A,onChange:J,onFocus:de,onPaste:me,onKeyDown:$,disabled:H,readOnly:V,rows:C?F:1,spellCheck:T.spellCheck??!0,autoCorrect:T.autoCorrect??"on",style:p}))});Le.displayName="Chatbar.Textarea";const Fe=e.forwardRef((l,i)=>{const{children:s,asChild:p,style:m,className:b,...A}=l;return W().open?null:e.createElement(p?B:"div",{...A,ref:i,className:S("rt-ChatbarInlineStart",b),style:m},s)});Fe.displayName="Chatbar.InlineStart";const He=e.forwardRef((l,i)=>{const{children:s,asChild:p,style:m,className:b,...A}=l;return W().open?null:e.createElement(p?B:"div",{...A,ref:i,className:S("rt-ChatbarInlineEnd",b),style:m},s)});He.displayName="Chatbar.InlineEnd";const Ne=e.forwardRef((l,i)=>{const{asChild:s,forceMount:p,renderAttachment:m,className:b,style:A,...h}=l,r=W();return!(r.attachments.length>0)&&!p?null:e.createElement(s?B:"div",{...h,ref:i,className:S("rt-ChatbarAttachmentsRow",b),style:A,role:"list","aria-label":h["aria-label"]??"Attachments"},e.createElement(Qe,{className:"rt-ChatbarScrollArea",scrollbars:"horizontal",size:"1"},e.createElement(ce,{align:"center",gap:"2",style:{minWidth:"fit-content"}},r.attachments.map(P=>e.createElement(Ae,{key:P.id,attachment:P,asChild:!!m},m?.(P))))))});Ne.displayName="Chatbar.AttachmentsRow";const Ae=e.forwardRef((l,i)=>{const{attachment:s,asChild:p,className:m,style:b,children:A,...h}=l,r=W(),a=p?B:"div",R=!!s.url&&s.type.startsWith("image/");return e.createElement(a,{...h,ref:i,className:S("rt-ChatbarAttachment",m),style:b,role:"listitem","data-kind":R?"image":"file",title:s.name},A??e.createElement(ce,{align:"center",gap:"2",pr:R?void 0:"6"},e.createElement("div",{className:"rt-ChatbarAttachmentPreview","aria-hidden":!0},R?e.createElement("img",{className:"rt-ChatbarAttachmentImage",src:s.url,alt:""}):e.createElement(Je,null)),!R&&e.createElement(ce,{direction:"column",gap:"0",style:{minWidth:0}},e.createElement(ve,{size:r.size,weight:"medium",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},s.name),e.createElement(ve,{size:"1",color:"gray"},Math.ceil(s.size/1024)," KB")),e.createElement(Se,{className:"rt-ChatbarAttachmentRemove","aria-label":`Remove ${s.name}`,size:"1",variant:"classic",highContrast:!0,color:"gray",onClick:()=>r.setAttachments(r.attachments.filter(P=>P.id!==s.id))},e.createElement(_e,null))))});Ae.displayName="Chatbar.Attachment";const De=e.forwardRef((l,i)=>{const{asChild:s,accept:p,multiple:m,className:b,style:A,...h}=l,r=W(),a=e.useRef(null),R=s?B:"button",P=p??r.accept,T=(Array.isArray(P)?P:P?.split(",")??[]).join(",");return e.useEffect(()=>{const u=()=>{r.fileDialogOpenRef.current=!1};return window.addEventListener("focus",u),()=>window.removeEventListener("focus",u)},[r.fileDialogOpenRef]),e.createElement(e.Fragment,null,e.createElement(R,{...h,ref:i,className:S("rt-ChatbarAttachTrigger",b),style:A,type:h.type??"button","aria-label":h["aria-label"]??"Add attachments",onPointerDown:u=>{r.fileDialogOpenRef.current=!0,h.onPointerDown?.(u)},onMouseDown:u=>{r.fileDialogOpenRef.current=!0,h.onMouseDown?.(u)},onClick:u=>{r.fileDialogOpenRef.current=!0,a.current&&a.current.click(),h.onClick?.(u)}}),e.createElement("input",{ref:a,type:"file",accept:T,multiple:m??r.multiple,tabIndex:-1,style:{display:"none"},onChange:u=>{const C=Array.from(u.currentTarget.files??[]);C.length>0&&r.appendFiles(C),r.fileDialogOpenRef.current=!1,u.currentTarget.value=""}}))});De.displayName="Chatbar.AttachTrigger";const ze=e.forwardRef((l,i)=>{const{asChild:s,children:p,className:m,style:b,...A}=l;return W().open?e.createElement(s?B:"div",{...A,ref:i,className:S("rt-ChatbarRow",m),style:b},e.createElement(ce,{align:"center",justify:"between",width:"100%"},p)):null});ze.displayName="Chatbar.Row";const ke=e.forwardRef((l,i)=>{const{className:s,style:p,...m}=l;return e.createElement("div",{...m,ref:i,className:S("rt-ChatbarRowStart",s),style:p})});ke.displayName="Chatbar.RowStart";const Ie=e.forwardRef((l,i)=>{const{className:s,style:p,...m}=l;return e.createElement("div",{...m,ref:i,className:S("rt-ChatbarRowEnd",s),style:p})});Ie.displayName="Chatbar.RowEnd";const je=e.forwardRef((l,i)=>{const{asChild:s,clearOnSend:p=!0,disabled:m,children:b,className:A,style:h,...r}=l,a=W(),P=a.value.trim().length>0||a.attachments.length>0,T=a.sendMode==="always"||a.sendMode==="whenDirty"&&P;if(a.sendMode==="never")return null;const u=C=>{a.disabled||a.readOnly||(a.onSubmit?.({value:a.value,attachments:a.attachments}),p&&(a.isValueControlled||a.setValue(""),a.clearOnSubmit&&a.setAttachments([])),r.onClick?.(C))};return e.createElement(Se,{...r,ref:i,size:a.size,variant:a.open?"solid":"ghost",disabled:m||a.disabled||a.readOnly,className:S("rt-ChatbarSend",A),style:{opacity:T?1:0,pointerEvents:T?"auto":"none",...h},asChild:s,onClick:u,"aria-label":r["aria-label"]??"Send"},b??e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-arrow-right-icon lucide-arrow-right"},e.createElement("path",{d:"M5 12h14"}),e.createElement("path",{d:"m12 5 7 7-7 7"})))});je.displayName="Chatbar.Send";export{De as AttachTrigger,Ae as Attachment,Ne as AttachmentsRow,He as InlineEnd,Fe as InlineStart,Me as Root,ze as Row,Ie as RowEnd,ke as RowStart,je as Send,Le as Textarea};
|
|
1
|
+
import*as e from"react";import S from"classnames";import{IconButton as Oe}from"./icon-button.js";import{CloseIcon as _e,FileTextIcon as Je}from"./icons.js";import{Flex as ce}from"./flex.js";import{ScrollArea as Qe}from"./scroll-area.js";import{Slot as B}from"./slot.js";import{Box as Xe}from"./box.js";import{Text as ve}from"./text.js";import{useDropzone as Ze}from"react-dropzone";const xe=typeof window<"u"?e.useLayoutEffect:e.useEffect,Me=e.createContext(null),W=()=>{const l=e.useContext(Me);if(!l)throw new Error("Chatbar context not found. Wrap parts in <Chatbar.Root>.");return l},Le=e.forwardRef((l,i)=>{const{className:s,style:p,children:m,value:b,defaultValue:A="",onValueChange:h,open:r,defaultOpen:o=!1,onOpenChange:R,expandOn:P="both",minLines:T=1,maxLines:u=6,sendMode:C="whenDirty",disabled:F,readOnly:Y,onSubmit:O,size:H="2",variant:V,color:N,radius:U,panelBackground:M,material:D,width:oe,maxWidth:G,asChild:re,attachments:_,defaultAttachments:ue=[],onAttachmentsChange:K,accept:J,multiple:z=!0,maxAttachments:w,maxFileSize:d,paste:de=!0,pasteAccept:Q,clearOnSubmit:me=!0,onAttachmentReject:$,dropzone:k=!0,apiRef:n,...c}=l,f=D||M,v=b!=null,[L,pe]=e.useState(A),X=v?b:L,I=r!=null,[Z,q]=e.useState(o),ee=I?r:Z,he=e.useRef(null),se=e.useRef(null),fe=e.useRef(!1),te="attachments"in l,[Re,we]=e.useState(ue),j=e.useMemo(()=>te?_??[]:Re,[te,_,Re]),ie=e.useRef(new Set),be=t=>Array.isArray(t)?t:typeof t=="string"?t.split(",").map(a=>a.trim()):[],ne=be(J),Pe=be(Q).length>0?be(Q):ne,Ce=(t,a)=>{if(a.length===0)return!0;const g=t.type.toLowerCase(),E=t.name.toLowerCase();for(const y of a){const x=y.toLowerCase();if(x.includes("/")){const[le,ye]=x.split("/"),[ae,Ge]=g.split("/");if(le==="*"||le===ae&&(ye==="*"||ye===Ge))return!0}else if(x.startsWith(".")&&E.endsWith(x))return!0}return!1},We=t=>{const a=[],g=[],E=typeof w=="number"?Math.max(w-j.length,0):1/0;for(const y of t){if(a.length>=E){g.push({file:y,reason:"count"});continue}if(typeof d=="number"&&y.size>d){g.push({file:y,reason:"size"});continue}if(!Ce(y,ne)){g.push({file:y,reason:"type"});continue}const x=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,le=/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(y.name),ae=(y.type||"").toLowerCase().startsWith("image/")||le?URL.createObjectURL(y):void 0;ae&&ie.current.add(ae),a.push({id:x,name:y.name,size:y.size,type:y.type,file:y,url:ae,status:"idle"})}return{accepted:a,rejected:g}},ge=t=>{const{accepted:a,rejected:g}=We(t);if(a.length>0){const E=j.concat(a);te||we(E),K?.(E),I||q(!0),R?.(!0)}g.length>0&&$?.(g)},Ve=t=>{const a=x=>Pe.length===0?Ce(x,ne):Ce(x,Pe),g=[],E=[],y=typeof w=="number"?Math.max(w-j.length,0):1/0;for(const x of t){if(g.length>=y){E.push({file:x,reason:"count"});continue}if(typeof d=="number"&&x.size>d){E.push({file:x,reason:"size"});continue}if(!a(x)){E.push({file:x,reason:"type"});continue}g.push(x)}g.length>0&&ge(g),E.length>0&&$?.(E)};e.useEffect(()=>{const t=new Set(j.map(a=>a.url).filter(Boolean));for(const a of Array.from(ie.current))t.has(a)||(URL.revokeObjectURL(a),ie.current.delete(a))},[j]),e.useEffect(()=>{const t=ie.current;return()=>{for(const a of Array.from(t))URL.revokeObjectURL(a);t.clear()}},[]);const Ue=re?B:"div",Ke=e.useCallback(t=>{const a=t.relatedTarget,g=he.current;g&&(a&&g.contains(a)||fe.current||(X?.trim?.()??"").length===0&&j.length===0&&(I||q(!1),R?.(!1)))},[I,R,X,j]),{getRootProps:$e,getInputProps:qe,isDragActive:Ee,open:Te}=Ze({onDrop:(t,a)=>{if(t.length>0&&ge(t),a.length>0&&$){const g=a.map(({file:E,errors:y})=>{const x=y[0]?.code==="file-too-large"?"size":y[0]?.code==="file-invalid-type"?"type":"count";return{file:E,reason:x}});$(g)}},accept:ne.length>0?ne.reduce((t,a)=>(a.includes("/")?t[a]=[]:a.startsWith(".")&&(t[a]=[]),t),{}):void 0,multiple:z,maxSize:d,noClick:!0,noKeyboard:!0,disabled:!k||F});e.useImperativeHandle(n,()=>({focusTextarea:()=>se.current?.focus({preventScroll:!0}),openFilePicker:()=>{fe.current=!0,Te()}}),[Te]);const Se=e.useCallback(t=>{if(!(t instanceof Element))return!1;const a=t;return a.closest(".rt-ChatbarDropOverlay")?!0:!!a.closest('button, [role="button"], a[href], input, textarea, select, [contenteditable], [tabindex]:not([tabindex="-1"])')},[]),Ye=e.useCallback(t=>{F||Se(t.target)||t.pointerType==="mouse"&&t.button!==0||(t.preventDefault(),se.current?.focus({preventScroll:!0}))},[F,Se,se]);return e.createElement(Me.Provider,{value:{open:ee,setOpen:t=>{I||q(t),R?.(t)},isOpenControlled:I,value:X,setValue:t=>{v||pe(t),h?.(t)},isValueControlled:v,size:H,expandOn:P,minLines:T,maxLines:u,sendMode:C,disabled:F,readOnly:Y,onSubmit:O,rootRef:he,textareaRef:se,attachments:j,setAttachments:t=>{te||we(t),K?.(t)},isAttachmentsControlled:te,accept:J,multiple:z,maxAttachments:w,maxFileSize:d,paste:de,pasteAccept:Q,clearOnSubmit:me,onAttachmentReject:$,dropzone:k,appendFiles:ge,appendFilesFromPaste:Ve,fileDialogOpenRef:fe}},e.createElement(Ue,{...c,ref:t=>{typeof i=="function"?i(t):i&&(i.current=t),he.current=t},className:S("rt-ChatbarRoot",`rt-r-size-${H}`,s),style:{position:"relative",width:oe,maxWidth:G,...p},"data-state":ee?"open":"closed","data-disabled":F?"":void 0,"data-readonly":Y?"":void 0,"data-drop-active":k&&Ee?"":void 0,"data-accent-color":N,"data-radius":U,"data-panel-background":f,"data-material":f,"aria-expanded":ee,onBlurCapture:Ke},k&&e.createElement("input",{...qe()}),e.createElement("div",{...k?$e():{},style:{width:"100%",height:"100%"},onPointerDown:Ye},e.createElement(Xe,{className:S("rt-ChatbarBox",`rt-variant-${V??"surface"}`),style:{position:"relative"},"data-accent-color":N,"data-radius":U,"data-panel-background":f,"data-material":f},e.createElement("div",{className:"rt-ChatbarGrid"},m),k&&Ee&&e.createElement("div",{className:"rt-ChatbarDropOverlay"},e.createElement("div",{className:"rt-ChatbarDropContent"},e.createElement(ve,{color:"gray",size:H,weight:"medium"},"Drop files here to attach")))))))});Le.displayName="Chatbar.Root";const Fe=e.forwardRef((l,i)=>{const{className:s,style:p,asChild:m,onFocus:b,onInput:A,onChange:h,onPaste:r,onKeyDown:o,submitOnEnter:R=!1,rows:P,...T}=l,u=W(),{open:C,minLines:F,maxLines:Y,expandOn:O,disabled:H,readOnly:V,setOpen:N,setValue:U,textareaRef:M,value:D,isValueControlled:oe,sendMode:G,paste:re,appendFilesFromPaste:_,size:ue}=u,K=e.useRef(0),J=e.useRef(0),z=e.useRef(0),w=e.useCallback(()=>{const n=M.current;if(!n)return;const c=window.getComputedStyle(n),f=parseFloat(c.lineHeight)||20,v=parseFloat(c.paddingTop)||0,L=parseFloat(c.paddingBottom)||0;K.current=f,J.current=v+L,z.current=Math.ceil(1*f)+v+L},[M]),d=e.useCallback(n=>{const c=M.current;if(!c)return;c.style.height="auto",K.current===0&&w();const f=K.current,v=J.current,L=n??C,pe=L?F:1,X=L?Y:1,I=Math.ceil(pe*f)+v,Z=Math.ceil(X*f)+v,q=Math.max(c.scrollHeight,I),ee=Math.min(q,Z);c.style.height=`${ee}px`,q>Z?(c.style.overflowY="auto",c.style.maxHeight=`${Z}px`):(c.style.overflowY="hidden",c.style.maxHeight="none")},[C,F,Y,M,w]);xe(()=>{d()},[d,D,C]),xe(()=>{if(!(O==="overflow"||O==="both")||C)return;const n=M.current;if(!n)return;n.style.height="auto",z.current===0&&w(),n.scrollHeight>z.current+1&&(N(!0),d(!0),requestAnimationFrame(()=>d(!0)))},[D,O,C,N,M,w,d]),xe(()=>{w(),d()},[w,d,ue]),e.useEffect(()=>{const n=M.current;if(!n||typeof ResizeObserver>"u")return;let c=K.current;const f=new ResizeObserver(()=>{const v=window.getComputedStyle(n),L=parseFloat(v.lineHeight)||20;L!==c&&(c=L,w(),requestAnimationFrame(()=>d()))});return f.observe(n),()=>f.disconnect()},[M,w,d]),e.useEffect(()=>{},[]);const de=e.useCallback(n=>{H||V||((O==="focus"||O==="both")&&!C&&N(!0),b?.(n))},[H,V,O,C,N,b]),Q=e.useCallback(n=>{const c=n.currentTarget,f=c.value;U(f),(O==="overflow"||O==="both")&&!C&&(c.style.height="auto",z.current===0&&w(),c.scrollHeight>z.current+1&&(N(!0),d(!0),requestAnimationFrame(()=>d(!0)))),requestAnimationFrame(()=>d()),h?.(n)},[O,C,N,U,h,d,w]),me=e.useCallback(n=>{if(re){const f=Array.from(n.clipboardData?.items??[]).filter(v=>v.kind==="file").map(v=>v.getAsFile()).filter(v=>!!v);f.length>0&&(n.preventDefault(),_(f))}setTimeout(()=>{C?d():d(!0)},0),r?.(n)},[re,C,d,r,_]),$=e.useCallback(n=>{if(!R){o?.(n);return}if(n.key==="Enter"&&!n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey&&!n.nativeEvent.isComposing){if(H||V){o?.(n);return}if(G==="never"){o?.(n);return}const f=D.trim().length>0||u.attachments.length>0;if(G==="whenDirty"&&!f){o?.(n);return}n.preventDefault(),u.onSubmit?.({value:D,attachments:u.attachments}),u.clearOnSubmit&&(oe||U(""),u.setAttachments([]))}o?.(n)},[R,H,V,G,D,oe,U,u,o]),k=m?B:"textarea";return e.createElement("div",{className:S("rt-ChatbarField","rt-ChatbarTextarea",s)},e.createElement(k,{...T,ref:n=>{typeof i=="function"?i(n):i&&(i.current=n),M.current=n},className:"rt-ChatbarInput",value:D,onInput:A,onChange:Q,onFocus:de,onPaste:me,onKeyDown:$,disabled:H,readOnly:V,rows:C?F:1,spellCheck:T.spellCheck??!0,autoCorrect:T.autoCorrect??"on",style:p}))});Fe.displayName="Chatbar.Textarea";const He=e.forwardRef((l,i)=>{const{children:s,asChild:p,style:m,className:b,...A}=l;return W().open?null:e.createElement(p?B:"div",{...A,ref:i,className:S("rt-ChatbarInlineStart",b),style:m},s)});He.displayName="Chatbar.InlineStart";const Ne=e.forwardRef((l,i)=>{const{children:s,asChild:p,style:m,className:b,...A}=l;return W().open?null:e.createElement(p?B:"div",{...A,ref:i,className:S("rt-ChatbarInlineEnd",b),style:m},s)});Ne.displayName="Chatbar.InlineEnd";const De=e.forwardRef((l,i)=>{const{asChild:s,forceMount:p,renderAttachment:m,className:b,style:A,...h}=l,r=W();return!(r.attachments.length>0)&&!p?null:e.createElement(s?B:"div",{...h,ref:i,className:S("rt-ChatbarAttachmentsRow",b),style:A,role:"list","aria-label":h["aria-label"]??"Attachments"},e.createElement(Qe,{className:"rt-ChatbarScrollArea",scrollbars:"horizontal",size:"1"},e.createElement(ce,{align:"center",gap:"2",style:{minWidth:"fit-content"}},r.attachments.map(P=>e.createElement(Ae,{key:P.id,attachment:P,asChild:!!m},m?.(P))))))});De.displayName="Chatbar.AttachmentsRow";const Ae=e.forwardRef((l,i)=>{const{attachment:s,asChild:p,className:m,style:b,children:A,...h}=l,r=W(),o=p?B:"div",R=!!s.url&&s.type.startsWith("image/");return e.createElement(o,{...h,ref:i,className:S("rt-ChatbarAttachment",m),style:b,role:"listitem","data-kind":R?"image":"file",title:s.name},A??e.createElement(ce,{align:"center",gap:"2",pr:R?void 0:"6"},e.createElement("div",{className:"rt-ChatbarAttachmentPreview","aria-hidden":!0},R?e.createElement("img",{className:"rt-ChatbarAttachmentImage",src:s.url,alt:""}):e.createElement(Je,null)),!R&&e.createElement(ce,{direction:"column",gap:"0",style:{minWidth:0}},e.createElement(ve,{size:r.size,weight:"medium",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},s.name),e.createElement(ve,{size:"1",color:"gray"},Math.ceil(s.size/1024)," KB")),e.createElement(Oe,{className:"rt-ChatbarAttachmentRemove","aria-label":`Remove ${s.name}`,size:"1",variant:"classic",highContrast:!0,color:"gray",onClick:()=>r.setAttachments(r.attachments.filter(P=>P.id!==s.id))},e.createElement(_e,null))))});Ae.displayName="Chatbar.Attachment";const ze=e.forwardRef((l,i)=>{const{asChild:s,accept:p,multiple:m,className:b,style:A,...h}=l,r=W(),o=e.useRef(null),R=s?B:"button",P=p??r.accept,T=(Array.isArray(P)?P:P?.split(",")??[]).join(",");return e.useEffect(()=>{const u=()=>{r.fileDialogOpenRef.current=!1};return window.addEventListener("focus",u),()=>window.removeEventListener("focus",u)},[r.fileDialogOpenRef]),e.createElement(e.Fragment,null,e.createElement(R,{...h,ref:i,className:S("rt-ChatbarAttachTrigger",b),style:A,type:h.type??"button","aria-label":h["aria-label"]??"Add attachments",onPointerDown:u=>{r.fileDialogOpenRef.current=!0,h.onPointerDown?.(u)},onMouseDown:u=>{r.fileDialogOpenRef.current=!0,h.onMouseDown?.(u)},onClick:u=>{r.fileDialogOpenRef.current=!0,o.current&&o.current.click(),h.onClick?.(u)}}),e.createElement("input",{ref:o,type:"file",accept:T,multiple:m??r.multiple,tabIndex:-1,style:{display:"none"},onChange:u=>{const C=Array.from(u.currentTarget.files??[]);C.length>0&&r.appendFiles(C),r.fileDialogOpenRef.current=!1,u.currentTarget.value=""}}))});ze.displayName="Chatbar.AttachTrigger";const ke=e.forwardRef((l,i)=>{const{asChild:s,children:p,className:m,style:b,...A}=l;return W().open?e.createElement(s?B:"div",{...A,ref:i,className:S("rt-ChatbarRow",m),style:b},e.createElement(ce,{align:"center",justify:"between",width:"100%"},p)):null});ke.displayName="Chatbar.Row";const Ie=e.forwardRef((l,i)=>{const{className:s,style:p,...m}=l;return e.createElement("div",{...m,ref:i,className:S("rt-ChatbarRowStart",s),style:p})});Ie.displayName="Chatbar.RowStart";const je=e.forwardRef((l,i)=>{const{className:s,style:p,...m}=l;return e.createElement("div",{...m,ref:i,className:S("rt-ChatbarRowEnd",s),style:p})});je.displayName="Chatbar.RowEnd";const Be=e.forwardRef((l,i)=>{const{asChild:s,clearOnSend:p=!0,disabled:m,children:b,className:A,style:h,...r}=l,o=W(),P=o.value.trim().length>0||o.attachments.length>0,T=o.sendMode==="always"||o.sendMode==="whenDirty"&&P;if(o.sendMode==="never")return null;const u=C=>{o.disabled||o.readOnly||(o.onSubmit?.({value:o.value,attachments:o.attachments}),p&&(o.isValueControlled||o.setValue(""),o.clearOnSubmit&&o.setAttachments([])),r.onClick?.(C))};return e.createElement(Oe,{...r,ref:i,size:o.size,variant:o.open?"solid":"ghost",disabled:m||o.disabled||o.readOnly,className:S("rt-ChatbarSend",A),style:{opacity:T?1:0,pointerEvents:T?"auto":"none",...h},asChild:s,onClick:u,"aria-label":r["aria-label"]??"Send"},b??e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-arrow-right-icon lucide-arrow-right"},e.createElement("path",{d:"M5 12h14"}),e.createElement("path",{d:"m12 5 7 7-7 7"})))});Be.displayName="Chatbar.Send";export{ze as AttachTrigger,Ae as Attachment,De as AttachmentsRow,Ne as InlineEnd,He as InlineStart,Le as Root,ke as Row,je as RowEnd,Ie as RowStart,Be as Send,Fe as Textarea};
|
|
2
2
|
//# sourceMappingURL=chatbar.js.map
|