@kolkrabbi/kol-workshop 0.48.0 → 0.49.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/kol-workshop",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "private": false,
5
5
  "description": "Docs viewer, shell and tag system",
6
6
  "license": "MIT",
@@ -13,12 +13,12 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "d3": "^7.9.0",
16
- "@kolkrabbi/kol-brand": "^0.2.0",
17
16
  "@kolkrabbi/kol-markdown": "^0.2.0",
18
- "@kolkrabbi/kol-search": "^0.3.0"
17
+ "@kolkrabbi/kol-search": "^0.3.0",
18
+ "@kolkrabbi/kol-brand": "^0.2.0"
19
19
  },
20
20
  "peerDependencies": {
21
- "@kolkrabbi/kol-component": ">=0.355.0",
21
+ "@kolkrabbi/kol-component": ">=0.396.0",
22
22
  "@kolkrabbi/kol-framework": ">=0.63.0",
23
23
  "@kolkrabbi/kol-shell": ">=0.89.0",
24
24
  "@kolkrabbi/kol-theme": ">=0.165.0",
@@ -29,11 +29,11 @@
29
29
  "react-router-dom": "^6.0.0 || ^7.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@kolkrabbi/kol-component": "^0.358.0",
33
- "@kolkrabbi/kol-framework": "^0.74.0",
34
- "@kolkrabbi/kol-icons": "^0.68.0",
35
- "@kolkrabbi/kol-shell": "^0.118.0",
36
- "@kolkrabbi/kol-theme": "^0.217.0"
32
+ "@kolkrabbi/kol-component": "^0.397.0",
33
+ "@kolkrabbi/kol-icons": "^0.75.0",
34
+ "@kolkrabbi/kol-theme": "^0.242.0",
35
+ "@kolkrabbi/kol-framework": "^0.74.1",
36
+ "@kolkrabbi/kol-shell": "^0.138.0"
37
37
  },
38
38
  "files": [
39
39
  "src",
@@ -149,7 +149,7 @@ export default function SearchPage({ items = [], spaces: allSpaces = [], facets
149
149
  <div className="flex flex-wrap items-center gap-2">
150
150
  <span className="kol-doc-eyebrow">Read as</span>
151
151
  {tokens.map((t, i) => (
152
- <Tag key={`${t.raw}-${i}`} hash={false} variant="secondary" onRemove={() => removeToken(t.raw)} aria-label={`Remove ${t.raw}`}>{readToken(t)}</Tag>
152
+ <Tag key={`${t.raw}-${i}`} hash={false} variant="secondary" onRemove={() => removeToken(t.raw)} removeLabel={`Remove ${t.raw}`}>{readToken(t)}</Tag>
153
153
  ))}
154
154
  </div>
155
155
  )}
@@ -216,6 +216,37 @@ const quickList = (ranked) => {
216
216
  return out.slice(0, QUICK_MAX)
217
217
  }
218
218
 
219
+ /* PAGES FIRST (his ruling 2026-11-20, plan W17.2: *"the pages have to be suggested before content within them"*): an item
220
+ * carrying `within` is something found inside a page (an icon), not a page. Every page is listed before any of it; what
221
+ * is inside pages follows, one heading per `within`, its best WITHIN_MAX rows, then one row to `withinHref?q=` (the full
222
+ * catalog, the typed word carried over). */
223
+ const WITHIN_MAX = 5
224
+ const toRow = ({ item, reasons, highlights }) => {
225
+ const titleHit = reasons.some((r) => r.field === 'title')
226
+ const first = reasons.find((r) => r.hit)
227
+ return {
228
+ id: item.id,
229
+ label: item.title,
230
+ group: item.within ?? item.category,
231
+ hint: titleHit ? item.hint : (first?.hit ?? item.description ?? item.hint),
232
+ href: item.href,
233
+ highlights: highlights.title,
234
+ /* `action` survives the reshape — a row may run a closure instead of going somewhere */
235
+ action: item.action,
236
+ }
237
+ }
238
+ const quickRows = (ranked, q) => {
239
+ const inside = new Map()
240
+ ranked.forEach((r) => { if (r.item.within) inside.set(r.item.within, [...(inside.get(r.item.within) ?? []), r]) })
241
+ return [
242
+ ...quickList(ranked.filter((r) => !r.item.within)).map(toRow),
243
+ ...[...inside].flatMap(([within, hits]) => [
244
+ ...hits.slice(0, WITHIN_MAX).map(toRow),
245
+ ...(hits[0].item.withinHref ? [{ id: `within:${within}`, label: `All ${within.toLowerCase()} for “${q}”`, group: within, hint: `${hits.length}`, href: `${hits[0].item.withinHref}?q=${encodeURIComponent(q)}` }] : []),
246
+ ]),
247
+ ]
248
+ }
249
+
219
250
  const toSearchItem = (item, i) => ({
220
251
  ...item,
221
252
  id: item.id ?? item.href ?? `${item.label ?? item.title}-${i}`,
@@ -552,22 +583,17 @@ const ShellLayout = ({ routes = [], basePath = '/', brand: brandProp, brandLogoS
552
583
  * search to the spaces in view. */
553
584
  const searchIndex = useMemo(() => createIndex((searchItems ?? []).map(toSearchItem)), [searchItems])
554
585
  const quickScope = scopedIds ? { space: scopedIds } : {}
555
- const searchResults = searchQuery
556
- ? quickList(search(searchIndex, searchQuery, { scope: quickScope }).results).map(({ item, reasons, highlights }) => {
557
- const titleHit = reasons.some((r) => r.field === 'title')
558
- const first = reasons.find((r) => r.hit)
559
- return {
560
- id: item.id,
561
- label: item.title,
562
- group: item.category,
563
- hint: titleHit ? item.hint : (first?.hit ?? item.description ?? item.hint),
564
- href: item.href,
565
- highlights: highlights.title,
566
- /* `action` survives the reshape — a row may run a closure instead of going somewhere */
567
- action: item.action,
568
- }
569
- })
570
- : []
586
+ /* a word that names a facet is read as its filter (`icons` → kind icon), which would hide the pages titled with it:
587
+ * the same word as plain text finds them, and they lead (plan-2026-11-20 W17.2) */
588
+ const searchResults = searchQuery ? (() => {
589
+ const q = searchQuery.trim()
590
+ const ranked = search(searchIndex, searchQuery, { scope: quickScope }).results
591
+ const titled = /^[^-"#][^":]*$/.test(q)
592
+ ? search(searchIndex, `"${q}"`, { scope: quickScope }).results.filter((r) => !r.item.within && r.reasons.some((x) => x.field === 'title'))
593
+ : []
594
+ const ids = new Set(titled.map((r) => r.item.id))
595
+ return quickRows([...titled, ...ranked.filter((r) => !ids.has(r.item.id))], q)
596
+ })() : []
571
597
  const openResultsPage = () => {
572
598
  const q = searchQuery.trim()
573
599
  closeSearch()