@kolkrabbi/kol-component 0.220.0 → 0.222.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.220.0",
3
+ "version": "0.222.0",
4
4
  "description": "KOL design-system components — atoms through organisms, emitting canonical kol-* classes. Pairs with @kolkrabbi/kol-theme for styling.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -120,6 +120,7 @@ export { default as Slider } from './molecules/Slider.jsx'
120
120
  export { default as SpecList } from './molecules/SpecList.jsx'
121
121
  export { default as SpectrumControls, HueStrip, SBSquare, WheelTriangle } from './organisms/SpectrumControls.jsx'
122
122
  export { default as SplitToolButton } from './molecules/SplitToolButton.jsx'
123
+ export { default as ToolPalette } from './organisms/ToolPalette.jsx'
123
124
  export { default as SwatchControls, SwatchStack, EyedropPick } from './molecules/SwatchControls.jsx'
124
125
  export { default as TabsRow } from './molecules/TabsRow.jsx'
125
126
 
@@ -152,7 +153,6 @@ export { default as ErrorBoundary } from './utilities/ErrorBoundary.jsx'
152
153
  export { default as FeatureSplit } from './organisms/FeatureSplit.jsx'
153
154
  export { default as FeaturedCarousel } from './organisms/FeaturedCarousel.jsx'
154
155
  export { default as FeaturesCardSection } from './organisms/FeaturesCardSection.jsx'
155
- export { default as FoundryCTA } from './organisms/FoundryCTA.jsx'
156
156
  export { default as SectionHero, default as FullBleedHero } from './organisms/SectionHero.jsx'
157
157
  export { default as SectionSplit } from './organisms/SectionSplit.jsx'
158
158
  export { default as SectionCards } from './organisms/SectionCards.jsx'
@@ -54,7 +54,14 @@ import { glyphSize } from '../hooks/glyphLadders.js'
54
54
  * @param {boolean} props.active - Whether this tool group is the active tool — lit trigger, `aria-pressed`
55
55
  * @param {'xs'|'sm'|'md'|'lg'} props.size - Trigger box on the pinned-square ladder — 22 · 26 · 32 · 40 (default: 'md'). The glyph follows the SOLO ladder; it is never set at the call site
56
56
  * @param {boolean} props.blurOnClick - Blur the trigger after click so a canvas can reclaim focus and refresh its cursor (default: false)
57
+ * @param {Function} props.onTrigger - Replaces the trigger's arm: fires with the trigger variant's id on every click. For a fold of one-shot ACTIONS (Boolean: the trigger re-runs the last-picked op) — no pressed state is implied (default: arm via `onChange`)
58
+ * @param {boolean} props.disabled - Disables the trigger — `.kol-btn:disabled` dims it (default: false)
59
+ * @param {ElementType} props.iconComponent - Glyph renderer receiving `{ name, size, className, style }` — Button's seam (default: DS `Icon`)
57
60
  * @param {string} props.aria-label - Trigger label fallback when no variant resolves
61
+ *
62
+ * A variant may carry its own `onSelect()` — that row does its own thing instead of `onChange`
63
+ * (Text: "Text" arms the tool, "Kinetic type" inserts a layer). Without `lastPicked` the trigger
64
+ * remembers the last row picked from the menu (kol-fxr ToolPalette, editor-panels-the-held-specs A3).
58
65
  * @param {string} props.className - Additional classes on the trigger
59
66
  */
60
67
 
@@ -77,6 +84,9 @@ const SplitToolButton = ({
77
84
  active = false,
78
85
  size = 'md',
79
86
  blurOnClick = false,
87
+ onTrigger,
88
+ disabled = false,
89
+ iconComponent: IconC = Icon,
80
90
  className = '',
81
91
  'aria-label': ariaLabel,
82
92
  }) => {
@@ -89,20 +99,23 @@ const SplitToolButton = ({
89
99
  role: 'menu',
90
100
  })
91
101
 
102
+ const [ownLast, setOwnLast] = useState(null)
92
103
  const byId = (id) => variants.find((v) => v.id === id)
93
- const triggerVariant = (active && byId(value)) || byId(lastPicked) || variants[0]
104
+ const triggerVariant = (active && byId(value)) || byId(lastPicked ?? ownLast) || variants[0]
94
105
  const label = triggerVariant?.label ?? ariaLabel
95
106
  const title = triggerVariant?.shortcut ? `${label} (${triggerVariant.shortcut})` : label
96
107
 
97
108
  /* Arm the last-picked variant on the same click that toggles the menu —
98
109
  * floating-ui's useClick (on the reference) handles the open/close half. */
99
110
  const handleTriggerClick = (event) => {
100
- if (!active && triggerVariant) onChange?.(triggerVariant.id)
111
+ if (onTrigger) { if (triggerVariant) onTrigger(triggerVariant.id) }
112
+ else if (!active && triggerVariant) onChange?.(triggerVariant.id)
101
113
  if (blurOnClick) event.currentTarget.blur()
102
114
  }
103
115
 
104
116
  const handleSelect = (variant) => {
105
- onChange?.(variant.id)
117
+ if (variant.onSelect) variant.onSelect()
118
+ else { onChange?.(variant.id); setOwnLast(variant.id) }
106
119
  setOpen(false)
107
120
  }
108
121
 
@@ -113,11 +126,12 @@ const SplitToolButton = ({
113
126
  {...popover.getReferenceProps({ onClick: handleTriggerClick })}
114
127
  type="button"
115
128
  className={`relative kol-btn kol-btn-ghost kol-btn-icon kol-btn-${size} ${active ? 'kol-btn-pressed' : 'kol-btn-quiet'} ${className}`.trim()}
116
- aria-pressed={active}
129
+ disabled={disabled}
130
+ aria-pressed={onTrigger ? undefined : active}
117
131
  aria-label={label}
118
132
  title={title}
119
133
  >
120
- {triggerVariant && <Icon name={triggerVariant.icon} size={glyphSize(size, true)} />}
134
+ {triggerVariant && <IconC name={triggerVariant.icon} size={glyphSize(size, true)} />}
121
135
  <FoldIndicator />
122
136
  </button>
123
137
  {/* w-max — floats size to content, the menu-family law (2026-08-09). */}
@@ -137,7 +151,7 @@ const SplitToolButton = ({
137
151
  className="w-full kol-helper-12 px-3 h-8 inline-flex items-center gap-2 text-body hover:text-emphasis text-left"
138
152
  >
139
153
  <span className="shrink-0 w-4 inline-flex items-center justify-center">
140
- <Icon name={variant.icon} size={14} />
154
+ <IconC name={variant.icon} size={14} />
141
155
  </span>
142
156
  <span className="flex-1 truncate">{variant.label}</span>
143
157
  <span className="kol-helper-10 text-emphasis shrink-0">
@@ -462,6 +462,11 @@ export default function ColumnBrowser({
462
462
  quickLook = null,
463
463
  onQuickLook,
464
464
  onPick,
465
+ /* `picked` — the file the CALLER holds picked (a key or an object; kol-client-olina 2026-09-25:
466
+ * a pick made in rows or grid was lost on the switch to columns, because this browser kept its
467
+ * own). Given, the browser opens on that file's level with its row selected and previewed, and
468
+ * follows it when it changes; absent (`undefined`), the pick is internal exactly as before. */
469
+ picked: pickedIn,
465
470
  urlOf,
466
471
  kindOf = defaultKindOf,
467
472
  kindLabel = DEFAULT_KIND_LABEL,
@@ -559,6 +564,16 @@ export default function ColumnBrowser({
559
564
  if (prefix !== level) { keepCursor.current = true; pickedByCollapse.current = true; onPrefix(level) }
560
565
  }
561
566
  const pickedByCollapse = useRef(false)
567
+ const pickedInKey = typeof pickedIn === 'string' ? pickedIn : pickedIn?.key ?? null
568
+ useEffect(() => {
569
+ if (pickedIn === undefined || (picked?.key ?? null) === pickedInKey) return
570
+ const o = typeof pickedIn === 'string' ? objects.find((x) => x.key === pickedIn) : pickedIn
571
+ if (!o) { setPicked(null); return }
572
+ const level = o.key.slice(0, o.key.lastIndexOf('/') + 1)
573
+ setPicked(o)
574
+ setCursor(seedCursor(level))
575
+ if (prefix !== level) { keepCursor.current = true; pickedByCollapse.current = true; onPrefix(level) }
576
+ }, [pickedInKey]) // eslint-disable-line react-hooks/exhaustive-deps
562
577
  useEffect(() => { if (pickedByCollapse.current) { pickedByCollapse.current = false; return } if (picked) pick(null) }, [prefix]) // eslint-disable-line react-hooks/exhaustive-deps
563
578
  useEffect(() => { setExpanded((prev) => (prev.size ? new Set() : prev)) }, [prefix])
564
579
  const levelsOf = (pfx) => {
@@ -580,6 +595,12 @@ export default function ColumnBrowser({
580
595
  * internal moves land on the same spot, so nothing jumps. */
581
596
  const seedCursor = (pfx) => {
582
597
  const lv = levelsOf(pfx)
598
+ /* a caller's `picked` file at this level is where the keyboard starts — on the file, not on
599
+ * the folder that opened its column */
600
+ if (pickedInKey?.startsWith(pfx) && !pickedInKey.slice(pfx.length).includes('/')) {
601
+ const idx = itemsAt(pfx).findIndex((it) => it.type === 'file' && it.o.key === pickedInKey)
602
+ if (idx >= 0) return { col: lv.length - 1, idx }
603
+ }
583
604
  if (lv.length < 2) return { col: 0, idx: 0 }
584
605
  const col = lv.length - 2
585
606
  const opened = lv[col + 1].slice(lv[col].length)
@@ -195,12 +195,19 @@ function useBucketLibrary({ client, bucket, defaults, settings: controlled, onSe
195
195
 
196
196
  /* ── shared pieces, kol-r2b2's ─────────────────────────────────────────────── */
197
197
 
198
- /* The frame is square until the file reports its size, then snaps to its nearest preset. */
199
- function ImageFrame({ src }) {
200
- const [ratio, setRatio] = useState('1 / 1')
198
+ /* The frame is square until the file reports its size, then snaps to its nearest preset. A photo
199
+ * near a preset fills it (`cover`, a few percent cropped); a vector or anything past the ladder's
200
+ * ends — a 2.8:1 wordmark, an 11:1 nav logo — shows whole (`contain`, kol-client-olina 2026-09-25). */
201
+ function ImageFrame({ src, vector }) {
202
+ const [frame, setFrame] = useState({ ratio: '1 / 1', contain: !!vector })
203
+ const onLoad = (e) => {
204
+ const { naturalWidth: w, naturalHeight: h } = e.target
205
+ const r = w && h ? w / h : 1
206
+ setFrame({ ratio: nearestRatio(w, h), contain: vector || r > 16 / 9 || r < 9 / 16 })
207
+ }
201
208
  return (
202
- <div className="w-full rounded overflow-hidden flex items-center justify-center" style={{ aspectRatio: ratio }}>
203
- <img src={src} alt="" className="w-full h-full object-cover" loading="lazy" onLoad={(e) => setRatio(nearestRatio(e.target.naturalWidth, e.target.naturalHeight))} />
209
+ <div className="w-full rounded overflow-hidden flex items-center justify-center" style={{ aspectRatio: frame.ratio }}>
210
+ <img src={src} alt="" className={`w-full h-full ${frame.contain ? 'object-contain' : 'object-cover'}`} loading="lazy" onLoad={onLoad} />
204
211
  </div>
205
212
  )
206
213
  }
@@ -1453,7 +1460,7 @@ export function MediaLibraryBrowse({
1453
1460
  <ColumnPreview key={previewFile.key} o={previewFile} urlOf={(o) => mediaUrl(o.key)} kindOf={kindOf} kindLabel={KIND_LABEL}
1454
1461
  formatSize={formatSize} formatDate={formatDate} width={previewWidth}
1455
1462
  renderPreview={(o) => {
1456
- if (isImage(o.contentType)) return <ImageFrame src={mediaUrl(o.key)} />
1463
+ if (isImage(o.contentType)) return <ImageFrame src={mediaUrl(o.key)} vector={o.contentType === 'image/svg+xml'} />
1457
1464
  const poster = posterFor(o.key, keySet)
1458
1465
  return <KindPreview o={o} urlOf={(x) => mediaUrl(x.key)} poster={poster ? mediaUrl(poster) : undefined} kindOf={kindOf} kindLabel={KIND_LABEL} />
1459
1466
  }} />
@@ -1631,6 +1638,7 @@ export function MediaLibraryBrowse({
1631
1638
  const real = rest.join('/')
1632
1639
  if (target && target.id !== bucketMeta.id) switchBucket(target.id, real); else setPrefix(real)
1633
1640
  }}
1641
+ picked={pickedFile ? { ...pickedFile, key: `${VROOT}${pickedFile.key}` } : null}
1634
1642
  onPick={(o) => setPickedFile(o ? { ...o, key: o.key.slice(VROOT.length) } : null)}
1635
1643
  quickLook={quickLook && { ...quickLook, files: quickLook.files.map((o) => ({ ...o, key: `${VROOT}${o.key}` })) }}
1636
1644
  onQuickLook={(q) => openQuickLook(q && { ...q, files: q.files.map((o) => ({ ...o, key: o.key.slice(VROOT.length) })) })}
@@ -1646,7 +1654,7 @@ export function MediaLibraryBrowse({
1646
1654
  stackView={stackView ?? settings.stackView ?? 'list'}
1647
1655
  renderPreview={(o) => {
1648
1656
  const real = { ...o, key: o.key.slice(VROOT.length) }
1649
- if (isImage(real.contentType)) return <ImageFrame src={mediaUrl(real.key)} />
1657
+ if (isImage(real.contentType)) return <ImageFrame src={mediaUrl(real.key)} vector={real.contentType === 'image/svg+xml'} />
1650
1658
  const poster = posterFor(real.key, keySet)
1651
1659
  return <KindPreview o={real} urlOf={(x) => mediaUrl(x.key)} poster={poster ? mediaUrl(poster) : undefined} kindOf={kindOf} kindLabel={KIND_LABEL} />
1652
1660
  }}
@@ -15,7 +15,7 @@ import { minHeightClass } from './sectionHeights.js'
15
15
  * TWO VARIANTS. `editorial` (default): the two-column band above. `centered`
16
16
  * (SectionHeroRound2, 2026-08-26): the quiet mid-page tier — a short rule, a
17
17
  * heading, a mono line and Buttons, centred — which was `FoundryCTA`, a second
18
- * way to render SectionText. FoundryCTA is its deprecated alias.
18
+ * way to render SectionText. FoundryCTA was its alias until 2026-09-25, when it dropped.
19
19
  *
20
20
  * @param {'full'|'80'|'60'|string} [height='60'] min-height on the family's ladder — full = 100dvh,
21
21
  * 80 = 70svh / 80vh, 60 = 50svh / 60vh (default), 40 = 35svh / 40vh; content stays vertically centred inside it
@@ -0,0 +1,70 @@
1
+ import { Icon } from '@kolkrabbi/kol-icons'
2
+ import Button from '../atoms/Button.jsx'
3
+ import Divider from '../atoms/Divider.jsx'
4
+ import SplitToolButton from '../molecules/SplitToolButton.jsx'
5
+
6
+ /**
7
+ * ToolPalette — the editor's tool bar as one row (kol-fxr `shell/panels/ToolPalette.jsx`,
8
+ * editor-panels-the-held-specs A3, 2026-09-25). Four kinds of cell, all on one pinned-square rung:
9
+ *
10
+ * - `tool` — arms a mode; lit while `activeId` is its id
11
+ * - `action` — a one-shot operation (flip, rotate, duplicate)
12
+ * - `split` — a fold of variants: `SplitToolButton`. A fold of TOOLS arms (Shape); a fold with
13
+ * `action: true` runs its variants instead, the trigger re-running the last-picked one
14
+ * (Boolean); a variant with `action: true` inside a tool fold is a one-shot row (Text →
15
+ * Kinetic type)
16
+ * - `divider` — a hairline between groups
17
+ *
18
+ * The store is the consumer's (the source read `useTool` + `useComposeState` directly): what
19
+ * is armed, what each action does and **when an item is disabled** — needs a selection, needs
20
+ * two booleanable layers — all arrive in `items` and are never inferred here.
21
+ *
22
+ * `min-w-0 overflow-x-auto`: at a narrow width the row scrolls in its own box instead of
23
+ * painting over the rail beside it, as the source learned.
24
+ *
25
+ * @param {Object} props
26
+ * @param {Array<{kind: 'tool'|'action'|'split'|'divider', id?: string, icon?: string, label?: string, shortcut?: string, disabled?: boolean, action?: boolean, variants?: Array<{id: string, label: string, icon: string, shortcut?: string, action?: boolean}>}>} props.items - The row, left to right
27
+ * @param {string} props.activeId - The armed tool's id — a `tool` item's, or any variant's of a tool fold
28
+ * @param {Function} props.onSelect - (id) => void — a tool (or a tool variant) was armed
29
+ * @param {Function} props.onAction - (id) => void — an action (or an action variant) was run
30
+ * @param {'xs'|'sm'|'md'|'lg'} props.size - The rung — 22 · 26 · 32 · 40 (default: 'md', the source's 32)
31
+ * @param {ElementType} props.iconComponent - Glyph renderer receiving `{ name, size, className, style }` (default: DS `Icon`)
32
+ * @param {string} props.className - Additional classes on the row
33
+ */
34
+ const blur = (e) => e.currentTarget.blur()
35
+
36
+ const ToolPalette = ({
37
+ items = [],
38
+ activeId,
39
+ onSelect,
40
+ onAction,
41
+ size = 'md',
42
+ iconComponent = Icon,
43
+ className = '',
44
+ }) => (
45
+ <div className={`flex items-center gap-1 min-w-0 overflow-x-auto ${className}`.trim()}>
46
+ {items.map((it, i) => {
47
+ if (it.kind === 'divider') return <Divider key={`d${i}`} variant="vertical" height={20} className="mx-1.5 shrink-0" />
48
+ const tip = it.shortcut ? `${it.label} (${it.shortcut})` : it.label
49
+ if (it.kind === 'split') {
50
+ const variants = (it.variants ?? []).map((v) => (v.action && !it.action ? { ...v, onSelect: () => onAction?.(v.id) } : v))
51
+ const run = (id) => (it.action ? onAction : onSelect)?.(id)
52
+ return (
53
+ <SplitToolButton key={it.id} variants={variants} value={activeId} size={size} iconComponent={iconComponent}
54
+ active={!it.action && variants.some((v) => v.id === activeId && !v.action)}
55
+ onChange={run} onTrigger={it.action ? run : undefined}
56
+ disabled={it.disabled} blurOnClick aria-label={it.label} />
57
+ )
58
+ }
59
+ const isTool = it.kind === 'tool'
60
+ return (
61
+ <Button key={it.id} variant="ghost" size={size} quiet iconOnly={it.icon} iconComponent={iconComponent}
62
+ pressed={isTool ? activeId === it.id : undefined} disabled={it.disabled}
63
+ aria-label={it.label} title={tip}
64
+ onClick={(e) => { (isTool ? onSelect : onAction)?.(it.id); blur(e) }} />
65
+ )
66
+ })}
67
+ </div>
68
+ )
69
+
70
+ export default ToolPalette
@@ -1,38 +0,0 @@
1
- import Button from '../atoms/Button.jsx'
2
- import SectionCta from './SectionCta.jsx'
3
-
4
- /* taxonomy-ok: nests component's Button */
5
-
6
- /**
7
- * @deprecated 2026-08-26 — `FoundryCTA` is `SectionCta variant="centered"`
8
- * (SectionHeroRound2: a second way to render SectionText). Same render; the
9
- * `action` object(s) become Buttons. Alias kept; removed at the next major.
10
- *
11
- * @param {ReactNode} heading · description
12
- * @param {Object|Array} action one {href, label, variant?, target?, rel?} or an array
13
- * @param {Function} onNavigate (href, event) => void
14
- */
15
- export default function FoundryCTA({ heading, description, action, onNavigate, className = '' }) {
16
- const actions = (Array.isArray(action) ? action : [action]).filter(Boolean)
17
- return (
18
- <SectionCta
19
- variant="centered"
20
- headline={heading}
21
- body={description}
22
- className={className}
23
- actions={actions.length > 0 ? actions.map((act, i) => (
24
- <Button
25
- key={i}
26
- variant={act.variant === 'secondary' ? 'outline' : 'primary'}
27
- size="md"
28
- href={act.href}
29
- target={act.target}
30
- rel={act.rel}
31
- onClick={onNavigate ? (e) => onNavigate(act.href, e) : undefined}
32
- >
33
- {act.label}
34
- </Button>
35
- )) : undefined}
36
- />
37
- )
38
- }