@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,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": "skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,eAAAE,IAAA,eAAAC,GAAAH,IAAA,IAAAI,EAAuB,oBACvBC,EAAuB,yBACvBC,EAAuB,0BACvBC,EAA+B,iCAC/BC,EAAyB,+BACzBC,EAA8D,6BAC9DC,EAAkC,6BAClCC,EAA4C,8BAC5CC,
|
|
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": "skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,eAAAE,IAAA,eAAAC,GAAAH,IAAA,IAAAI,EAAuB,oBACvBC,EAAuB,yBACvBC,EAAuB,0BACv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AAGjC,GACF,mBAA4B,GAAGhB,CAAY,KAC3C,uBAAgC,GAAGC,CAAO,KAC1C,uBAAgC,GAAGC,CAAO,IAC7C,GAEAhB,EAAA,cAAC,OAAI,UAAU,2BAA2B,eAAc+D,GAAc,QACnEpB,CACH,EACC2B,EACH,CAEJ,CACF,EAEAxE,EAAU,YAAc,kBACxBA,EAAU,OAAS",
|
|
6
6
|
"names": ["shell_inspector_exports", "__export", "Inspector", "__toCommonJS", "React", "import_classnames", "Sheet", "import_visually_hidden", "import_shell_context", "import_shell_hooks", "import_shell_resize", "import_shell_handles", "import_shell_types", "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", "classNames"]
|
|
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,MA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C,sBAAsB,GAAG,wBAAwB,CAAC,CAAC;AAExD,KAAK,gBAAgB,GAAG,KAAK,CAAC,yBAAyB,CAAC,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,aAAa,CAAA;CAAE,CAAC;AAErJ,eAAO,MAAM,OAAO,EA+Yf,gBAAgB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var ye=Object.create;var w=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var Pe=(i,l)=>{for(var s in l)w(i,s,{get:l[s],enumerable:!0})},Y=(i,l,s,c)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of Me(l))!ge.call(i,u)&&u!==s&&w(i,u,{get:()=>l[u],enumerable:!(c=Se(l,u))||c.enumerable});return i};var
|
|
1
|
+
"use strict";var ye=Object.create;var w=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var Pe=(i,l)=>{for(var s in l)w(i,s,{get:l[s],enumerable:!0})},Y=(i,l,s,c)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of Me(l))!ge.call(i,u)&&u!==s&&w(i,u,{get:()=>l[u],enumerable:!(c=Se(l,u))||c.enumerable});return i};var O=(i,l,s)=>(s=i!=null?ye(he(i)):{},Y(l||!i||!i.__esModule?w(s,"default",{value:i,enumerable:!0}):s,i)),ve=i=>Y(w({},"__esModule",{value:!0}),i);var Re={};Pe(Re,{Sidebar:()=>W});module.exports=ve(Re);var r=O(require("react")),Z=O(require("classnames")),V=O(require("../sheet.js")),ee=require("../visually-hidden.js"),B=require("../shell.context.js"),v=require("../shell.hooks.js"),te=require("./shell-resize.js"),M=require("./shell-handles.js"),De=require("../shell.types.js");const W=r.forwardRef(({className:i,presentation:l={initial:"overlay",md:"fixed"},expandedSize:s=288,minSize:c=200,maxSize:u=400,resizable:N=!1,collapsible:ne=!0,onExpand:A,onCollapse:I,onResize:k,onResizeStart:re,onResizeEnd:oe,snapPoints:ae,snapTolerance:ie,collapseThreshold:se,paneId:T,persistence:H,children:de,style:le,thinSize:h=64,toggleModes:D,state:m,defaultState:y,onStateChange:F,...f},g)=>{const t=(0,B.useShell)(),$=(0,v.useResponsivePresentation)(l),P=$==="overlay",ue=$==="stacked",b=r.useRef(null),ce=r.useCallback(e=>{b.current=e,typeof g=="function"?g(e):g&&(g.current=e)},[g]),L=r.Children.toArray(de),j=L.filter(e=>r.isValidElement(e)&&e.type===M.SidebarHandle),q=L.filter(e=>!(r.isValidElement(e)&&e.type===M.SidebarHandle)),R=r.useMemo(()=>{const e=f.onSizeChange,n=f.sizeUpdate,o=f.sizeUpdateMs??50;if(!e)return()=>{};if(n==="debounce"){let a=null;return(d,S)=>{a&&clearTimeout(a),a=setTimeout(()=>{e(d,S)},o)}}if(n==="throttle"){let a=0;return(d,S)=>{const X=Date.now();X-a>=o&&(a=X,e(d,S))}}return(a,d)=>e(a,d)},[f.onSizeChange,f.sizeUpdate,f.sizeUpdateMs]),fe=r.useId();r.useEffect(()=>(t.setHasSidebar(!0),()=>{t.setHasSidebar(!1)}),[t,fe]);const C=r.useRef(null);r.useEffect(()=>{const e=typeof m<"u";if(C.current===null){C.current=e;return}C.current!==e&&(console.warn("Shell.Sidebar: Switching between controlled and uncontrolled `state` is not supported."),C.current=e)},[m]);const p=(0,v.useResponsiveValue)(m),K=(0,v.useResponsiveValue)(y),G=r.useRef(!1);r.useEffect(()=>{if(!G.current&&t.currentBreakpointReady){if(G.current=!0,typeof m<"u"&&p){t.sidebarMode!==p&&t.setSidebarMode(p);return}if(typeof y<"u"){const e=K??y;t.sidebarMode!==e&&t.setSidebarMode(e),F?.(e,{reason:"init"});return}}},[t.currentBreakpointReady,K,p,m,y]),r.useEffect(()=>{p!==void 0&&t.sidebarMode!==p&&t.setSidebarMode(p)},[p,t.sidebarMode]);const z=r.useRef(null);r.useEffect(()=>{typeof m>"u"&&(z.current===null?z.current=t.sidebarMode:z.current!==t.sidebarMode&&(z.current=t.sidebarMode,F?.(t.sidebarMode,{reason:"toggle"})))},[t.sidebarMode,m,F]),r.useEffect(()=>{t.sidebarMode==="expanded"?A?.():I?.()},[t.sidebarMode,A,I]);const J=t.sidebarMode!=="collapsed",x=r.useMemo(()=>{if(!T||H)return H;const e=`kookie-ui:shell:sidebar:${T}`;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))}}},[T,H]);r.useEffect(()=>{let e=!0;return(async()=>{if(!N||!x?.load||P)return;const n=await x.load();e&&typeof n=="number"&&b.current&&(b.current.style.setProperty("--sidebar-size",`${n}px`),k?.(n))})(),()=>{e=!1}},[N,x,k,P]);const E=(0,B.useShell)(),U=r.useCallback(()=>{const e=y??"expanded";return e==="thin"||e==="expanded"?e:"expanded"},[y]);r.useEffect(()=>{if(!E.setSidebarToggleComputer)return;const e=D??"both",n=o=>{if(e==="both")return o==="collapsed"?"thin":o==="thin"?"expanded":"collapsed";const a=U();return o==="collapsed"?a:o===a?"collapsed":a};return E.setSidebarToggleComputer(n),()=>{E.setSidebarToggleComputer?.(o=>o==="collapsed"?"thin":o==="thin"?"expanded":"collapsed")}},[E,D,U]);const Q=r.useRef(s),be=r.useRef("expanded");r.useEffect(()=>{t.sidebarMode!=="collapsed"&&(be.current=t.sidebarMode,Q.current=t.sidebarMode==="thin"?h:s)},[t.sidebarMode,h,s]);const pe=N&&!P&&t.sidebarMode==="expanded"?r.createElement(te.PaneResizeContext.Provider,{value:{containerRef:b,cssVarName:"--sidebar-size",minSize:c,maxSize:u,defaultSize:s,orientation:"vertical",edge:"end",computeNext:(e,n,o)=>{const a=getComputedStyle(b.current).direction==="rtl",d=e-n;return o+(a?-d:d)},onResize:k,onResizeStart:re,onResizeEnd:e=>{oe?.(e),R(e,{reason:"resize"}),x?.save?.(e)},target:"sidebar",collapsible:ne,snapPoints:ae,snapTolerance:ie??8,collapseThreshold:se,requestCollapse:()=>t.setSidebarMode("collapsed"),requestToggle:()=>t.togglePane("sidebar")}},j.length>0?j.map((e,n)=>r.cloneElement(e,{key:e.key??n})):r.createElement(M.PaneHandle,null)):null,{state:Ce,defaultState:ze,onStateChange:xe,size:Ee,defaultSize:we,onSizeChange:Ne,sizeUpdate:ke,sizeUpdateMs:Te,...me}=f,_=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),d=document.documentElement.clientWidth||window.innerWidth||0;return a/100*d}const o=Number.parseFloat(n);return Number.isFinite(o)?o:void 0},[]);if(r.useEffect(()=>{if(!b.current)return;const{size:e,defaultSize:n}=f;if(typeof e>"u"&&typeof n<"u"){const o=_(n);if(typeof o=="number"&&Number.isFinite(o)){const S=Math.min((typeof u=="number"?u:void 0)??o,Math.max((typeof c=="number"?c:void 0)??o,o));b.current.style.setProperty("--sidebar-size",`${S}px`),R(S,{reason:"init"})}}},[]),r.useEffect(()=>{if(!b.current)return;const{size:e}=f;if(typeof e>"u")return;const n=_(e);if(typeof n=="number"&&Number.isFinite(n)){const d=Math.min((typeof u=="number"?u:void 0)??n,Math.max((typeof c=="number"?c:void 0)??n,n));b.current.style.setProperty("--sidebar-size",`${d}px`),R(d,{reason:"controlled"})}},[f.size,c,u,_,R]),P){const e=t.sidebarMode!=="collapsed";return r.createElement(V.Root,{open:e,onOpenChange:n=>t.setSidebarMode(n?"expanded":"collapsed")},r.createElement(V.Content,{side:"start",style:{padding:0},width:{initial:`${e?t.sidebarMode==="thin"?h:s:Q.current}px`}},r.createElement(ee.VisuallyHidden,null,r.createElement(V.Title,null,"Navigation")),q))}return r.createElement("div",{...me,ref:ce,className:(0,Z.default)("rt-ShellSidebar",i),"data-mode":t.sidebarMode,"data-peek":t.peekTarget==="sidebar"||void 0,"data-presentation":t.currentBreakpointReady?$:void 0,"data-open":t.currentBreakpointReady&&ue&&J||void 0,style:{...le,"--sidebar-size":`${s}px`,"--sidebar-thin-size":`${h}px`,"--sidebar-min-size":`${c}px`,"--sidebar-max-size":`${u}px`,...t.peekTarget==="sidebar"&&t.sidebarMode==="collapsed"&&!P?(()=>{const e=D??"both",n=t.sidebarMode;let o;if(e==="both")o=n==="collapsed"?"thin":n==="thin"?"expanded":"collapsed";else{const a=U();o=n==="collapsed"?a:"collapsed"}return o==="thin"?{"--peek-sidebar-width":`${h}px`}:{"--peek-sidebar-width":`var(--sidebar-size, ${s}px)`}})():{}}},r.createElement("div",{className:"rt-ShellSidebarContent","data-visible":J||void 0},q),pe)});W.displayName="Shell.Sidebar",W.Handle=M.SidebarHandle;
|
|
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": "skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,IAAA,eAAAC,GAAAH,IAAA,IAAAI,EAAuB,oBACvBC,EAAuB,yBACvBC,EAAuB,0BACvBC,GAA+B,iCAC/BC,EAAyB,+BACzBC,EAA8D,6BAC9DC,GAAkC,6BAClCC,EAA0C,8BAE1CC,
|
|
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": "skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,IAAA,eAAAC,GAAAH,IAAA,IAAAI,EAAuB,oBACvBC,EAAuB,yBACvBC,EAAuB,0BACvBC,GAA+B,iCAC/BC,EAAyB,+BACzBC,EAA8D,6BAC9DC,GAAkC,6BAClCC,EAA0C,8BAE1CC,GAA6B,6BA0CtB,MAAMV,EAAUE,EAAM,WAC3B,CACE,CACE,UAAAS,EACA,aA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,WAC5C,CACA,OAAIiC,IAAS,OACJ,CACJ,uBAAgC,GAAGhF,CAAQ,IAC9C,EAEK,CACJ,uBAAgC,uBAAuBjB,CAAY,KACtE,CACF,GAAG,EACH,CAAC,CACP,GAEAX,EAAA,cAAC,OAAI,UAAU,yBAAyB,eAAc+D,GAAoB,QACvElB,CACH,EACCkC,EACH,CAEJ,CACF,EAEAjF,EAAQ,YAAc,gBACtBA,EAAQ,OAAS",
|
|
6
6
|
"names": ["shell_sidebar_exports", "__export", "Sidebar", "__toCommonJS", "React", "import_classnames", "Sheet", "import_visually_hidden", "import_shell_context", "import_shell_hooks", "import_shell_resize", "import_shell_handles", "import_shell_types", "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", "classNames", "next"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbar.d.ts","sourceRoot":"","sources":["../../../src/components/chatbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAA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M,QAAQ,mKAGZ,CAAC;AAGH,QAAA,MAAM,MAAM,mKAGV,CAAC;AAGH,UAAU,SAAU,SAAQ,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,IAAI,qFAuDR,CAAC;AAGH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC1H,YAAY,EAAE,SAAS,IAAI,gBAAgB,EAAE,aAAa,IAAI,oBAAoB,EAAE,QAAQ,IAAI,eAAe,EAAE,SAAS,IAAI,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var nt=Object.create;var ue=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var it=(a,o)=>{for(var r in o)ue(a,r,{get:o[r],enumerable:!0})},We=(a,o,r,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of ot(o))!st.call(a,c)&&c!==r&&ue(a,c,{get:()=>o[c],enumerable:!(u=at(o,c))||u.enumerable});return a};var Ve=(a,o,r)=>(r=a!=null?nt(rt(a)):{},We(o||!a||!a.__esModule?ue(r,"default",{value:a,enumerable:!0}):r,a)),lt=a=>We(ue({},"__esModule",{value:!0}),a);var ct={};it(ct,{AttachTrigger:()=>Le,Attachment:()=>me,AttachmentsRow:()=>Me,InlineEnd:()=>Oe,InlineStart:()=>Se,Root:()=>Ee,Row:()=>Fe,RowEnd:()=>Ne,RowStart:()=>He,Send:()=>De,Textarea:()=>Te});module.exports=lt(ct);var e=Ve(require("react")),T=Ve(require("classnames")),Pe=require("./icon-button.js"),pe=require("./icons.js"),ae=require("./flex.js"),Ke=require("./scroll-area.js"),D=require("./slot.js"),$e=require("./box.js"),dt=require("./card.js"),de=require("./text.js"),pt=require("./inset.js"),qe=require("react-dropzone");const we=typeof window<"u"?e.useLayoutEffect:e.useEffect,Ue=e.createContext(null),W=()=>{const a=e.useContext(Ue);if(!a)throw new Error("Chatbar context not found. Wrap parts in <Chatbar.Root>.");return a},Ee=e.forwardRef((a,o)=>{const{className:r,style:u,children:c,value:b,defaultValue:A="",onValueChange:h,open:l,defaultOpen:s=!1,onOpenChange:R,expandOn:P="both",minLines:S=1,maxLines:m=6,sendMode:C="whenDirty",disabled:F,readOnly:Y,onSubmit:O,size:H="2",variant:V,color:N,radius:U,panelBackground:M,material:z,width:oe,maxWidth:G,asChild:re,attachments:se,defaultAttachments:he=[],onAttachmentsChange:K,accept:_,multiple:k=!0,maxAttachments:w,maxFileSize:p,paste:fe=!0,pasteAccept:J,clearOnSubmit:be=!0,onAttachmentReject:$,dropzone:I=!0,apiRef:n,...d}=a,f=z||M,v=b!=null,[L,Ce]=e.useState(A),Q=v?b:L,j=l!=null,[X,q]=e.useState(s),Z=j?l:X,ge=e.useRef(null),ie=e.useRef(null),ye=e.useRef(!1),le="attachments"in a,[Ye,ze]=e.useState(he),B=le?se??[]:Ye,ee=e.useRef(new Set),ve=t=>Array.isArray(t)?t:typeof t=="string"?t.split(",").map(i=>i.trim()):[],te=ve(_),ke=ve(J).length>0?ve(J):te,xe=(t,i)=>{if(i.length===0)return!0;const g=t.type.toLowerCase(),E=t.name.toLowerCase();for(const y of i){const x=y.toLowerCase();if(x.includes("/")){const[ce,Re]=x.split("/"),[ne,tt]=g.split("/");if(ce==="*"||ce===ne&&(Re==="*"||Re===tt))return!0}else if(x.startsWith(".")&&E.endsWith(x))return!0}return!1},Ge=t=>{const i=[],g=[],E=typeof w=="number"?Math.max(w-B.length,0):1/0;for(const y of t){if(i.length>=E){g.push({file:y,reason:"count"});continue}if(typeof p=="number"&&y.size>p){g.push({file:y,reason:"size"});continue}if(!xe(y,te)){g.push({file:y,reason:"type"});continue}const x=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ce=/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(y.name),ne=(y.type||"").toLowerCase().startsWith("image/")||ce?URL.createObjectURL(y):void 0;ne&&ee.current.add(ne),i.push({id:x,name:y.name,size:y.size,type:y.type,file:y,url:ne,status:"idle"})}return{accepted:i,rejected:g}},Ae=t=>{const{accepted:i,rejected:g}=Ge(t);if(i.length>0){const E=B.concat(i);le||ze(E),K?.(E),j||q(!0),R?.(!0)}g.length>0&&$?.(g)},_e=t=>{const i=x=>ke.length===0?xe(x,te):xe(x,ke),g=[],E=[],y=typeof w=="number"?Math.max(w-B.length,0):1/0;for(const x of t){if(g.length>=y){E.push({file:x,reason:"count"});continue}if(typeof p=="number"&&x.size>p){E.push({file:x,reason:"size"});continue}if(!i(x)){E.push({file:x,reason:"type"});continue}g.push(x)}g.length>0&&Ae(g),E.length>0&&$?.(E)};e.useEffect(()=>{const t=new Set(B.map(i=>i.url).filter(Boolean));for(const i of Array.from(ee.current))t.has(i)||(URL.revokeObjectURL(i),ee.current.delete(i))},[B]),e.useEffect(()=>()=>{for(const t of Array.from(ee.current))URL.revokeObjectURL(t);ee.current.clear()},[]);const Je=re?D.Slot:"div",Qe=e.useCallback(t=>{const i=t.relatedTarget,g=ge.current;g&&(i&&g.contains(i)||ye.current||(Q?.trim?.()??"").length===0&&B.length===0&&(j||q(!1),R?.(!1)))},[j,R,Q,B]),{getRootProps:Xe,getInputProps:Ze,isDragActive:Ie,open:je}=(0,qe.useDropzone)({onDrop:(t,i)=>{if(t.length>0&&Ae(t),i.length>0&&$){const g=i.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,i)=>(i.includes("/")?t[i]=[]:i.startsWith(".")&&(t[i]=[]),t),{}):void 0,multiple:k,maxSize:p,noClick:!0,noKeyboard:!0,disabled:!I||F});e.useImperativeHandle(n,()=>({focusTextarea:()=>ie.current?.focus({preventScroll:!0}),openFilePicker:()=>{ye.current=!0,je()}}),[je]);const Be=e.useCallback(t=>{if(!(t instanceof Element))return!1;const i=t;return i.closest(".rt-ChatbarDropOverlay")?!0:!!i.closest('button, [role="button"], a[href], input, textarea, select, [contenteditable], [tabindex]:not([tabindex="-1"])')},[]),et=e.useCallback(t=>{F||Be(t.target)||t.pointerType==="mouse"&&t.button!==0||(t.preventDefault(),ie.current?.focus({preventScroll:!0}))},[F,Be,ie]);return e.createElement(Ue.Provider,{value:{open:Z,setOpen:t=>{j||q(t),R?.(t)},isOpenControlled:j,value:Q,setValue:t=>{v||Ce(t),h?.(t)},isValueControlled:v,size:H,expandOn:P,minLines:S,maxLines:m,sendMode:C,disabled:F,readOnly:Y,onSubmit:O,rootRef:ge,textareaRef:ie,attachments:B,setAttachments:t=>{le||ze(t),K?.(t)},isAttachmentsControlled:le,accept:_,multiple:k,maxAttachments:w,maxFileSize:p,paste:fe,pasteAccept:J,clearOnSubmit:be,onAttachmentReject:$,dropzone:I,appendFiles:Ae,appendFilesFromPaste:_e,fileDialogOpenRef:ye}},e.createElement(Je,{...d,ref:t=>{typeof o=="function"?o(t):o&&(o.current=t),ge.current=t},className:(0,T.default)("rt-ChatbarRoot",`rt-r-size-${H}`,r),style:{position:"relative",width:oe,maxWidth:G,...u},"data-state":Z?"open":"closed","data-disabled":F?"":void 0,"data-readonly":Y?"":void 0,"data-drop-active":I&&Ie?"":void 0,"data-accent-color":N,"data-radius":U,"data-panel-background":f,"data-material":f,"aria-expanded":Z,onBlurCapture:Qe},I&&e.createElement("input",{...Ze()}),e.createElement("div",{...I?Xe():{},style:{width:"100%",height:"100%"},onPointerDown:et},e.createElement($e.Box,{className:(0,T.default)("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"},c),I&&Ie&&e.createElement("div",{className:"rt-ChatbarDropOverlay"},e.createElement("div",{className:"rt-ChatbarDropContent"},e.createElement(de.Text,{color:"gray",size:H,weight:"medium"},"Drop files here to attach")))))))});Ee.displayName="Chatbar.Root";const Te=e.forwardRef((a,o)=>{const{className:r,style:u,asChild:c,onFocus:b,onInput:A,onChange:h,onPaste:l,onKeyDown:s,submitOnEnter:R=!1,rows:P,...S}=a,m=W(),{open:C,minLines:F,maxLines:Y,expandOn:O,disabled:H,readOnly:V,setOpen:N,setValue:U,textareaRef:M,value:z,isValueControlled:oe,sendMode:G,paste:re,appendFilesFromPaste:se,size:he}=m,K=e.useRef(0),_=e.useRef(0),k=e.useRef(0),w=e.useCallback(()=>{const n=M.current;if(!n)return;const d=window.getComputedStyle(n),f=parseFloat(d.lineHeight)||20,v=parseFloat(d.paddingTop)||0,L=parseFloat(d.paddingBottom)||0;K.current=f,_.current=v+L,k.current=Math.ceil(1*f)+v+L},[M]),p=e.useCallback(n=>{const d=M.current;if(!d)return;d.style.height="auto",K.current===0&&w();const f=K.current,v=_.current,L=n??C,Ce=L?F:1,Q=L?Y:1,j=Math.ceil(Ce*f)+v,X=Math.ceil(Q*f)+v,q=Math.max(d.scrollHeight,j),Z=Math.min(q,X);d.style.height=`${Z}px`,q>X?(d.style.overflowY="auto",d.style.maxHeight=`${X}px`):(d.style.overflowY="hidden",d.style.maxHeight="none")},[C,F,Y,M,w]);we(()=>{p()},[p,z,C]),we(()=>{if(!(O==="overflow"||O==="both")||C)return;const n=M.current;if(!n)return;n.style.height="auto",k.current===0&&w(),n.scrollHeight>k.current+1&&(N(!0),p(!0),requestAnimationFrame(()=>p(!0)))},[z,O,C,N,M,w,p]),we(()=>{w(),p()},[w,p,he]),e.useEffect(()=>{const n=M.current;if(!n||typeof ResizeObserver>"u")return;let d=K.current;const f=new ResizeObserver(()=>{const v=window.getComputedStyle(n),L=parseFloat(v.lineHeight)||20;L!==d&&(d=L,w(),requestAnimationFrame(()=>p()))});return f.observe(n),()=>f.disconnect()},[M,w,p]),e.useEffect(()=>{},[]);const fe=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 d=n.currentTarget,f=d.value;U(f),(O==="overflow"||O==="both")&&!C&&(d.style.height="auto",k.current===0&&w(),d.scrollHeight>k.current+1&&(N(!0),p(!0),requestAnimationFrame(()=>p(!0)))),requestAnimationFrame(()=>p()),h?.(n)},[O,C,N,U,h,p,w]),be=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(),se(f))}setTimeout(()=>{C?p():p(!0)},0),l?.(n)},[re,C,p,l,se]),$=e.useCallback(n=>{if(!R){s?.(n);return}if(n.key==="Enter"&&!n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey&&!n.nativeEvent.isComposing){if(H||V){s?.(n);return}if(G==="never"){s?.(n);return}const f=z.trim().length>0||m.attachments.length>0;if(G==="whenDirty"&&!f){s?.(n);return}n.preventDefault(),m.onSubmit?.({value:z,attachments:m.attachments}),m.clearOnSubmit&&(oe||U(""),m.setAttachments([]))}s?.(n)},[R,H,V,G,z,oe,U,m,s]),I=c?D.Slot:"textarea";return e.createElement("div",{className:(0,T.default)("rt-ChatbarField","rt-ChatbarTextarea",r)},e.createElement(I,{...S,ref:n=>{typeof o=="function"?o(n):o&&(o.current=n),M.current=n},className:"rt-ChatbarInput",value:z,onInput:A,onChange:J,onFocus:fe,onPaste:be,onKeyDown:$,disabled:H,readOnly:V,rows:C?F:1,spellCheck:S.spellCheck??!0,autoCorrect:S.autoCorrect??"on",style:u}))});Te.displayName="Chatbar.Textarea";const Se=e.forwardRef((a,o)=>{const{children:r,asChild:u,style:c,className:b,...A}=a;return W().open?null:e.createElement(u?D.Slot:"div",{...A,ref:o,className:(0,T.default)("rt-ChatbarInlineStart",b),style:c},r)});Se.displayName="Chatbar.InlineStart";const Oe=e.forwardRef((a,o)=>{const{children:r,asChild:u,style:c,className:b,...A}=a;return W().open?null:e.createElement(u?D.Slot:"div",{...A,ref:o,className:(0,T.default)("rt-ChatbarInlineEnd",b),style:c},r)});Oe.displayName="Chatbar.InlineEnd";const Me=e.forwardRef((a,o)=>{const{asChild:r,forceMount:u,renderAttachment:c,className:b,style:A,...h}=a,l=W();return!(l.attachments.length>0)&&!u?null:e.createElement(r?D.Slot:"div",{...h,ref:o,className:(0,T.default)("rt-ChatbarAttachmentsRow",b),style:A,role:"list","aria-label":h["aria-label"]??"Attachments"},e.createElement(Ke.ScrollArea,{className:"rt-ChatbarScrollArea",scrollbars:"horizontal",size:"1"},e.createElement(ae.Flex,{align:"center",gap:"2",style:{minWidth:"fit-content"}},l.attachments.map(P=>e.createElement(me,{key:P.id,attachment:P,asChild:!!c},c?.(P))))))});Me.displayName="Chatbar.AttachmentsRow";const me=e.forwardRef((a,o)=>{const{attachment:r,asChild:u,className:c,style:b,children:A,...h}=a,l=W(),s=u?D.Slot:"div",R=!!r.url&&r.type.startsWith("image/");return e.createElement(s,{...h,ref:o,className:(0,T.default)("rt-ChatbarAttachment",c),style:b,role:"listitem","data-kind":R?"image":"file",title:r.name},A??e.createElement(ae.Flex,{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:r.url,alt:""}):e.createElement(pe.FileTextIcon,null)),!R&&e.createElement(ae.Flex,{direction:"column",gap:"0",style:{minWidth:0}},e.createElement(de.Text,{size:l.size,weight:"medium",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},r.name),e.createElement(de.Text,{size:"1",color:"gray"},Math.ceil(r.size/1024)," KB")),e.createElement(Pe.IconButton,{className:"rt-ChatbarAttachmentRemove","aria-label":`Remove ${r.name}`,size:"1",variant:"classic",highContrast:!0,color:"gray",onClick:()=>l.setAttachments(l.attachments.filter(P=>P.id!==r.id))},e.createElement(pe.CloseIcon,null))))});me.displayName="Chatbar.Attachment";const Le=e.forwardRef((a,o)=>{const{asChild:r,accept:u,multiple:c,className:b,style:A,...h}=a,l=W(),s=e.useRef(null),R=r?D.Slot:"button",P=u??l.accept,S=(Array.isArray(P)?P:P?.split(",")??[]).join(",");return e.useEffect(()=>{const m=()=>{l.fileDialogOpenRef.current=!1};return window.addEventListener("focus",m),()=>window.removeEventListener("focus",m)},[l.fileDialogOpenRef]),e.createElement(e.Fragment,null,e.createElement(R,{...h,ref:o,className:(0,T.default)("rt-ChatbarAttachTrigger",b),style:A,type:h.type??"button","aria-label":h["aria-label"]??"Add attachments",onPointerDown:m=>{l.fileDialogOpenRef.current=!0,h.onPointerDown?.(m)},onMouseDown:m=>{l.fileDialogOpenRef.current=!0,h.onMouseDown?.(m)},onClick:m=>{l.fileDialogOpenRef.current=!0,s.current&&s.current.click(),h.onClick?.(m)}}),e.createElement("input",{ref:s,type:"file",accept:S,multiple:c??l.multiple,tabIndex:-1,style:{display:"none"},onChange:m=>{const C=Array.from(m.currentTarget.files??[]);C.length>0&&l.appendFiles(C),l.fileDialogOpenRef.current=!1,m.currentTarget.value=""}}))});Le.displayName="Chatbar.AttachTrigger";const Fe=e.forwardRef((a,o)=>{const{asChild:r,children:u,className:c,style:b,...A}=a;return W().open?e.createElement(r?D.Slot:"div",{...A,ref:o,className:(0,T.default)("rt-ChatbarRow",c),style:b},e.createElement(ae.Flex,{align:"center",justify:"between",width:"100%"},u)):null});Fe.displayName="Chatbar.Row";const He=e.forwardRef((a,o)=>{const{className:r,style:u,...c}=a;return e.createElement("div",{...c,ref:o,className:(0,T.default)("rt-ChatbarRowStart",r),style:u})});He.displayName="Chatbar.RowStart";const Ne=e.forwardRef((a,o)=>{const{className:r,style:u,...c}=a;return e.createElement("div",{...c,ref:o,className:(0,T.default)("rt-ChatbarRowEnd",r),style:u})});Ne.displayName="Chatbar.RowEnd";const De=e.forwardRef((a,o)=>{const{asChild:r,clearOnSend:u=!0,disabled:c,children:b,className:A,style:h,...l}=a,s=W(),P=s.value.trim().length>0||s.attachments.length>0,S=s.sendMode==="always"||s.sendMode==="whenDirty"&&P;if(s.sendMode==="never")return null;const m=C=>{s.disabled||s.readOnly||(s.onSubmit?.({value:s.value,attachments:s.attachments}),u&&(s.isValueControlled||s.setValue(""),s.clearOnSubmit&&s.setAttachments([])),l.onClick?.(C))};return e.createElement(Pe.IconButton,{...l,ref:o,size:s.size,variant:s.open?"solid":"ghost",disabled:c||s.disabled||s.readOnly,className:(0,T.default)("rt-ChatbarSend",A),style:{opacity:S?1:0,pointerEvents:S?"auto":"none",...h},asChild:r,onClick:m,"aria-label":l["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"})))});De.displayName="Chatbar.Send";
|
|
1
|
+
"use strict";var nt=Object.create;var ue=Object.defineProperty;var at=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var rt=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var it=(a,o)=>{for(var r in o)ue(a,r,{get:o[r],enumerable:!0})},Ve=(a,o,r,u)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of ot(o))!st.call(a,c)&&c!==r&&ue(a,c,{get:()=>o[c],enumerable:!(u=at(o,c))||u.enumerable});return a};var Ue=(a,o,r)=>(r=a!=null?nt(rt(a)):{},Ve(o||!a||!a.__esModule?ue(r,"default",{value:a,enumerable:!0}):r,a)),lt=a=>Ve(ue({},"__esModule",{value:!0}),a);var ct={};it(ct,{AttachTrigger:()=>Le,Attachment:()=>me,AttachmentsRow:()=>Me,InlineEnd:()=>Oe,InlineStart:()=>Se,Root:()=>Ee,Row:()=>Fe,RowEnd:()=>Ne,RowStart:()=>He,Send:()=>De,Textarea:()=>Te});module.exports=lt(ct);var e=Ue(require("react")),T=Ue(require("classnames")),Pe=require("./icon-button.js"),pe=require("./icons.js"),oe=require("./flex.js"),$e=require("./scroll-area.js"),D=require("./slot.js"),qe=require("./box.js"),de=require("./text.js"),Ye=require("react-dropzone");const we=typeof window<"u"?e.useLayoutEffect:e.useEffect,Ke=e.createContext(null),W=()=>{const a=e.useContext(Ke);if(!a)throw new Error("Chatbar context not found. Wrap parts in <Chatbar.Root>.");return a},Ee=e.forwardRef((a,o)=>{const{className:r,style:u,children:c,value:b,defaultValue:A="",onValueChange:h,open:l,defaultOpen:i=!1,onOpenChange:R,expandOn:P="both",minLines:S=1,maxLines:m=6,sendMode:C="whenDirty",disabled:F,readOnly:Y,onSubmit:O,size:H="2",variant:V,color:N,radius:U,panelBackground:M,material:z,width:re,maxWidth:G,asChild:se,attachments:_,defaultAttachments:he=[],onAttachmentsChange:K,accept:J,multiple:k=!0,maxAttachments:w,maxFileSize:p,paste:fe=!0,pasteAccept:Q,clearOnSubmit:be=!0,onAttachmentReject:$,dropzone:I=!0,apiRef:n,...d}=a,f=z||M,v=b!=null,[L,Ce]=e.useState(A),X=v?b:L,j=l!=null,[Z,q]=e.useState(i),ee=j?l:Z,ge=e.useRef(null),ie=e.useRef(null),ye=e.useRef(!1),te="attachments"in a,[ze,ke]=e.useState(he),B=e.useMemo(()=>te?_??[]:ze,[te,_,ze]),le=e.useRef(new Set),ve=t=>Array.isArray(t)?t:typeof t=="string"?t.split(",").map(s=>s.trim()):[],ne=ve(J),Ie=ve(Q).length>0?ve(Q):ne,xe=(t,s)=>{if(s.length===0)return!0;const g=t.type.toLowerCase(),E=t.name.toLowerCase();for(const y of s){const x=y.toLowerCase();if(x.includes("/")){const[ce,Re]=x.split("/"),[ae,tt]=g.split("/");if(ce==="*"||ce===ae&&(Re==="*"||Re===tt))return!0}else if(x.startsWith(".")&&E.endsWith(x))return!0}return!1},Ge=t=>{const s=[],g=[],E=typeof w=="number"?Math.max(w-B.length,0):1/0;for(const y of t){if(s.length>=E){g.push({file:y,reason:"count"});continue}if(typeof p=="number"&&y.size>p){g.push({file:y,reason:"size"});continue}if(!xe(y,ne)){g.push({file:y,reason:"type"});continue}const x=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ce=/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(y.name),ae=(y.type||"").toLowerCase().startsWith("image/")||ce?URL.createObjectURL(y):void 0;ae&&le.current.add(ae),s.push({id:x,name:y.name,size:y.size,type:y.type,file:y,url:ae,status:"idle"})}return{accepted:s,rejected:g}},Ae=t=>{const{accepted:s,rejected:g}=Ge(t);if(s.length>0){const E=B.concat(s);te||ke(E),K?.(E),j||q(!0),R?.(!0)}g.length>0&&$?.(g)},_e=t=>{const s=x=>Ie.length===0?xe(x,ne):xe(x,Ie),g=[],E=[],y=typeof w=="number"?Math.max(w-B.length,0):1/0;for(const x of t){if(g.length>=y){E.push({file:x,reason:"count"});continue}if(typeof p=="number"&&x.size>p){E.push({file:x,reason:"size"});continue}if(!s(x)){E.push({file:x,reason:"type"});continue}g.push(x)}g.length>0&&Ae(g),E.length>0&&$?.(E)};e.useEffect(()=>{const t=new Set(B.map(s=>s.url).filter(Boolean));for(const s of Array.from(le.current))t.has(s)||(URL.revokeObjectURL(s),le.current.delete(s))},[B]),e.useEffect(()=>{const t=le.current;return()=>{for(const s of Array.from(t))URL.revokeObjectURL(s);t.clear()}},[]);const Je=se?D.Slot:"div",Qe=e.useCallback(t=>{const s=t.relatedTarget,g=ge.current;g&&(s&&g.contains(s)||ye.current||(X?.trim?.()??"").length===0&&B.length===0&&(j||q(!1),R?.(!1)))},[j,R,X,B]),{getRootProps:Xe,getInputProps:Ze,isDragActive:je,open:Be}=(0,Ye.useDropzone)({onDrop:(t,s)=>{if(t.length>0&&Ae(t),s.length>0&&$){const g=s.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,s)=>(s.includes("/")?t[s]=[]:s.startsWith(".")&&(t[s]=[]),t),{}):void 0,multiple:k,maxSize:p,noClick:!0,noKeyboard:!0,disabled:!I||F});e.useImperativeHandle(n,()=>({focusTextarea:()=>ie.current?.focus({preventScroll:!0}),openFilePicker:()=>{ye.current=!0,Be()}}),[Be]);const We=e.useCallback(t=>{if(!(t instanceof Element))return!1;const s=t;return s.closest(".rt-ChatbarDropOverlay")?!0:!!s.closest('button, [role="button"], a[href], input, textarea, select, [contenteditable], [tabindex]:not([tabindex="-1"])')},[]),et=e.useCallback(t=>{F||We(t.target)||t.pointerType==="mouse"&&t.button!==0||(t.preventDefault(),ie.current?.focus({preventScroll:!0}))},[F,We,ie]);return e.createElement(Ke.Provider,{value:{open:ee,setOpen:t=>{j||q(t),R?.(t)},isOpenControlled:j,value:X,setValue:t=>{v||Ce(t),h?.(t)},isValueControlled:v,size:H,expandOn:P,minLines:S,maxLines:m,sendMode:C,disabled:F,readOnly:Y,onSubmit:O,rootRef:ge,textareaRef:ie,attachments:B,setAttachments:t=>{te||ke(t),K?.(t)},isAttachmentsControlled:te,accept:J,multiple:k,maxAttachments:w,maxFileSize:p,paste:fe,pasteAccept:Q,clearOnSubmit:be,onAttachmentReject:$,dropzone:I,appendFiles:Ae,appendFilesFromPaste:_e,fileDialogOpenRef:ye}},e.createElement(Je,{...d,ref:t=>{typeof o=="function"?o(t):o&&(o.current=t),ge.current=t},className:(0,T.default)("rt-ChatbarRoot",`rt-r-size-${H}`,r),style:{position:"relative",width:re,maxWidth:G,...u},"data-state":ee?"open":"closed","data-disabled":F?"":void 0,"data-readonly":Y?"":void 0,"data-drop-active":I&&je?"":void 0,"data-accent-color":N,"data-radius":U,"data-panel-background":f,"data-material":f,"aria-expanded":ee,onBlurCapture:Qe},I&&e.createElement("input",{...Ze()}),e.createElement("div",{...I?Xe():{},style:{width:"100%",height:"100%"},onPointerDown:et},e.createElement(qe.Box,{className:(0,T.default)("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"},c),I&&je&&e.createElement("div",{className:"rt-ChatbarDropOverlay"},e.createElement("div",{className:"rt-ChatbarDropContent"},e.createElement(de.Text,{color:"gray",size:H,weight:"medium"},"Drop files here to attach")))))))});Ee.displayName="Chatbar.Root";const Te=e.forwardRef((a,o)=>{const{className:r,style:u,asChild:c,onFocus:b,onInput:A,onChange:h,onPaste:l,onKeyDown:i,submitOnEnter:R=!1,rows:P,...S}=a,m=W(),{open:C,minLines:F,maxLines:Y,expandOn:O,disabled:H,readOnly:V,setOpen:N,setValue:U,textareaRef:M,value:z,isValueControlled:re,sendMode:G,paste:se,appendFilesFromPaste:_,size:he}=m,K=e.useRef(0),J=e.useRef(0),k=e.useRef(0),w=e.useCallback(()=>{const n=M.current;if(!n)return;const d=window.getComputedStyle(n),f=parseFloat(d.lineHeight)||20,v=parseFloat(d.paddingTop)||0,L=parseFloat(d.paddingBottom)||0;K.current=f,J.current=v+L,k.current=Math.ceil(1*f)+v+L},[M]),p=e.useCallback(n=>{const d=M.current;if(!d)return;d.style.height="auto",K.current===0&&w();const f=K.current,v=J.current,L=n??C,Ce=L?F:1,X=L?Y:1,j=Math.ceil(Ce*f)+v,Z=Math.ceil(X*f)+v,q=Math.max(d.scrollHeight,j),ee=Math.min(q,Z);d.style.height=`${ee}px`,q>Z?(d.style.overflowY="auto",d.style.maxHeight=`${Z}px`):(d.style.overflowY="hidden",d.style.maxHeight="none")},[C,F,Y,M,w]);we(()=>{p()},[p,z,C]),we(()=>{if(!(O==="overflow"||O==="both")||C)return;const n=M.current;if(!n)return;n.style.height="auto",k.current===0&&w(),n.scrollHeight>k.current+1&&(N(!0),p(!0),requestAnimationFrame(()=>p(!0)))},[z,O,C,N,M,w,p]),we(()=>{w(),p()},[w,p,he]),e.useEffect(()=>{const n=M.current;if(!n||typeof ResizeObserver>"u")return;let d=K.current;const f=new ResizeObserver(()=>{const v=window.getComputedStyle(n),L=parseFloat(v.lineHeight)||20;L!==d&&(d=L,w(),requestAnimationFrame(()=>p()))});return f.observe(n),()=>f.disconnect()},[M,w,p]),e.useEffect(()=>{},[]);const fe=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 d=n.currentTarget,f=d.value;U(f),(O==="overflow"||O==="both")&&!C&&(d.style.height="auto",k.current===0&&w(),d.scrollHeight>k.current+1&&(N(!0),p(!0),requestAnimationFrame(()=>p(!0)))),requestAnimationFrame(()=>p()),h?.(n)},[O,C,N,U,h,p,w]),be=e.useCallback(n=>{if(se){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?p():p(!0)},0),l?.(n)},[se,C,p,l,_]),$=e.useCallback(n=>{if(!R){i?.(n);return}if(n.key==="Enter"&&!n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey&&!n.nativeEvent.isComposing){if(H||V){i?.(n);return}if(G==="never"){i?.(n);return}const f=z.trim().length>0||m.attachments.length>0;if(G==="whenDirty"&&!f){i?.(n);return}n.preventDefault(),m.onSubmit?.({value:z,attachments:m.attachments}),m.clearOnSubmit&&(re||U(""),m.setAttachments([]))}i?.(n)},[R,H,V,G,z,re,U,m,i]),I=c?D.Slot:"textarea";return e.createElement("div",{className:(0,T.default)("rt-ChatbarField","rt-ChatbarTextarea",r)},e.createElement(I,{...S,ref:n=>{typeof o=="function"?o(n):o&&(o.current=n),M.current=n},className:"rt-ChatbarInput",value:z,onInput:A,onChange:Q,onFocus:fe,onPaste:be,onKeyDown:$,disabled:H,readOnly:V,rows:C?F:1,spellCheck:S.spellCheck??!0,autoCorrect:S.autoCorrect??"on",style:u}))});Te.displayName="Chatbar.Textarea";const Se=e.forwardRef((a,o)=>{const{children:r,asChild:u,style:c,className:b,...A}=a;return W().open?null:e.createElement(u?D.Slot:"div",{...A,ref:o,className:(0,T.default)("rt-ChatbarInlineStart",b),style:c},r)});Se.displayName="Chatbar.InlineStart";const Oe=e.forwardRef((a,o)=>{const{children:r,asChild:u,style:c,className:b,...A}=a;return W().open?null:e.createElement(u?D.Slot:"div",{...A,ref:o,className:(0,T.default)("rt-ChatbarInlineEnd",b),style:c},r)});Oe.displayName="Chatbar.InlineEnd";const Me=e.forwardRef((a,o)=>{const{asChild:r,forceMount:u,renderAttachment:c,className:b,style:A,...h}=a,l=W();return!(l.attachments.length>0)&&!u?null:e.createElement(r?D.Slot:"div",{...h,ref:o,className:(0,T.default)("rt-ChatbarAttachmentsRow",b),style:A,role:"list","aria-label":h["aria-label"]??"Attachments"},e.createElement($e.ScrollArea,{className:"rt-ChatbarScrollArea",scrollbars:"horizontal",size:"1"},e.createElement(oe.Flex,{align:"center",gap:"2",style:{minWidth:"fit-content"}},l.attachments.map(P=>e.createElement(me,{key:P.id,attachment:P,asChild:!!c},c?.(P))))))});Me.displayName="Chatbar.AttachmentsRow";const me=e.forwardRef((a,o)=>{const{attachment:r,asChild:u,className:c,style:b,children:A,...h}=a,l=W(),i=u?D.Slot:"div",R=!!r.url&&r.type.startsWith("image/");return e.createElement(i,{...h,ref:o,className:(0,T.default)("rt-ChatbarAttachment",c),style:b,role:"listitem","data-kind":R?"image":"file",title:r.name},A??e.createElement(oe.Flex,{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:r.url,alt:""}):e.createElement(pe.FileTextIcon,null)),!R&&e.createElement(oe.Flex,{direction:"column",gap:"0",style:{minWidth:0}},e.createElement(de.Text,{size:l.size,weight:"medium",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},r.name),e.createElement(de.Text,{size:"1",color:"gray"},Math.ceil(r.size/1024)," KB")),e.createElement(Pe.IconButton,{className:"rt-ChatbarAttachmentRemove","aria-label":`Remove ${r.name}`,size:"1",variant:"classic",highContrast:!0,color:"gray",onClick:()=>l.setAttachments(l.attachments.filter(P=>P.id!==r.id))},e.createElement(pe.CloseIcon,null))))});me.displayName="Chatbar.Attachment";const Le=e.forwardRef((a,o)=>{const{asChild:r,accept:u,multiple:c,className:b,style:A,...h}=a,l=W(),i=e.useRef(null),R=r?D.Slot:"button",P=u??l.accept,S=(Array.isArray(P)?P:P?.split(",")??[]).join(",");return e.useEffect(()=>{const m=()=>{l.fileDialogOpenRef.current=!1};return window.addEventListener("focus",m),()=>window.removeEventListener("focus",m)},[l.fileDialogOpenRef]),e.createElement(e.Fragment,null,e.createElement(R,{...h,ref:o,className:(0,T.default)("rt-ChatbarAttachTrigger",b),style:A,type:h.type??"button","aria-label":h["aria-label"]??"Add attachments",onPointerDown:m=>{l.fileDialogOpenRef.current=!0,h.onPointerDown?.(m)},onMouseDown:m=>{l.fileDialogOpenRef.current=!0,h.onMouseDown?.(m)},onClick:m=>{l.fileDialogOpenRef.current=!0,i.current&&i.current.click(),h.onClick?.(m)}}),e.createElement("input",{ref:i,type:"file",accept:S,multiple:c??l.multiple,tabIndex:-1,style:{display:"none"},onChange:m=>{const C=Array.from(m.currentTarget.files??[]);C.length>0&&l.appendFiles(C),l.fileDialogOpenRef.current=!1,m.currentTarget.value=""}}))});Le.displayName="Chatbar.AttachTrigger";const Fe=e.forwardRef((a,o)=>{const{asChild:r,children:u,className:c,style:b,...A}=a;return W().open?e.createElement(r?D.Slot:"div",{...A,ref:o,className:(0,T.default)("rt-ChatbarRow",c),style:b},e.createElement(oe.Flex,{align:"center",justify:"between",width:"100%"},u)):null});Fe.displayName="Chatbar.Row";const He=e.forwardRef((a,o)=>{const{className:r,style:u,...c}=a;return e.createElement("div",{...c,ref:o,className:(0,T.default)("rt-ChatbarRowStart",r),style:u})});He.displayName="Chatbar.RowStart";const Ne=e.forwardRef((a,o)=>{const{className:r,style:u,...c}=a;return e.createElement("div",{...c,ref:o,className:(0,T.default)("rt-ChatbarRowEnd",r),style:u})});Ne.displayName="Chatbar.RowEnd";const De=e.forwardRef((a,o)=>{const{asChild:r,clearOnSend:u=!0,disabled:c,children:b,className:A,style:h,...l}=a,i=W(),P=i.value.trim().length>0||i.attachments.length>0,S=i.sendMode==="always"||i.sendMode==="whenDirty"&&P;if(i.sendMode==="never")return null;const m=C=>{i.disabled||i.readOnly||(i.onSubmit?.({value:i.value,attachments:i.attachments}),u&&(i.isValueControlled||i.setValue(""),i.clearOnSubmit&&i.setAttachments([])),l.onClick?.(C))};return e.createElement(Pe.IconButton,{...l,ref:o,size:i.size,variant:i.open?"solid":"ghost",disabled:c||i.disabled||i.readOnly,className:(0,T.default)("rt-ChatbarSend",A),style:{opacity:S?1:0,pointerEvents:S?"auto":"none",...h},asChild:r,onClick:m,"aria-label":l["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"})))});De.displayName="Chatbar.Send";
|
|
2
2
|
//# sourceMappingURL=chatbar.js.map
|