@kolkrabbi/kol-component 0.307.0 → 0.309.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.307.0",
3
+ "version": "0.309.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.2.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@kolkrabbi/kol-icons": ">=0.22.0",
@@ -38,7 +38,7 @@
38
38
  "react-dom": "^18.3.0 || ^19.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@kolkrabbi/kol-icons": "^0.47.0"
41
+ "@kolkrabbi/kol-icons": "^0.51.0"
42
42
  },
43
43
  "files": [
44
44
  "src",
@@ -1,6 +1,8 @@
1
1
  import { useState } from 'react'
2
2
 
3
3
  const SIZE_MAP = {
4
+ /* xs — a rail glyph's 20 (HubAccountRow, kol-fxr 2026-10-28: the signed-in row draws the user where the glyph sits) */
5
+ xs: 'w-5 h-5 kol-helper-10',
4
6
  sm: 'w-8 h-8 kol-helper-12',
5
7
  md: 'w-10 h-10 kol-helper-14',
6
8
  lg: 'w-14 h-14 kol-helper-16',
@@ -21,7 +23,7 @@ const SIZE_MAP = {
21
23
  * @param {string} [src] resolved image src — the consumer resolves it, this
22
24
  * atom never builds a URL
23
25
  * @param {string} [alt=''] photo alt text
24
- * @param {'sm'|'md'|'lg'|'xl'} [size='sm']
26
+ * @param {'xs'|'sm'|'md'|'lg'|'xl'} [size='sm'] `xs` is 20, a rail row's glyph
25
27
  */
26
28
  export default function Avatar({ initial, src, alt = '', size = 'sm', className = '' }) {
27
29
  const sizeCls = SIZE_MAP[size] ?? SIZE_MAP.sm
@@ -1,7 +1,11 @@
1
1
  import { useState, useEffect } from 'react'
2
2
 
3
3
  /**
4
- * Logomark — An inlined SVG mark. fetches and INLINES an SVG so currentColor theming works: an
4
+ * VectorLoader — ANY SVG by URL, fetched and INLINED so `currentColor` theming works (`Logomark` until kol-component
5
+ * 0.308.0 — user 2026-10-28: "Logomark is the loader Im talking about, it just has a terrible name"; the old name
6
+ * stays an alias on the retirements ledger). `src` is the URL; `svgUrl` is the old prop and still works. Pair it
7
+ * with a path export — `@kolkrabbi/kol-icons/identity/kolkrabbi/kolkrabbi-wordmark.svg?url` — or any file of your own.
8
+ * Fetches and inlines so currentColor theming works: an
5
9
  * <img> renders a currentColor mark black in dark mode (invisible). Ported
6
10
  * verbatim from the kol-mirror cut (module-level cache; async resolve even on
7
11
  * cache hit — sync setState in an effect cascades renders).
@@ -38,19 +42,20 @@ function sanitizeSvg(svg) {
38
42
  }
39
43
  }
40
44
 
41
- export default function Logomark({ svgUrl, size = 20, className = '', ...props }) {
42
- const [svgContent, setSvgContent] = useState(() => svgCache.get(svgUrl) || null)
45
+ export default function VectorLoader({ src, svgUrl, size = 20, className = '', ...props }) {
46
+ const url = src ?? svgUrl
47
+ const [svgContent, setSvgContent] = useState(() => svgCache.get(url) || null)
43
48
 
44
49
  useEffect(() => {
45
- if (!svgUrl) return
50
+ if (!url) return
46
51
  let active = true
47
52
  Promise.resolve(
48
- svgCache.get(svgUrl) ?? fetch(svgUrl).then(res => res.text()).then(raw => { const svg = sanitizeSvg(raw); svgCache.set(svgUrl, svg); return svg })
53
+ svgCache.get(url) ?? fetch(url).then(res => res.text()).then(raw => { const svg = sanitizeSvg(raw); svgCache.set(url, svg); return svg })
49
54
  )
50
55
  .then(svg => { if (active) setSvgContent(svg) })
51
56
  .catch(() => {})
52
57
  return () => { active = false }
53
- }, [svgUrl])
58
+ }, [url])
54
59
 
55
60
  if (!svgContent) return <span style={{ width: size, height: size, display: 'inline-block' }} />
56
61
 
package/src/index.js CHANGED
@@ -183,7 +183,8 @@ export { default as PageHeader, PAGE_HEADER_ROLES } from './molecules/PageHeader
183
183
  /* the one nav rail (2026-10-22) — `variant` app (the flat 48px rail) · site (the grouped site
184
184
  * sidebar, kol-framework's SideNav until then). Moved from kol-shell, which re-exports all three. */
185
185
  export { default as NavRail, RAIL_PRESETS, registerRailPreset } from './organisms/NavRail.jsx'
186
- export { default as Logomark } from './atoms/Logomark.jsx'
186
+ /* any SVG by URL, inlined — `Logomark` until 0.308.0 (2026-10-28: "it just has a terrible name"); the alias is on the ledger */
187
+ export { default as VectorLoader, default as Logomark } from './atoms/VectorLoader.jsx'
187
188
  export { RailSlotProvider, useRailSlot } from './hooks/railSlot.jsx'
188
189
  export { MastheadContext, MASTHEADS, useMasthead, mastheadTitleClass } from './utilities/masthead.js'
189
190
  export { default as ErrorBoundary } from './utilities/ErrorBoundary.jsx'
@@ -23,6 +23,15 @@ import ToggleCheckbox from '../atoms/ToggleCheckbox.jsx'
23
23
  * masks the field (`autoComplete="current-password"`) for the family's sign-in prompts. The
24
24
  * native fallback cannot mask — mount a ModalProvider. `placeholder` sits in the same options.
25
25
  *
26
+ * FORM (HubAccountRow, kol-fxr 2026-10-28 — sign-in asks Email AND Password): `form(title, fields, { okLabel, cancelLabel })`
27
+ * draws one field per `{ id, placeholder, type?, autoComplete?, defaultValue? }` and resolves `{ [id]: value }` on submit,
28
+ * `null` on cancel. The first field takes the focus; Enter in any field submits.
29
+ *
30
+ * THE PAGE HOLDS STILL UNDER THE KEYBOARD (PromptHoldsWithKeyboard, kol-fxr 2026-10-28 — user: *"does the UI have to move
31
+ * upp to show keyboard?"*): every dialog sits in the VISUAL viewport (`visualViewport` resize/scroll), so on an iPhone it
32
+ * rides above the keyboard; a field takes its focus without scrolling (`preventScroll`), and the document's scroll is put
33
+ * back when the keyboard closes and when the dialog does.
34
+ *
26
35
  * KEYBOARD: the dialog opens focused (prompt → its field, confirm/alert → OK), Tab cycles inside
27
36
  * it, and Enter on a focused button presses that button rather than submitting.
28
37
  *
@@ -77,8 +86,12 @@ export function ModalProvider({ children }) {
77
86
  new Promise((resolve) => setState({ kind: 'alert', title, okLabel, resolve })),
78
87
  [])
79
88
 
89
+ const form = useCallback((title, fields = [], { okLabel, cancelLabel } = {}) =>
90
+ new Promise((resolve) => setState({ kind: 'form', title, fields, okLabel, cancelLabel, resolve })),
91
+ [])
92
+
80
93
  return (
81
- <ModalCtx.Provider value={{ prompt, confirm, alert }}>
94
+ <ModalCtx.Provider value={{ prompt, confirm, alert, form }}>
82
95
  {children}
83
96
  {state && typeof document !== 'undefined' && createPortal(
84
97
  <ModalView state={state} closeWith={closeWith} />,
@@ -91,18 +104,47 @@ export function ModalProvider({ children }) {
91
104
  function ModalView({ state, closeWith }) {
92
105
  const [val, setVal] = useState(state.defaultValue ?? '')
93
106
  const [values, setValues] = useState(() => Object.fromEntries((state.options ?? []).map((o) => [o.id, !!o.defaultValue])))
107
+ const [fieldVals, setFieldVals] = useState(() => Object.fromEntries((state.fields ?? []).map((f) => [f.id, f.defaultValue ?? ''])))
94
108
  const inputRef = useRef(null)
95
109
  const dialogRef = useRef(null)
110
+ const overlayRef = useRef(null)
111
+ const typing = state.kind === 'prompt' || state.kind === 'form'
112
+
113
+ /* the visual viewport (PromptHoldsWithKeyboard): the scrim is sized to it, so the dialog centres above the keyboard
114
+ * instead of the browser scrolling the page to clear it; the scroll the page had is restored when the keyboard goes
115
+ * (the visual viewport back to full height) and when the dialog closes */
116
+ useEffect(() => {
117
+ if (typeof window === 'undefined') return undefined
118
+ const y0 = window.scrollY
119
+ const vv = window.visualViewport
120
+ const fit = () => {
121
+ const el = overlayRef.current
122
+ if (!vv || !el) return
123
+ el.style.top = `${vv.offsetTop}px`
124
+ el.style.left = `${vv.offsetLeft}px`
125
+ el.style.width = `${vv.width}px`
126
+ el.style.height = `${vv.height}px`
127
+ if (vv.height >= window.innerHeight - 1 && window.scrollY !== y0) window.scrollTo(0, y0)
128
+ }
129
+ fit()
130
+ vv?.addEventListener('resize', fit)
131
+ vv?.addEventListener('scroll', fit)
132
+ return () => {
133
+ vv?.removeEventListener('resize', fit)
134
+ vv?.removeEventListener('scroll', fit)
135
+ if (window.scrollY !== y0) window.scrollTo(0, y0)
136
+ }
137
+ }, [])
96
138
 
97
139
  /* alert resolves `undefined` whichever way it is dismissed; a confirm with toggles resolves
98
140
  * `{ ok, values }` */
99
141
  const answer = (ok) => (state.options ? { ok, values } : ok)
100
- const submit = () => closeWith(state.kind === 'prompt' ? val : state.kind === 'alert' ? undefined : answer(true))
101
- const cancel = () => closeWith(state.kind === 'prompt' ? null : state.kind === 'alert' ? undefined : answer(false))
142
+ const submit = () => closeWith(state.kind === 'prompt' ? val : state.kind === 'form' ? fieldVals : state.kind === 'alert' ? undefined : answer(true))
143
+ const cancel = () => closeWith(typing ? null : state.kind === 'alert' ? undefined : answer(false))
102
144
 
103
145
  /* focus once on open — the key effect below re-runs per keystroke and would steal it back */
104
146
  useEffect(() => {
105
- if (state.kind === 'prompt') inputRef.current?.focus()
147
+ if (typing) inputRef.current?.focus({ preventScroll: true })
106
148
  else dialogRef.current?.querySelector('[data-modal-ok]')?.focus()
107
149
  }, [state.kind])
108
150
 
@@ -121,10 +163,11 @@ function ModalView({ state, closeWith }) {
121
163
  }
122
164
  window.addEventListener('keydown', onKey)
123
165
  return () => window.removeEventListener('keydown', onKey)
124
- }, [state.kind, val, values, closeWith]) // eslint-disable-line react-hooks/exhaustive-deps
166
+ }, [state.kind, val, values, fieldVals, closeWith]) // eslint-disable-line react-hooks/exhaustive-deps
125
167
 
126
168
  return (
127
169
  <div
170
+ ref={overlayRef}
128
171
  onMouseDown={cancel}
129
172
  /* THE scrim (overlay-scrim-outliers sweep, 2026-09-03): the docs said Modal
130
173
  wore `.kol-overlay-scrim`; the source drew a raw `rgba(0,0,0,0.5)`. The
@@ -137,7 +180,7 @@ function ModalView({ state, closeWith }) {
137
180
  >
138
181
  <div
139
182
  ref={dialogRef}
140
- role={state.kind === 'prompt' ? 'dialog' : 'alertdialog'}
183
+ role={typing ? 'dialog' : 'alertdialog'}
141
184
  aria-modal="true"
142
185
  aria-labelledby="kol-modal-title"
143
186
  onMouseDown={(e) => e.stopPropagation()}
@@ -166,6 +209,21 @@ function ModalView({ state, closeWith }) {
166
209
  className="w-full"
167
210
  />
168
211
  )}
212
+ {state.kind === 'form' && state.fields.map((f, i) => (
213
+ <Input
214
+ key={f.id}
215
+ ref={i === 0 ? inputRef : undefined}
216
+ type={f.type ?? 'text'}
217
+ autoComplete={f.autoComplete}
218
+ placeholder={f.placeholder}
219
+ aria-label={f.placeholder ?? f.id}
220
+ variant="outline"
221
+ size="sm"
222
+ value={fieldVals[f.id]}
223
+ onChange={(e) => setFieldVals((v) => ({ ...v, [f.id]: e.target.value }))}
224
+ className="w-full"
225
+ />
226
+ ))}
169
227
  {state.options && (
170
228
  <div className="flex flex-col gap-3">
171
229
  {state.options.map((o) => (
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
2
  import gsap from 'gsap'
3
- /* taxonomy-ok: organism — nests Button (atom) + Logomark (atom) + Tooltip (utility). Moved
3
+ /* taxonomy-ok: organism — nests Button (atom) + VectorLoader (atom) + Tooltip (utility). Moved
4
4
  * from kol-shell 2026-10-22 (the one nav rail, user: "lets go for your recommendation"): the
5
5
  * app rail and the site rail are one component, and a site must not install the app shell
6
6
  * for its sidebar — the PageHeader precedent. kol-shell re-exports it. */
@@ -13,7 +13,7 @@ import { GRAB } from '../utilities/motion.js'
13
13
  * built the gesture itself). It lived here until then. */
14
14
  import useGrabEdge from '../hooks/useGrabEdge.js'
15
15
  import { Icon } from '@kolkrabbi/kol-icons'
16
- import Logomark from '../atoms/Logomark.jsx'
16
+ import VectorLoader from '../atoms/VectorLoader.jsx'
17
17
  import { useRailSlot } from '../hooks/railSlot.jsx'
18
18
  import { RAIL_ROW } from '../hooks/railRow.js'
19
19
  import NavRailSite from './NavRailSite.jsx'
@@ -408,7 +408,7 @@ function AppRail({
408
408
  onClick={() => onNavigate?.('/')}
409
409
  className="text-oq-96 cursor-pointer flex items-center gap-3 w-full overflow-hidden shrink-0 pt-1 mb-4"
410
410
  >
411
- <span className="w-8 flex justify-center shrink-0"><Logomark svgUrl={logomark.svgUrl} size={20} /></span>
411
+ <span className="w-8 flex justify-center shrink-0"><VectorLoader src={logomark.svgUrl} size={20} /></span>
412
412
  <span className="kol-helper-12 uppercase flex-1 min-w-0 truncate">{logomark.title}</span>
413
413
  </div>
414
414
  </Tooltip>
@@ -126,8 +126,12 @@ import useDragResize from '../hooks/useDragResize.js'
126
126
  * THE RAIL'S BEHAVIOURS ARE PROPS (SiteRailTitleNavigatesOnly, kol-branding 2026-10-27 — user: "clicking on title
127
127
  * shouldnt also expand, that is what the chevron is for", and: a small rail behaviour should never need a ticket here —
128
128
  * a sensible default plus a prop the consumer sets in its own repo):
129
- * `discloseOnTitle` `true` lets a foldernote's TITLE also open its pages; default `false` — the title navigates, the
130
- * chevron alone expands and collapses
129
+ * `discloseOnTitle` `true` lets a foldernote's TITLE also open its pages; default `false` — the title navigates, and
130
+ * the rest of the row (everything right of the title, the chevron at its end) expands and collapses
131
+ * (2026-10-28: "it should expand anywhere except the title")
132
+ * `fade` `true` (default) — the tree fades out at its foot where the window clips it, as the app rail and
133
+ * the workshop rail do (2026-10-28: "we also are missing a fade when list clips in navrail");
134
+ * `false` draws it plain
131
135
  * `defaultOpen` category ids open on first render (default none — the rail loads closed, elder ruling 2026-08-06)
132
136
  * `openOnRoute` `true` opens the category holding the current route whenever the route changes (default `false`
133
137
  * — nothing auto-expands on arrival); it only adds, never closes what you opened
@@ -204,6 +208,7 @@ export default function NavRailSite({
204
208
  expandOnSelect = false,
205
209
  defaultCollapsed = false,
206
210
  discloseOnTitle = false,
211
+ fade = true,
207
212
  defaultOpen = [],
208
213
  openOnRoute = false,
209
214
  }) {
@@ -368,24 +373,28 @@ export default function NavRailSite({
368
373
  definition, and an <a href> would promise a page that does
369
374
  not exist. Clicking it discloses its pages. */
370
375
  const head = isFolder ? (
371
- /* the row opens the page (and discloses only with `discloseOnTitle`); the caret beside it (a sibling — a
372
- * button cannot sit inside a link) toggles the disclosure */
376
+ /* THE TITLE NAVIGATES, THE REST OF THE ROW EXPANDS (user 2026-10-28: *"it should expand anywhere except the
377
+ * title, so press title > get overview, press the row f.e. on right of the title, expand category"* — the
378
+ * 12px chevron was the only target). The link keeps the row's full box and wash but only its glyph and title
379
+ * take the pointer (`.kol-sidenav-hop--split`); the caret is a button under it filling the whole row
380
+ * (`.kol-sidenav-hop-caret--row`), the chevron at its end, so a press anywhere else on the row lands on it.
381
+ * `discloseOnTitle` still lets the title open its pages too. Collapsed, the link takes the whole row again. */
373
382
  <>
374
- <RouteLeaf {...leafProps(cat.to)} onPress={discloseOnTitle ? () => discloseCat(cat.id) : undefined} className={(active) => `${rowCls}${(active || isActiveCat(cat)) ? ' is-active' : ''}`}>
375
- {glyph}
376
- <span className="kol-sidenav-hop-label flex-1 min-w-0">{cat.label}</span>
377
- </RouteLeaf>
378
383
  <button
379
384
  type="button"
380
385
  /* no display utility on the caret — it would outrank the collapsed rule's display:none (the 2026-08-09 defect; the
381
386
  * box lives in .kol-sidenav-hop-caret, kol-framework.css) */
382
- className={`kol-sidenav-hop-caret bg-transparent border-0 cursor-pointer p-0 text-emphasis${isOpen ? '' : ' -rotate-90'}`}
387
+ className="kol-sidenav-hop-caret kol-sidenav-hop-caret--row bg-transparent border-0 cursor-pointer pt-3 pr-4 pb-0 pl-0 text-emphasis"
383
388
  aria-expanded={isOpen}
384
389
  aria-label={isOpen ? `Collapse ${cat.label}` : `Expand ${cat.label}`}
385
390
  onClick={() => (collapsed ? (expandOnSelect && toggleCollapsed(), discloseCat(cat.id)) : toggleCat(cat.id))}
386
391
  >
387
- <Icon name="chevron-down" size={12} />
392
+ <span className={`kol-sidenav-hop-chevron${isOpen ? '' : ' -rotate-90'}`}><Icon name="chevron-down" size={12} /></span>
388
393
  </button>
394
+ <RouteLeaf {...leafProps(cat.to)} onPress={discloseOnTitle ? () => discloseCat(cat.id) : undefined} className={(active) => `${rowCls} kol-sidenav-hop--split${(active || isActiveCat(cat)) ? ' is-active' : ''}`}>
395
+ {glyph}
396
+ <span className="kol-sidenav-hop-label flex-1 min-w-0"><span className="kol-sidenav-hop-title">{cat.label}</span></span>
397
+ </RouteLeaf>
389
398
  </>
390
399
  ) : isLink ? (
391
400
  <RouteLeaf {...leafProps(cat.to)} className={(active) => `${rowCls}${active ? ' is-active' : ''}`}>
@@ -449,7 +458,7 @@ export default function NavRailSite({
449
458
  {/* ONE TREE IN BOTH STATES (2026-10-24, the clip model): the Tooltip wraps the row expanded too,
450
459
  disabled — wrapping only when collapsed rebuilt every row on the toggle, losing hover and
451
460
  focus and flashing the rail. Portalled, so overflow can't clip it. */}
452
- <Tooltip label={cat.label} placement="right" triggerClassName="block" disabled={!collapsed}>
461
+ <Tooltip label={cat.label} placement="right" triggerClassName={isFolder ? 'block relative kol-sidenav-hop-split' : 'block'} disabled={!collapsed}>
453
462
  {head}
454
463
  </Tooltip>
455
464
 
@@ -482,7 +491,7 @@ export default function NavRailSite({
482
491
  * collapsed tree they scrolled off below the footer — "pinned" only
483
492
  * held while the tree was shorter than the rail. They are the block
484
493
  * after it now, above the footer, the tree scrolling underneath. */}
485
- <div className="kol-sidenav-scroll flex-1 overflow-y-auto pt-4 pb-4 [scrollbar-width:thin]">
494
+ <div className={`kol-sidenav-scroll flex-1 overflow-y-auto pt-4 [scrollbar-width:thin] ${fade ? 'pb-12 kol-sidenav-scroll--fade' : 'pb-4'}`}>
486
495
  <nav aria-label="Sections">
487
496
  <ul className="kol-sidenav-tree flex flex-col gap-[2px]">
488
497
  {navTree.map(renderCat)}