@kolkrabbi/kol-workshop 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/search/SearchPage.jsx +8 -3
- package/src/shell/ShellLayout.jsx +22 -5
- package/src/shell/index.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-workshop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Docs viewer, shell and tag system",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"d3": "^7.9.0",
|
|
16
16
|
"@kolkrabbi/kol-brand": "^0.2.0",
|
|
17
|
-
"@kolkrabbi/kol-
|
|
18
|
-
"@kolkrabbi/kol-
|
|
17
|
+
"@kolkrabbi/kol-search": "^0.3.0",
|
|
18
|
+
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"@kolkrabbi/kol-component": ">=0.296.0",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"react-router-dom": "^6.0.0 || ^7.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@kolkrabbi/kol-framework": "^0.64.0",
|
|
33
|
-
"@kolkrabbi/kol-icons": "^0.52.0",
|
|
34
32
|
"@kolkrabbi/kol-component": "^0.316.0",
|
|
35
|
-
"@kolkrabbi/kol-
|
|
36
|
-
"@kolkrabbi/kol-
|
|
33
|
+
"@kolkrabbi/kol-icons": "^0.52.0",
|
|
34
|
+
"@kolkrabbi/kol-framework": "^0.64.0",
|
|
35
|
+
"@kolkrabbi/kol-shell": "^0.89.1",
|
|
36
|
+
"@kolkrabbi/kol-theme": "^0.199.0"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"src",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Fragment, useEffect, useMemo, useRef, useState } from 'react'
|
|
1
|
+
import { Fragment, useContext, useEffect, useMemo, useRef, useState } from 'react'
|
|
2
2
|
import { getTagColor } from '@kolkrabbi/kol-markdown'
|
|
3
3
|
import { useNavigate, useSearchParams } from 'react-router-dom'
|
|
4
4
|
import { EmptyState, Input, Tag } from '@kolkrabbi/kol-component'
|
|
5
5
|
import ResultRow from './ResultRow.jsx'
|
|
6
|
+
import { ShellSearchScopeContext } from '../shell/ShellLayout.jsx'
|
|
6
7
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
7
8
|
import { createIndex, search, parseQuery } from '@kolkrabbi/kol-search'
|
|
8
9
|
|
|
@@ -48,12 +49,16 @@ const readToken = (t) => (t.kind === 'term'
|
|
|
48
49
|
? `${t.field} ${t.value}`
|
|
49
50
|
: `${t.negate ? 'not ' : ''}${t.field === 'tags' ? 'tag' : t.field}: ${t.value}${t.via === 'smart' ? ' (from the word)' : ''}`)
|
|
50
51
|
|
|
51
|
-
export default function SearchPage({ items = [], spaces = [], facets = DEFAULT_FACETS, limit = 60, rowVariant = 'underline', rowMeta = 'facts', kindIcons, resultsPath }) {
|
|
52
|
+
export default function SearchPage({ items = [], spaces: allSpaces = [], facets = DEFAULT_FACETS, limit = 60, rowVariant = 'underline', rowMeta = 'facts', kindIcons, resultsPath }) {
|
|
52
53
|
const [params, setParams] = useSearchParams()
|
|
53
54
|
const navigate = useNavigate()
|
|
54
55
|
const q = params.get('q') ?? ''
|
|
55
56
|
const index = useMemo(() => createIndex(items), [items])
|
|
56
|
-
|
|
57
|
+
/* the shell's Settings › Search scope (WorkshopSearchScope, 2026-10-29): results and the scope row cover only the
|
|
58
|
+
* spaces in view; null (outside a shell, or All) = every space */
|
|
59
|
+
const inScope = useContext(ShellSearchScopeContext)
|
|
60
|
+
const spaces = inScope ? allSpaces.filter((sp) => inScope.includes(sp.value)) : allSpaces
|
|
61
|
+
const out = useMemo(() => search(index, q, { scope: inScope ? { space: inScope } : {}, limit }), [index, q, limit, inScope?.join('\n')])
|
|
57
62
|
|
|
58
63
|
/* `resultsPath`: the query is written to THAT route — a box on a search home sends its first
|
|
59
64
|
* keystroke straight to the results page instead of filtering in place */
|
|
@@ -55,6 +55,11 @@ export const ShellNavCollapsedContext = (globalThis[Symbol.for('@kolkrabbi/kol-w
|
|
|
55
55
|
* const meta = usePageMetaValue() — in a rail
|
|
56
56
|
* Cleared on unmount, so a page that says nothing gets an empty context, never
|
|
57
57
|
* the previous page's. */
|
|
58
|
+
/* THE SEARCH SCOPE REACHES THE RESULTS PAGE (WorkshopSearchScope, kol-hq 2026-10-29 — user: let the user choose which
|
|
59
|
+
* repos' docs are in view, *"I dont want any reinventions"*). The shell provides the space ids Settings › Search has in
|
|
60
|
+
* scope, or null for all; `SearchPage` reads it so the page and quick search cover the same spaces. */
|
|
61
|
+
export const ShellSearchScopeContext = (globalThis[Symbol.for('@kolkrabbi/kol-workshop/ShellSearchScopeContext')] ??= createContext(null))
|
|
62
|
+
|
|
58
63
|
const ShellPageMetaContext = (globalThis[Symbol.for('@kolkrabbi/kol-workshop/ShellPageMetaContext')] ??= createContext({ meta: null, setMeta: null }))
|
|
59
64
|
|
|
60
65
|
export function usePageMeta(meta) {
|
|
@@ -460,7 +465,12 @@ const ShellLayout = ({ routes = [], basePath = '/', brand: brandProp, brandLogoS
|
|
|
460
465
|
|
|
461
466
|
// Adapt the old flat `routes` + callbacks to the DS ShellHeader API
|
|
462
467
|
// (brand node · nav[{label,href,icon}] · isActive · onNavigate · actions slot).
|
|
463
|
-
|
|
468
|
+
/* THE SCOPE (WorkshopSearchScope, kol-hq 2026-10-29): `scope` is 'all' · 'this' · the picked space ids, and it
|
|
469
|
+
* replaces `limitToSpace` (an old `true` reads as 'this'). Search and the tab bar follow it; the active space's tab
|
|
470
|
+
* always stays, so the page you are on never disappears. null = every space; a Pick with nothing ticked reads as This. */
|
|
471
|
+
const scope = prefs.scope ?? (prefs.limitToSpace ? 'this' : 'all')
|
|
472
|
+
const scopedIds = Array.isArray(scope) && scope.length ? scope : scope !== 'all' && activeRoute ? [activeRoute.id] : null
|
|
473
|
+
const navItems = routes.filter((r) => !scopedIds || r === activeRoute || scopedIds.includes(r.id)).map((r) => ({
|
|
464
474
|
label: r.label,
|
|
465
475
|
href: r.path ? joinPath(r.path) : basePath,
|
|
466
476
|
icon: r.icon,
|
|
@@ -519,10 +529,10 @@ const ShellLayout = ({ routes = [], basePath = '/', brand: brandProp, brandLogoS
|
|
|
519
529
|
/* THE ENGINE IS kol-search (2026-09-28) — the search modal ran a first-substring
|
|
520
530
|
* match, so `atom` ranked AppHub first on a word in its description and only
|
|
521
531
|
* one row lit its match. Ranked now, every hit highlighted, and a word that
|
|
522
|
-
* names a category (`atom`) filters by it.
|
|
523
|
-
*
|
|
532
|
+
* names a category (`atom`) filters by it. The scope (settings) narrows quick
|
|
533
|
+
* search to the spaces in view. */
|
|
524
534
|
const searchIndex = useMemo(() => createIndex((searchItems ?? []).map(toSearchItem)), [searchItems])
|
|
525
|
-
const quickScope =
|
|
535
|
+
const quickScope = scopedIds ? { space: scopedIds } : {}
|
|
526
536
|
const searchResults = searchQuery
|
|
527
537
|
? search(searchIndex, searchQuery, { scope: quickScope, limit: 12 }).results.map(({ item, reasons, highlights }) => {
|
|
528
538
|
const titleHit = reasons.some((r) => r.field === 'title')
|
|
@@ -555,7 +565,12 @@ const ShellLayout = ({ routes = [], basePath = '/', brand: brandProp, brandLogoS
|
|
|
555
565
|
{ id: 'toc', label: 'Right rail', type: 'switch', on: !tocCollapsed, onChange: (on) => { setTocCollapsed(!on); setPref('tocHidden', !on) } },
|
|
556
566
|
] },
|
|
557
567
|
{ label: 'Search', rows: [
|
|
558
|
-
|
|
568
|
+
/* Pick starts from what was in view — This → the active space, All → every space */
|
|
569
|
+
{ id: 'scope', label: 'Scope', type: 'choice', value: Array.isArray(scope) ? 'pick' : scope,
|
|
570
|
+
options: [{ value: 'all', label: 'All' }, { value: 'this', label: 'This' }, { value: 'pick', label: 'Pick' }],
|
|
571
|
+
onChange: (v) => setPref('scope', v !== 'pick' ? v : scopedIds ?? routes.map((r) => r.id)) },
|
|
572
|
+
...(Array.isArray(scope) ? routes.map((r) => ({ id: `scope-${r.id}`, label: r.label, type: 'switch', on: scope.includes(r.id),
|
|
573
|
+
onChange: (on) => setPref('scope', on ? [...scope, r.id] : scope.filter((id) => id !== r.id)) })) : []),
|
|
559
574
|
] },
|
|
560
575
|
...settings,
|
|
561
576
|
]
|
|
@@ -568,6 +583,7 @@ const ShellLayout = ({ routes = [], basePath = '/', brand: brandProp, brandLogoS
|
|
|
568
583
|
}
|
|
569
584
|
|
|
570
585
|
return (
|
|
586
|
+
<ShellSearchScopeContext.Provider value={scopedIds}>
|
|
571
587
|
<ShellPageMetaContext.Provider value={{ meta: pageMeta, setMeta: setPageMeta }}>
|
|
572
588
|
<ShellTocContext.Provider value={setTocContent}>
|
|
573
589
|
<ShellFullHeightContext.Provider value={setIsFullHeight}>
|
|
@@ -737,6 +753,7 @@ const ShellLayout = ({ routes = [], basePath = '/', brand: brandProp, brandLogoS
|
|
|
737
753
|
</ShellFullHeightContext.Provider>
|
|
738
754
|
</ShellTocContext.Provider>
|
|
739
755
|
</ShellPageMetaContext.Provider>
|
|
756
|
+
</ShellSearchScopeContext.Provider>
|
|
740
757
|
)
|
|
741
758
|
}
|
|
742
759
|
|
package/src/shell/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* against.
|
|
8
8
|
*/
|
|
9
9
|
export { default as ShellLayout } from './ShellLayout.jsx'
|
|
10
|
-
export { ShellTocContext, ShellFullHeightContext, ShellTocCollapsedContext, ShellNavCollapsedContext, ShellContentWidthContext, SHELL_SCROLL_ROOT, usePageMeta, usePageMetaValue } from './ShellLayout.jsx'
|
|
10
|
+
export { ShellTocContext, ShellFullHeightContext, ShellTocCollapsedContext, ShellNavCollapsedContext, ShellContentWidthContext, ShellSearchScopeContext, SHELL_SCROLL_ROOT, usePageMeta, usePageMetaValue } from './ShellLayout.jsx'
|
|
11
11
|
export { default as ShellSidebar } from './ShellSidebar.jsx'
|
|
12
12
|
/* the workshop rail IS a NavRail preset (2026-10-24): `NavRail preset="workshop"` renders ShellSidebar once this
|
|
13
13
|
* package is imported — kol-component cannot import kol-workshop, so the name is registered from here */
|