@kolkrabbi/kol-component 0.336.1 → 0.338.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.
|
|
3
|
+
"version": "0.338.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"embla-carousel-react": "^8.6.0",
|
|
30
30
|
"pdfjs-dist": "^6.3.289",
|
|
31
31
|
"react-syntax-highlighter": "^16.1.1",
|
|
32
|
+
"@kolkrabbi/kol-markdown": "^0.2.0",
|
|
32
33
|
"@kolkrabbi/kol-search": "^0.3.0",
|
|
33
|
-
"@kolkrabbi/kol-growth": "^0.5.0"
|
|
34
|
-
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
34
|
+
"@kolkrabbi/kol-growth": "^0.5.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@kolkrabbi/kol-icons": ">=0.61.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^18.3.0 || ^19.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@kolkrabbi/kol-icons": "^0.
|
|
45
|
+
"@kolkrabbi/kol-icons": "^0.64.0"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"src",
|
package/src/molecules/Modal.jsx
CHANGED
|
@@ -72,6 +72,15 @@ import QuickLookHeader from './QuickLookHeader.jsx'
|
|
|
72
72
|
*
|
|
73
73
|
* Mounted once at the app root (BrandLayout). Renders into `document.body`
|
|
74
74
|
* via portal, so it floats above any rail / scroll-context.
|
|
75
|
+
*
|
|
76
|
+
* CONTAINER (float-operational W2, 2026-11-04 — a specimen page shows the confirm open inside its box): `container`
|
|
77
|
+
* (an Element) is the portal target instead of `<body>`; the scrim turns `absolute` and fills that element (give it
|
|
78
|
+
* `position: relative` and a height), the visual-viewport fit is skipped, the focus does not scroll the page and the
|
|
79
|
+
* keys (Tab, Enter, Esc) are heard inside the box only.
|
|
80
|
+
* Unset, nothing changes.
|
|
81
|
+
*
|
|
82
|
+
* const [box, setBox] = useState(null)
|
|
83
|
+
* <div ref={setBox} className="relative h-[420px]"><ModalProvider container={box}>…</ModalProvider></div>
|
|
75
84
|
*/
|
|
76
85
|
|
|
77
86
|
const ModalCtx = (globalThis[Symbol.for('@kolkrabbi/kol-component/ModalCtx')] ??= createContext(null))
|
|
@@ -87,7 +96,7 @@ const MODAL_VARIANTS = {
|
|
|
87
96
|
}
|
|
88
97
|
const modalVariant = (v, fallback) => MODAL_VARIANTS[v] ?? MODAL_VARIANTS[fallback]
|
|
89
98
|
|
|
90
|
-
export function ModalProvider({ children, variant = 'bordered' }) {
|
|
99
|
+
export function ModalProvider({ children, variant = 'bordered', container }) {
|
|
91
100
|
const [state, setState] = useState(null)
|
|
92
101
|
|
|
93
102
|
const closeWith = useCallback((value) => {
|
|
@@ -117,14 +126,14 @@ export function ModalProvider({ children, variant = 'bordered' }) {
|
|
|
117
126
|
<ModalCtx.Provider value={{ prompt, confirm, alert, form }}>
|
|
118
127
|
{children}
|
|
119
128
|
{state && typeof document !== 'undefined' && createPortal(
|
|
120
|
-
<ModalView state={state} closeWith={closeWith} variant={state.variant ?? variant} />,
|
|
121
|
-
document.body,
|
|
129
|
+
<ModalView state={state} closeWith={closeWith} variant={state.variant ?? variant} contained={!!container} />,
|
|
130
|
+
container ?? document.body,
|
|
122
131
|
)}
|
|
123
132
|
</ModalCtx.Provider>
|
|
124
133
|
)
|
|
125
134
|
}
|
|
126
135
|
|
|
127
|
-
function ModalView({ state, closeWith, variant }) {
|
|
136
|
+
function ModalView({ state, closeWith, variant, contained }) {
|
|
128
137
|
const look = modalVariant(variant, 'bordered')
|
|
129
138
|
const float = variant === 'float'
|
|
130
139
|
const [val, setVal] = useState(state.defaultValue ?? '')
|
|
@@ -139,7 +148,7 @@ function ModalView({ state, closeWith, variant }) {
|
|
|
139
148
|
* instead of the browser scrolling the page to clear it; the scroll the page had is restored when the keyboard goes
|
|
140
149
|
* (the visual viewport back to full height) and when the dialog closes */
|
|
141
150
|
useEffect(() => {
|
|
142
|
-
if (typeof window === 'undefined') return undefined
|
|
151
|
+
if (typeof window === 'undefined' || contained) return undefined
|
|
143
152
|
const y0 = window.scrollY
|
|
144
153
|
const vv = window.visualViewport
|
|
145
154
|
const fit = () => {
|
|
@@ -170,7 +179,7 @@ function ModalView({ state, closeWith, variant }) {
|
|
|
170
179
|
/* focus once on open — the key effect below re-runs per keystroke and would steal it back */
|
|
171
180
|
useEffect(() => {
|
|
172
181
|
if (typing) inputRef.current?.focus({ preventScroll: true })
|
|
173
|
-
else dialogRef.current?.querySelector('[data-modal-ok]')?.focus()
|
|
182
|
+
else dialogRef.current?.querySelector('[data-modal-ok]')?.focus(contained ? { preventScroll: true } : undefined)
|
|
174
183
|
}, [state.kind])
|
|
175
184
|
|
|
176
185
|
useEffect(() => {
|
|
@@ -186,8 +195,10 @@ function ModalView({ state, closeWith, variant }) {
|
|
|
186
195
|
els[next].focus()
|
|
187
196
|
}
|
|
188
197
|
}
|
|
189
|
-
|
|
190
|
-
|
|
198
|
+
/* contained, the keys are the box's: Tab, Enter and Esc elsewhere on the page stay the page's */
|
|
199
|
+
const on = contained ? overlayRef.current : window
|
|
200
|
+
on?.addEventListener('keydown', onKey)
|
|
201
|
+
return () => on?.removeEventListener('keydown', onKey)
|
|
191
202
|
}, [state.kind, val, values, fieldVals, closeWith]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
192
203
|
|
|
193
204
|
return (
|
|
@@ -199,7 +210,7 @@ function ModalView({ state, closeWith, variant }) {
|
|
|
199
210
|
z stays above the drawers it can open from. */
|
|
200
211
|
className="kol-overlay-scrim"
|
|
201
212
|
style={{
|
|
202
|
-
position: 'fixed', inset: 0, zIndex: 1000,
|
|
213
|
+
position: contained ? 'absolute' : 'fixed', inset: 0, zIndex: 1000,
|
|
203
214
|
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
204
215
|
}}
|
|
205
216
|
>
|
|
@@ -213,7 +224,7 @@ function ModalView({ state, closeWith, variant }) {
|
|
|
213
224
|
style={{
|
|
214
225
|
...look.style,
|
|
215
226
|
minWidth: 320,
|
|
216
|
-
maxWidth: '90vw',
|
|
227
|
+
maxWidth: contained ? '90%' : '90vw',
|
|
217
228
|
...(float ? { width: 562 } : {}),
|
|
218
229
|
}}
|
|
219
230
|
>
|
|
@@ -333,8 +344,10 @@ export function useModal() {
|
|
|
333
344
|
* @param {string} [icon] float: the header's glyph
|
|
334
345
|
* @param {Function} [onMinimise] float: the − control
|
|
335
346
|
* @param {boolean} [blocking=true]
|
|
347
|
+
* @param {Element} [container] the portal target instead of `<body>` (float-operational W2, 2026-11-04): the layer turns
|
|
348
|
+
* `absolute` and fills it — a specimen box (`position: relative`, a height) shows the window open in place. Unset, unchanged.
|
|
336
349
|
*/
|
|
337
|
-
export function Dialog({ open, onClose, title, width = 560, variant = 'lift', icon, onMinimise, blocking = true, children }) {
|
|
350
|
+
export function Dialog({ open, onClose, title, width = 560, variant = 'lift', icon, onMinimise, blocking = true, container, children }) {
|
|
338
351
|
const look = modalVariant(variant, 'lift')
|
|
339
352
|
const float = variant === 'float'
|
|
340
353
|
useEffect(() => {
|
|
@@ -348,7 +361,7 @@ export function Dialog({ open, onClose, title, width = 560, variant = 'lift', ic
|
|
|
348
361
|
<div
|
|
349
362
|
onMouseDown={blocking ? onClose : undefined}
|
|
350
363
|
className={blocking ? 'kol-overlay-scrim' : 'pointer-events-none'}
|
|
351
|
-
style={{ position: 'fixed', inset: 0, zIndex: 150, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
|
364
|
+
style={{ position: container ? 'absolute' : 'fixed', inset: 0, zIndex: 150, display: 'flex', alignItems: 'center', justifyContent: 'center' }}
|
|
352
365
|
>
|
|
353
366
|
<div
|
|
354
367
|
role="dialog"
|
|
@@ -359,13 +372,13 @@ export function Dialog({ open, onClose, title, width = 560, variant = 'lift', ic
|
|
|
359
372
|
/* THE OVERLAY PANEL (MetricRebuild, 2026-10-31 — user: the filter dialog read as "a borderless box floating
|
|
360
373
|
* mid-page"): it painted the page's own surface behind an fg-08 hairline, so on a dark page it was the page.
|
|
361
374
|
* `.kol-overlay-panel` is the lift every KOL overlay wears (oq-04, no border — the scrim is the edge). */
|
|
362
|
-
className={float ? `kol-modal pointer-events-auto flex flex-col gap-[18px] p-6 max-h-[85vh] overflow-auto ${look.className}` : `kol-modal flex flex-col rounded max-h-[85vh] ${look.className}${blocking ? '' : ' pointer-events-auto'}`}
|
|
363
|
-
style={{ ...look.style, width: `min(${width}px, calc(100vw - 32px))` }}
|
|
375
|
+
className={float ? `kol-modal pointer-events-auto flex flex-col gap-[18px] p-6 ${container ? 'max-h-[85%]' : 'max-h-[85vh]'} overflow-auto ${look.className}` : `kol-modal flex flex-col rounded ${container ? 'max-h-[85%]' : 'max-h-[85vh]'} ${look.className}${blocking ? '' : ' pointer-events-auto'}`}
|
|
376
|
+
style={{ ...look.style, width: `min(${width}px, calc(${container ? '100%' : '100vw'} - 32px))` }}
|
|
364
377
|
>
|
|
365
378
|
{float && title && <QuickLookHeader variant="float" icon={icon} title={title} onMinimise={onMinimise} onClose={onClose} />}
|
|
366
379
|
{children}
|
|
367
380
|
</div>
|
|
368
381
|
</div>,
|
|
369
|
-
document.body,
|
|
382
|
+
container ?? document.body,
|
|
370
383
|
)
|
|
371
384
|
}
|
|
@@ -31,10 +31,12 @@ import { Tooltip } from '../utilities/Popover.jsx'
|
|
|
31
31
|
* @param {Function} [onHide] the rail's hide slot (expanded: put kol-shell's RailDisplayControls in `footer`)
|
|
32
32
|
* @param {Array} [defaultExpanded] paths of sections open at mount
|
|
33
33
|
* @param {ReactNode} [footer]
|
|
34
|
+
* @param {Function} [onItemHover] collapsed only: `(item, element)` when the pointer enters a slot, `(null, null)` when it
|
|
35
|
+
* leaves — the seam a hover flyout hangs off (kol-shell's RailFlyout, FloatLayout 2026-11-04)
|
|
34
36
|
*/
|
|
35
37
|
const isOn = (path, current) => !!path && path === current
|
|
36
38
|
|
|
37
|
-
export default function NavRailFloat({ items = [], currentPath = '', onNavigate, collapsed = false, onCollapsedChange, title, icon = 'grid', onSwitch, switcher, onSearch, onHide, defaultExpanded = [], footer, className = '' }) {
|
|
39
|
+
export default function NavRailFloat({ items = [], currentPath = '', onNavigate, collapsed = false, onCollapsedChange, title, icon = 'grid', onSwitch, switcher, onSearch, onHide, defaultExpanded = [], footer, onItemHover, className = '' }) {
|
|
38
40
|
const [open, setOpen] = useState(() => new Set(defaultExpanded))
|
|
39
41
|
const toggle = (path) => setOpen((s) => { const n = new Set(s); n.has(path) ? n.delete(path) : n.add(path); return n })
|
|
40
42
|
const go = (path) => () => onNavigate?.(path)
|
|
@@ -56,7 +58,8 @@ export default function NavRailFloat({ items = [], currentPath = '', onNavigate,
|
|
|
56
58
|
if (it.heading) return i === 0 ? null : <span key={`h${i}`} className="h-4 shrink-0" aria-hidden />
|
|
57
59
|
const on = isOn(it.path, currentPath) || !!it.sub?.some((c) => isOn(c.path, currentPath))
|
|
58
60
|
return (
|
|
59
|
-
<span key={it.path ?? it.label} className="relative flex w-full justify-center"
|
|
61
|
+
<span key={it.path ?? it.label} className="relative flex w-full justify-center"
|
|
62
|
+
onMouseEnter={onItemHover && ((e) => onItemHover(it, e.currentTarget))} onMouseLeave={onItemHover && (() => onItemHover(null, null))}>
|
|
60
63
|
{on && <span className="absolute left-[5px] top-1/2 h-3.5 w-[3px] -translate-y-1/2 rounded-full bg-[var(--kol-surface-on-primary)]" aria-hidden />}
|
|
61
64
|
{slot(it.path ?? it.label, it.label, it.icon, { on, onClick: go(it.path) })}
|
|
62
65
|
</span>
|