@kolkrabbi/kol-component 0.332.0 → 0.333.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 +3 -3
- package/src/molecules/TabsRow.jsx +13 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kolkrabbi/kol-component",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.333.0",
|
|
4
4
|
"description": "The core component library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"pdfjs-dist": "^6.3.289",
|
|
28
28
|
"react-syntax-highlighter": "^16.1.1",
|
|
29
29
|
"@kolkrabbi/kol-growth": "^0.5.0",
|
|
30
|
-
"@kolkrabbi/kol-
|
|
31
|
-
"@kolkrabbi/kol-
|
|
30
|
+
"@kolkrabbi/kol-search": "^0.3.0",
|
|
31
|
+
"@kolkrabbi/kol-markdown": "^0.2.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@kolkrabbi/kol-icons": ">=0.22.0",
|
|
@@ -75,7 +75,10 @@ import { floatSurfaceClass } from '../utilities/tone.js'
|
|
|
75
75
|
* @param {boolean} [labels=false] the tab bar with labels: 66 tall, items 58 tall and 84 wide, 4 in, a 24 glyph over an 11 label
|
|
76
76
|
* @param {boolean} [foldable=false] a sideways swipe (> 40px) folds the pill into a 28×72 edge tab; a tap restores it
|
|
77
77
|
* @param {boolean} [folded] · {Function} [onFoldChange] the folded state, controlled (else the pill holds it)
|
|
78
|
-
* @param {'left'|'right'} [foldSide='left'] the screen edge the tab sits on
|
|
78
|
+
* @param {'left'|'right'|'swipe'} [foldSide='left'] the screen edge the tab sits on; `swipe` — the edge the swipe went toward
|
|
79
|
+
* (FloatFoldBothSidesGrey, kol-fxr 2026-11-03)
|
|
80
|
+
* @param {'ground'|'handle'} [foldTone='ground'] the edge tab's look: `ground` is the pill's own; `handle` is the grey edge
|
|
81
|
+
* handle (iOS's), `--kol-oq-24` with an `--kol-oq-96` chevron, whatever the pill's `surface`
|
|
79
82
|
* Tabs are `{ id, label }` or `{ value, label }` (either key), plus `icon` for stacked; a stacked tab's `selected`
|
|
80
83
|
* lights it whatever `value` is — action slots (the transport) light more than one.
|
|
81
84
|
*/
|
|
@@ -103,7 +106,7 @@ export const tabbarPillSlot = (at, { count, labels = false, split = false } = {}
|
|
|
103
106
|
/* the collapse's motion — one duration for the width and the glyph swap (300, user 2026-10-23: 180 read as abrupt) */
|
|
104
107
|
const COLLAPSE_MS = 300
|
|
105
108
|
|
|
106
|
-
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, variant, look: lookLegacy, type = 'mono', filled = false, placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, dock, active, foldable, folded, onFoldChange, foldSide, surface, split, labels, size, tracked = false, overflow = 'scroll', ariaLabel, className, style }) {
|
|
109
|
+
export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMinimise, variant, look: lookLegacy, type = 'mono', filled = false, placement = 'inline', shape = 'bar', collapsed = false, onExpand, edge, border, shadow, dock, active, foldable, folded, onFoldChange, foldSide, foldTone, surface, split, labels, size, tracked = false, overflow = 'scroll', ariaLabel, className, style }) {
|
|
107
110
|
const tabs = raw.map((t) => ({ ...t, id: t.id ?? t.value }))
|
|
108
111
|
const look = variant ?? lookLegacy ?? 'underline'
|
|
109
112
|
const wrap = overflow === 'wrap'
|
|
@@ -111,7 +114,7 @@ export default function TabsRow({ tabs: raw = [], value, onChange, onClose, onMi
|
|
|
111
114
|
if (look === 'float') return <Overflow mode={overflow} value={value}><ChipTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 'md'} float ariaLabel={ariaLabel} className={`${wrap ? 'flex-wrap ' : ''}${className ?? ''}`} /></Overflow>
|
|
112
115
|
if (look === 'chip') return <Overflow mode={overflow} value={value}><ChipTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 'sm'} filled={filled} ariaLabel={ariaLabel} className={`${wrap ? 'flex-wrap ' : ''}${className ?? ''}`} /></Overflow>
|
|
113
116
|
if (look === 'text') return <Overflow mode={overflow} value={value}><TextTabs tabs={tabs} value={value} onChange={onChange} size={size ?? 14} tracked={tracked} className={`${wrap ? 'flex-wrap gap-y-2 ' : ''}${className ?? 'gap-6'}`} style={style} /></Overflow>
|
|
114
|
-
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} dock={dock} active={active} foldable={foldable} folded={folded} onFoldChange={onFoldChange} foldSide={foldSide} surface={surface} split={split} labels={labels} ariaLabel={ariaLabel} className={className ?? ''} />
|
|
117
|
+
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} dock={dock} active={active} foldable={foldable} folded={folded} onFoldChange={onFoldChange} foldSide={foldSide} foldTone={foldTone} surface={surface} split={split} labels={labels} ariaLabel={ariaLabel} className={className ?? ''} />
|
|
115
118
|
return <Overflow mode={overflow} value={value}><UnderlineTabs tabs={tabs} value={value} onChange={onChange} onClose={onClose} onMinimise={onMinimise} wrap={wrap} type={type} /></Overflow>
|
|
116
119
|
}
|
|
117
120
|
|
|
@@ -174,9 +177,10 @@ function TextTabs({ tabs, value, onChange, size, tracked, className, style }) {
|
|
|
174
177
|
/* the fold: a sideways swipe past this folds the pill, as frame E's prototype measures it */
|
|
175
178
|
const FOLD_SWIPE = 40
|
|
176
179
|
|
|
177
|
-
function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapsed = false, onExpand, edge = 'bottom', border = true, shadow = false, dock = false, active: activeShape = 'fill', foldable = false, folded: foldedProp, onFoldChange, foldSide = 'left', surface = 'solid', split: splitProp = false, labels = false, ariaLabel = 'Sections', className }) {
|
|
180
|
+
function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapsed = false, onExpand, edge = 'bottom', border = true, shadow = false, dock = false, active: activeShape = 'fill', foldable = false, folded: foldedProp, onFoldChange, foldSide: foldSideProp = 'left', foldTone = 'ground', surface = 'solid', split: splitProp = false, labels = false, ariaLabel = 'Sections', className }) {
|
|
178
181
|
const [foldedOwn, setFoldedOwn] = useState(false)
|
|
179
182
|
const swipe = useRef({ x: null, swiped: false })
|
|
183
|
+
const [swipeSide, setSwipeSide] = useState('left')
|
|
180
184
|
if (tabs.length === 0) return null
|
|
181
185
|
const phone = placement === 'phone'
|
|
182
186
|
const pill = phone && shape === 'pill'
|
|
@@ -199,26 +203,28 @@ function StackedTabs({ tabs, value, onChange, placement, shape = 'bar', collapse
|
|
|
199
203
|
onPointerUp: (e) => {
|
|
200
204
|
const { x } = swipe.current
|
|
201
205
|
swipe.current.x = null
|
|
202
|
-
if (x != null && Math.abs(e.clientX - x) > FOLD_SWIPE) { swipe.current.swiped = true; setFolded(true) }
|
|
206
|
+
if (x != null && Math.abs(e.clientX - x) > FOLD_SWIPE) { swipe.current.swiped = true; setSwipeSide(e.clientX < x ? 'left' : 'right'); setFolded(true) }
|
|
203
207
|
},
|
|
204
208
|
/* a swipe that ended on a slot must not also press it */
|
|
205
209
|
onClickCapture: (e) => { if (swipe.current.swiped) { swipe.current.swiped = false; e.stopPropagation(); e.preventDefault() } },
|
|
206
210
|
style: { touchAction: 'pan-y' },
|
|
207
211
|
} : {}
|
|
208
212
|
if (isFolded) {
|
|
213
|
+
const foldSide = foldSideProp === 'swipe' ? swipeSide : foldSideProp
|
|
214
|
+
const handle = foldTone === 'handle'
|
|
209
215
|
/* THE EDGE TAB (frame E): 28×72 flush to the screen edge, the pill's ground, no border, a chevron pointing back in */
|
|
210
216
|
return (
|
|
211
217
|
<button
|
|
212
218
|
type="button"
|
|
213
219
|
aria-label={`Show ${ariaLabel.toLowerCase()}`}
|
|
214
220
|
onClick={() => setFolded(false)}
|
|
215
|
-
className={`kol-mobile-tabbar-tab md:hidden fixed z-[calc(var(--kol-z-sticky)+1)] flex items-center justify-center cursor-pointer ${material}`.trim()}
|
|
221
|
+
className={`kol-mobile-tabbar-tab md:hidden fixed z-[calc(var(--kol-z-sticky)+1)] flex items-center justify-center cursor-pointer ${handle ? '' : material}`.trim()}
|
|
216
222
|
style={{
|
|
217
223
|
[foldSide]: 0,
|
|
218
224
|
[top ? 'top' : 'bottom']: `calc(env(safe-area-inset-${top ? 'top' : 'bottom'}, 0px) + ${TABBAR_PILL_INSET + 8}px)`,
|
|
219
225
|
width: 28, height: 72, padding: 0, border: 'none',
|
|
220
226
|
borderRadius: foldSide === 'left' ? '0 16px 16px 0' : '16px 0 0 16px',
|
|
221
|
-
...(glass ? {} : { background: 'var(--kol-surface-secondary)' }), color: RAIL_ROW.rest,
|
|
227
|
+
...(handle ? { background: 'var(--kol-oq-24)' } : glass ? {} : { background: 'var(--kol-surface-secondary)' }), color: handle ? RAIL_ROW.active : RAIL_ROW.rest,
|
|
222
228
|
}}
|
|
223
229
|
>
|
|
224
230
|
<Icon name={foldSide === 'left' ? 'chevron-right' : 'chevron-left'} size={18} />
|