@kolkrabbi/kol-component 0.304.0 → 0.305.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-component",
3
- "version": "0.304.0",
3
+ "version": "0.305.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "embla-carousel-react": "^8.6.0",
27
27
  "pdfjs-dist": "^6.3.289",
28
28
  "react-syntax-highlighter": "^16.1.1",
29
- "@kolkrabbi/kol-markdown": "^0.1.3",
30
- "@kolkrabbi/kol-search": "^0.3.0"
29
+ "@kolkrabbi/kol-search": "^0.3.0",
30
+ "@kolkrabbi/kol-markdown": "^0.1.3"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@kolkrabbi/kol-icons": ">=0.22.0",
@@ -121,6 +121,14 @@ import useDragResize from '../hooks/useDragResize.js'
121
121
  * ruling "pressing any icon would expand the sidebar"): a
122
122
  * collapsed rail stays collapsed, the press does its job
123
123
  * `defaultCollapsed` boots collapsed when nothing is stored (useDragResize)
124
+ * THE RAIL'S BEHAVIOURS ARE PROPS (SiteRailTitleNavigatesOnly, kol-branding 2026-10-27 — user: "clicking on title
125
+ * shouldnt also expand, that is what the chevron is for", and: a small rail behaviour should never need a ticket here —
126
+ * a sensible default plus a prop the consumer sets in its own repo):
127
+ * `discloseOnTitle` `true` lets a foldernote's TITLE also open its pages; default `false` — the title navigates, the
128
+ * chevron alone expands and collapses
129
+ * `defaultOpen` category ids open on first render (default none — the rail loads closed, elder ruling 2026-08-06)
130
+ * `openOnRoute` `true` opens the category holding the current route whenever the route changes (default `false`
131
+ * — nothing auto-expands on arrival); it only adds, never closes what you opened
124
132
  * `background` (2026-08-09, prop): `true` (default) paints the rail surface;
125
133
  * `false` renders chromeless so the rail can float over a consumer's media
126
134
  * (the brand-hero model — the consumer owns the plane). `hairline` (2026-08-26,
@@ -193,6 +201,9 @@ export default function NavRailSite({
193
201
  iconComponent,
194
202
  expandOnSelect = false,
195
203
  defaultCollapsed = false,
204
+ discloseOnTitle = false,
205
+ defaultOpen = [],
206
+ openOnRoute = false,
196
207
  }) {
197
208
  const Glyph = iconComponent ?? Icon
198
209
  const isPageActive = (to) => (isActive ? isActive(to) : pathname === to)
@@ -226,7 +237,7 @@ export default function NavRailSite({
226
237
  /* Which categories are disclosed. INDEPENDENT per category (elder ruling
227
238
  * 2026-08-01) — arriving somewhere must not silently close wherever you
228
239
  * were. Loads closed, in-memory only (elder ruling 2026-08-06). */
229
- const [openCats, setOpenCats] = useState(() => new Set())
240
+ const [openCats, setOpenCats] = useState(() => new Set(defaultOpen))
230
241
  /* the ONE open panel leaf (by id) and where its panel sits */
231
242
  const [openPanel, setOpenPanel] = useState(null)
232
243
  const [panelBox, setPanelBox] = useState(null)
@@ -236,6 +247,13 @@ export default function NavRailSite({
236
247
  return next
237
248
  })
238
249
  const discloseCat = (id) => setOpenCats((prev) => new Set(prev).add(id))
250
+ /* `openOnRoute`: the category holding the route opens on arrival, adding to what is open */
251
+ useEffect(() => {
252
+ if (!openOnRoute) return
253
+ const here = [...navTree, ...bottomItems].find((c) => c.id != null && (isActiveCat(c) || (c.to && isPageActive(c.to))))
254
+ if (here) discloseCat(here.id)
255
+ // eslint-disable-next-line react-hooks/exhaustive-deps
256
+ }, [openOnRoute, pathname])
239
257
 
240
258
  /* One collapse contract, two gestures — the hook owns the stamp, the
241
259
  * storage schema and the state; the chip Button and the grab edge both
@@ -348,10 +366,10 @@ export default function NavRailSite({
348
366
  definition, and an <a href> would promise a page that does
349
367
  not exist. Clicking it discloses its pages. */
350
368
  const head = isFolder ? (
351
- /* the row opens the page and discloses; the caret beside it (a sibling — a button cannot sit
352
- * inside a link) toggles the disclosure alone */
369
+ /* the row opens the page (and discloses only with `discloseOnTitle`); the caret beside it (a sibling — a
370
+ * button cannot sit inside a link) toggles the disclosure */
353
371
  <>
354
- <RouteLeaf {...leafProps(cat.to)} onPress={() => discloseCat(cat.id)} className={(active) => `${rowCls}${(active || isActiveCat(cat)) ? ' is-active' : ''}`}>
372
+ <RouteLeaf {...leafProps(cat.to)} onPress={discloseOnTitle ? () => discloseCat(cat.id) : undefined} className={(active) => `${rowCls}${(active || isActiveCat(cat)) ? ' is-active' : ''}`}>
355
373
  {glyph}
356
374
  <span className="kol-sidenav-hop-label flex-1 min-w-0">{cat.label}</span>
357
375
  </RouteLeaf>