@kolkrabbi/kol-component 0.260.0 → 0.261.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.260.0",
3
+ "version": "0.261.0",
4
4
  "description": "The core component library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "react-dom": "^18.3.0 || ^19.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@kolkrabbi/kol-icons": "^0.37.0"
41
+ "@kolkrabbi/kol-icons": "^0.38.0"
42
42
  },
43
43
  "files": [
44
44
  "src",
@@ -0,0 +1,61 @@
1
+ import { Icon } from '@kolkrabbi/kol-icons'
2
+ import { SOLO } from '../hooks/glyphLadders.js'
3
+ import { Tooltip } from '../utilities/Popover.jsx'
4
+
5
+ /* taxonomy-ok: atom — one control, Icon + the DS Tooltip */
6
+
7
+ /**
8
+ * IconToggle — an icon-only toggle: the icon is the control, the state is its INK, the name is the
9
+ * tooltip (IconToggle, kol-mirror 2026-10-15 — user: *"why is everything in brackets icon AND TEXT?
10
+ * all of this is also listed in shortcuts so? … because we want to minimise noise"*).
11
+ *
12
+ * The interactive twin of `IconFrame`: no ground, no border, no pressed fill. `IconFrame` has no
13
+ * states by law and `ToggleBracket` is text, so neither fits; `Button pressed` paints the inverted
14
+ * fill, which is the tool-palette idiom and too loud for studio chrome. It owns `.kol-icon-toggle`
15
+ * for the same reason IconFrame owns its classes — nothing of `kol-btn-*` to inherit.
16
+ *
17
+ * Ink on the `oq` ladder (icons-use-oq law): on 96 · off 32 · off-hover 64 · disabled 12;
18
+ * `tone="danger"` puts the ON ink on `--ui-error` (mirror's Lock: a locked view reads as a warning).
19
+ * Square on the size ladder (xs 22 · sm 26 · md 32), glyph on the solo ladder.
20
+ *
21
+ * @param {boolean} pressed state → `aria-pressed`
22
+ * @param {Function} onChange `(next) => void`
23
+ * @param {string} icon icon when off (and on, without `iconOn`)
24
+ * @param {string} [iconOn] icon when on (Lock: `unlock` → `lock`)
25
+ * @param {string} label `aria-label` — required, there is no visible text
26
+ * @param {string} [title] tooltip, default `label` (mirror: "Lock the view (L)")
27
+ * @param {'default'|'danger'} [tone='default']
28
+ * @param {'xs'|'sm'|'md'} [size='sm']
29
+ * @param {boolean} [disabled]
30
+ */
31
+ export default function IconToggle({
32
+ pressed = false,
33
+ onChange,
34
+ icon,
35
+ iconOn,
36
+ label,
37
+ title,
38
+ tone = 'default',
39
+ size = 'sm',
40
+ disabled = false,
41
+ iconComponent: IconCmp = Icon,
42
+ className = '',
43
+ ...rest
44
+ }) {
45
+ const cls = `kol-icon-toggle kol-icon-toggle-${size}${tone === 'danger' ? ' kol-icon-toggle-danger' : ''} ${className}`.trim()
46
+ return (
47
+ <Tooltip label={title ?? label} triggerClassName="inline-flex shrink-0">
48
+ <button
49
+ type="button"
50
+ className={cls}
51
+ aria-pressed={pressed}
52
+ aria-label={label}
53
+ disabled={disabled}
54
+ onClick={() => onChange?.(!pressed)}
55
+ {...rest}
56
+ >
57
+ <IconCmp name={pressed && iconOn ? iconOn : icon} size={SOLO[size] ?? SOLO.sm} />
58
+ </button>
59
+ </Tooltip>
60
+ )
61
+ }
package/src/index.js CHANGED
@@ -35,6 +35,7 @@ export { default as DocsToc } from './molecules/DocsToc.jsx'
35
35
  export { default as DropdownTagFilter } from './molecules/DropdownTagFilter.jsx'
36
36
  export { default as EmptyState } from './molecules/EmptyState.jsx'
37
37
  export { default as IconFrame } from './atoms/IconFrame.jsx'
38
+ export { default as IconToggle } from './atoms/IconToggle.jsx'
38
39
  export { default as ExitPreview } from './utilities/ExitPreview.jsx'
39
40
  export { default as Figure } from './atoms/Figure.jsx'
40
41
  export { default as FullscreenOverlay } from './utilities/FullscreenOverlay.jsx'
@@ -2,15 +2,13 @@ import { createContext, useContext, useEffect, useMemo, useState } from 'react'
2
2
  import { Icon } from '@kolkrabbi/kol-icons'
3
3
  import ActionButton from '../molecules/ActionButton.jsx'
4
4
  import Button from '../atoms/Button.jsx'
5
- import CloseButton from '../atoms/CloseButton.jsx'
6
5
  import Divider from '../atoms/Divider.jsx'
7
6
  import Dropdown from '../molecules/Dropdown.jsx'
8
7
  import Input from '../atoms/Input.jsx'
9
- import SizeOrDownload from '../atoms/SizeOrDownload.jsx'
10
8
  import ViewToggle from '../atoms/ViewToggle.jsx'
11
9
  import FullscreenOverlay from '../utilities/FullscreenOverlay.jsx'
12
10
  import { Tooltip } from '../utilities/Popover.jsx'
13
- import ContentCard from '../molecules/ContentCard.jsx'
11
+ import MediaTile from '../molecules/MediaTile.jsx'
14
12
  import ContentRow from '../molecules/ContentRow.jsx'
15
13
  import ContentFilters from './ContentFilters.jsx'
16
14
  import { MenuItem, MenuDropdownItem, MenuDropdownDivider } from '../molecules/MenuItem.jsx'
@@ -33,8 +31,8 @@ import { filterMedia } from '../utilities/mediaSearch.js'
33
31
  * Same contract as kol-dashboards / kol-chess / kol-content.
34
32
  *
35
33
  * COMPOSED, NOT BUILT. Every part is an existing DS member:
36
- * ContentCard — the grid tile, `variant="default"` (thumb · download in the
37
- * frame corner · title · date · size-or-download · inline actions)
34
+ * MediaTile — the grid tile, preview over name — `picker`'s tile (was ContentCard
35
+ * default until 2026-10-15, MediaLibraryModalTilesBroken)
38
36
  * ContentRow — the list row, `variant="default"` (thumb · title · date · size · actions)
39
37
  * MediaCard / MediaRow retired 2026-08-26 (ContentSetRetirement);
40
38
  * this was the DS's own last composition of them, swapped 2026-08-27
@@ -711,23 +709,18 @@ function FilesBody({ files, viewMode, onOpen, onPick }) {
711
709
  </div>
712
710
  )
713
711
  }
714
- /* INLINE controls, never labelled Buttons (ContentSetRetirement, 2026-08-27):
715
- * the card's `actions` float in the plate's corner beside the title, so a
716
- * labelled Button there sits on the copy — kol-r2b2's column of
717
- * `.kol-inline-control`s is the shape that fits. The card's download is the
718
- * frame-corner `control` + the size slot (SizeOrDownload); the row keeps its
719
- * glyph beside Copy. `Use` (picker only) is the same control wearing `plus`. */
720
- const actionsFor = (row, form) => (
721
- <div className={form === 'row' ? 'flex items-center gap-2' : 'flex h-full flex-col items-center justify-between'}>
712
+ /* INLINE controls, never labelled Buttons (ContentSetRetirement, 2026-08-27) —
713
+ * the list row's Use · Copy · Download. `Use` (picker only) is the same control
714
+ * wearing `plus`. The grid's tile carries none (see below). */
715
+ const actionsFor = (row) => (
716
+ <div className="flex items-center gap-2">
722
717
  {onPick && <ActionButton chrome="inline" size="sm" icon="plus" confirmIcon="check" label="Use" confirmLabel="Used" onAction={() => onPick(row)} />}
723
718
  <ActionButton chrome="inline" size="sm" icon="copy" confirmIcon="check" label="Copy URL" confirmLabel="Copied" onAction={() => copy(urlFor(row))} />
724
- {form === 'row' && (
725
- <ActionButton chrome="inline" size="sm" icon="download" confirmIcon="check" label="Download" confirmLabel="Downloaded" href={urlFor(row)} />
726
- )}
719
+ <ActionButton chrome="inline" size="sm" icon="download" confirmIcon="check" label="Download" confirmLabel="Downloaded" href={urlFor(row)} />
727
720
  </div>
728
721
  )
729
- /* the title voice is the family's ruled default (heading-04 card / heading-05
730
- * row, truncated by ContentText); the full key rides as the tooltip, as before */
722
+ /* the row's title voice is the family's ruled default (heading-05, truncated by
723
+ * ContentText); the tile's is MediaTile's. The full key rides as the tooltip. */
731
724
  const nameFor = (row) => <Tooltip label={row.key} asChild><span>{row.displayKey}</span></Tooltip>
732
725
  const date = (row) => (row.uploaded ? String(row.uploaded).slice(0, 10) : undefined)
733
726
  const size = (row) => formatSize(row.size) || undefined
@@ -744,24 +737,25 @@ function FilesBody({ files, viewMode, onOpen, onPick }) {
744
737
  title={nameFor(row)}
745
738
  date={date(row)}
746
739
  size={size(row)}
747
- actions={actionsFor(row, 'row')}
740
+ actions={actionsFor(row)}
748
741
  />
749
742
  ))}
750
743
  </div>
751
744
  ) : (
752
- <div className="kol-media-grid">
745
+ /* THE PICKER'S TILE (MediaLibraryModalTilesBroken, kol-mirror 2026-10-15). The grid wore
746
+ * `ContentCard` default — a heading-04 filename, and an actions column that sat on the size —
747
+ * while `picker`'s grid is `MediaTile`, preview over name (the card was retired from the file
748
+ * grid 2026-09-23 for exactly that). Same item here: a click opens the lightbox, where Use and
749
+ * Copy URL live; a double-click (or Enter) uses the file. */
750
+ <div className="kol-media-grid gap-y-5">
753
751
  {files.map((row) => (
754
- <ContentCard
752
+ <MediaTile
755
753
  key={row.key}
756
- variant="default"
757
- media={thumbFor(row)}
758
- control={
759
- <ActionButton chrome="media" icon="download" confirmIcon="check" label="Download" confirmLabel="Downloaded" href={urlFor(row)} />
760
- }
761
- title={nameFor(row)}
762
- date={date(row)}
763
- size={size(row) && <SizeOrDownload href={urlFor(row)}>{size(row)}</SizeOrDownload>}
764
- actions={actionsFor(row, 'card')}
754
+ markKey={row.key}
755
+ preview={<div className="w-full h-full flex items-center justify-center bg-fg-04 overflow-hidden"><Thumb row={row} mediaUrl={mediaUrl} /></div>}
756
+ name={nameFor(row)}
757
+ onClick={openerFor(row)}
758
+ onDoubleClick={onPick ? () => onPick(row) : undefined}
765
759
  />
766
760
  ))}
767
761
  </div>
@@ -1090,7 +1084,9 @@ function PickerBrowse({ client, accept, onClose, onSelect, title = 'MEDIA', ...b
1090
1084
  return (
1091
1085
  /* THE X SITS ON THE HEADER ROW (MediaPickerCloseOnTheHeaderRow, kol-fxr 2026-10-10 — user: *"x
1092
1086
  * close is in a weird place, align better"*). The overlay's corner close floated ~100px above
1093
- * the header and lined up with nothing; it rides `headerTrailing`, after the gear, instead. */
1087
+ * the header and lined up with nothing. In the control cluster after the gear it read as one more
1088
+ * control (media-picker-close-and-title, kol-mirror 2026-10-15), so it is the header's own ×:
1089
+ * alone at the far end of the title's row, the drawer's shape. */
1094
1090
  <FullscreenOverlay open scrim onClose={onClose} closeButton={false}>
1095
1091
  <div className="kol-media-picker gap-4">
1096
1092
  <MediaLibraryBrowse
@@ -1102,7 +1098,7 @@ function PickerBrowse({ client, accept, onClose, onSelect, title = 'MEDIA', ...b
1102
1098
  settings={settings}
1103
1099
  onSettingsChange={setSettings}
1104
1100
  onPickFile={setFile}
1105
- headerTrailing={<>{browseProps.headerTrailing}<CloseButton onClick={onClose} /></>}
1101
+ onHeaderClose={onClose}
1106
1102
  />
1107
1103
  <div className="mt-auto flex items-center justify-end gap-4">
1108
1104
  <span className="kol-mono-12 text-fg-48 truncate mr-auto">{file ? file.key : 'Select a file'}</span>
@@ -8,6 +8,7 @@ import Divider from '../atoms/Divider.jsx'
8
8
  import Input from '../atoms/Input.jsx'
9
9
  import Tag from '../atoms/Tag.jsx'
10
10
  import IconFrame from '../atoms/IconFrame.jsx'
11
+ import CloseButton from '../atoms/CloseButton.jsx'
11
12
  import ActionButton from '../molecules/ActionButton.jsx'
12
13
  import SizeOrDownload from '../atoms/SizeOrDownload.jsx'
13
14
  import ToggleCheckbox from '../atoms/ToggleCheckbox.jsx'
@@ -903,7 +904,7 @@ function TrashPanel({ trash, onClose, run, confirm }) {
903
904
  )
904
905
  }
905
906
 
906
- function LibraryHeader({ title, buckets, bucketId, appRoot, onBucket, bucketMeta, writable, headerActions, onSettings, onTrash, onHome, headerTrailing }) {
907
+ function LibraryHeader({ title, buckets, bucketId, appRoot, onBucket, bucketMeta, writable, headerActions, onSettings, onTrash, onHome, headerTrailing, onClose }) {
907
908
  /* the app's masthead voice when a Shell sets one (2026-09-29), else the display voice as before */
908
909
  const titleCls = mastheadTitleClass(useMasthead(), 'kol-sans-display-03')
909
910
  /* ONE BUCKET, NO DROPDOWN (user 2026-09-22) — a picker with one thing in it chooses nothing. */
@@ -916,12 +917,14 @@ function LibraryHeader({ title, buckets, bucketId, appRoot, onBucket, bucketMeta
916
917
  <header className="flex items-baseline justify-between gap-4">
917
918
  {onHome ? (
918
919
  <button type="button" onClick={onHome}
919
- className={`${titleCls} min-w-0 truncate text-left cursor-pointer transition-opacity hover:opacity-64`}
920
+ className={`${titleCls} text-fg-96 min-w-0 truncate text-left cursor-pointer transition-opacity hover:opacity-64`}
920
921
  aria-label={`${title} — back to the top`}>{title}</button>
921
922
  ) : (
922
- <h1 className={`${titleCls} min-w-0 truncate`}>{title}</h1>
923
+ /* its own ink (media-picker-close-and-title, kol-mirror 2026-10-15): portalled into a body
924
+ * with no colour, the title inherited black on the dark card */
925
+ <h1 className={`${titleCls} text-fg-96 min-w-0 truncate`}>{title}</h1>
923
926
  )}
924
- <div className="flex items-center gap-2 min-w-0">
927
+ <div className={`flex items-center gap-2 min-w-0${onClose ? ' ml-auto' : ''}`}>
925
928
  {options.length > 0 && <Dropdown className="min-w-0 max-w-[45vw] md:w-48 md:max-w-none" value={appRoot ? 'all' : bucketId} onChange={onBucket} options={options} />}
926
929
  {headerActions}
927
930
  {/* The DS's own `Tooltip` (utilities/Popover → `.kol-tooltip`), not a `title`
@@ -947,6 +950,10 @@ function LibraryHeader({ title, buckets, bucketId, appRoot, onBucket, bucketMeta
947
950
  * the row directly beneath it. */}
948
951
  {headerTrailing}
949
952
  </div>
953
+ {/* THE × IS THE CARD'S, NOT A CONTROL (media-picker-close-and-title, kol-mirror 2026-10-15 — user:
954
+ * "you ever seen a close out button before??", pointing at the Display Settings drawer). Alone at
955
+ * the far end of the title's row, outside the control cluster — the drawer's shape. */}
956
+ {onClose && <CloseButton onClick={onClose} className="shrink-0 self-center" />}
950
957
  </header>
951
958
  )
952
959
  }
@@ -1031,6 +1038,8 @@ export function MediaLibraryBrowse({
1031
1038
  * rendering what it rendered. */
1032
1039
  view: viewProp, onViewChange,
1033
1040
  folderTree, headerActions, headerTrailing, refreshKey, onOpen, autoFocus = false, settingsFooter, className = '', banner,
1041
+ /* `onHeaderClose` — a × alone at the far end of the title row, outside the controls (the picker card) */
1042
+ onHeaderClose,
1034
1043
  /* `smartFolder` — a smart folder's id to open ON (a Home tile linking straight to one); the chips
1035
1044
  * take over from there (media D1 plan v2) */
1036
1045
  smartFolder,
@@ -2341,7 +2350,7 @@ export function MediaLibraryBrowse({
2341
2350
  return (
2342
2351
  <div ref={pageRef} {...press} className={`flex flex-col gap-6 ${className}`.trim()}>
2343
2352
  <RowSize.Provider value={rowSize}>
2344
- <LibraryHeader title={title} buckets={buckets} bucketId={bucketMeta.id} appRoot={atTitleRoot} bucketMeta={bucketMeta} writable={writable} headerActions={headerActions} headerTrailing={headerTrailing} onTrash={trash ? () => setTrashOpen(true) : undefined}
2353
+ <LibraryHeader title={title} buckets={buckets} bucketId={bucketMeta.id} appRoot={atTitleRoot} bucketMeta={bucketMeta} writable={writable} headerActions={headerActions} headerTrailing={headerTrailing} onClose={onHeaderClose} onTrash={trash ? () => setTrashOpen(true) : undefined}
2345
2354
  onHome={goTitleRoot}
2346
2355
  onBucket={(v) => { if (v === 'all') goTitleRoot(); else { setAppRoot(false); switchBucket(v) } }}
2347
2356
  onSettings={onOpenSettings ?? (() => setSettingsOpen(true))} />