reifyui 0.7.0 → 0.7.2

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": "reifyui",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI \u2014 model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
5
5
  "keywords": [
6
6
  "react",
@@ -4,12 +4,12 @@
4
4
  // things — a full-width row with a Preview button, and a bare text chip — which is how one surface
5
5
  // ends up with a download affordance the other never got.
6
6
  //
7
- // `compact` is the only difference between them, and it is a size, not a second component: in a
8
- // grid cell there is room for a glyph and a name, so the sub-line and the button labels collapse
9
- // to icons. Everything remains reachable.
10
- import { Fragment } from 'react';
7
+ // There is ONE card. There was briefly a `compact` variant for grid cells, which shrank the
8
+ // actions to two 20px glyphs on a tinted background; it was a worse version of the thing it was
9
+ // a variant of, which is what a variant usually is. A cell narrow enough to need a different card
10
+ // is a cell too narrow to show the file at all — the name ellipsises and the card still works.
11
11
  import { FileTypeIcon, extOf } from './FileTypeIcon.jsx';
12
- import { IcDownload, IcEye } from './icons.jsx';
12
+ import { IcDownload } from './icons.jsx';
13
13
 
14
14
  /** "PPTX · output" — what it is, then where it came from. `origin` is the caller's word. */
15
15
  function subtitle(name, origin, bytes) {
@@ -26,39 +26,33 @@ export function bytesLabel(n) {
26
26
  return `${(n / 1048576).toFixed(1)} MB`;
27
27
  }
28
28
 
29
- export function FileCard({
30
- name, origin, bytes, onPreview, onDownload, compact = false, className = '',
31
- }) {
29
+ export function FileCard({ name, origin = 'output', bytes, onPreview, onDownload, className = '' }) {
32
30
  // The whole card opens the preview, and the eye repeats it as an explicit target — a card that
33
31
  // is clickable without saying so is a card people do not click.
34
32
  const open = onPreview ? (e) => { e.stopPropagation(); onPreview(); } : undefined;
35
33
  return (
36
- <div className={'uic-filecard' + (compact ? ' is-compact' : '') + (open ? ' is-clickable' : '')
37
- + (className ? ' ' + className : '')}
34
+ <div className={'uic-filecard' + (open ? ' is-clickable' : '') + (className ? ' ' + className : '')}
38
35
  onClick={open}
39
36
  role={open ? 'button' : undefined}
40
37
  tabIndex={open ? 0 : undefined}
41
38
  onKeyDown={open ? (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(e); } } : undefined}
42
39
  title={name}>
43
- <span className="uic-filecard-ic"><FileTypeIcon name={name} size={compact ? 20 : 30} /></span>
40
+ <span className="uic-filecard-ic"><FileTypeIcon name={name} size={32} /></span>
44
41
  <span className="uic-filecard-meta">
45
42
  <span className="uic-filecard-name">{name}</span>
46
- {!compact && <span className="uic-filecard-sub">{subtitle(name, origin, bytes)}</span>}
43
+ <span className="uic-filecard-sub">{subtitle(name, origin, bytes)}</span>
47
44
  </span>
48
- <Fragment>
49
- {onDownload && (
50
- <button type="button" className="uic-filecard-btn" aria-label={`Download ${name}`} title="Download"
51
- onClick={(e) => { e.stopPropagation(); onDownload(); }}>
52
- <IcDownload />
53
- </button>
54
- )}
55
- {onPreview && (
56
- <button type="button" className="uic-filecard-btn" aria-label={`Preview ${name}`} title="Preview"
57
- onClick={open}>
58
- <IcEye />
59
- </button>
60
- )}
61
- </Fragment>
45
+ {onDownload && (
46
+ <button type="button" className="uic-filecard-dl" aria-label={`Download ${name}`} title="Download"
47
+ onClick={(e) => { e.stopPropagation(); onDownload(); }}>
48
+ <IcDownload size={18} />
49
+ </button>
50
+ )}
51
+ {onPreview && (
52
+ <button type="button" className="uic-filecard-open" aria-label={`Preview ${name}`} onClick={open}>
53
+ Preview
54
+ </button>
55
+ )}
62
56
  </div>
63
57
  );
64
58
  }
package/src/index.js CHANGED
@@ -44,7 +44,7 @@ export {
44
44
  export { AuthForm } from './auth/AuthForm.jsx';
45
45
  export { GoogleButton, GOOGLE_ENABLED } from './auth/GoogleButton.jsx';
46
46
  // Shared AI-spreadsheet grid (reusable in the Sheets product AND studio Spaces).
47
- export { SheetGrid, sheetToDelimited, sheetToAoA } from './sheet/SheetGrid.jsx';
47
+ export { SheetGrid, sheetToDelimited, sheetToAoA, fitRowHeights } from './sheet/SheetGrid.jsx';
48
48
  // Files, drawn the same wherever they appear. FileTypeIcon uses react-file-icon when it is
49
49
  // installed (an optional peer) and falls back to an extension badge when it is not.
50
50
  export { FileTypeIcon, extOf } from './components/FileTypeIcon.jsx';
@@ -468,7 +468,7 @@ export function SheetGrid({
468
468
  </thead>
469
469
  <tbody>
470
470
  {rows.map((row, ri) => (
471
- <tr key={row.id}
471
+ <tr key={row.id} data-row-id={row.id}
472
472
  style={{
473
473
  ...(rowHeight(row) ? { height: rowHeight(row) } : null),
474
474
  '--shg-clamp': Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18)),
@@ -496,7 +496,7 @@ export function SheetGrid({
496
496
  runCell: onRunCell && !readOnly ? () => onRunCell(row.id, col.id) : null,
497
497
  });
498
498
  return (
499
- <td key={col.id}
499
+ <td key={col.id} data-col-id={col.id}
500
500
  className={'shg-cell' + (computed ? ' shg-cell-compute' : '')
501
501
  + (c.status && computed ? ` shg-cell-${c.status}` : '')
502
502
  + (peer ? ' shg-cell-peer' : '')}
@@ -713,6 +713,36 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
713
713
  );
714
714
  }
715
715
 
716
+ /**
717
+ * The height each row would need to show its content in full, measured from what is on screen.
718
+ *
719
+ * A row is clamped to its height by design — a sheet you cannot scan is not a sheet. But after a
720
+ * run, the thing a person wants is the answer, and an answer cut off at one line with no way to
721
+ * see the rest is the grid hiding the work it just paid for. So the host measures and commits a
722
+ * height, ONCE, rather than the grid guessing continuously.
723
+ *
724
+ * Measured, not estimated: `scrollHeight` is what the content actually occupies at this width,
725
+ * including the file cards. A formula over character counts would be a number nobody derived.
726
+ *
727
+ * Returns { rowId: px } for the rows given (or every row), clamped to [min, max].
728
+ */
729
+ export function fitRowHeights(container, { rowIds, min = 34, max = 320, padding = 12 } = {}) {
730
+ if (!container) return {};
731
+ const out = {};
732
+ const rows = container.querySelectorAll('tr[data-row-id]');
733
+ for (const tr of rows) {
734
+ const id = tr.getAttribute('data-row-id');
735
+ if (rowIds && !rowIds.includes(id)) continue;
736
+ let tallest = 0;
737
+ for (const cell of tr.querySelectorAll('td[data-col-id] .shg-val')) {
738
+ // The value box is clipped to the row; its scrollHeight is the content's real height.
739
+ tallest = Math.max(tallest, cell.scrollHeight);
740
+ }
741
+ if (tallest) out[id] = Math.min(max, Math.max(min, Math.round(tallest + padding)));
742
+ }
743
+ return out;
744
+ }
745
+
716
746
  // ── Export helpers (CSV / TSV / array-of-arrays) ─────────────────────────────
717
747
  // cellText(cell, column) lets a host say what one of its own column types is worth in a flat
718
748
  // file. Without it a cell whose value is an object exports as raw JSON, which is what a
package/styles/file.css CHANGED
@@ -23,25 +23,24 @@
23
23
  display: block; margin-top: 2px; font-size: 12px; color: var(--uic-mute, #5B5D66);
24
24
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
25
25
  }
26
- .uic-filecard-btn {
27
- width: 28px; height: 28px; flex: 0 0 auto; border-radius: 8px;
26
+ .uic-filecard-dl {
27
+ width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px;
28
28
  display: inline-flex; align-items: center; justify-content: center;
29
29
  border: 1px solid transparent; background: transparent; cursor: pointer;
30
30
  color: var(--uic-mute, #5B5D66);
31
31
  }
32
- .uic-filecard-btn:hover { background: var(--uic-brand-faint, #EFF3FF); color: var(--uic-brand, #285AFF); }
32
+ .uic-filecard-dl:hover { background: var(--uic-brand-faint, #EFF3FF); color: var(--uic-brand, #285AFF); }
33
+ .uic-filecard-open {
34
+ flex: 0 0 auto; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
35
+ white-space: nowrap; padding: 7px 15px; border-radius: 9px;
36
+ color: var(--uic-brand, #285AFF); background: var(--uic-surface, #FFFFFF);
37
+ border: 1px solid var(--uic-line, #DDDFE6);
38
+ }
39
+ .uic-filecard-open:hover { border-color: var(--uic-brand-soft, #E1E9FF); background: var(--uic-brand-faint, #EFF3FF); }
40
+ .uic-filecard-dl:focus-visible, .uic-filecard-open:focus-visible {
41
+ outline: 2px solid var(--uic-brand, #285AFF); outline-offset: 2px;
42
+ }
33
43
 
34
- /* Compact is a size, not a second component: in a grid cell there is room for a glyph and a name,
35
- so the sub-line goes and the buttons appear on hover. Everything stays reachable by keyboard. */
36
- .uic-filecard.is-compact {
37
- gap: 6px; padding: 3px 5px; border-radius: 8px; box-shadow: none;
38
- background: var(--uic-brand-faint, #EFF3FF); border-color: transparent;
39
- max-width: 100%;
40
- }
41
- .uic-filecard.is-compact .uic-filecard-name { font-size: 11.5px; font-weight: 500; }
42
- .uic-filecard.is-compact .uic-filecard-btn { width: 20px; height: 20px; opacity: 0; }
43
- .uic-filecard.is-compact:hover .uic-filecard-btn,
44
- .uic-filecard.is-compact:focus-within .uic-filecard-btn { opacity: 1; }
45
44
 
46
45
  /* The fallback glyph, for a build without react-file-icon. A file with no icon still has to be
47
46
  identifiable, so the extension itself is the icon. */
package/styles/sheet.css CHANGED
@@ -60,10 +60,10 @@
60
60
  /* The cell is the constraint on its own value. This used to carry an inline max-width of the
61
61
  column width minus 20, or 400px where the column had no explicit width — a number nothing
62
62
  derived, which ellipsised a value long before its own cell ran out of room. */
63
- .shg-val { display: flex; align-items: center; gap: 6px; padding: 0 10px; height: 100%;
63
+ .shg-val { display: flex; align-items: flex-start; gap: 6px; padding: 6px 10px; height: 100%;
64
64
  width: 100%; min-width: 0; box-sizing: border-box; }
65
65
  .shg-val-txt {
66
- flex: 1; min-width: 0; color: var(--uic-ink, #111317);
66
+ flex: 1; min-width: 0; color: var(--uic-ink, #111317); align-self: flex-start;
67
67
  /* Wrap to the row's height; the last visible line ellipsizes. Rows at the
68
68
  default height clamp to one line (classic sheet behavior); taller rows
69
69
  show more lines. --shg-clamp is set per row from its height. */