boltdocs 2.7.10 → 2.7.11

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.
Files changed (137) hide show
  1. package/dist/client/index.cjs +1929 -1
  2. package/dist/client/index.js +1880 -1
  3. package/dist/client/mdx.cjs +7 -1
  4. package/dist/client/mdx.js +7 -1
  5. package/dist/client/primitives.cjs +60 -1
  6. package/dist/client/primitives.js +20 -1
  7. package/dist/docs-layout-BXHV0xw_.cjs +1431 -0
  8. package/dist/docs-layout-DwFndmj5.js +1231 -0
  9. package/dist/icons-dev-3cZMyt8r.cjs +1204 -0
  10. package/dist/icons-dev-Df8OQ481.js +839 -0
  11. package/dist/image-DtrI2cw3.cjs +268 -0
  12. package/dist/image-jxPb-2iV.js +214 -0
  13. package/dist/mdx-BdWkJTeB.cjs +523 -0
  14. package/dist/mdx-UTTLFWJq.js +494 -0
  15. package/dist/node/cli-entry.cjs +1 -1
  16. package/dist/node/cli-entry.mjs +1 -1
  17. package/dist/node/index.cjs +1 -1
  18. package/dist/node/index.mjs +1 -1
  19. package/dist/{node-DtEDyN1u.cjs → node-BSM4qcDK.cjs} +1 -1
  20. package/dist/{node-_1jhMGYx.mjs → node-BspZN3R2.mjs} +1 -1
  21. package/dist/{package-DrwtlXfk.cjs → package-DIIrjuWI.cjs} +1 -1
  22. package/dist/{package--0Yf0t1N.mjs → package-K0zsjGIz.mjs} +1 -1
  23. package/dist/{search-dialog-ByvGScjt.js → search-dialog-BHuIiUC6.js} +3 -1
  24. package/dist/search-dialog-BNF10tDl.js +375 -0
  25. package/dist/search-dialog-BwkDuI9R.cjs +220 -0
  26. package/dist/search-dialog-C7xuvyNk.cjs +386 -0
  27. package/dist/search-dialog-CIQg6k8c.cjs +8 -0
  28. package/dist/search-dialog-D-DDN7zJ.js +208 -0
  29. package/package.json +3 -4
  30. package/dist/docs-layout-KoWNZc8_.js +0 -6
  31. package/dist/docs-layout-x2yKt2cL.cjs +0 -6
  32. package/dist/icons-dev-B_RZIyxu.js +0 -6
  33. package/dist/icons-dev-BlV3wWFT.cjs +0 -6
  34. package/dist/image-BHhTvQzr.cjs +0 -6
  35. package/dist/image-CqKzYD8f.js +0 -6
  36. package/dist/mdx-DudBEac0.js +0 -7
  37. package/dist/mdx-r4cDQxWu.cjs +0 -7
  38. package/dist/search-dialog-B584t9ZF.js +0 -6
  39. package/dist/search-dialog-BvBopRsZ.cjs +0 -6
  40. package/dist/search-dialog-Cyko6TJm.cjs +0 -6
  41. package/dist/search-dialog-D6BNohIJ.js +0 -6
  42. package/dist/search-dialog-DuYTIefy.cjs +0 -6
  43. package/src/client/app/config-context.tsx +0 -51
  44. package/src/client/app/doc-page.tsx +0 -38
  45. package/src/client/app/docs-layout.tsx +0 -28
  46. package/src/client/app/head.tsx +0 -122
  47. package/src/client/app/helmet-compat.tsx +0 -36
  48. package/src/client/app/mdx-component.tsx +0 -8
  49. package/src/client/app/mdx-components-context.tsx +0 -72
  50. package/src/client/app/routes-context.tsx +0 -34
  51. package/src/client/app/scroll-handler.tsx +0 -74
  52. package/src/client/app/theme-context.tsx +0 -103
  53. package/src/client/app/ui-context.tsx +0 -42
  54. package/src/client/components/docs-layout-default.tsx +0 -85
  55. package/src/client/components/icons-dev.tsx +0 -282
  56. package/src/client/components/mdx/callout.tsx +0 -97
  57. package/src/client/components/mdx/card.tsx +0 -99
  58. package/src/client/components/mdx/cards.tsx +0 -27
  59. package/src/client/components/mdx/code-block.tsx +0 -184
  60. package/src/client/components/mdx/field.tsx +0 -33
  61. package/src/client/components/mdx/image.tsx +0 -44
  62. package/src/client/components/mdx/index.ts +0 -19
  63. package/src/client/components/mdx/table.tsx +0 -54
  64. package/src/client/components/mdx/typographics.tsx +0 -120
  65. package/src/client/components/mdx/use-code-block.ts +0 -34
  66. package/src/client/components/primitives/breadcrumbs.tsx +0 -54
  67. package/src/client/components/primitives/button-group.tsx +0 -54
  68. package/src/client/components/primitives/button.tsx +0 -6
  69. package/src/client/components/primitives/code-block.tsx +0 -120
  70. package/src/client/components/primitives/docs-layout.tsx +0 -125
  71. package/src/client/components/primitives/error-boundary.tsx +0 -107
  72. package/src/client/components/primitives/heading.tsx +0 -128
  73. package/src/client/components/primitives/helpers/observer.ts +0 -141
  74. package/src/client/components/primitives/image.tsx +0 -26
  75. package/src/client/components/primitives/link.tsx +0 -102
  76. package/src/client/components/primitives/menu.tsx +0 -137
  77. package/src/client/components/primitives/navbar.tsx +0 -466
  78. package/src/client/components/primitives/on-this-page.tsx +0 -430
  79. package/src/client/components/primitives/page-nav.tsx +0 -51
  80. package/src/client/components/primitives/popover.tsx +0 -28
  81. package/src/client/components/primitives/search-dialog.tsx +0 -193
  82. package/src/client/components/primitives/sidebar.tsx +0 -423
  83. package/src/client/components/primitives/skeleton.tsx +0 -26
  84. package/src/client/components/primitives/tabs.tsx +0 -70
  85. package/src/client/components/primitives/tooltip.tsx +0 -81
  86. package/src/client/components/primitives/types.ts +0 -11
  87. package/src/client/components/ui-base/banner.tsx +0 -66
  88. package/src/client/components/ui-base/breadcrumbs.tsx +0 -44
  89. package/src/client/components/ui-base/copy-markdown.tsx +0 -107
  90. package/src/client/components/ui-base/error-boundary.tsx +0 -15
  91. package/src/client/components/ui-base/github-stars.tsx +0 -29
  92. package/src/client/components/ui-base/icons.tsx +0 -240
  93. package/src/client/components/ui-base/index.ts +0 -16
  94. package/src/client/components/ui-base/last-updated.tsx +0 -27
  95. package/src/client/components/ui-base/navbar.tsx +0 -266
  96. package/src/client/components/ui-base/not-found.tsx +0 -26
  97. package/src/client/components/ui-base/on-this-page.tsx +0 -57
  98. package/src/client/components/ui-base/page-nav.tsx +0 -50
  99. package/src/client/components/ui-base/search-dialog.tsx +0 -163
  100. package/src/client/components/ui-base/search-highlight.tsx +0 -10
  101. package/src/client/components/ui-base/sidebar.tsx +0 -92
  102. package/src/client/components/ui-base/tabs.tsx +0 -83
  103. package/src/client/components/ui-base/theme-toggle.tsx +0 -130
  104. package/src/client/components/ui-base/version-i18n.tsx +0 -80
  105. package/src/client/hooks/index.ts +0 -13
  106. package/src/client/hooks/use-analytics.ts +0 -272
  107. package/src/client/hooks/use-breadcrumbs.ts +0 -22
  108. package/src/client/hooks/use-i18n.ts +0 -182
  109. package/src/client/hooks/use-localized-to.ts +0 -113
  110. package/src/client/hooks/use-location.ts +0 -5
  111. package/src/client/hooks/use-navbar.ts +0 -130
  112. package/src/client/hooks/use-page-nav.ts +0 -46
  113. package/src/client/hooks/use-routes.ts +0 -108
  114. package/src/client/hooks/use-search-highlight.ts +0 -185
  115. package/src/client/hooks/use-search.ts +0 -118
  116. package/src/client/hooks/use-sidebar.ts +0 -205
  117. package/src/client/hooks/use-tabs.ts +0 -46
  118. package/src/client/hooks/use-version.ts +0 -111
  119. package/src/client/index.ts +0 -31
  120. package/src/client/mdx.ts +0 -2
  121. package/src/client/primitives.ts +0 -19
  122. package/src/client/ssg/boltdocs-shell.tsx +0 -148
  123. package/src/client/ssg/create-routes.tsx +0 -473
  124. package/src/client/ssg/index.ts +0 -4
  125. package/src/client/ssg/mdx-page.tsx +0 -38
  126. package/src/client/store/boltdocs-context.tsx +0 -137
  127. package/src/client/theme/neutral.css +0 -141
  128. package/src/client/theme/reset.css +0 -189
  129. package/src/client/types.ts +0 -116
  130. package/src/client/utils/cn.ts +0 -6
  131. package/src/client/utils/copy-clipboard.ts +0 -22
  132. package/src/client/utils/get-base-file-path.ts +0 -21
  133. package/src/client/utils/github.ts +0 -121
  134. package/src/client/utils/i18n.ts +0 -23
  135. package/src/client/utils/path.ts +0 -9
  136. package/src/client/utils/react-to-text.ts +0 -34
  137. package/src/client/virtual.d.ts +0 -24
@@ -1,430 +0,0 @@
1
- import {
2
- createContext,
3
- use,
4
- useEffect,
5
- useImperativeHandle,
6
- useMemo,
7
- useRef,
8
- useState,
9
- type ReactNode,
10
- type RefObject,
11
- } from 'react'
12
- import scrollIntoView from 'scroll-into-view-if-needed'
13
- import { cn } from '../../utils/cn'
14
- import type { ComponentBase } from './types'
15
- import { getItemId, Observer } from './helpers/observer'
16
-
17
- export interface TOCItemType {
18
- title: ReactNode
19
- url: string
20
- depth: number
21
- _step?: number
22
- }
23
-
24
- export type TableOfContents = TOCItemType[]
25
-
26
- export interface TOCItemInfo {
27
- id: string
28
- active: boolean
29
- /** last time the item is updated */
30
- t: number
31
- /** currently active but not intersecting in viewport */
32
- fallback: boolean
33
- original?: TOCItemType
34
- }
35
-
36
- export interface AnchorProviderProps {
37
- toc: TOCItemType[]
38
- /**
39
- * Only accept one active item at most
40
- * @defaultValue false
41
- */
42
- single?: boolean
43
- /**
44
- * Custom IntersectionObserver options
45
- */
46
- observerOptions?: IntersectionObserverInit
47
- children?: ReactNode
48
- }
49
-
50
- export interface ScrollProviderProps {
51
- /**
52
- * Scroll into the view of container when active
53
- */
54
- containerRef: RefObject<HTMLElement | null>
55
- children?: ReactNode
56
- }
57
-
58
- export interface OnThisPageContentProps extends ComponentBase {
59
- ref?: React.Ref<HTMLDivElement>
60
- scrollRef?: RefObject<HTMLElement | null>
61
- }
62
-
63
- export interface OnThisPageItemProps extends ComponentBase {
64
- level?: number
65
- }
66
-
67
- export interface OnThisPageLinkProps extends ComponentBase {
68
- href?: string
69
- active?: boolean
70
- onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void
71
- }
72
-
73
- export interface OnThisPageIndicatorProps extends ComponentBase {
74
- style?: React.CSSProperties
75
- }
76
-
77
- const ItemsContext = createContext<TOCItemInfo[] | null>(null)
78
- const ScrollContext = createContext<RefObject<HTMLElement | null> | null>(null)
79
-
80
- export function useItems() {
81
- const ctx = use(ItemsContext)
82
- if (!ctx)
83
- throw new Error(
84
- `Component must be used under the <AnchorProvider /> component.`,
85
- )
86
- return ctx
87
- }
88
-
89
- export function useActiveAnchor(): string | undefined {
90
- const items = useItems()
91
- return useMemo(() => {
92
- let out: TOCItemInfo | undefined
93
- for (const item of items) {
94
- if (!item.active) continue
95
- if (!out || item.t > out.t) {
96
- out = item
97
- }
98
- }
99
- return out?.id
100
- }, [items])
101
- }
102
-
103
- export function useActiveAnchors(): string[] {
104
- const items = useItems()
105
- return useMemo(() => {
106
- const out: string[] = []
107
- for (const item of items) {
108
- if (item.active) out.push(item.id)
109
- }
110
- return out
111
- }, [items])
112
- }
113
-
114
- /** Optional: add auto-scroll to TOC items. */
115
- export function ScrollProvider({
116
- containerRef,
117
- children,
118
- }: ScrollProviderProps) {
119
- return (
120
- <ScrollContext.Provider value={containerRef}>
121
- {children}
122
- </ScrollContext.Provider>
123
- )
124
- }
125
-
126
- export function AnchorProvider({
127
- toc,
128
- single = false,
129
- observerOptions,
130
- children,
131
- }: AnchorProviderProps) {
132
- const observer = useMemo(() => new Observer(), [])
133
- const [items, setItems] = useState<TOCItemInfo[]>(observer.items)
134
-
135
- observer.single = single
136
- useEffect(() => {
137
- observer.setItems(toc)
138
- }, [observer, toc])
139
-
140
- useEffect(() => {
141
- // We use a rootMargin that acts as an activation "line" near the top.
142
- // headings are "intersecting" (active=true) when they are BELOW this line.
143
- // Default to a more permissive margin for detecting visible headings
144
- const defaultOptions = {
145
- rootMargin: '-80px 0% -60% 0%',
146
- threshold: 0,
147
- }
148
- const options = observerOptions
149
- ? { ...defaultOptions, ...observerOptions }
150
- : defaultOptions
151
-
152
- observer.watch(options)
153
- observer.onChange = () => setItems([...observer.items])
154
-
155
- return () => {
156
- observer.unwatch()
157
- }
158
- }, [observer])
159
-
160
- return <ItemsContext.Provider value={items}>{children}</ItemsContext.Provider>
161
- }
162
-
163
- export const OnThisPage = ({ children, className }: ComponentBase) => {
164
- return (
165
- <nav
166
- className={cn(
167
- 'sticky top-navbar hidden xl:flex flex-col shrink-0',
168
- 'w-toc',
169
- 'py-4 pl-6 pr-4',
170
- className,
171
- )}
172
- >
173
- {children}
174
- </nav>
175
- )
176
- }
177
-
178
- const OnThisPageHeader = ({ children, className, ...props }: ComponentBase) => {
179
- return (
180
- <div
181
- className={cn('mb-4 text-xs font-bold text-body', className)}
182
- {...props}
183
- >
184
- {children}
185
- </div>
186
- )
187
- }
188
-
189
- const OnThisPageContent = ({
190
- children,
191
- className,
192
- ref,
193
- ...props
194
- }: OnThisPageContentProps) => {
195
- const internalRef = useRef<HTMLDivElement>(null)
196
-
197
- useImperativeHandle(ref, () => internalRef.current!)
198
-
199
- return (
200
- <div
201
- ref={internalRef}
202
- className={cn(
203
- 'relative overflow-y-auto boltdocs-otp-content pb-12',
204
- 'max-h-[70%]',
205
- className,
206
- )}
207
- style={{
208
- maskImage: 'linear-gradient(to bottom, black 90%, transparent 100%)',
209
- WebkitMaskImage:
210
- 'linear-gradient(to bottom, black 90%, transparent 100%)',
211
- }}
212
- {...props}
213
- >
214
- {children}
215
- </div>
216
- )
217
- }
218
-
219
- OnThisPageContent.displayName = 'OnThisPageContent'
220
-
221
- const OnThisPageList = ({ children, className }: ComponentBase) => {
222
- return (
223
- <ul
224
- className={cn(
225
- 'relative space-y-0.5 text-sm border-l border-subtle',
226
- className,
227
- )}
228
- >
229
- {children}
230
- </ul>
231
- )
232
- }
233
-
234
- const OnThisPageItem = ({
235
- level,
236
- children,
237
- className,
238
- }: OnThisPageItemProps) => {
239
- return <li className={cn(level === 3 && 'pl-3', className)}>{children}</li>
240
- }
241
-
242
- const OnThisPageLink = ({
243
- children,
244
- href,
245
- active,
246
- onClick,
247
- className,
248
- }: OnThisPageLinkProps) => {
249
- const items = use(ItemsContext)
250
- const containerRef = use(ScrollContext)
251
- const id = href ? getItemId(href) : null
252
- const anchorRef = useRef<HTMLAnchorElement>(null)
253
-
254
- const computedActive =
255
- active !== undefined
256
- ? active
257
- : id && items
258
- ? !!items.find((i) => i.id === id)?.active
259
- : false
260
-
261
- useEffect(() => {
262
- if (computedActive && anchorRef.current && containerRef?.current) {
263
- scrollIntoView(anchorRef.current, {
264
- behavior: 'smooth',
265
- block: 'center',
266
- inline: 'center',
267
- scrollMode: 'if-needed',
268
- boundary: containerRef.current,
269
- })
270
- }
271
- }, [computedActive, containerRef])
272
-
273
- const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
274
- if (onClick) {
275
- onClick(e)
276
- } else if (href && href.startsWith('#')) {
277
- e.preventDefault()
278
- const elementId = href.slice(1)
279
- const el = document.getElementById(elementId)
280
- if (el) {
281
- el.scrollIntoView({ behavior: 'smooth' })
282
- window.history.pushState(null, '', href)
283
- }
284
- }
285
- }
286
-
287
- return (
288
- <a
289
- ref={anchorRef}
290
- href={href}
291
- onClick={handleClick}
292
- data-active={computedActive}
293
- className={cn(
294
- 'block py-0.5 pl-4 text-[13px] outline-none transition-colors',
295
- computedActive ? 'text-primary-500' : 'text-muted hover:text-body',
296
- className,
297
- )}
298
- >
299
- {children}
300
- </a>
301
- )
302
- }
303
-
304
- const OnThisPageIndicator = ({
305
- style,
306
- className,
307
- }: OnThisPageIndicatorProps) => {
308
- const containerRef = useRef<HTMLDivElement>(null)
309
- const [internalStyle, setInternalStyle] = useState<React.CSSProperties>({
310
- opacity: 0,
311
- ...style,
312
- })
313
-
314
- const items = useItems()
315
-
316
- useEffect(() => {
317
- const parent = containerRef.current?.parentElement
318
- if (!parent) return
319
-
320
- const activeLinks = parent.querySelectorAll('a[data-active="true"]')
321
-
322
- if (activeLinks.length > 0) {
323
- const firstActiveLink = activeLinks[0] as HTMLElement
324
- const lastActiveLink = activeLinks[activeLinks.length - 1] as HTMLElement
325
-
326
- const firstRect = firstActiveLink.getBoundingClientRect()
327
- const lastRect = lastActiveLink.getBoundingClientRect()
328
- const parentRect = parent.getBoundingClientRect()
329
-
330
- const offsetTop = firstRect.top - parentRect.top
331
- const height = lastRect.bottom - firstRect.top
332
-
333
- setInternalStyle({
334
- transform: `translateY(${offsetTop}px)`,
335
- height: `${height}px`,
336
- opacity: 1,
337
- ...style,
338
- })
339
- } else {
340
- setInternalStyle({
341
- opacity: 0,
342
- ...style,
343
- })
344
- }
345
- }, [items, style])
346
-
347
- return (
348
- <div
349
- ref={containerRef}
350
- className={cn(
351
- 'absolute -left-px w-0.5 rounded-full bg-primary-500',
352
- className,
353
- )}
354
- style={{
355
- transition:
356
- 'transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), height 180ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 150ms',
357
- ...internalStyle,
358
- }}
359
- />
360
- )
361
- }
362
-
363
- /**
364
- * High-level automated list of toc items
365
- */
366
- export function OnThisPageItems({
367
- headings = [],
368
- className,
369
- }: {
370
- headings: { level: number; text: string; id: string }[]
371
- } & ComponentBase) {
372
- const activeIds = useActiveAnchors()
373
-
374
- if (headings.length === 0) return null
375
-
376
- return (
377
- <OnThisPageList className={className}>
378
- <OnThisPageIndicator />
379
- {headings.map((h) => (
380
- <OnThisPageItem key={h.id} level={h.level}>
381
- <OnThisPageLink href={`#${h.id}`} active={activeIds.includes(h.id)}>
382
- {h.text}
383
- </OnThisPageLink>
384
- </OnThisPageItem>
385
- ))}
386
- </OnThisPageList>
387
- )
388
- }
389
-
390
- /**
391
- * High-level automated Table of Contents tree
392
- */
393
- export function OnThisPageTree({
394
- headings = [],
395
- className,
396
- }: {
397
- headings: { level: number; text: string; id: string }[]
398
- } & ComponentBase) {
399
- const toc = useMemo(
400
- () =>
401
- headings.map((h) => ({ title: h.text, url: `#${h.id}`, depth: h.level })),
402
- [headings],
403
- )
404
-
405
- const scrollContainerRef = useRef<HTMLDivElement>(null)
406
-
407
- if (headings.length === 0) return null
408
-
409
- return (
410
- <AnchorProvider toc={toc} single={false}>
411
- <ScrollProvider containerRef={scrollContainerRef}>
412
- <OnThisPageContent ref={scrollContainerRef}>
413
- <OnThisPageItems headings={headings} className={className} />
414
- </OnThisPageContent>
415
- </ScrollProvider>
416
- </AnchorProvider>
417
- )
418
- }
419
-
420
- OnThisPage.Root = OnThisPage
421
- OnThisPage.Header = OnThisPageHeader
422
- OnThisPage.Content = OnThisPageContent
423
- OnThisPage.List = OnThisPageList
424
- OnThisPage.Item = OnThisPageItem
425
- OnThisPage.Link = OnThisPageLink
426
- OnThisPage.Indicator = OnThisPageIndicator
427
- OnThisPage.Items = OnThisPageItems
428
- OnThisPage.Tree = OnThisPageTree
429
-
430
- export default OnThisPage
@@ -1,51 +0,0 @@
1
- import { Link } from './link'
2
- import { ChevronLeft, ChevronRight } from '../ui-base/icons'
3
- import { cn } from '../../utils/cn'
4
- import type { ComponentBase } from './types'
5
-
6
- export interface PageNavProps extends ComponentBase {
7
- to: string
8
- direction: 'prev' | 'next'
9
- }
10
-
11
- export const PageNav = ({ children, className }: ComponentBase) => {
12
- return (
13
- <nav className={cn('grid sm:grid-cols-2 gap-4', className)}>{children}</nav>
14
- )
15
- }
16
-
17
- const PageNavLink = ({ children, to, direction, className }: PageNavProps) => {
18
- const isNext = direction === 'next'
19
- return (
20
- <Link
21
- href={to}
22
- className={cn(
23
- 'flex items-center outline-none no-underline',
24
- isNext ? 'justify-end' : 'justify-start',
25
- className,
26
- )}
27
- >
28
- {!isNext && <ChevronLeft className="shrink-0" />}
29
- <div className="flex flex-col flex-1">{children}</div>
30
- {isNext && <ChevronRight className="shrink-0" />}
31
- </Link>
32
- )
33
- }
34
-
35
- const PageNavTitle = ({ children, className }: ComponentBase) => {
36
- return <span className={cn(className)}>{children}</span>
37
- }
38
-
39
- const PageNavDescription = ({ children, className }: ComponentBase) => {
40
- return <span className={cn('truncate', className)}>{children}</span>
41
- }
42
-
43
- const PageNavIcon = ({ children }: ComponentBase) => {
44
- return <>{children}</>
45
- }
46
-
47
- PageNav.Root = PageNav
48
- PageNav.Link = PageNavLink
49
- PageNav.Title = PageNavTitle
50
- PageNav.Description = PageNavDescription
51
- PageNav.Icon = PageNavIcon
@@ -1,28 +0,0 @@
1
- import {
2
- Popover as RACPopover,
3
- type PopoverProps as RACPopoverProps,
4
- } from 'react-aria-components'
5
- import { cn } from '../../utils/cn'
6
-
7
- export interface PopoverProps extends Omit<RACPopoverProps, 'children'> {
8
- children: React.ReactNode
9
- className?: string
10
- }
11
-
12
- /**
13
- * A reusable Popover primitive with premium glassmorphism styling and smooth animations.
14
- */
15
- export const Popover = ({ children, className, ...props }: PopoverProps) => {
16
- return (
17
- <RACPopover
18
- offset={8}
19
- className={cn(
20
- 'z-50 overflow-auto outline-none transition-none',
21
- className,
22
- )}
23
- {...props}
24
- >
25
- {children as any}
26
- </RACPopover>
27
- )
28
- }
@@ -1,193 +0,0 @@
1
- 'use client'
2
-
3
- import * as RAC from 'react-aria-components'
4
- import { Hash, FileText, CornerDownLeft } from '../ui-base/icons'
5
- import { cn } from '../../utils/cn'
6
- import type { ComponentBase } from './types'
7
-
8
- export interface SearchDialogItemProps
9
- extends Omit<RAC.ListBoxItemProps, 'children'> {
10
- className?: string
11
- children: React.ReactNode
12
- }
13
-
14
- export interface SearchDialogItemIconProps {
15
- isHeading?: boolean
16
- className?: string
17
- }
18
-
19
- /**
20
- * Pure, unstyled SearchDialog Overlay (maps to RAC.ModalOverlay)
21
- */
22
- export const SearchDialog = ({
23
- className,
24
- ...props
25
- }: RAC.ModalOverlayProps) => {
26
- return (
27
- <RAC.ModalOverlay
28
- className={cn('fixed inset-0 z-100', className)}
29
- {...props}
30
- />
31
- )
32
- }
33
-
34
- /**
35
- * Pure, unstyled SearchDialog Content (maps to RAC.Modal)
36
- */
37
- const SearchDialogContent = ({
38
- className,
39
- ...props
40
- }: RAC.ModalOverlayProps) => <RAC.Modal className={cn(className)} {...props} />
41
-
42
- /**
43
- * Pure, unstyled SearchDialog Dialog (maps to RAC.Dialog)
44
- */
45
- const SearchDialogDialog = ({ className, ...props }: RAC.DialogProps) => (
46
- <RAC.Dialog
47
- className={cn('flex flex-col focus:outline-none', className)}
48
- {...props}
49
- />
50
- )
51
-
52
- /**
53
- * Pure, unstyled SearchDialog Input Field (maps to RAC.SearchField)
54
- */
55
- const SearchDialogField = ({ className, ...props }: RAC.SearchFieldProps) => (
56
- <RAC.SearchField className={cn('flex items-center', className)} {...props} />
57
- )
58
-
59
- /**
60
- * Pure, unstyled SearchInput (maps to RAC.Input)
61
- */
62
- const SearchDialogSearchInput = ({ className, ...props }: RAC.InputProps) => (
63
- <RAC.Input
64
- className={cn('w-full bg-transparent outline-none border-none', className)}
65
- {...props}
66
- />
67
- )
68
-
69
- /**
70
- * Pure, unstyled Clear Button (maps to RAC.Button with slot="clear")
71
- */
72
- const SearchDialogClearButton = ({ className, ...props }: RAC.ButtonProps) => (
73
- <RAC.Button slot="clear" className={cn(className)} {...props} />
74
- )
75
-
76
- /**
77
- * Pure, unstyled Autocomplete container (maps to RAC.Autocomplete)
78
- */
79
- const SearchDialogAutocomplete = <T extends object>({
80
- children,
81
- className,
82
- onSelectionChange,
83
- ...props
84
- }: RAC.AutocompleteProps<T> & {
85
- className?: string
86
- onSelectionChange?: (key: RAC.Key) => void
87
- }) => {
88
- const Autocomplete = RAC.Autocomplete as any
89
- return (
90
- <div className={cn('flex-1 min-h-0', className)}>
91
- <Autocomplete
92
- {...props}
93
- onSelectionChange={onSelectionChange}
94
- className="flex flex-col min-h-0"
95
- >
96
- {children}
97
- </Autocomplete>
98
- </div>
99
- )
100
- }
101
-
102
- /**
103
- * Pure, unstyled List Box (maps to RAC.ListBox)
104
- */
105
- const SearchDialogList = <T extends object>({
106
- children,
107
- className,
108
- ...props
109
- }: RAC.ListBoxProps<T> & { className?: string }) => {
110
- return (
111
- <RAC.ListBox
112
- {...props}
113
- className={cn('flex-1 overflow-y-auto outline-none min-h-0', className)}
114
- >
115
- {children as any}
116
- </RAC.ListBox>
117
- )
118
- }
119
-
120
- /**
121
- * Pure, unstyled List Box Item (maps to RAC.ListBoxItem)
122
- */
123
- const SearchDialogItemRoot = ({
124
- children,
125
- className,
126
- ...props
127
- }: SearchDialogItemProps) => {
128
- return (
129
- <RAC.ListBoxItem
130
- {...props}
131
- className={cn(
132
- 'group flex items-center outline-none cursor-pointer',
133
- className,
134
- )}
135
- >
136
- {(itemProps) => (
137
- <>
138
- {children}
139
- {(itemProps.isFocused || itemProps.isSelected) && (
140
- <div className="ml-auto opacity-50 flex items-center gap-1">
141
- <span className="text-[10px]">Select</span>
142
- <CornerDownLeft size={10} />
143
- </div>
144
- )}
145
- </>
146
- )}
147
- </RAC.ListBoxItem>
148
- )
149
- }
150
-
151
- const SearchDialogItemIcon = ({
152
- isHeading,
153
- className,
154
- }: SearchDialogItemIconProps) => {
155
- return (
156
- <div className={cn('shrink-0', className)}>
157
- {isHeading ? <Hash size={18} /> : <FileText size={18} />}
158
- </div>
159
- )
160
- }
161
-
162
- const SearchDialogItemTitle = ({ children, className }: ComponentBase) => {
163
- return (
164
- <span className={cn('block truncate flex-1', className)}>{children}</span>
165
- )
166
- }
167
-
168
- const SearchDialogItemBio = ({ children, className }: ComponentBase) => {
169
- return (
170
- <span className={cn('ml-2 truncate hidden sm:inline', className)}>
171
- {children}
172
- </span>
173
- )
174
- }
175
-
176
- // Compound API wiring
177
- SearchDialog.Root = SearchDialog
178
- SearchDialog.Overlay = SearchDialog
179
- SearchDialog.Content = SearchDialogContent
180
- SearchDialog.Dialog = SearchDialogDialog
181
- SearchDialog.Autocomplete = SearchDialogAutocomplete
182
- SearchDialog.List = SearchDialogList
183
-
184
- SearchDialog.Input = Object.assign(SearchDialogField, {
185
- SearchInput: SearchDialogSearchInput,
186
- Button: SearchDialogClearButton,
187
- })
188
-
189
- SearchDialog.Item = Object.assign(SearchDialogItemRoot, {
190
- Icon: SearchDialogItemIcon,
191
- Title: SearchDialogItemTitle,
192
- Bio: SearchDialogItemBio,
193
- })