@kolkrabbi/kol-component 0.302.0 → 0.304.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 +4 -4
- package/src/index.js +1 -1
- package/src/molecules/TabsRow.jsx +70 -11
- package/src/organisms/NavRailSite.jsx +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.304.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-
|
|
30
|
-
"@kolkrabbi/kol-
|
|
29
|
+
"@kolkrabbi/kol-markdown": "^0.1.3",
|
|
30
|
+
"@kolkrabbi/kol-search": "^0.3.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.
|
|
41
|
+
"@kolkrabbi/kol-icons": "^0.47.0"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
44
|
"src",
|
package/src/index.js
CHANGED
|
@@ -145,7 +145,7 @@ export { default as SplitToolButton } from './molecules/SplitToolButton.jsx'
|
|
|
145
145
|
export { default as ToolPalette } from './organisms/ToolPalette.jsx'
|
|
146
146
|
export { default as DocumentEditor } from './organisms/DocumentEditor.jsx'
|
|
147
147
|
export { default as SwatchControls, SwatchStack, EyedropPick } from './molecules/SwatchControls.jsx'
|
|
148
|
-
export { default as TabsRow, TABBAR_H, TABBAR_PILL_INSET, tabbarPillWidth } from './molecules/TabsRow.jsx'
|
|
148
|
+
export { default as TabsRow, TABBAR_H, TABBAR_PILL_INSET, TABBAR_PILL_TAB, tabbarPillWidth } from './molecules/TabsRow.jsx'
|
|
149
149
|
/** @deprecated 2026-10-17 — alias of `TabsRow look="chip"` */
|
|
150
150
|
export { default as TabChips } from './molecules/TabChips.jsx'
|
|
151
151
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef } from 'react'
|
|
1
|
+
import { useRef, useState } from 'react'
|
|
2
2
|
import CloseButton from '../atoms/CloseButton.jsx'
|
|
3
3
|
import Button from '../atoms/Button.jsx'
|
|
4
4
|
import { Icon } from '@kolkrabbi/kol-icons'
|
|
@@ -38,7 +38,17 @@ import { RAIL_ROW } from '../hooks/railRow.js'
|
|
|
38
38
|
* phone bar collapses into one round × at its right end — the pill shrinks to a 56 circle where More was, the bar
|
|
39
39
|
* keeps its width and shows the × in More's slot — while a sheet is open; `onExpand` is the ×. It expands back
|
|
40
40
|
* @param {Function} [onExpand] the ×'s press
|
|
41
|
-
*
|
|
41
|
+
* THE PILL'S OPTIONS (PhoneNavTopAndFold + TransportPill, kol-fxr 2026-10-27, frame E — one pill that the phone nav and
|
|
42
|
+
* the transport both compose, so the two stay one size and one look):
|
|
43
|
+
* @param {'bottom'|'top'} [edge='bottom'] the pill's edge; `top` sits TABBAR_PILL_INSET under the top safe-area inset
|
|
44
|
+
* @param {boolean} [border=true] the pill's 1px oq-08 hairline
|
|
45
|
+
* @param {boolean} [shadow=false] a drop shadow — for a pill that floats over content (the transport), not the nav
|
|
46
|
+
* @param {'fill'|'circle'} [active='fill'] the lit slot: `fill` its whole 56 slot (today), `circle` a 44×44 1:1 circle
|
|
47
|
+
* @param {boolean} [foldable=false] a sideways swipe (> 40px) folds the pill into a 28×72 edge tab; a tap restores it
|
|
48
|
+
* @param {boolean} [folded] · {Function} [onFoldChange] the folded state, controlled (else the pill holds it)
|
|
49
|
+
* @param {'left'|'right'} [foldSide='left'] the screen edge the tab sits on
|
|
50
|
+
* Tabs are `{ id, label }` or `{ value, label }` (either key), plus `icon` for stacked; a stacked tab's `selected`
|
|
51
|
+
* lights it whatever `value` is — action slots (the transport) light more than one.
|
|
42
52
|
*/
|
|
43
53
|
export const TABBAR_H = 56
|
|
44
54
|
/* the pill's air off the bottom edge — a page under it owes TABBAR_H + this */
|
|
@@ -49,11 +59,11 @@ export const tabbarPillWidth = (count) => count * TABBAR_PILL_TAB + 14
|
|
|
49
59
|
/* the collapse's motion — one duration for the width and the glyph swap (300, user 2026-10-23: 180 read as abrupt) */
|
|
50
60
|
const COLLAPSE_MS = 300
|
|
51
61
|
|
|
52
|
-
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, look = 'underline', placement = 'inline', shape = 'bar', collapsed = false, onExpand, size, tracked = false, ariaLabel, className, style }) {
|
|
62
|
+
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, look = 'underline', placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, active, foldable, folded, onFoldChange, foldSide, size, tracked = false, ariaLabel, className, style }) {
|
|
53
63
|
const tabs = raw.map((t) => ({ ...t, id: t.id ?? t.value }))
|
|
54
64
|
if (look === 'chip') return <ChipTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 'sm'} ariaLabel={ariaLabel} className={className ?? ''} />
|
|
55
65
|
if (look === 'text') return <TextTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 14} tracked={tracked} className={className ?? 'gap-6'} style={style} />
|
|
56
|
-
if (look === 'stacked') return <StackedTabs tabs={tabs} value={value} onChange={onChange} placement={placement} shape={shape} collapsed={collapsed} onExpand={onExpand} className={className ?? ''} />
|
|
66
|
+
if (look === 'stacked') return <StackedTabs tabs={tabs} value={value} onChange={onChange} placement={placement} shape={shape} collapsed={collapsed} onExpand={onExpand} edge={edge} border={border} shadow={shadow} active={active} foldable={foldable} folded={folded} onFoldChange={onFoldChange} foldSide={foldSide} ariaLabel={ariaLabel} className={className ?? ''} />
|
|
57
67
|
return <UnderlineTabs tabs={tabs} value={value} onChange={onChange} onClose={onClose} onMinimise={onMinimise} />
|
|
58
68
|
}
|
|
59
69
|
|
|
@@ -93,14 +103,56 @@ function TextTabs({ tabs, value, onChange, size, tracked, className, style }) {
|
|
|
93
103
|
}
|
|
94
104
|
|
|
95
105
|
/* stacked — MobileTabBar's tab verbatim; its fixed bottom pill is `placement="phone"`, inline is a plain row */
|
|
96
|
-
|
|
106
|
+
/* the fold: a sideways swipe past this folds the pill, as frame E's prototype measures it */
|
|
107
|
+
const FOLD_SWIPE = 40
|
|
108
|
+
|
|
109
|
+
function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapsed = false, onExpand, edge = 'bottom', border = true, shadow = false, active: activeShape = 'fill', foldable = false, folded: foldedProp, onFoldChange, foldSide = 'left', ariaLabel = 'Sections', className }) {
|
|
110
|
+
const [foldedOwn, setFoldedOwn] = useState(false)
|
|
111
|
+
const swipe = useRef({ x: null, swiped: false })
|
|
97
112
|
if (tabs.length === 0) return null
|
|
98
113
|
const phone = placement === 'phone'
|
|
99
114
|
const pill = phone && shape === 'pill'
|
|
100
115
|
const isCollapsed = phone && collapsed
|
|
101
116
|
const W = tabbarPillWidth(tabs.length)
|
|
117
|
+
const top = pill && edge === 'top'
|
|
118
|
+
const isFolded = pill && foldable && (foldedProp ?? foldedOwn)
|
|
119
|
+
const setFolded = (v) => { if (foldedProp === undefined) setFoldedOwn(v); onFoldChange?.(v) }
|
|
120
|
+
/* the edge offset: the pill's inset from the safe area on its edge */
|
|
121
|
+
const inset = `calc(env(safe-area-inset-${top ? 'top' : 'bottom'}, 0px) + ${TABBAR_PILL_INSET}px)`
|
|
122
|
+
const swipeProps = pill && foldable ? {
|
|
123
|
+
onPointerDown: (e) => { swipe.current.x = e.clientX },
|
|
124
|
+
onPointerUp: (e) => {
|
|
125
|
+
const { x } = swipe.current
|
|
126
|
+
swipe.current.x = null
|
|
127
|
+
if (x != null && Math.abs(e.clientX - x) > FOLD_SWIPE) { swipe.current.swiped = true; setFolded(true) }
|
|
128
|
+
},
|
|
129
|
+
/* a swipe that ended on a slot must not also press it */
|
|
130
|
+
onClickCapture: (e) => { if (swipe.current.swiped) { swipe.current.swiped = false; e.stopPropagation(); e.preventDefault() } },
|
|
131
|
+
style: { touchAction: 'pan-y' },
|
|
132
|
+
} : {}
|
|
133
|
+
if (isFolded) {
|
|
134
|
+
/* THE EDGE TAB (frame E): 28×72 flush to the screen edge, the pill's ground, no border, a chevron pointing back in */
|
|
135
|
+
return (
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
aria-label={`Show ${ariaLabel.toLowerCase()}`}
|
|
139
|
+
onClick={() => setFolded(false)}
|
|
140
|
+
className="kol-mobile-tabbar-tab md:hidden fixed z-[calc(var(--kol-z-sticky)+1)] flex items-center justify-center cursor-pointer"
|
|
141
|
+
style={{
|
|
142
|
+
[foldSide]: 0,
|
|
143
|
+
[top ? 'top' : 'bottom']: `calc(env(safe-area-inset-${top ? 'top' : 'bottom'}, 0px) + ${TABBAR_PILL_INSET + 8}px)`,
|
|
144
|
+
width: 28, height: 72, padding: 0, border: 'none',
|
|
145
|
+
borderRadius: foldSide === 'left' ? '0 16px 16px 0' : '16px 0 0 16px',
|
|
146
|
+
background: 'var(--kol-surface-secondary)', color: RAIL_ROW.rest,
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
<Icon name={foldSide === 'left' ? 'chevron-right' : 'chevron-left'} size={18} />
|
|
150
|
+
</button>
|
|
151
|
+
)
|
|
152
|
+
}
|
|
102
153
|
return (
|
|
103
154
|
<nav
|
|
155
|
+
{...swipeProps}
|
|
104
156
|
className={`${pill
|
|
105
157
|
? 'kol-mobile-tabbar kol-mobile-tabbar-pill md:hidden fixed z-[calc(var(--kol-z-sticky)+1)] rounded-full p-1.5 overflow-hidden '
|
|
106
158
|
: phone ? 'kol-mobile-tabbar md:hidden fixed inset-x-0 bottom-0 z-[var(--kol-z-sticky)] ' : ''}flex items-stretch ${className}`.trim()}
|
|
@@ -111,10 +163,13 @@ function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapse
|
|
|
111
163
|
height: TABBAR_H,
|
|
112
164
|
width: isCollapsed ? TABBAR_H : W,
|
|
113
165
|
right: `calc(50% - ${W / 2}px)`,
|
|
114
|
-
bottom:
|
|
166
|
+
[top ? 'top' : 'bottom']: inset,
|
|
115
167
|
background: 'var(--kol-surface-secondary)',
|
|
116
|
-
|
|
168
|
+
/* without the hairline the 1px it took stays, transparent, so the slots never move */
|
|
169
|
+
border: `1px solid ${border ? 'var(--kol-oq-08)' : 'transparent'}`,
|
|
170
|
+
boxShadow: shadow ? '0 8px 40px rgba(0, 0, 0, 0.45)' : undefined,
|
|
117
171
|
transition: `width ${COLLAPSE_MS}ms ease`,
|
|
172
|
+
...swipeProps.style,
|
|
118
173
|
} : phone ? {
|
|
119
174
|
height: TABBAR_H,
|
|
120
175
|
/* the pill's own ground, not the page's — it floats OVER content, so a
|
|
@@ -123,11 +178,12 @@ function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapse
|
|
|
123
178
|
borderTop: '1px solid var(--kol-oq-08)',
|
|
124
179
|
paddingBottom: 'env(safe-area-inset-bottom, 0px)',
|
|
125
180
|
} : { height: TABBAR_H }}
|
|
126
|
-
aria-label=
|
|
181
|
+
aria-label={ariaLabel}
|
|
127
182
|
>
|
|
128
183
|
<div className={`flex items-stretch ${pill ? 'flex-none' : 'flex-1 min-w-0'}`} style={{ width: pill ? W - 14 : undefined, opacity: isCollapsed ? 0 : 1, pointerEvents: isCollapsed ? 'none' : 'auto', transition: `opacity ${COLLAPSE_MS}ms ease` }}>
|
|
129
184
|
{tabs.map((t) => {
|
|
130
|
-
const active = t.id === value
|
|
185
|
+
const active = t.selected ?? t.id === value
|
|
186
|
+
const circle = pill && activeShape === 'circle'
|
|
131
187
|
return (
|
|
132
188
|
<button
|
|
133
189
|
key={t.id}
|
|
@@ -140,9 +196,12 @@ function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapse
|
|
|
140
196
|
className={pill ? 'flex items-center justify-center rounded-full cursor-pointer' : 'flex-1 min-w-0 flex flex-col items-center justify-center gap-1 cursor-pointer'}
|
|
141
197
|
/* the PHONE bar wears the rail's row type and ink (review 2, § 7.1 — RAIL_ROW, the one constant the rail reads);
|
|
142
198
|
* an inline stacked row keeps MobileTabBar's own */
|
|
143
|
-
style={{ background: pill && active ? 'var(--kol-oq-08)' : 'transparent', border: 'none', width: pill ? 56 : undefined, color: phone ? (active ? RAIL_ROW.active : RAIL_ROW.rest) : (active ? 'var(--kol-fg-default)' : 'var(--kol-fg-48)') }}
|
|
199
|
+
style={{ background: pill && active && !circle ? 'var(--kol-oq-08)' : 'transparent', border: 'none', width: pill ? 56 : undefined, color: phone ? (active ? RAIL_ROW.active : RAIL_ROW.rest) : (active ? 'var(--kol-fg-default)' : 'var(--kol-fg-48)') }}
|
|
144
200
|
>
|
|
145
|
-
{
|
|
201
|
+
{/* the circle: 44×44, 1:1 inside the 56 slot (frame E — the fill stretched to the slot's width) */}
|
|
202
|
+
{t.icon && (circle
|
|
203
|
+
? <span className="inline-flex items-center justify-center rounded-full" style={{ width: 44, height: 44, background: active ? 'var(--kol-oq-08)' : 'transparent' }}><Icon name={t.icon} size={28} /></span>
|
|
204
|
+
: <Icon name={t.icon} size={pill ? 28 : phone ? 24 : 18} />)}
|
|
146
205
|
{/* helper is single-line chrome, which a tab label always is */}
|
|
147
206
|
{!phone && <span className="kol-helper-10 truncate max-w-full px-1">{t.label}</span>}
|
|
148
207
|
</button>
|
|
@@ -129,13 +129,18 @@ import useDragResize from '../hooks/useDragResize.js'
|
|
|
129
129
|
*/
|
|
130
130
|
|
|
131
131
|
const pageBase =
|
|
132
|
-
'kol-sidenav-link kol-helper-10 block relative py-[4px]
|
|
132
|
+
'kol-sidenav-link kol-helper-10 block relative py-[4px] pr-6 no-underline transition-colors duration-150'
|
|
133
133
|
|
|
134
134
|
/* The active-dot pseudo-element is positioned by `--kol-sidenav-dot-left`
|
|
135
135
|
* (kol-components-atoms.css). The page row indents one step past the chrome inset
|
|
136
136
|
* (`--kol-pad-chrome-x` + the icon column + the gap, 2026-10-24 — it was a literal
|
|
137
137
|
* 3.5rem); the dot sits 0.875rem inside that, in the gutter the icon column leaves. */
|
|
138
|
-
|
|
138
|
+
/* ON THE TITLE COLUMN (user 2026-10-27: "that line doesnt align with the page titles"): a section's own pages start where
|
|
139
|
+
* its title starts, the rail's gutter + the icon column + the gap (52), and 2px in, as a group's pages sit (user: "I would
|
|
140
|
+
* have left it at 2px to the right") — they sat on --kol-pad-chrome-x, 4 right of the title.
|
|
141
|
+
* A group's pages keep their step under the group label (below), as ruled 2026-10-24. */
|
|
142
|
+
/* inline, as the group's pages are: a new arbitrary utility in package source is never generated in a consumer */
|
|
143
|
+
const pageStyle = { paddingLeft: 'calc(var(--kol-sidenav-pad-x) + 2rem + 2px)', '--kol-sidenav-dot-left': 'calc(var(--kol-sidenav-pad-x) + 1.125rem + 2px)' }
|
|
139
144
|
/* Category and page must not share a stop: category `emphasis`, page `strong`
|
|
140
145
|
* — two rungs of one ladder, so the tree reads as hierarchy (elder ruling). */
|
|
141
146
|
const pageCls = `${pageBase} text-strong hover:text-emphasis`
|