@kushagradhawan/kookie-ui 0.1.70 → 0.1.72
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/README.md +4 -0
- package/components.css +63 -380
- package/dist/cjs/components/_internal/base-button.d.ts.map +1 -1
- package/dist/cjs/components/_internal/base-button.js +1 -1
- package/dist/cjs/components/_internal/base-button.js.map +3 -3
- package/dist/cjs/components/_internal/shell-bottom.d.ts +2 -21
- package/dist/cjs/components/_internal/shell-bottom.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-bottom.js +1 -1
- package/dist/cjs/components/_internal/shell-bottom.js.map +3 -3
- package/dist/cjs/components/_internal/shell-inspector.d.ts +10 -21
- package/dist/cjs/components/_internal/shell-inspector.d.ts.map +1 -1
- package/dist/cjs/components/_internal/shell-inspector.js +1 -1
- package/dist/cjs/components/_internal/shell-inspector.js.map +3 -3
- package/dist/cjs/components/_internal/shell-prop-helpers.d.ts +7 -0
- package/dist/cjs/components/_internal/shell-prop-helpers.d.ts.map +1 -0
- package/dist/cjs/components/_internal/shell-prop-helpers.js +2 -0
- package/dist/cjs/components/_internal/shell-prop-helpers.js.map +7 -0
- package/dist/cjs/components/_internal/shell-sidebar.d.ts +4 -21
- 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 +3 -3
- package/dist/cjs/components/button.d.ts.map +1 -1
- package/dist/cjs/components/button.js +1 -1
- package/dist/cjs/components/button.js.map +3 -3
- package/dist/cjs/components/chatbar.d.ts +11 -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/icon-button.d.ts.map +1 -1
- package/dist/cjs/components/icon-button.js +2 -2
- package/dist/cjs/components/icon-button.js.map +3 -3
- package/dist/cjs/components/schemas/shell.schema.d.ts +70 -70
- package/dist/cjs/components/shell.context.d.ts +1 -0
- package/dist/cjs/components/shell.context.d.ts.map +1 -1
- package/dist/cjs/components/shell.context.js.map +2 -2
- package/dist/cjs/components/shell.d.ts +6 -26
- package/dist/cjs/components/shell.d.ts.map +1 -1
- package/dist/cjs/components/shell.hooks.d.ts +19 -2
- package/dist/cjs/components/shell.hooks.d.ts.map +1 -1
- package/dist/cjs/components/shell.hooks.js +1 -1
- package/dist/cjs/components/shell.hooks.js.map +3 -3
- 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 +21 -0
- 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 +2 -2
- package/dist/cjs/components/toggle-button.d.ts.map +1 -1
- package/dist/cjs/components/toggle-button.js +1 -1
- package/dist/cjs/components/toggle-button.js.map +3 -3
- package/dist/cjs/components/toggle-icon-button.d.ts.map +1 -1
- package/dist/cjs/components/toggle-icon-button.js +1 -1
- package/dist/cjs/components/toggle-icon-button.js.map +3 -3
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +1 -1
- package/dist/cjs/hooks/index.js.map +3 -3
- package/dist/cjs/hooks/use-live-announcer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-live-announcer.js +2 -2
- package/dist/cjs/hooks/use-live-announcer.js.map +3 -3
- package/dist/cjs/hooks/use-toggle-state.d.ts +37 -0
- package/dist/cjs/hooks/use-toggle-state.d.ts.map +1 -0
- package/dist/cjs/hooks/use-toggle-state.js +2 -0
- package/dist/cjs/hooks/use-toggle-state.js.map +7 -0
- package/dist/cjs/hooks/use-tooltip-wrapper.d.ts +29 -0
- package/dist/cjs/hooks/use-tooltip-wrapper.d.ts.map +1 -0
- package/dist/cjs/hooks/use-tooltip-wrapper.js +2 -0
- package/dist/cjs/hooks/use-tooltip-wrapper.js.map +7 -0
- package/dist/esm/components/_internal/base-button.d.ts.map +1 -1
- package/dist/esm/components/_internal/base-button.js +1 -1
- package/dist/esm/components/_internal/base-button.js.map +3 -3
- package/dist/esm/components/_internal/shell-bottom.d.ts +2 -21
- package/dist/esm/components/_internal/shell-bottom.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-bottom.js +1 -1
- package/dist/esm/components/_internal/shell-bottom.js.map +3 -3
- package/dist/esm/components/_internal/shell-inspector.d.ts +10 -21
- package/dist/esm/components/_internal/shell-inspector.d.ts.map +1 -1
- package/dist/esm/components/_internal/shell-inspector.js +1 -1
- package/dist/esm/components/_internal/shell-inspector.js.map +3 -3
- package/dist/esm/components/_internal/shell-prop-helpers.d.ts +7 -0
- package/dist/esm/components/_internal/shell-prop-helpers.d.ts.map +1 -0
- package/dist/esm/components/_internal/shell-prop-helpers.js +2 -0
- package/dist/esm/components/_internal/shell-prop-helpers.js.map +7 -0
- package/dist/esm/components/_internal/shell-sidebar.d.ts +4 -21
- 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 +3 -3
- package/dist/esm/components/button.d.ts.map +1 -1
- package/dist/esm/components/button.js +1 -1
- package/dist/esm/components/button.js.map +3 -3
- package/dist/esm/components/chatbar.d.ts +11 -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/icon-button.d.ts.map +1 -1
- package/dist/esm/components/icon-button.js +2 -2
- package/dist/esm/components/icon-button.js.map +3 -3
- package/dist/esm/components/schemas/shell.schema.d.ts +70 -70
- package/dist/esm/components/shell.context.d.ts +1 -0
- package/dist/esm/components/shell.context.d.ts.map +1 -1
- package/dist/esm/components/shell.context.js.map +2 -2
- package/dist/esm/components/shell.d.ts +6 -26
- package/dist/esm/components/shell.d.ts.map +1 -1
- package/dist/esm/components/shell.hooks.d.ts +19 -2
- package/dist/esm/components/shell.hooks.d.ts.map +1 -1
- 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 +21 -0
- package/dist/esm/components/shell.types.d.ts.map +1 -1
- package/dist/esm/components/shell.types.js.map +2 -2
- package/dist/esm/components/toggle-button.d.ts.map +1 -1
- package/dist/esm/components/toggle-button.js +1 -1
- package/dist/esm/components/toggle-button.js.map +3 -3
- package/dist/esm/components/toggle-icon-button.d.ts.map +1 -1
- package/dist/esm/components/toggle-icon-button.js +1 -1
- package/dist/esm/components/toggle-icon-button.js.map +3 -3
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/hooks/index.js.map +3 -3
- package/dist/esm/hooks/use-live-announcer.d.ts.map +1 -1
- package/dist/esm/hooks/use-live-announcer.js +2 -2
- package/dist/esm/hooks/use-live-announcer.js.map +3 -3
- package/dist/esm/hooks/use-toggle-state.d.ts +37 -0
- package/dist/esm/hooks/use-toggle-state.d.ts.map +1 -0
- package/dist/esm/hooks/use-toggle-state.js +2 -0
- package/dist/esm/hooks/use-toggle-state.js.map +7 -0
- package/dist/esm/hooks/use-tooltip-wrapper.d.ts +29 -0
- package/dist/esm/hooks/use-tooltip-wrapper.d.ts.map +1 -0
- package/dist/esm/hooks/use-tooltip-wrapper.js +2 -0
- package/dist/esm/hooks/use-tooltip-wrapper.js.map +7 -0
- package/package.json +4 -4
- 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/base-button.css +136 -614
- package/src/components/_internal/base-button.tsx +15 -13
- package/src/components/_internal/shell-bottom.tsx +305 -321
- package/src/components/_internal/shell-inspector.tsx +310 -320
- package/src/components/_internal/shell-prop-helpers.ts +53 -0
- package/src/components/_internal/shell-sidebar.tsx +370 -384
- package/src/components/button.tsx +13 -42
- package/src/components/chatbar.tsx +7 -3
- package/src/components/icon-button.tsx +20 -44
- package/src/components/image.css +10 -8
- package/src/components/shell.context.tsx +1 -0
- package/src/components/shell.hooks.ts +67 -2
- package/src/components/shell.tsx +199 -209
- package/src/components/shell.types.ts +23 -0
- package/src/components/toggle-button.tsx +30 -59
- package/src/components/toggle-icon-button.tsx +29 -51
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-live-announcer.ts +34 -7
- package/src/hooks/use-toggle-state.ts +72 -0
- package/src/hooks/use-tooltip-wrapper.ts +28 -0
- package/src/styles/tokens/color.css +11 -1
- package/styles.css +70 -381
- package/tokens/base.css +7 -1
- package/tokens.css +7 -1
|
@@ -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, 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 onSizeChange = (props as any).onSizeChange;\n const sizeUpdate = (props as any).sizeUpdate;\n const sizeUpdateMs = (props as any).sizeUpdateMs;\n const emitSizeChange = React.useMemo(() => {\n const cb = onSizeChange as undefined | ((s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => void);\n const strategy = sizeUpdate as undefined | 'throttle' | 'debounce';\n const ms = 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 }, [onSizeChange, sizeUpdate, 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 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 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 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 }, [shell, resolvedState]);\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 const controlledSize = (props as any).size;\n React.useEffect(() => {\n if (!localRef.current) return;\n if (typeof controlledSize === 'undefined') return;\n const px = normalizeToPx(controlledSize);\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 }, [controlledSize, minSize, maxSize, normalizeToPx, emitSizeChange]);\n\n if (isOverlay) {\n const open = shell.sidebarMode !== 'collapsed';\n return (\n <Sheet.Root open={open} onOpenChange={(o) => shell.setSidebarMode(o ? 'expanded' : 'collapsed')}>\n <Sheet.Content\n side=\"start\"\n style={{ padding: 0 }}\n width={{\n initial: `${open ? (shell.sidebarMode === 'thin' ? thinSize : expandedSize) : lastOverlayWidthRef.current}px`,\n }}\n >\n <VisuallyHidden>\n <Sheet.Title>Navigation</Sheet.Title>\n </VisuallyHidden>\n {contentChildren}\n </Sheet.Content>\n </Sheet.Root>\n );\n }\n return (\n <div\n {...domProps}\n ref={setRef}\n className={classNames('rt-ShellSidebar', className)}\n data-mode={shell.sidebarMode}\n data-peek={shell.peekTarget === 'sidebar' || undefined}\n data-presentation={shell.currentBreakpointReady ? resolvedPresentation : undefined}\n data-open={(shell.currentBreakpointReady && isStacked && isContentVisible) || undefined}\n style={{\n ...style,\n ['--sidebar-size' as any]: `${expandedSize}px`,\n ['--sidebar-thin-size' as any]: `${thinSize}px`,\n ['--sidebar-min-size' as any]: `${minSize}px`,\n ['--sidebar-max-size' as any]: `${maxSize}px`,\n ...(shell.peekTarget === 'sidebar' && shell.sidebarMode === 'collapsed' && !isOverlay\n ? (() => {\n const strategy: 'both' | 'single' = toggleModes ?? 'both';\n const current = shell.sidebarMode as SidebarMode;\n let next: SidebarMode;\n if (strategy === 'both') {\n next = current === 'collapsed' ? 'thin' : current === 'thin' ? 'expanded' : 'collapsed';\n } else {\n const target = resolveDefaultSidebarMode();\n next = current === 'collapsed' ? target : 'collapsed';\n }\n if (next === 'thin') {\n return {\n ['--peek-sidebar-width' as any]: `${thinSize}px`,\n } as React.CSSProperties;\n }\n return {\n ['--peek-sidebar-width' as any]: `var(--sidebar-size, ${expandedSize}px)`,\n } as React.CSSProperties;\n })()\n : {}),\n }}\n >\n <div className=\"rt-ShellSidebarContent\" data-visible={isContentVisible || undefined}>\n {contentChildren}\n </div>\n {handleEl}\n </div>\n );\n },\n) as SidebarComponent;\n\nSidebar.displayName = 'Shell.Sidebar';\nSidebar.Handle = SidebarHandle;\n"],
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,OAAgB,aACvB,UAAYC,MAAW,cACvB,OAAS,kBAAAC,OAAsB,wBAC/B,OAAS,YAAAC,MAAgB,sBACzB,OAAS,6BAAAC,GAA2B,
|
|
6
|
-
"names": ["React", "classNames", "Sheet", "VisuallyHidden", "useShell", "useResponsivePresentation", "
|
|
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, useResponsiveInitialState } from '../shell.hooks.js';\nimport { PaneResizeContext } from './shell-resize.js';\nimport { extractPaneDomProps } from './shell-prop-helpers.js';\nimport { SidebarHandle, PaneHandle } from './shell-handles.js';\nimport type { Breakpoint, PaneMode, PaneSizePersistence, ResponsivePresentation, SidebarMode, Responsive, PaneBaseProps } from '../shell.types.js';\nimport { _BREAKPOINTS } from '../shell.types.js';\n\ntype SidebarPaneProps = PaneBaseProps & {\n mode?: PaneMode;\n defaultMode?: any;\n onModeChange?: (mode: PaneMode | SidebarMode) => void;\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<SidebarPaneProps, '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\nconst SIDEBAR_DOM_PROP_KEYS = [\n 'className',\n 'children',\n 'state',\n 'defaultState',\n 'onStateChange',\n 'thinSize',\n 'toggleModes',\n 'size',\n 'defaultSize',\n 'onSizeChange',\n 'sizeUpdate',\n 'sizeUpdateMs',\n 'style',\n] as const satisfies readonly (keyof SidebarPublicProps)[];\n\nexport const Sidebar = React.forwardRef<HTMLDivElement, SidebarPublicProps>((initialProps, ref) => {\n const {\n className,\n presentation = { initial: 'overlay', md: 'fixed' },\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 state,\n defaultState,\n onStateChange,\n size,\n defaultSize,\n onSizeChange,\n sizeUpdate,\n sizeUpdateMs = 50,\n } = initialProps;\n const sidebarDomProps = extractPaneDomProps(initialProps, SIDEBAR_DOM_PROP_KEYS);\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 = onSizeChange as undefined | ((s: number, meta: { reason: 'init' | 'resize' | 'controlled' }) => void);\n const strategy = sizeUpdate as undefined | 'throttle' | 'debounce';\n const ms = 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 }, [onSizeChange, sizeUpdate, 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 console.error('Shell.Sidebar: Do not pass both `state` and `defaultState`. Choose one.');\n }\n if (typeof size !== 'undefined' && typeof defaultSize !== 'undefined') {\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 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 stateIsResponsive = typeof state === 'object' && state !== null;\n const { resolvedDefault: resolvedSidebarDefault } = useResponsiveInitialState<SidebarMode>({\n controlledValue: state,\n defaultValue: defaultState,\n currentValue: shell.sidebarMode as SidebarMode,\n setValue: shell.setSidebarMode,\n breakpointReady: shell.currentBreakpointReady,\n controlledIsResponsive: stateIsResponsive,\n onResponsiveChange: (next) => onStateChange?.(next, { reason: 'responsive' }),\n onInit: (initial) => onStateChange?.(initial, { reason: 'init' }),\n });\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 try {\n const v = window.localStorage.getItem(key);\n return v ? Number(v) : undefined;\n } catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn('Shell.Sidebar: failed to load persisted size', err);\n }\n return undefined;\n }\n },\n save: (size: number) => {\n if (typeof window === 'undefined') return;\n try {\n window.localStorage.setItem(key, String(size));\n } catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn('Shell.Sidebar: failed to save persisted size', err);\n }\n }\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 = resolvedSidebarDefault ?? (typeof defaultState === 'string' ? defaultState : undefined) ?? 'expanded';\n return resolved === 'thin' || resolved === 'expanded' ? resolved : 'expanded';\n }, [resolvedSidebarDefault, 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 // 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 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 const controlledSize = size;\n React.useEffect(() => {\n if (!localRef.current) return;\n if (typeof controlledSize === 'undefined') return;\n const px = normalizeToPx(controlledSize);\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 }, [controlledSize, 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 {...sidebarDomProps}\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}) as SidebarComponent;\n\nSidebar.displayName = 'Shell.Sidebar';\nSidebar.Handle = SidebarHandle;\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,OAAgB,aACvB,UAAYC,MAAW,cACvB,OAAS,kBAAAC,OAAsB,wBAC/B,OAAS,YAAAC,MAAgB,sBACzB,OAAS,6BAAAC,GAA2B,6BAAAC,OAAiC,oBACrE,OAAS,qBAAAC,OAAyB,oBAClC,OAAS,uBAAAC,OAA2B,0BACpC,OAAS,iBAAAC,EAAe,cAAAC,OAAkB,qBAE1C,MAA6B,oBAyB7B,MAAMC,GAAwB,CAC5B,YACA,WACA,QACA,eACA,gBACA,WACA,cACA,OACA,cACA,eACA,aACA,eACA,OACF,EAEaC,EAAUZ,EAAM,WAA+C,CAACa,EAAcC,IAAQ,CACjG,KAAM,CACJ,UAAAC,EACA,aAAAC,EAAe,CAAE,QAAS,UAAW,GAAI,OAAQ,EACjD,aAAAC,EAAe,IACf,QAAAC,EAAU,IACV,QAAAC,EAAU,IACV,UAAAC,EAAY,GACZ,YAAAC,EAAc,GACd,SAAAC,EACA,WAAAC,EACA,SAAAC,EACA,cAAAC,GACA,YAAAC,GACA,WAAAC,GACA,cAAAC,GACA,kBAAAC,GAC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,CAAS,EAClD,YAAW8B,EAAM,YACjB,YAAWA,EAAM,aAAe,WAAa,OAC7C,oBAAmBA,EAAM,uBAAyBC,EAAuB,OACzE,YAAYD,EAAM,wBAA0BG,IAAayB,GAAqB,OAC9E,MAAO,CACL,GAAGxC,GACF,iBAA0B,GAAGhB,CAAY,KACzC,sBAA+B,GAAGiB,CAAQ,KAC1C,qBAA8B,GAAGhB,CAAO,KACxC,qBAA8B,GAAGC,CAAO,KACzC,GAAI0B,EAAM,aAAe,WAAaA,EAAM,cAAgB,aAAe,CAACE,GACvE,IAAM,CACL,MAAMW,EAA8BvB,GAAe,OAC7CgD,EAAUtC,EAAM,YACtB,IAAIyB,EACJ,GAAIZ,IAAa,OACfY,EAAOa,IAAY,YAAc,OAASA,IAAY,OAAS,WAAa,gBACvE,CACL,MAAMC,EAASJ,EAA0B,EACzCV,EAAOa,IAAY,YAAcC,EAAS,WAC5C,CACA,OAAId,IAAS,OACJ,CACJ,uBAAgC,GAAGpC,CAAQ,IAC9C,EAEK,CACJ,uBAAgC,uBAAuBjB,CAAY,KACtE,CACF,GAAG,EACH,CAAC,CACP,GAEAjB,EAAA,cAAC,OAAI,UAAU,yBAAyB,eAAcyE,GAAoB,QACvElB,CACH,EACCiC,EACH,CAEJ,CAAC,EAED5E,EAAQ,YAAc,gBACtBA,EAAQ,OAASH",
|
|
6
|
+
"names": ["React", "classNames", "Sheet", "VisuallyHidden", "useShell", "useResponsivePresentation", "useResponsiveInitialState", "PaneResizeContext", "extractPaneDomProps", "SidebarHandle", "PaneHandle", "SIDEBAR_DOM_PROP_KEYS", "Sidebar", "initialProps", "ref", "className", "presentation", "expandedSize", "minSize", "maxSize", "resizable", "collapsible", "onExpand", "onCollapse", "onResize", "onResizeStart", "onResizeEnd", "snapPoints", "snapTolerance", "collapseThreshold", "paneId", "persistence", "children", "style", "thinSize", "toggleModes", "state", "defaultState", "onStateChange", "size", "defaultSize", "onSizeChange", "sizeUpdate", "sizeUpdateMs", "sidebarDomProps", "shell", "resolvedPresentation", "isOverlay", "isStacked", "localRef", "setRef", "node", "childArray", "handleChildren", "el", "contentChildren", "emitSizeChange", "cb", "strategy", "ms", "t", "s", "meta", "last", "now", "sidebarId", "wasControlledRef", "isControlled", "stateIsResponsive", "resolvedSidebarDefault", "next", "initial", "lastNotifyModeRef", "isContentVisible", "persistenceAdapter", "key", "v", "mounted", "loaded", "shellForToggle", "resolveDefaultSidebarMode", "resolved", "compute", "current", "target", "cur", "lastOverlayWidthRef", "lastOverlayModeRef", "handleEl", "client", "startClient", "startSize", "isRtl", "delta", "i", "normalizeToPx", "value", "str", "rem", "pct", "base", "n", "px", "clamped", "controlledSize", "open", "o"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,UAAU,yBAAyB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,UAAU,oBAAoB;IA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AC,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC;AAElE;;;GAGG;AACH,KAAK,eAAe,GAAG,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;CAAE,KAAK,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;AAElK;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,QAAA,MAAM,MAAM,EA6DP,eAAe,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAIhD,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as i from"react";import
|
|
1
|
+
import*as i from"react";import R from"classnames";import{BaseButton as C}from"./_internal/base-button.js";import{Tooltip as h}from"./tooltip.js";import{useTooltipWrapper as w}from"../hooks/use-tooltip-wrapper.js";const d=i.forwardRef(({className:c,style:s,tooltip:a,tooltipSide:f="top",tooltipAlign:b="center",tooltipDelayDuration:m,tooltipDisableHoverableContent:B,overrideStyles:o,...y},g)=>{const{tooltipId:v,hasTooltip:O,accessibilityProps:S}=w(a),u=i.useMemo(()=>{if(!o)return;const p={},e=(n,t)=>{t!==void 0&&(p[n]=t)},r=(n,t)=>{t&&(e(`--button-override-${n}color`,t.color),e(`--button-override-${n}background`,t.background),e(`--button-override-${n}background-color`,t.backgroundColor),e(`--button-override-${n}box-shadow`,t.boxShadow),e(`--button-override-${n}filter`,t.filter),e(`--button-override-${n}outline`,t.outline),e(`--button-override-${n}outline-offset`,t.outlineOffset),e(`--button-override-${n}opacity`,t.opacity))};return r("",o.normal),r("hover-",o.hover),r("active-",o.active),r("pressed-",o.pressed),r("open-",o.open),r("disabled-",o.disabled),o.focus&&(e("--button-override-focus-outline",o.focus.outline),e("--button-override-focus-outline-offset",o.focus.outlineOffset)),p},[o]),P=i.useMemo(()=>u?{...u,...s}:s,[u,s]),l=i.createElement(C,{...y,...S,ref:g,className:R("rt-Button",c),style:P});return O?i.createElement(h,{content:a,side:f,align:b,delayDuration:m,disableHoverableContent:B,id:v},l):l});d.displayName="Button";export{d as Button};
|
|
2
2
|
//# sourceMappingURL=button.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/button.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\n\nimport { BaseButton } from './_internal/base-button.js';\nimport { Tooltip } from './tooltip.js';\nimport type { BaseButtonProps } from './_internal/base-button.js';\n\n/**\n * Styles that can be overridden for a particular interaction state\n */\ninterface ButtonOverrideStateStyles {\n color?: string;\n background?: string;\n backgroundColor?: string;\n boxShadow?: string;\n filter?: string;\n outline?: string;\n outlineOffset?: string;\n opacity?: string | number;\n}\n\n/**\n * Full set of override styles keyed by interaction state\n */\ninterface ButtonOverrideStyles {\n /** Default/idle state styles */\n normal?: ButtonOverrideStateStyles;\n /** Hover state styles */\n hover?: ButtonOverrideStateStyles;\n /** Active (mouse down) state styles */\n active?: ButtonOverrideStateStyles;\n /** Toggle pressed state styles (data-state=\"on\") */\n pressed?: ButtonOverrideStateStyles;\n /** Open state styles (e.g., when used as a trigger) */\n open?: ButtonOverrideStateStyles;\n /** Disabled state styles */\n disabled?: ButtonOverrideStateStyles;\n /** Focus-visible outline styles */\n focus?: Pick<ButtonOverrideStateStyles, 'outline' | 'outlineOffset'>;\n}\n\ntype ButtonElement = React.ElementRef<typeof BaseButton>;\n\n/**\n * Tooltip configuration props that can be passed to Button\n * These props are forwarded to the underlying Tooltip component\n */\ninterface ButtonTooltipProps {\n /** Content to display in the tooltip on hover/focus */\n tooltip?: React.ReactNode;\n /** Side of the button where the tooltip should appear */\n tooltipSide?: 'top' | 'right' | 'bottom' | 'left';\n /** Alignment of the tooltip relative to the button */\n tooltipAlign?: 'start' | 'center' | 'end';\n /** Delay before showing the tooltip (in milliseconds) */\n tooltipDelayDuration?: number;\n /** Whether to disable hoverable content behavior */\n tooltipDisableHoverableContent?: boolean;\n}\n\n/**\n * Core Button props excluding the 'as' prop for polymorphic behavior\n * Combines BaseButton props with tooltip functionality\n */\ntype ButtonOwnProps = Omit<BaseButtonProps, 'as'> &\n ButtonTooltipProps & {\n /**\n * When using variant=\"override\", provide token-based styles per state.\n * We propagate these into CSS variables consumed by the override variant.\n */\n overrideStyles?: ButtonOverrideStyles;\n };\n\n/**\n * Polymorphic Button props that support rendering as different HTML elements\n * @template C - The element type to render as (defaults to 'button')\n */\ntype ButtonProps<C extends React.ElementType = 'button'> = ButtonOwnProps & {\n /** Element type to render as (e.g., 'a', 'span', etc.) */\n as?: C;\n} & Omit<React.ComponentPropsWithoutRef<C>, keyof ButtonOwnProps>;\n\n/**\n * Button component type that supports polymorphic rendering\n * @template C - The element type to render as\n */\ntype ButtonComponent = <C extends React.ElementType = 'button'>(
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aAEvB,OAAS,cAAAC,MAAkB,6BAC3B,OAAS,WAAAC,MAAe,
|
|
6
|
-
"names": ["React", "classNames", "BaseButton", "Tooltip", "Button", "className", "tooltip", "tooltipSide", "tooltipAlign", "tooltipDelayDuration", "tooltipDisableHoverableContent", "overrideStyles", "props", "forwardedRef", "tooltipId", "hasTooltip", "tooltipAccessibilityProps", "overrideVars", "vars", "setVar", "key", "value", "apply", "prefix", "s", "button"]
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nimport classNames from 'classnames';\n\nimport { BaseButton } from './_internal/base-button.js';\nimport { Tooltip } from './tooltip.js';\nimport { useTooltipWrapper } from '../hooks/use-tooltip-wrapper.js';\nimport type { BaseButtonProps } from './_internal/base-button.js';\n\n/**\n * Styles that can be overridden for a particular interaction state\n */\ninterface ButtonOverrideStateStyles {\n color?: string;\n background?: string;\n backgroundColor?: string;\n boxShadow?: string;\n filter?: string;\n outline?: string;\n outlineOffset?: string;\n opacity?: string | number;\n}\n\n/**\n * Full set of override styles keyed by interaction state\n */\ninterface ButtonOverrideStyles {\n /** Default/idle state styles */\n normal?: ButtonOverrideStateStyles;\n /** Hover state styles */\n hover?: ButtonOverrideStateStyles;\n /** Active (mouse down) state styles */\n active?: ButtonOverrideStateStyles;\n /** Toggle pressed state styles (data-state=\"on\") */\n pressed?: ButtonOverrideStateStyles;\n /** Open state styles (e.g., when used as a trigger) */\n open?: ButtonOverrideStateStyles;\n /** Disabled state styles */\n disabled?: ButtonOverrideStateStyles;\n /** Focus-visible outline styles */\n focus?: Pick<ButtonOverrideStateStyles, 'outline' | 'outlineOffset'>;\n}\n\ntype ButtonElement = React.ElementRef<typeof BaseButton>;\n\n/**\n * Tooltip configuration props that can be passed to Button\n * These props are forwarded to the underlying Tooltip component\n */\ninterface ButtonTooltipProps {\n /** Content to display in the tooltip on hover/focus */\n tooltip?: React.ReactNode;\n /** Side of the button where the tooltip should appear */\n tooltipSide?: 'top' | 'right' | 'bottom' | 'left';\n /** Alignment of the tooltip relative to the button */\n tooltipAlign?: 'start' | 'center' | 'end';\n /** Delay before showing the tooltip (in milliseconds) */\n tooltipDelayDuration?: number;\n /** Whether to disable hoverable content behavior */\n tooltipDisableHoverableContent?: boolean;\n}\n\n/**\n * Core Button props excluding the 'as' prop for polymorphic behavior\n * Combines BaseButton props with tooltip functionality\n */\ntype ButtonOwnProps = Omit<BaseButtonProps, 'as'> &\n ButtonTooltipProps & {\n /**\n * When using variant=\"override\", provide token-based styles per state.\n * We propagate these into CSS variables consumed by the override variant.\n */\n overrideStyles?: ButtonOverrideStyles;\n };\n\n/**\n * Polymorphic Button props that support rendering as different HTML elements\n * @template C - The element type to render as (defaults to 'button')\n */\ntype ButtonProps<C extends React.ElementType = 'button'> = ButtonOwnProps & {\n /** Element type to render as (e.g., 'a', 'span', etc.) */\n as?: C;\n} & Omit<React.ComponentPropsWithoutRef<C>, keyof ButtonOwnProps>;\n\n/**\n * Button component type that supports polymorphic rendering\n * @template C - The element type to render as\n */\ntype ButtonComponent = <C extends React.ElementType = 'button'>(props: ButtonProps<C> & { ref?: React.ForwardedRef<ButtonElement> }) => React.ReactElement | null;\n\n/**\n * Button component for triggering actions throughout your interface\n *\n * The Button component is the primary interactive element in the Kookie User Interface.\n * It provides six visual variants, four sizes, comprehensive color options, and built-in\n * tooltip support. The component automatically handles icon sizing, supports responsive\n * layouts, and provides accessibility compliance out of the box.\n *\n * @example\n * ```tsx\n * // Basic button\n * <Button>Click me</Button>\n *\n * // Button with variant and size\n * <Button variant=\"solid\" size=\"3\">Primary Action</Button>\n *\n * // Button with tooltip\n * <Button tooltip=\"Save your progress\">Save</Button>\n *\n * // Polymorphic button as link\n * <Button as=\"a\" href=\"/dashboard\">Go to Dashboard</Button>\n * ```\n */\nconst Button = React.forwardRef(\n (\n { className, style, tooltip, tooltipSide = 'top', tooltipAlign = 'center', tooltipDelayDuration, tooltipDisableHoverableContent, overrideStyles, ...props }: ButtonProps,\n forwardedRef: React.ForwardedRef<ButtonElement>,\n ) => {\n // Use shared tooltip wrapper hook for accessibility props\n const { tooltipId, hasTooltip, accessibilityProps: tooltipAccessibilityProps } = useTooltipWrapper(tooltip);\n\n // Create the base button element with tooltip accessibility props\n // Map overrideStyles to CSS variables consumed by the override variant rules\n const overrideVars = React.useMemo(() => {\n if (!overrideStyles) return undefined;\n const vars: Record<string, string | number> = {};\n const setVar = (key: string, value: string | number | undefined) => {\n if (value !== undefined) vars[key] = value;\n };\n const apply = (prefix: string, s?: ButtonOverrideStateStyles) => {\n if (!s) return;\n setVar(`--button-override-${prefix}color`, s.color);\n setVar(`--button-override-${prefix}background`, s.background);\n setVar(`--button-override-${prefix}background-color`, s.backgroundColor);\n setVar(`--button-override-${prefix}box-shadow`, s.boxShadow);\n setVar(`--button-override-${prefix}filter`, s.filter);\n setVar(`--button-override-${prefix}outline`, s.outline);\n setVar(`--button-override-${prefix}outline-offset`, s.outlineOffset);\n setVar(`--button-override-${prefix}opacity`, s.opacity);\n };\n\n apply('', overrideStyles.normal);\n apply('hover-', overrideStyles.hover);\n apply('active-', overrideStyles.active);\n apply('pressed-', overrideStyles.pressed);\n apply('open-', overrideStyles.open);\n apply('disabled-', overrideStyles.disabled);\n\n if (overrideStyles.focus) {\n setVar('--button-override-focus-outline', overrideStyles.focus.outline);\n setVar('--button-override-focus-outline-offset', overrideStyles.focus.outlineOffset);\n }\n\n return vars as React.CSSProperties;\n }, [overrideStyles]);\n\n // Combine override styles with user-provided styles\n const combinedStyle = React.useMemo(() => (overrideVars ? { ...overrideVars, ...style } : style), [overrideVars, style]);\n\n const button = <BaseButton {...props} {...tooltipAccessibilityProps} ref={forwardedRef} className={classNames('rt-Button', className)} style={combinedStyle} />;\n\n // If no tooltip is provided, return the button as-is for better performance\n if (!hasTooltip) {\n return button;\n }\n\n // Wrap with Tooltip when tooltip content is provided\n // This creates a compound component that handles both button and tooltip functionality\n return (\n <Tooltip content={tooltip} side={tooltipSide} align={tooltipAlign} delayDuration={tooltipDelayDuration} disableHoverableContent={tooltipDisableHoverableContent} id={tooltipId}>\n {button}\n </Tooltip>\n );\n },\n) as ButtonComponent & { displayName?: string };\n\nButton.displayName = 'Button';\n\nexport { Button };\nexport type { ButtonProps, ButtonOverrideStyles, ButtonOverrideStateStyles };\n"],
|
|
5
|
+
"mappings": "AAAA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aAEvB,OAAS,cAAAC,MAAkB,6BAC3B,OAAS,WAAAC,MAAe,eACxB,OAAS,qBAAAC,MAAyB,kCA2GlC,MAAMC,EAASL,EAAM,WACnB,CACE,CAAE,UAAAM,EAAW,MAAAC,EAAO,QAAAC,EAAS,YAAAC,EAAc,MAAO,aAAAC,EAAe,SAAU,qBAAAC,EAAsB,+BAAAC,EAAgC,eAAAC,EAAgB,GAAGC,CAAM,EA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KH,EAAc,UAAWd,EAAW,YAAaK,CAAS,EAAG,MAAOqB,EAAe,EAG7J,OAAKV,EAOHjB,EAAA,cAACG,EAAA,CAAQ,QAASK,EAAS,KAAMC,EAAa,MAAOC,EAAc,cAAeC,EAAsB,wBAAyBC,EAAgC,GAAII,GAClKY,CACH,EAROA,CAUX,CACF,EAEAvB,EAAO,YAAc",
|
|
6
|
+
"names": ["React", "classNames", "BaseButton", "Tooltip", "useTooltipWrapper", "Button", "className", "style", "tooltip", "tooltipSide", "tooltipAlign", "tooltipDelayDuration", "tooltipDisableHoverableContent", "overrideStyles", "props", "forwardedRef", "tooltipId", "hasTooltip", "tooltipAccessibilityProps", "overrideVars", "vars", "setVar", "key", "value", "apply", "prefix", "s", "combinedStyle", "button"]
|
|
7
7
|
}
|
|
@@ -214,11 +214,20 @@ interface RowProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children
|
|
|
214
214
|
declare const Row: React.ForwardRefExoticComponent<RowProps & React.RefAttributes<HTMLDivElement>>;
|
|
215
215
|
declare const RowStart: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
216
216
|
declare const RowEnd: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
217
|
-
type SendProps = IconButtonProps & {
|
|
217
|
+
type SendProps = Omit<IconButtonProps, 'aria-label' | 'aria-labelledby'> & {
|
|
218
|
+
/** Optional override for accessible name. Defaults to "Send". */
|
|
219
|
+
'aria-label'?: string;
|
|
220
|
+
'aria-labelledby'?: string;
|
|
218
221
|
asChild?: boolean;
|
|
219
222
|
clearOnSend?: boolean;
|
|
220
223
|
};
|
|
221
|
-
declare const Send: React.ForwardRefExoticComponent<
|
|
224
|
+
declare const Send: React.ForwardRefExoticComponent<Omit<IconButtonProps, "aria-label" | "aria-labelledby"> & {
|
|
225
|
+
/** Optional override for accessible name. Defaults to "Send". */
|
|
226
|
+
'aria-label'?: string;
|
|
227
|
+
'aria-labelledby'?: string;
|
|
228
|
+
asChild?: boolean;
|
|
229
|
+
clearOnSend?: boolean;
|
|
230
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
222
231
|
export { Root, Textarea, InlineStart, InlineEnd, AttachmentsRow, Attachment, AttachTrigger, Row, RowStart, RowEnd, Send };
|
|
223
232
|
export type { RootProps as ChatbarRootProps, TextareaProps as ChatbarTextareaProps, RowProps as ChatbarRowProps, SendProps as ChatbarSendProps, ChatbarAttachment };
|
|
224
233
|
//# sourceMappingURL=chatbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbar.d.ts","sourceRoot":"","sources":["../../../src/components/chatbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAKzF,KAAK,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AACvD,KAAK,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAGjD,4CAA4C;AAC5C,KAAK,gBAAgB,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAChE;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,C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con as _e,FileTextIcon as Je}from"./icons.js";import{Flex as ce}from"./flex.js";import{ScrollArea as Qe}from"./scroll-area.js";import{Slot as B}from"./slot.js";import{Box as Xe}from"./box.js";import{Text as ve}from"./text.js";import{useDropzone as Ze}from"react-dropzone";const xe=typeof window<"u"?e.useLayoutEffect:e.useEffect,Me=e.createContext(null),W=()=>{const l=e.useContext(Me);if(!l)throw new Error("Chatbar context not found. Wrap parts in <Chatbar.Root>.");return l},Le=e.forwardRef((l,s)=>{const{className:r,style:p,children:m,value:C,defaultValue:R="",onValueChange:h,open:i,defaultOpen:w=!1,onOpenChange:g,expandOn:o="both",minLines:L=1,maxLines:u=6,sendMode:f="whenDirty",disabled:S,readOnly:V,onSubmit:O,size:H="2",variant:U,color:N,radius:K,panelBackground:M,material:D,width:oe,maxWidth:G,asChild:re,attachments:_,defaultAttachments:ue=[],onAttachmentsChange:$,accept:J,multiple:z=!0,maxAttachments:P,maxFileSize:d,paste:de=!0,pasteAccept:Q,clearOnSubmit:me=!0,onAttachmentReject:q,dropzone:k=!0,apiRef:n,...c}=l,b=D||M,x=C!=null,[F,pe]=e.useState(R),X=x?C:F,I=i!=null,[Z,Y]=e.useState(w),ee=I?i:Z,he=e.useRef(null),se=e.useRef(null),fe=e.useRef(!1),te="attachments"in l,[Re,we]=e.useState(ue),j=e.useMemo(()=>te?_??[]:Re,[te,_,Re]),ie=e.useRef(new Set),be=t=>Array.isArray(t)?t:typeof t=="string"?t.split(",").map(a=>a.trim()):[],ne=be(J),Pe=be(Q).length>0?be(Q):ne,Ce=(t,a)=>{if(a.length===0)return!0;const y=t.type.toLowerCase(),E=t.name.toLowerCase();for(const v of a){const A=v.toLowerCase();if(A.includes("/")){const[le,ye]=A.split("/"),[ae,Ge]=y.split("/");if(le==="*"||le===ae&&(ye==="*"||ye===Ge))return!0}else if(A.startsWith(".")&&E.endsWith(A))return!0}return!1},We=t=>{const a=[],y=[],E=typeof P=="number"?Math.max(P-j.length,0):1/0;for(const v of t){if(a.length>=E){y.push({file:v,reason:"count"});continue}if(typeof d=="number"&&v.size>d){y.push({file:v,reason:"size"});continue}if(!Ce(v,ne)){y.push({file:v,reason:"type"});continue}const A=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,le=/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(v.name),ae=(v.type||"").toLowerCase().startsWith("image/")||le?URL.createObjectURL(v):void 0;ae&&ie.current.add(ae),a.push({id:A,name:v.name,size:v.size,type:v.type,file:v,url:ae,status:"idle"})}return{accepted:a,rejected:y}},ge=t=>{const{accepted:a,rejected:y}=We(t);if(a.length>0){const E=j.concat(a);te||we(E),$?.(E),I||Y(!0),g?.(!0)}y.length>0&&q?.(y)},Ve=t=>{const a=A=>Pe.length===0?Ce(A,ne):Ce(A,Pe),y=[],E=[],v=typeof P=="number"?Math.max(P-j.length,0):1/0;for(const A of t){if(y.length>=v){E.push({file:A,reason:"count"});continue}if(typeof d=="number"&&A.size>d){E.push({file:A,reason:"size"});continue}if(!a(A)){E.push({file:A,reason:"type"});continue}y.push(A)}y.length>0&&ge(y),E.length>0&&q?.(E)};e.useEffect(()=>{const t=new Set(j.map(a=>a.url).filter(Boolean));for(const a of Array.from(ie.current))t.has(a)||(URL.revokeObjectURL(a),ie.current.delete(a))},[j]),e.useEffect(()=>{const t=ie.current;return()=>{for(const a of Array.from(t))URL.revokeObjectURL(a);t.clear()}},[]);const Ue=re?B:"div",Ke=e.useCallback(t=>{const a=t.relatedTarget,y=he.current;y&&(a&&y.contains(a)||fe.current||(X?.trim?.()??"").length===0&&j.length===0&&(I||Y(!1),g?.(!1)))},[I,g,X,j]),{getRootProps:$e,getInputProps:qe,isDragActive:Ee,open:Te}=Ze({onDrop:(t,a)=>{if(t.length>0&&ge(t),a.length>0&&q){const y=a.map(({file:E,errors:v})=>{const A=v[0]?.code==="file-too-large"?"size":v[0]?.code==="file-invalid-type"?"type":"count";return{file:E,reason:A}});q(y)}},accept:ne.length>0?ne.reduce((t,a)=>(a.includes("/")?t[a]=[]:a.startsWith(".")&&(t[a]=[]),t),{}):void 0,multiple:z,maxSize:d,noClick:!0,noKeyboard:!0,disabled:!k||S});e.useImperativeHandle(n,()=>({focusTextarea:()=>se.current?.focus({preventScroll:!0}),openFilePicker:()=>{fe.current=!0,Te()}}),[Te]);const Se=e.useCallback(t=>{if(!(t instanceof Element))return!1;const a=t;return a.closest(".rt-ChatbarDropOverlay")?!0:!!a.closest('button, [role="button"], a[href], input, textarea, select, [contenteditable], [tabindex]:not([tabindex="-1"])')},[]),Ye=e.useCallback(t=>{S||Se(t.target)||t.pointerType==="mouse"&&t.button!==0||(t.preventDefault(),se.current?.focus({preventScroll:!0}))},[S,Se,se]);return e.createElement(Me.Provider,{value:{open:ee,setOpen:t=>{I||Y(t),g?.(t)},isOpenControlled:I,value:X,setValue:t=>{x||pe(t),h?.(t)},isValueControlled:x,size:H,expandOn:o,minLines:L,maxLines:u,sendMode:f,disabled:S,readOnly:V,onSubmit:O,rootRef:he,textareaRef:se,attachments:j,setAttachments:t=>{te||we(t),$?.(t)},isAttachmentsControlled:te,accept:J,multiple:z,maxAttachments:P,maxFileSize:d,paste:de,pasteAccept:Q,clearOnSubmit:me,onAttachmentReject:q,dropzone:k,appendFiles:ge,appendFilesFromPaste:Ve,fileDialogOpenRef:fe}},e.createElement(Ue,{...c,ref:t=>{typeof s=="function"?s(t):s&&(s.current=t),he.current=t},className:T("rt-ChatbarRoot",`rt-r-size-${H}`,r),style:{position:"relative",width:oe,maxWidth:G,...p},"data-state":ee?"open":"closed","data-disabled":S?"":void 0,"data-readonly":V?"":void 0,"data-drop-active":k&&Ee?"":void 0,"data-accent-color":N,"data-radius":K,"data-panel-background":b,"data-material":b,"aria-expanded":ee,onBlurCapture:Ke},k&&e.createElement("input",{...qe()}),e.createElement("div",{...k?$e():{},style:{width:"100%",height:"100%"},onPointerDown:Ye},e.createElement(Xe,{className:T("rt-ChatbarBox",`rt-variant-${U??"surface"}`),style:{position:"relative"},"data-accent-color":N,"data-radius":K,"data-panel-background":b,"data-material":b},e.createElement("div",{className:"rt-ChatbarGrid"},m),k&&Ee&&e.createElement("div",{className:"rt-ChatbarDropOverlay"},e.createElement("div",{className:"rt-ChatbarDropContent"},e.createElement(ve,{color:"gray",size:H,weight:"medium"},"Drop files here to attach")))))))});Le.displayName="Chatbar.Root";const Fe=e.forwardRef((l,s)=>{const{className:r,style:p,asChild:m,onFocus:C,onInput:R,onChange:h,onPaste:i,onKeyDown:w,submitOnEnter:g=!1,rows:o,...L}=l,u=W(),{open:f,minLines:S,maxLines:V,expandOn:O,disabled:H,readOnly:U,setOpen:N,setValue:K,textareaRef:M,value:D,isValueControlled:oe,sendMode:G,paste:re,appendFilesFromPaste:_,size:ue}=u,$=e.useRef(0),J=e.useRef(0),z=e.useRef(0),P=e.useCallback(()=>{const n=M.current;if(!n)return;const c=window.getComputedStyle(n),b=parseFloat(c.lineHeight)||20,x=parseFloat(c.paddingTop)||0,F=parseFloat(c.paddingBottom)||0;$.current=b,J.current=x+F,z.current=Math.ceil(1*b)+x+F},[M]),d=e.useCallback(n=>{const c=M.current;if(!c)return;c.style.height="auto",$.current===0&&P();const b=$.current,x=J.current,F=n??f,pe=F?S:1,X=F?V:1,I=Math.ceil(pe*b)+x,Z=Math.ceil(X*b)+x,Y=Math.max(c.scrollHeight,I),ee=Math.min(Y,Z);c.style.height=`${ee}px`,Y>Z?(c.style.overflowY="auto",c.style.maxHeight=`${Z}px`):(c.style.overflowY="hidden",c.style.maxHeight="none")},[f,S,V,M,P]);xe(()=>{d()},[d,D,f]),xe(()=>{if(!(O==="overflow"||O==="both")||f)return;const n=M.current;if(!n)return;n.style.height="auto",z.current===0&&P(),n.scrollHeight>z.current+1&&(N(!0),d(!0),requestAnimationFrame(()=>d(!0)))},[D,O,f,N,M,P,d]),xe(()=>{P(),d()},[P,d,ue]),e.useEffect(()=>{const n=M.current;if(!n||typeof ResizeObserver>"u")return;let c=$.current;const b=new ResizeObserver(()=>{const x=window.getComputedStyle(n),F=parseFloat(x.lineHeight)||20;F!==c&&(c=F,P(),requestAnimationFrame(()=>d()))});return b.observe(n),()=>b.disconnect()},[M,P,d]),e.useEffect(()=>{},[]);const de=e.useCallback(n=>{H||U||((O==="focus"||O==="both")&&!f&&N(!0),C?.(n))},[H,U,O,f,N,C]),Q=e.useCallback(n=>{const c=n.currentTarget,b=c.value;K(b),(O==="overflow"||O==="both")&&!f&&(c.style.height="auto",z.current===0&&P(),c.scrollHeight>z.current+1&&(N(!0),d(!0),requestAnimationFrame(()=>d(!0)))),requestAnimationFrame(()=>d()),h?.(n)},[O,f,N,K,h,d,P]),me=e.useCallback(n=>{if(re){const b=Array.from(n.clipboardData?.items??[]).filter(x=>x.kind==="file").map(x=>x.getAsFile()).filter(x=>!!x);b.length>0&&(n.preventDefault(),_(b))}setTimeout(()=>{f?d():d(!0)},0),i?.(n)},[re,f,d,i,_]),q=e.useCallback(n=>{if(!g){w?.(n);return}if(n.key==="Enter"&&!n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey&&!n.nativeEvent.isComposing){if(H||U){w?.(n);return}if(G==="never"){w?.(n);return}const b=D.trim().length>0||u.attachments.length>0;if(G==="whenDirty"&&!b){w?.(n);return}n.preventDefault(),u.onSubmit?.({value:D,attachments:u.attachments}),u.clearOnSubmit&&(oe||K(""),u.setAttachments([]))}w?.(n)},[g,H,U,G,D,oe,K,u,w]),k=m?B:"textarea";return e.createElement("div",{className:T("rt-ChatbarField","rt-ChatbarTextarea",r)},e.createElement(k,{...L,ref:n=>{typeof s=="function"?s(n):s&&(s.current=n),M.current=n},className:"rt-ChatbarInput",value:D,onInput:R,onChange:Q,onFocus:de,onPaste:me,onKeyDown:q,disabled:H,readOnly:U,rows:f?S:1,spellCheck:L.spellCheck??!0,autoCorrect:L.autoCorrect??"on",style:p}))});Fe.displayName="Chatbar.Textarea";const He=e.forwardRef((l,s)=>{const{children:r,asChild:p,style:m,className:C,...R}=l;return W().open?null:e.createElement(p?B:"div",{...R,ref:s,className:T("rt-ChatbarInlineStart",C),style:m},r)});He.displayName="Chatbar.InlineStart";const Ne=e.forwardRef((l,s)=>{const{children:r,asChild:p,style:m,className:C,...R}=l;return W().open?null:e.createElement(p?B:"div",{...R,ref:s,className:T("rt-ChatbarInlineEnd",C),style:m},r)});Ne.displayName="Chatbar.InlineEnd";const De=e.forwardRef((l,s)=>{const{asChild:r,forceMount:p,renderAttachment:m,className:C,style:R,...h}=l,i=W();return!(i.attachments.length>0)&&!p?null:e.createElement(r?B:"div",{...h,ref:s,className:T("rt-ChatbarAttachmentsRow",C),style:R,role:"list","aria-label":h["aria-label"]??"Attachments"},e.createElement(Qe,{className:"rt-ChatbarScrollArea",scrollbars:"horizontal",size:"1"},e.createElement(ce,{align:"center",gap:"2",style:{minWidth:"fit-content"}},i.attachments.map(o=>e.createElement(Ae,{key:o.id,attachment:o,asChild:!!m},m?.(o))))))});De.displayName="Chatbar.AttachmentsRow";const Ae=e.forwardRef((l,s)=>{const{attachment:r,asChild:p,className:m,style:C,children:R,...h}=l,i=W(),w=p?B:"div",g=!!r.url&&r.type.startsWith("image/");return e.createElement(w,{...h,ref:s,className:T("rt-ChatbarAttachment",m),style:C,role:"listitem","data-kind":g?"image":"file",title:r.name},R??e.createElement(ce,{align:"center",gap:"2",pr:g?void 0:"6"},e.createElement("div",{className:"rt-ChatbarAttachmentPreview","aria-hidden":!0},g?e.createElement("img",{className:"rt-ChatbarAttachmentImage",src:r.url,alt:""}):e.createElement(Je,null)),!g&&e.createElement(ce,{direction:"column",gap:"0",style:{minWidth:0}},e.createElement(ve,{size:i.size,weight:"medium",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},r.name),e.createElement(ve,{size:"1",color:"gray"},Math.ceil(r.size/1024)," KB")),e.createElement(Oe,{className:"rt-ChatbarAttachmentRemove","aria-label":`Remove ${r.name}`,size:"1",variant:"classic",highContrast:!0,color:"gray",onClick:()=>i.setAttachments(i.attachments.filter(o=>o.id!==r.id))},e.createElement(_e,null))))});Ae.displayName="Chatbar.Attachment";const ze=e.forwardRef((l,s)=>{const{asChild:r,accept:p,multiple:m,className:C,style:R,...h}=l,i=W(),w=e.useRef(null),g=r?B:"button",o=p??i.accept,L=(Array.isArray(o)?o:o?.split(",")??[]).join(",");return e.useEffect(()=>{const u=()=>{i.fileDialogOpenRef.current=!1};return window.addEventListener("focus",u),()=>window.removeEventListener("focus",u)},[i.fileDialogOpenRef]),e.createElement(e.Fragment,null,e.createElement(g,{...h,ref:s,className:T("rt-ChatbarAttachTrigger",C),style:R,type:h.type??"button","aria-label":h["aria-label"]??"Add attachments",onPointerDown:u=>{i.fileDialogOpenRef.current=!0,h.onPointerDown?.(u)},onMouseDown:u=>{i.fileDialogOpenRef.current=!0,h.onMouseDown?.(u)},onClick:u=>{i.fileDialogOpenRef.current=!0,w.current&&w.current.click(),h.onClick?.(u)}}),e.createElement("input",{ref:w,type:"file",accept:L,multiple:m??i.multiple,tabIndex:-1,style:{display:"none"},onChange:u=>{const f=Array.from(u.currentTarget.files??[]);f.length>0&&i.appendFiles(f),i.fileDialogOpenRef.current=!1,u.currentTarget.value=""}}))});ze.displayName="Chatbar.AttachTrigger";const ke=e.forwardRef((l,s)=>{const{asChild:r,children:p,className:m,style:C,...R}=l;return W().open?e.createElement(r?B:"div",{...R,ref:s,className:T("rt-ChatbarRow",m),style:C},e.createElement(ce,{align:"center",justify:"between",width:"100%"},p)):null});ke.displayName="Chatbar.Row";const Ie=e.forwardRef((l,s)=>{const{className:r,style:p,...m}=l;return e.createElement("div",{...m,ref:s,className:T("rt-ChatbarRowStart",r),style:p})});Ie.displayName="Chatbar.RowStart";const je=e.forwardRef((l,s)=>{const{className:r,style:p,...m}=l;return e.createElement("div",{...m,ref:s,className:T("rt-ChatbarRowEnd",r),style:p})});je.displayName="Chatbar.RowEnd";const Be=e.forwardRef((l,s)=>{const{asChild:r,clearOnSend:p=!0,disabled:m,children:C,className:R,style:h,size:i,variant:w,...g}=l,o=W(),u=o.value.trim().length>0||o.attachments.length>0,f=o.sendMode==="always"||o.sendMode==="whenDirty"&&u;if(o.sendMode==="never")return null;const S=V=>{o.disabled||o.readOnly||(o.onSubmit?.({value:o.value,attachments:o.attachments}),p&&(o.isValueControlled||o.setValue(""),o.clearOnSubmit&&o.setAttachments([])),g.onClick?.(V))};return e.createElement(Oe,{...g,ref:s,size:i??o.size,variant:w??(o.open?"solid":"ghost"),disabled:m||o.disabled||o.readOnly,className:T("rt-ChatbarSend",R),style:{opacity:f?1:0,pointerEvents:f?"auto":"none",...h},asChild:r,onClick:S,"aria-label":g["aria-label"]??"Send"},C??e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-arrow-right-icon lucide-arrow-right"},e.createElement("path",{d:"M5 12h14"}),e.createElement("path",{d:"m12 5 7 7-7 7"})))});Be.displayName="Chatbar.Send";export{ze as AttachTrigger,Ae as Attachment,De as AttachmentsRow,Ne as InlineEnd,He as InlineStart,Le as Root,ke as Row,je as RowEnd,Ie as RowStart,Be as Send,Fe as Textarea};
|
|
1
|
+
import*as e from"react";import O from"classnames";import{IconButton as Oe}from"./icon-button.js";import{CloseIcon as _e,FileTextIcon as Je}from"./icons.js";import{Flex as ce}from"./flex.js";import{ScrollArea as Qe}from"./scroll-area.js";import{Slot as W}from"./slot.js";import{Box as Xe}from"./box.js";import{Text as ve}from"./text.js";import{useDropzone as Ze}from"react-dropzone";const xe=typeof window<"u"?e.useLayoutEffect:e.useEffect,Me=e.createContext(null),V=()=>{const l=e.useContext(Me);if(!l)throw new Error("Chatbar context not found. Wrap parts in <Chatbar.Root>.");return l},Le=e.forwardRef((l,s)=>{const{className:r,style:m,children:d,value:f,defaultValue:x="",onValueChange:p,open:i,defaultOpen:A=!1,onOpenChange:R,expandOn:P="both",minLines:S=1,maxLines:a=6,sendMode:C="whenDirty",disabled:M,readOnly:D,onSubmit:T,size:L="2",variant:U,color:N,radius:K,panelBackground:F,material:z,width:oe,maxWidth:G,asChild:re,attachments:_,defaultAttachments:ue=[],onAttachmentsChange:$,accept:J,multiple:k=!0,maxAttachments:w,maxFileSize:u,paste:de=!0,pasteAccept:Q,clearOnSubmit:me=!0,onAttachmentReject:q,dropzone:I=!0,apiRef:n,...c}=l,h=z||F,y=f!=null,[H,pe]=e.useState(x),X=y?f:H,j=i!=null,[Z,Y]=e.useState(A),ee=j?i:Z,he=e.useRef(null),se=e.useRef(null),fe=e.useRef(!1),te="attachments"in l,[Re,we]=e.useState(ue),B=e.useMemo(()=>te?_??[]:Re,[te,_,Re]),ie=e.useRef(new Set),be=t=>Array.isArray(t)?t:typeof t=="string"?t.split(",").map(o=>o.trim()):[],ne=be(J),Pe=be(Q).length>0?be(Q):ne,ge=(t,o)=>{if(o.length===0)return!0;const b=t.type.toLowerCase(),E=t.name.toLowerCase();for(const g of o){const v=g.toLowerCase();if(v.includes("/")){const[le,ye]=v.split("/"),[ae,Ge]=b.split("/");if(le==="*"||le===ae&&(ye==="*"||ye===Ge))return!0}else if(v.startsWith(".")&&E.endsWith(v))return!0}return!1},We=t=>{const o=[],b=[],E=typeof w=="number"?Math.max(w-B.length,0):1/0;for(const g of t){if(o.length>=E){b.push({file:g,reason:"count"});continue}if(typeof u=="number"&&g.size>u){b.push({file:g,reason:"size"});continue}if(!ge(g,ne)){b.push({file:g,reason:"type"});continue}const v=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,le=/\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(g.name),ae=(g.type||"").toLowerCase().startsWith("image/")||le?URL.createObjectURL(g):void 0;ae&&ie.current.add(ae),o.push({id:v,name:g.name,size:g.size,type:g.type,file:g,url:ae,status:"idle"})}return{accepted:o,rejected:b}},Ce=t=>{const{accepted:o,rejected:b}=We(t);if(o.length>0){const E=B.concat(o);te||we(E),$?.(E),j||Y(!0),R?.(!0)}b.length>0&&q?.(b)},Ve=t=>{const o=v=>Pe.length===0?ge(v,ne):ge(v,Pe),b=[],E=[],g=typeof w=="number"?Math.max(w-B.length,0):1/0;for(const v of t){if(b.length>=g){E.push({file:v,reason:"count"});continue}if(typeof u=="number"&&v.size>u){E.push({file:v,reason:"size"});continue}if(!o(v)){E.push({file:v,reason:"type"});continue}b.push(v)}b.length>0&&Ce(b),E.length>0&&q?.(E)};e.useEffect(()=>{const t=new Set(B.map(o=>o.url).filter(Boolean));for(const o of Array.from(ie.current))t.has(o)||(URL.revokeObjectURL(o),ie.current.delete(o))},[B]),e.useEffect(()=>{const t=ie.current;return()=>{for(const o of Array.from(t))URL.revokeObjectURL(o);t.clear()}},[]);const Ue=re?W:"div",Ke=e.useCallback(t=>{const o=t.relatedTarget,b=he.current;b&&(o&&b.contains(o)||fe.current||(X?.trim?.()??"").length===0&&B.length===0&&(j||Y(!1),R?.(!1)))},[j,R,X,B]),{getRootProps:$e,getInputProps:qe,isDragActive:Ee,open:Te}=Ze({onDrop:(t,o)=>{if(t.length>0&&Ce(t),o.length>0&&q){const b=o.map(({file:E,errors:g})=>{const v=g[0]?.code==="file-too-large"?"size":g[0]?.code==="file-invalid-type"?"type":"count";return{file:E,reason:v}});q(b)}},accept:ne.length>0?ne.reduce((t,o)=>(o.includes("/")?t[o]=[]:o.startsWith(".")&&(t[o]=[]),t),{}):void 0,multiple:k,maxSize:u,noClick:!0,noKeyboard:!0,disabled:!I||M});e.useImperativeHandle(n,()=>({focusTextarea:()=>se.current?.focus({preventScroll:!0}),openFilePicker:()=>{fe.current=!0,Te()}}),[Te]);const Se=e.useCallback(t=>{if(!(t instanceof Element))return!1;const o=t;return o.closest(".rt-ChatbarDropOverlay")?!0:!!o.closest('button, [role="button"], a[href], input, textarea, select, [contenteditable], [tabindex]:not([tabindex="-1"])')},[]),Ye=e.useCallback(t=>{M||Se(t.target)||t.pointerType==="mouse"&&t.button!==0||(t.preventDefault(),se.current?.focus({preventScroll:!0}))},[M,Se,se]);return e.createElement(Me.Provider,{value:{open:ee,setOpen:t=>{j||Y(t),R?.(t)},isOpenControlled:j,value:X,setValue:t=>{y||pe(t),p?.(t)},isValueControlled:y,size:L,expandOn:P,minLines:S,maxLines:a,sendMode:C,disabled:M,readOnly:D,onSubmit:T,rootRef:he,textareaRef:se,attachments:B,setAttachments:t=>{te||we(t),$?.(t)},isAttachmentsControlled:te,accept:J,multiple:k,maxAttachments:w,maxFileSize:u,paste:de,pasteAccept:Q,clearOnSubmit:me,onAttachmentReject:q,dropzone:I,appendFiles:Ce,appendFilesFromPaste:Ve,fileDialogOpenRef:fe}},e.createElement(Ue,{...c,ref:t=>{typeof s=="function"?s(t):s&&(s.current=t),he.current=t},className:O("rt-ChatbarRoot",`rt-r-size-${L}`,r),style:{position:"relative",width:oe,maxWidth:G,...m},"data-state":ee?"open":"closed","data-disabled":M?"":void 0,"data-readonly":D?"":void 0,"data-drop-active":I&&Ee?"":void 0,"data-accent-color":N,"data-radius":K,"data-panel-background":h,"data-material":h,"aria-expanded":ee,onBlurCapture:Ke},I&&e.createElement("input",{...qe()}),e.createElement("div",{...I?$e():{},style:{width:"100%",height:"100%"},onPointerDown:Ye},e.createElement(Xe,{className:O("rt-ChatbarBox",`rt-variant-${U??"surface"}`),style:{position:"relative"},"data-accent-color":N,"data-radius":K,"data-panel-background":h,"data-material":h},e.createElement("div",{className:"rt-ChatbarGrid"},d),I&&Ee&&e.createElement("div",{className:"rt-ChatbarDropOverlay"},e.createElement("div",{className:"rt-ChatbarDropContent"},e.createElement(ve,{color:"gray",size:L,weight:"medium"},"Drop files here to attach")))))))});Le.displayName="Chatbar.Root";const Fe=e.forwardRef((l,s)=>{const{className:r,style:m,asChild:d,onFocus:f,onInput:x,onChange:p,onPaste:i,onKeyDown:A,submitOnEnter:R=!1,rows:P,...S}=l,a=V(),{open:C,minLines:M,maxLines:D,expandOn:T,disabled:L,readOnly:U,setOpen:N,setValue:K,textareaRef:F,value:z,isValueControlled:oe,sendMode:G,paste:re,appendFilesFromPaste:_,size:ue}=a,$=e.useRef(0),J=e.useRef(0),k=e.useRef(0),w=e.useCallback(()=>{const n=F.current;if(!n)return;const c=window.getComputedStyle(n),h=parseFloat(c.lineHeight)||20,y=parseFloat(c.paddingTop)||0,H=parseFloat(c.paddingBottom)||0;$.current=h,J.current=y+H,k.current=Math.ceil(1*h)+y+H},[F]),u=e.useCallback(n=>{const c=F.current;if(!c)return;c.style.height="auto",$.current===0&&w();const h=$.current,y=J.current,H=n??C,pe=H?M:1,X=H?D:1,j=Math.ceil(pe*h)+y,Z=Math.ceil(X*h)+y,Y=Math.max(c.scrollHeight,j),ee=Math.min(Y,Z);c.style.height=`${ee}px`,Y>Z?(c.style.overflowY="auto",c.style.maxHeight=`${Z}px`):(c.style.overflowY="hidden",c.style.maxHeight="none")},[C,M,D,F,w]);xe(()=>{u()},[u,z,C]),xe(()=>{if(!(T==="overflow"||T==="both")||C)return;const n=F.current;if(!n)return;n.style.height="auto",k.current===0&&w(),n.scrollHeight>k.current+1&&(N(!0),u(!0),requestAnimationFrame(()=>u(!0)))},[z,T,C,N,F,w,u]),xe(()=>{w(),u()},[w,u,ue]),e.useEffect(()=>{const n=F.current;if(!n||typeof ResizeObserver>"u")return;let c=$.current;const h=new ResizeObserver(()=>{const y=window.getComputedStyle(n),H=parseFloat(y.lineHeight)||20;H!==c&&(c=H,w(),requestAnimationFrame(()=>u()))});return h.observe(n),()=>h.disconnect()},[F,w,u]),e.useEffect(()=>{},[]);const de=e.useCallback(n=>{L||U||((T==="focus"||T==="both")&&!C&&N(!0),f?.(n))},[L,U,T,C,N,f]),Q=e.useCallback(n=>{const c=n.currentTarget,h=c.value;K(h),(T==="overflow"||T==="both")&&!C&&(c.style.height="auto",k.current===0&&w(),c.scrollHeight>k.current+1&&(N(!0),u(!0),requestAnimationFrame(()=>u(!0)))),requestAnimationFrame(()=>u()),p?.(n)},[T,C,N,K,p,u,w]),me=e.useCallback(n=>{if(re){const h=Array.from(n.clipboardData?.items??[]).filter(y=>y.kind==="file").map(y=>y.getAsFile()).filter(y=>!!y);h.length>0&&(n.preventDefault(),_(h))}setTimeout(()=>{C?u():u(!0)},0),i?.(n)},[re,C,u,i,_]),q=e.useCallback(n=>{if(!R){A?.(n);return}if(n.key==="Enter"&&!n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey&&!n.nativeEvent.isComposing){if(L||U){A?.(n);return}if(G==="never"){A?.(n);return}const h=z.trim().length>0||a.attachments.length>0;if(G==="whenDirty"&&!h){A?.(n);return}n.preventDefault(),a.onSubmit?.({value:z,attachments:a.attachments}),a.clearOnSubmit&&(oe||K(""),a.setAttachments([]))}A?.(n)},[R,L,U,G,z,oe,K,a,A]),I=d?W:"textarea";return e.createElement("div",{className:O("rt-ChatbarField","rt-ChatbarTextarea",r)},e.createElement(I,{...S,ref:n=>{typeof s=="function"?s(n):s&&(s.current=n),F.current=n},className:"rt-ChatbarInput",value:z,onInput:x,onChange:Q,onFocus:de,onPaste:me,onKeyDown:q,disabled:L,readOnly:U,rows:C?M:1,spellCheck:S.spellCheck??!0,autoCorrect:S.autoCorrect??"on",style:m}))});Fe.displayName="Chatbar.Textarea";const He=e.forwardRef((l,s)=>{const{children:r,asChild:m,style:d,className:f,...x}=l;return V().open?null:e.createElement(m?W:"div",{...x,ref:s,className:O("rt-ChatbarInlineStart",f),style:d},r)});He.displayName="Chatbar.InlineStart";const Ne=e.forwardRef((l,s)=>{const{children:r,asChild:m,style:d,className:f,...x}=l;return V().open?null:e.createElement(m?W:"div",{...x,ref:s,className:O("rt-ChatbarInlineEnd",f),style:d},r)});Ne.displayName="Chatbar.InlineEnd";const De=e.forwardRef((l,s)=>{const{asChild:r,forceMount:m,renderAttachment:d,className:f,style:x,...p}=l,i=V();return!(i.attachments.length>0)&&!m?null:e.createElement(r?W:"div",{...p,ref:s,className:O("rt-ChatbarAttachmentsRow",f),style:x,role:"list","aria-label":p["aria-label"]??"Attachments"},e.createElement(Qe,{className:"rt-ChatbarScrollArea",scrollbars:"horizontal",size:"1"},e.createElement(ce,{align:"center",gap:"2",style:{minWidth:"fit-content"}},i.attachments.map(P=>e.createElement(Ae,{key:P.id,attachment:P,asChild:!!d},d?.(P))))))});De.displayName="Chatbar.AttachmentsRow";const Ae=e.forwardRef((l,s)=>{const{attachment:r,asChild:m,className:d,style:f,children:x,...p}=l,i=V(),A=m?W:"div",R=!!r.url&&r.type.startsWith("image/");return e.createElement(A,{...p,ref:s,className:O("rt-ChatbarAttachment",d),style:f,role:"listitem","data-kind":R?"image":"file",title:r.name},x??e.createElement(ce,{align:"center",gap:"2",pr:R?void 0:"6"},e.createElement("div",{className:"rt-ChatbarAttachmentPreview","aria-hidden":!0},R?e.createElement("img",{className:"rt-ChatbarAttachmentImage",src:r.url,alt:""}):e.createElement(Je,null)),!R&&e.createElement(ce,{direction:"column",gap:"0",style:{minWidth:0}},e.createElement(ve,{size:i.size,weight:"medium",style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},r.name),e.createElement(ve,{size:"1",color:"gray"},Math.ceil(r.size/1024)," KB")),e.createElement(Oe,{className:"rt-ChatbarAttachmentRemove","aria-label":`Remove ${r.name}`,size:"1",variant:"classic",highContrast:!0,color:"gray",onClick:()=>i.setAttachments(i.attachments.filter(P=>P.id!==r.id))},e.createElement(_e,null))))});Ae.displayName="Chatbar.Attachment";const ze=e.forwardRef((l,s)=>{const{asChild:r,accept:m,multiple:d,className:f,style:x,...p}=l,i=V(),A=e.useRef(null),R=r?W:"button",P=m??i.accept,S=(Array.isArray(P)?P:P?.split(",")??[]).join(",");return e.useEffect(()=>{const a=()=>{i.fileDialogOpenRef.current=!1};return window.addEventListener("focus",a),()=>window.removeEventListener("focus",a)},[i.fileDialogOpenRef]),e.createElement(e.Fragment,null,e.createElement(R,{...p,ref:s,className:O("rt-ChatbarAttachTrigger",f),style:x,type:p.type??"button","aria-label":p["aria-label"]??"Add attachments",onPointerDown:a=>{i.fileDialogOpenRef.current=!0,p.onPointerDown?.(a)},onMouseDown:a=>{i.fileDialogOpenRef.current=!0,p.onMouseDown?.(a)},onClick:a=>{i.fileDialogOpenRef.current=!0,A.current&&A.current.click(),p.onClick?.(a)}}),e.createElement("input",{ref:A,type:"file",accept:S,multiple:d??i.multiple,tabIndex:-1,style:{display:"none"},onChange:a=>{const C=Array.from(a.currentTarget.files??[]);C.length>0&&i.appendFiles(C),i.fileDialogOpenRef.current=!1,a.currentTarget.value=""}}))});ze.displayName="Chatbar.AttachTrigger";const ke=e.forwardRef((l,s)=>{const{asChild:r,children:m,className:d,style:f,...x}=l;return V().open?e.createElement(r?W:"div",{...x,ref:s,className:O("rt-ChatbarRow",d),style:f},e.createElement(ce,{align:"center",justify:"between",width:"100%"},m)):null});ke.displayName="Chatbar.Row";const Ie=e.forwardRef((l,s)=>{const{className:r,style:m,...d}=l;return e.createElement("div",{...d,ref:s,className:O("rt-ChatbarRowStart",r),style:m})});Ie.displayName="Chatbar.RowStart";const je=e.forwardRef((l,s)=>{const{className:r,style:m,...d}=l;return e.createElement("div",{...d,ref:s,className:O("rt-ChatbarRowEnd",r),style:m})});je.displayName="Chatbar.RowEnd";const Be=e.forwardRef((l,s)=>{const{asChild:r,clearOnSend:m=!0,disabled:d,children:f,className:x,style:p,size:i,variant:A,"aria-label":R,"aria-labelledby":P,...S}=l,a=V(),M=a.value.trim().length>0||a.attachments.length>0,D=a.sendMode==="always"||a.sendMode==="whenDirty"&&M;if(a.sendMode==="never")return null;const T=L=>{a.disabled||a.readOnly||(a.onSubmit?.({value:a.value,attachments:a.attachments}),m&&(a.isValueControlled||a.setValue(""),a.clearOnSubmit&&a.setAttachments([])),S.onClick?.(L))};return e.createElement(Oe,{...S,ref:s,size:i??a.size,variant:A??(a.open?"solid":"ghost"),disabled:d||a.disabled||a.readOnly,className:O("rt-ChatbarSend",x),style:{opacity:D?1:0,pointerEvents:D?"auto":"none",...p},asChild:r,onClick:T,"aria-label":R??(P?void 0:"Send"),"aria-labelledby":P},f??e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-arrow-right-icon lucide-arrow-right"},e.createElement("path",{d:"M5 12h14"}),e.createElement("path",{d:"m12 5 7 7-7 7"})))});Be.displayName="Chatbar.Send";export{ze as AttachTrigger,Ae as Attachment,De as AttachmentsRow,Ne as InlineEnd,He as InlineStart,Le as Root,ke as Row,je as RowEnd,Ie as RowStart,Be as Send,Fe as Textarea};
|
|
2
2
|
//# sourceMappingURL=chatbar.js.map
|