reifyui 0.13.4 → 0.13.5

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.13.4",
3
+ "version": "0.13.5",
4
4
  "description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI — model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
5
5
  "keywords": [
6
6
  "react",
@@ -49,6 +49,7 @@ function kindOf(name, mime = '') {
49
49
  if (mime.startsWith('audio/') || ['mp3', 'wav', 'ogg', 'm4a', 'flac'].includes(e)) return 'audio';
50
50
  if (e === 'csv' || e === 'tsv') return 'csv';
51
51
  if (e === 'md' || e === 'markdown') return 'markdown';
52
+ if (e === 'html' || e === 'htm') return 'html'; // the page itself, or its source: the header switches
52
53
  if (SHEET.has(e)) return 'sheet';
53
54
  if (OFFICE.has(e)) return 'office';
54
55
  if (mime.startsWith('text/') || LANG[e] || /^(txt|log|env|conf|cfg|gitignore)$/.test(e)) return 'code';
@@ -98,6 +99,9 @@ export function FilePreview({
98
99
  const { url, name } = file || {};
99
100
  const [st, setSt] = useState({ kind: 'loading' });
100
101
  const [tab, setTab] = useState(0);
102
+ // An HTML file opens as the page it is; Source shows what was written. The choice lives in the
103
+ // header, beside the name, so it reads as a property of the file being looked at.
104
+ const [view, setView] = useState('preview');
101
105
 
102
106
  useEffect(() => {
103
107
  if (!url) return undefined;
@@ -105,6 +109,7 @@ export function FilePreview({
105
109
  let obj;
106
110
  setSt({ kind: 'loading' });
107
111
  setTab(0);
112
+ setView('preview');
108
113
  const get = fetchFile || ((u) => fetch(u, { cache: 'no-store' }));
109
114
 
110
115
  (async () => {
@@ -142,7 +147,7 @@ export function FilePreview({
142
147
  }
143
148
  return;
144
149
  }
145
- if (kind === 'csv' || kind === 'markdown' || kind === 'code') {
150
+ if (kind === 'csv' || kind === 'markdown' || kind === 'code' || kind === 'html') {
146
151
  const text = await res.text();
147
152
  if (!alive) return;
148
153
  if (kind === 'csv') setSt({ kind: 'csv', rows: delimitedToRows(text, extOf(name) === 'tsv' ? '\t' : ',') });
@@ -164,6 +169,14 @@ export function FilePreview({
164
169
  <header className="uic-fp-head">
165
170
  <span className="uic-fp-ic"><FileTypeIcon name={name} size={20} /></span>
166
171
  <span className="uic-fp-name" title={name}>{name}</span>
172
+ {st.kind === 'html' && (
173
+ <div className="uic-fp-seg" role="tablist" aria-label="Show the page or its source">
174
+ {[['preview', 'Preview'], ['source', 'Source']].map(([id, label]) => (
175
+ <button key={id} type="button" role="tab" aria-selected={view === id}
176
+ className={'uic-fp-seg-btn' + (view === id ? ' is-on' : '')} onClick={() => setView(id)}>{label}</button>
177
+ ))}
178
+ </div>
179
+ )}
167
180
  <button type="button" className="uic-fp-btn" aria-label={`Download ${name}`} title="Download"
168
181
  onClick={download}><IcDownload /></button>
169
182
  {onClose && (
@@ -184,6 +197,12 @@ export function FilePreview({
184
197
  </div>
185
198
  )}
186
199
  {st.kind === 'code' && <CodeBlock code={st.text || ''} lang={LANG[extOf(name)] || 'plaintext'} />}
200
+ {st.kind === 'html' && view === 'source' && <CodeBlock code={st.text || ''} lang="xml" />}
201
+ {st.kind === 'html' && view === 'preview' && (
202
+ // The page runs in its own origin with scripts only: a mockup's own script and styles
203
+ // work, and nothing in it can read the host page, its cookies or its storage.
204
+ <iframe className="uic-fp-frame" title={name} sandbox="allow-scripts" srcDoc={st.text || ''} />
205
+ )}
187
206
  {st.kind === 'csv' && <Grid rows={st.rows} />}
188
207
  {st.kind === 'sheet' && st.sheets && (
189
208
  <div className="uic-fp-xlsx">
package/styles/file.css CHANGED
@@ -74,6 +74,10 @@
74
74
  display: inline-flex; align-items: center; justify-content: center;
75
75
  }
76
76
  .uic-fp-btn:hover { background: var(--uic-brand-faint, #EFF3FF); color: var(--uic-ink, #111317); }
77
+ /* the Preview | Source switch of an HTML file, a segmented control in the header */
78
+ .uic-fp-seg { flex: 0 0 auto; display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--uic-surface-2, #F7F8FA); border: 1px solid var(--uic-line, #DDDFE6); }
79
+ .uic-fp-seg-btn { height: 24px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--uic-mute, #5B5D66); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
80
+ .uic-fp-seg-btn.is-on { background: var(--uic-surface, #FFFFFF); color: var(--uic-ink, #111317); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
77
81
 
78
82
  .uic-fp-body { flex: 1; min-height: 0; overflow: auto; }
79
83
  .uic-fp-pad { padding: 18px; }