@diegopluna/narvi 0.5.8 → 0.5.10
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/dist/components/dialog/ConfirmDialog.svelte +1 -2
- package/dist/components/dialog/DialogDescription.svelte +2 -2
- package/dist/components/dialog/DialogTitle.svelte +2 -2
- package/dist/components/input/Input.svelte +156 -15
- package/dist/components/input/Input.svelte.d.ts +17 -3
- package/dist/components/markdown/Markdown.svelte +68 -7
- package/dist/components/markdown/Markdown.svelte.d.ts +9 -0
- package/dist/components/markdown/MarkdownBlocks.svelte +4 -3
- package/dist/components/markdown/MarkdownCode.svelte +108 -9
- package/dist/components/markdown/MarkdownCode.svelte.d.ts +5 -1
- package/dist/components/markdown/MarkdownHtmlPreview.svelte +186 -0
- package/dist/components/markdown/MarkdownHtmlPreview.svelte.d.ts +11 -0
- package/dist/components/markdown/MarkdownPreview.svelte +17 -0
- package/dist/components/markdown/MarkdownPreview.svelte.d.ts +6 -0
- package/dist/components/markdown/MarkdownTable.svelte +61 -4
- package/dist/components/markdown/context.d.ts +21 -0
- package/dist/components/markdown/labels.d.ts +12 -0
- package/dist/components/markdown/labels.js +5 -0
- package/dist/components/markdown/preview.d.ts +9 -0
- package/dist/components/markdown/preview.js +14 -0
- package/dist/components/markdown/static.d.ts +2 -0
- package/dist/components/markdown/static.js +5 -1
- package/dist/components/markdown/table-image.d.ts +15 -0
- package/dist/components/markdown/table-image.js +342 -0
- package/dist/components/message/MessageAction.svelte +17 -2
- package/dist/components/message/MessageAction.svelte.d.ts +7 -0
- package/dist/internal/Glyph.svelte +11 -0
- package/dist/internal/Glyph.svelte.d.ts +2 -0
- package/dist/internal/closing.svelte.d.ts +0 -6
- package/dist/internal/closing.svelte.js +0 -33
- package/dist/internal/markers.stylex.d.ts +4 -0
- package/dist/internal/markers.stylex.js +2 -0
- package/dist/markdown/highlight.d.ts +2 -2
- package/dist/markdown/highlight.js +2 -2
- package/dist/markdown/html.d.ts +3 -1
- package/dist/markdown/html.js +6 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +2 -2
- package/dist/markdown/table.d.ts +20 -1
- package/dist/markdown/table.js +111 -0
- package/package.json +19 -19
- package/skills/building-ui/SKILL.md +5 -5
- package/skills/building-ui/references/components.md +26 -26
- package/skills/markdown/SKILL.md +26 -7
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
package/dist/markdown/table.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { inlinesToHtml } from './html.js';
|
|
1
2
|
/** The text of inline nodes, without their formatting. A formula is its TeX. */
|
|
2
3
|
export function inlineText(nodes) {
|
|
3
4
|
let out = '';
|
|
@@ -58,3 +59,113 @@ export function tableToCsv(table, separator = ',') {
|
|
|
58
59
|
.map((r) => r.children.map((c) => cell(inlineText(c.children))).join(separator))
|
|
59
60
|
.join('\r\n');
|
|
60
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* The table as HTML, for a rich-text editor: a `<table>` with a head and a body, each cell's
|
|
64
|
+
* alignment as `align` and as `text-align`, and its emphasis, code and links kept. Raw HTML in
|
|
65
|
+
* a cell is written as text, and a link or image the default policy refuses is its words.
|
|
66
|
+
*/
|
|
67
|
+
export function tableToHtml(table) {
|
|
68
|
+
const [head, ...body] = table.children;
|
|
69
|
+
if (!head)
|
|
70
|
+
return '';
|
|
71
|
+
const row = (cells, tag) => '<tr>' +
|
|
72
|
+
cells.children
|
|
73
|
+
.map((cell, i) => {
|
|
74
|
+
const align = table.align[i];
|
|
75
|
+
const aligned = align ? ` align="${align}" style="text-align: ${align}"` : '';
|
|
76
|
+
const html = inlinesToHtml(cell.children, { rawHtml: false, safeLinks: true });
|
|
77
|
+
return `<${tag}${aligned}>${html}</${tag}>`;
|
|
78
|
+
})
|
|
79
|
+
.join('') +
|
|
80
|
+
'</tr>';
|
|
81
|
+
return (`<table><thead>${row(head, 'th')}</thead>` +
|
|
82
|
+
(body.length > 0 ? `<tbody>${body.map((r) => row(r, 'td')).join('')}</tbody>` : '') +
|
|
83
|
+
'</table>');
|
|
84
|
+
}
|
|
85
|
+
// What takes no column in a terminal: marks that join the letter before them, formatting
|
|
86
|
+
// characters (zero-width spaces and joiners) and control characters
|
|
87
|
+
const reZeroWidth = /^[\p{Mn}\p{Me}\p{Cf}\p{Cc}]+$/u;
|
|
88
|
+
// What takes two: a picture shown as an emoji, by default or because it asks to be (U+FE0F),
|
|
89
|
+
// and a flag, which is two regional letters
|
|
90
|
+
const reEmoji = /\p{Emoji_Presentation}|\p{Extended_Pictographic}️|\p{Regional_Indicator}/u;
|
|
91
|
+
/** East Asian wide and full-width characters: CJK, kana, Hangul and their punctuation. */
|
|
92
|
+
function wide(code) {
|
|
93
|
+
return ((code >= 0x1100 && code <= 0x115f) ||
|
|
94
|
+
(code >= 0x2e80 && code <= 0x303e) ||
|
|
95
|
+
(code >= 0x3041 && code <= 0x33ff) ||
|
|
96
|
+
(code >= 0x3400 && code <= 0x4dbf) ||
|
|
97
|
+
(code >= 0x4e00 && code <= 0x9fff) ||
|
|
98
|
+
(code >= 0xa000 && code <= 0xa4cf) ||
|
|
99
|
+
(code >= 0xa960 && code <= 0xa97f) ||
|
|
100
|
+
(code >= 0xac00 && code <= 0xd7a3) ||
|
|
101
|
+
(code >= 0xf900 && code <= 0xfaff) ||
|
|
102
|
+
(code >= 0xfe10 && code <= 0xfe19) ||
|
|
103
|
+
(code >= 0xfe30 && code <= 0xfe6f) ||
|
|
104
|
+
(code >= 0xff00 && code <= 0xff60) ||
|
|
105
|
+
(code >= 0xffe0 && code <= 0xffe6) ||
|
|
106
|
+
(code >= 0x16fe0 && code <= 0x16fe4) ||
|
|
107
|
+
(code >= 0x17000 && code <= 0x18cff) ||
|
|
108
|
+
(code >= 0x1b000 && code <= 0x1b2ff) ||
|
|
109
|
+
(code >= 0x20000 && code <= 0x3fffd));
|
|
110
|
+
}
|
|
111
|
+
let segmenter;
|
|
112
|
+
/** The characters as a reader sees them: an emoji made of five code points is one. */
|
|
113
|
+
function graphemes(text) {
|
|
114
|
+
if (segmenter === undefined)
|
|
115
|
+
segmenter =
|
|
116
|
+
typeof Intl !== 'undefined' && 'Segmenter' in Intl
|
|
117
|
+
? new Intl.Segmenter(undefined, { granularity: 'grapheme' })
|
|
118
|
+
: null;
|
|
119
|
+
if (!segmenter)
|
|
120
|
+
return Array.from(text);
|
|
121
|
+
return Array.from(segmenter.segment(text), (part) => part.segment);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* How many columns text takes in a monospace font, as a terminal draws it: two for a CJK
|
|
125
|
+
* character or an emoji, none for a combining mark or a zero-width space, one for the rest.
|
|
126
|
+
*/
|
|
127
|
+
export function displayWidth(text) {
|
|
128
|
+
// Most cells are plain ASCII: counted without looking at each character
|
|
129
|
+
if (/^[\x20-\x7e]*$/.test(text))
|
|
130
|
+
return text.length;
|
|
131
|
+
let width = 0;
|
|
132
|
+
for (const character of graphemes(text)) {
|
|
133
|
+
if (reZeroWidth.test(character))
|
|
134
|
+
continue;
|
|
135
|
+
width += reEmoji.test(character) || wide(character.codePointAt(0)) ? 2 : 1;
|
|
136
|
+
}
|
|
137
|
+
return width;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The table as text whose columns line up in a monospace font: for a terminal, a commit
|
|
141
|
+
* message or a chat that takes no formatting. Columns are two spaces apart, the head is
|
|
142
|
+
* underlined with dashes, and each column is aligned as the table says, counting wide
|
|
143
|
+
* characters as two columns. Lines carry no spaces at their end.
|
|
144
|
+
*/
|
|
145
|
+
export function tableToText(table) {
|
|
146
|
+
const rows = table.children.map((r) => r.children.map((c) => {
|
|
147
|
+
const text = inlineText(c.children).replace(/\s+/g, ' ').trim();
|
|
148
|
+
return { text, width: displayWidth(text) };
|
|
149
|
+
}));
|
|
150
|
+
const count = Math.max(table.align.length, ...rows.map((r) => r.length));
|
|
151
|
+
const widths = Array.from({ length: count }, (_, i) => Math.max(1, ...rows.map((r) => r[i]?.width ?? 0)));
|
|
152
|
+
const line = (cells) => widths
|
|
153
|
+
.map((width, i) => {
|
|
154
|
+
const cell = cells[i] ?? { text: '', width: 0 };
|
|
155
|
+
const room = width - cell.width;
|
|
156
|
+
const align = table.align[i];
|
|
157
|
+
if (align === 'right')
|
|
158
|
+
return ' '.repeat(room) + cell.text;
|
|
159
|
+
if (align === 'center') {
|
|
160
|
+
const before = Math.floor(room / 2);
|
|
161
|
+
return ' '.repeat(before) + cell.text + ' '.repeat(room - before);
|
|
162
|
+
}
|
|
163
|
+
return cell.text + ' '.repeat(room);
|
|
164
|
+
})
|
|
165
|
+
.join(' ')
|
|
166
|
+
.trimEnd();
|
|
167
|
+
const [head, ...body] = rows;
|
|
168
|
+
if (!head)
|
|
169
|
+
return '';
|
|
170
|
+
return [line(head), widths.map((w) => '-'.repeat(w)).join(' '), ...body.map(line)].join('\n');
|
|
171
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegopluna/narvi",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"packageManager": "pnpm@12.18.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -112,13 +112,13 @@
|
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@codemirror/autocomplete": "^6.20.4",
|
|
115
|
-
"@codemirror/commands": "^6.11.
|
|
115
|
+
"@codemirror/commands": "^6.11.2",
|
|
116
116
|
"@codemirror/lang-css": "^6.3.1",
|
|
117
117
|
"@codemirror/lang-html": "^6.4.12",
|
|
118
118
|
"@codemirror/lang-javascript": "^6.2.5",
|
|
119
119
|
"@codemirror/language": "^6.13.1",
|
|
120
120
|
"@codemirror/state": "^6.7.6",
|
|
121
|
-
"@codemirror/view": "^6.
|
|
121
|
+
"@codemirror/view": "^6.44.2",
|
|
122
122
|
"@eslint/js": "^10.0.1",
|
|
123
123
|
"@fontsource-variable/fraunces": "^5.3.0",
|
|
124
124
|
"@fontsource-variable/geist": "^5.3.0",
|
|
@@ -130,24 +130,24 @@
|
|
|
130
130
|
"@fontsource/ibm-plex-sans": "^5.3.0",
|
|
131
131
|
"@fontsource/instrument-serif": "^5.3.0",
|
|
132
132
|
"@humanspeak/svelte-markdown": "2.2.0",
|
|
133
|
-
"@lezer/common": "^1.5.
|
|
133
|
+
"@lezer/common": "^1.5.7",
|
|
134
134
|
"@lezer/highlight": "^1.2.5",
|
|
135
|
-
"@lezer/javascript": "^1.5.
|
|
136
|
-
"@lezer/lr": "^1.4.
|
|
135
|
+
"@lezer/javascript": "^1.5.7",
|
|
136
|
+
"@lezer/lr": "^1.4.13",
|
|
137
137
|
"@replit/codemirror-lang-svelte": "^6.0.0",
|
|
138
138
|
"@sveltejs/adapter-static": "^4.0.1",
|
|
139
|
-
"@sveltejs/kit": "^3.4.
|
|
139
|
+
"@sveltejs/kit": "^3.4.1",
|
|
140
140
|
"@sveltejs/package": "^2.5.8",
|
|
141
|
-
"@sveltejs/vite-plugin-svelte": "^7.3.
|
|
141
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.2",
|
|
142
142
|
"@tanstack/intent": "0.5.6",
|
|
143
143
|
"@types/markdown-it": "14.2.0",
|
|
144
|
-
"@types/node": "^24.19.
|
|
144
|
+
"@types/node": "^24.19.4",
|
|
145
145
|
"@types/react": "19.2.14",
|
|
146
146
|
"@types/react-dom": "19.2.3",
|
|
147
147
|
"@vitest/browser-playwright": "^4.1.12",
|
|
148
148
|
"axe-core": "^4.14.1",
|
|
149
|
-
"eslint": "^10.
|
|
150
|
-
"eslint-config-prettier": "^10.1.
|
|
149
|
+
"eslint": "^10.16.0",
|
|
150
|
+
"eslint-config-prettier": "^10.1.9",
|
|
151
151
|
"eslint-plugin-svelte": "^3.24.1",
|
|
152
152
|
"globals": "^17.14.0",
|
|
153
153
|
"markdown-it": "15.0.3",
|
|
@@ -166,30 +166,30 @@
|
|
|
166
166
|
"remark-rehype": "11.1.2",
|
|
167
167
|
"shiki": "^4.6.0",
|
|
168
168
|
"streamdown": "2.7.1",
|
|
169
|
-
"svelte": "^5.
|
|
169
|
+
"svelte": "^5.59.2",
|
|
170
170
|
"svelte-check": "^4.7.8",
|
|
171
171
|
"svelte-exmarkdown": "5.0.2",
|
|
172
172
|
"svelte-streamdown": "5.0.0",
|
|
173
173
|
"typescript": "^6.0.3",
|
|
174
|
-
"typescript-eslint": "^8.
|
|
174
|
+
"typescript-eslint": "^8.74.0",
|
|
175
175
|
"unified": "11.0.5",
|
|
176
|
-
"vite": "^8.
|
|
176
|
+
"vite": "^8.4.0",
|
|
177
177
|
"vitest": "^4.1.12",
|
|
178
178
|
"vitest-browser-svelte": "^2.2.1",
|
|
179
|
-
"wrangler": "^4.
|
|
179
|
+
"wrangler": "^4.169.1"
|
|
180
180
|
},
|
|
181
181
|
"peerDependencies": {
|
|
182
182
|
"svelte": "^5.20.0",
|
|
183
183
|
"vite": ">=6"
|
|
184
184
|
},
|
|
185
185
|
"dependencies": {
|
|
186
|
-
"@pierre/highlights": "0.
|
|
186
|
+
"@pierre/highlights": "0.6.0",
|
|
187
187
|
"@stylexjs/stylex": "0.19.2",
|
|
188
188
|
"@stylexjs/unplugin": "0.19.2",
|
|
189
|
-
"@ui-sdk/core": "0.1.0-beta.
|
|
190
|
-
"@ui-sdk/svelte": "0.1.0-beta.
|
|
189
|
+
"@ui-sdk/core": "0.1.0-beta.23",
|
|
190
|
+
"@ui-sdk/svelte": "0.1.0-beta.23",
|
|
191
191
|
"decode-named-character-reference": "1.3.0",
|
|
192
|
-
"dompurify": "3.
|
|
192
|
+
"dompurify": "3.5.0",
|
|
193
193
|
"esm-env": "^1.2.2",
|
|
194
194
|
"katex": "0.19.1",
|
|
195
195
|
"lightningcss": "^1.33.0",
|
|
@@ -12,7 +12,7 @@ metadata:
|
|
|
12
12
|
Grid, and Narvi's conventions for colour, labels and copy.
|
|
13
13
|
type: core
|
|
14
14
|
library: '@diegopluna/narvi'
|
|
15
|
-
library_version: '0.5.
|
|
15
|
+
library_version: '0.5.10'
|
|
16
16
|
requires:
|
|
17
17
|
- setup
|
|
18
18
|
sources:
|
|
@@ -29,6 +29,7 @@ sources:
|
|
|
29
29
|
- src/lib/components/dialog/ConfirmDialog.svelte
|
|
30
30
|
- src/lib/components/notice/Notice.svelte
|
|
31
31
|
- src/lib/components/field/Field.svelte
|
|
32
|
+
- src/lib/components/input/Input.svelte
|
|
32
33
|
- src/lib/components/list/ListRoot.svelte
|
|
33
34
|
- src/lib/components/table/*
|
|
34
35
|
- src/lib/components/choice-cards/ChoiceCards.svelte
|
|
@@ -175,9 +176,8 @@ wires up `id`, `aria-describedby` and `aria-invalid`. Don't hand-write their `<l
|
|
|
175
176
|
- `group` makes the Field a fieldset named by its legend, for several controls under one label
|
|
176
177
|
(radios, a start and an end). The help and the error describe the group; its controls take
|
|
177
178
|
no id from it.
|
|
178
|
-
- `Input` takes an `icon` snippet at its start,
|
|
179
|
-
|
|
180
|
-
an icon, `sx` styles the element around the field; `inputSx` and `inputClass` style the field.
|
|
179
|
+
- `Input` takes an `icon` snippet at its start, an `end` snippet for your controls inside its
|
|
180
|
+
end (a clear `Button size="xs" iconOnly variant="ghost"`), or `reveal` for a password's eye.
|
|
181
181
|
- For one choice among a few that each need a line of detail, use `ChoiceCards`
|
|
182
182
|
(`options: { value, label, detail?, icon?, disabled? }[]`, `bind:value`, `aria-label`).
|
|
183
183
|
|
|
@@ -480,7 +480,7 @@ Parts of a thread that are easy to redraw by hand, and shouldn't be:
|
|
|
480
480
|
- **MEDIUM: a raw `<label>` beside an Input.** It misses Field's description and error wiring.
|
|
481
481
|
- **HIGH: `Dialog.Content size="lg"` written for 44rem.** Since the sizes gained `lg` 36rem,
|
|
482
482
|
`xl` 44 and `2xl` 56, the old `lg` is `xl`.
|
|
483
|
-
- **MEDIUM: an
|
|
483
|
+
- **MEDIUM: an icon, a clear button or an eye placed beside an Input.** Use `icon`, `end` or `reveal`.
|
|
484
484
|
- **MEDIUM: a toast's `onDismiss` alone for "Undo, or else forget".** A toast that runs out of
|
|
485
485
|
time calls `onAutoClose`, not `onDismiss`, so the forgetting never happens. Pass both.
|
|
486
486
|
- **MEDIUM: a SettingsRow's `<label for>` on a group.** A `SegmentedControl` or a set of radios
|
|
@@ -66,27 +66,27 @@ Markdown's table styles: Markdown's tables and this one share their look.
|
|
|
66
66
|
|
|
67
67
|
## Controls and forms
|
|
68
68
|
|
|
69
|
-
| Component | Use it for
|
|
70
|
-
| --------------------------- |
|
|
71
|
-
| `Button` | An action; `href` makes it a link; `variant` (12, from `primary` to `success-outline`), `size` (`micro` to `lg`), `shape`, `justify`, `loading`, `iconOnly`, `pressed`, `tooltip`
|
|
72
|
-
| `Field` | Label, help text and error around one control
|
|
73
|
-
| `Input` | One line of text
|
|
74
|
-
| `Textarea` | Several lines of text
|
|
75
|
-
| `Select` | One choice from a short list (`options: { value, label, icon?, detail?, detailMono?, group? }[]`, `align`, `optionIcon`)
|
|
76
|
-
| `Checkbox` | An option on or off, or several from a list
|
|
77
|
-
| `ChoiceCards` | One choice among a few, each a card with a title and a line of detail
|
|
78
|
-
| `Switch` | A setting that takes effect at once
|
|
79
|
-
| `SegmentedControl` | One of a few options, all visible (`options: { value, label, title? }[]`, `onchange`)
|
|
80
|
-
| `Slider` | A value or a range along a track
|
|
81
|
-
| `ColorField` | A colour: a swatch that opens Narvi's picker, beside a hex field (`label`, `bind:value`, `onchange`, `size`, `labels`)
|
|
82
|
-
| `SplitButton` | A main action joined to a menu of how to do it (`menu`, `menuLabel`, `label`, `variant` incl. `ghost`, `shape`, `mainDisabled`, `mainSx`/`menuSx`, `menuMinWidth`)
|
|
83
|
-
| `Toggle` | A button that stays pressed (`tone`: `accent`, or `neutral` for toolbar icons)
|
|
84
|
-
| `ToggleGroup.Root`, `.Item` | Toggles that belong together: one pressed, or any number; toggle buttons (`aria-pressed`) either way, never radios
|
|
85
|
-
| `SettingsGroup` | A titled group of settings: a heading, an action, the rows on one card
|
|
86
|
-
| `SettingsRow` | One setting: what it is, beside its control (`leading`, `dimmed`, `mono`)
|
|
87
|
-
| `Tabs` | Views that share one place (`tabs: TabItem[]`, `label`, `bind:value`; `activation="manual"` for a slow panel)
|
|
88
|
-
| `SearchButton` | Looks like a search field and opens search (`label`, `shortcut`): for a window's bar
|
|
89
|
-
| `TabStrip` | Tabs for what is open in a pane: closable, addable, scrolling (`tabs`, `bind:value`, `onclose`, `onadd`); `menu`, `onmove`, `onrename`, `onkeep`, `trailing`, `variant`. The panels are yours
|
|
69
|
+
| Component | Use it for | Docs slug |
|
|
70
|
+
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
|
|
71
|
+
| `Button` | An action; `href` makes it a link; `variant` (12, from `primary` to `success-outline`), `size` (`micro` to `lg`), `shape`, `justify`, `loading`, `iconOnly`, `pressed`, `tooltip` | `button` |
|
|
72
|
+
| `Field` | Label, help text and error around one control | `field` |
|
|
73
|
+
| `Input` | One line of text; an `icon` at its start, controls in an `end` snippet, or `reveal` for a password with an eye (`revealLabel`, "Show password"); with either, `inputSx` and `inputClass` style the field itself | `input` |
|
|
74
|
+
| `Textarea` | Several lines of text | `textarea` |
|
|
75
|
+
| `Select` | One choice from a short list (`options: { value, label, icon?, detail?, detailMono?, group? }[]`, `align`, `optionIcon`) | `select` |
|
|
76
|
+
| `Checkbox` | An option on or off, or several from a list | `checkbox` |
|
|
77
|
+
| `ChoiceCards` | One choice among a few, each a card with a title and a line of detail | `choice-cards` |
|
|
78
|
+
| `Switch` | A setting that takes effect at once | `switch` |
|
|
79
|
+
| `SegmentedControl` | One of a few options, all visible (`options: { value, label, title? }[]`, `onchange`) | `segmented-control` |
|
|
80
|
+
| `Slider` | A value or a range along a track | `slider` |
|
|
81
|
+
| `ColorField` | A colour: a swatch that opens Narvi's picker, beside a hex field (`label`, `bind:value`, `onchange`, `size`, `labels`) | `color-field` |
|
|
82
|
+
| `SplitButton` | A main action joined to a menu of how to do it (`menu`, `menuLabel`, `label`, `variant` incl. `ghost`, `shape`, `mainDisabled`, `mainSx`/`menuSx`, `menuMinWidth`) | `split-button` |
|
|
83
|
+
| `Toggle` | A button that stays pressed (`tone`: `accent`, or `neutral` for toolbar icons) | `toggle` |
|
|
84
|
+
| `ToggleGroup.Root`, `.Item` | Toggles that belong together: one pressed, or any number; toggle buttons (`aria-pressed`) either way, never radios | `toggle-group` |
|
|
85
|
+
| `SettingsGroup` | A titled group of settings: a heading, an action, the rows on one card | `settings-group` |
|
|
86
|
+
| `SettingsRow` | One setting: what it is, beside its control (`leading`, `dimmed`, `mono`) | `settings-row` |
|
|
87
|
+
| `Tabs` | Views that share one place (`tabs: TabItem[]`, `label`, `bind:value`; `activation="manual"` for a slow panel) | `tabs` |
|
|
88
|
+
| `SearchButton` | Looks like a search field and opens search (`label`, `shortcut`): for a window's bar | `search-button` |
|
|
89
|
+
| `TabStrip` | Tabs for what is open in a pane: closable, addable, scrolling (`tabs`, `bind:value`, `onclose`, `onadd`); `menu`, `onmove`, `onrename`, `onkeep`, `trailing`, `variant`. The panels are yours | `tab-strip` |
|
|
90
90
|
|
|
91
91
|
### Tab strips
|
|
92
92
|
|
|
@@ -176,11 +176,11 @@ browser; a `container` on a Root or a Content still wins, and the popups inside
|
|
|
176
176
|
{@render children()}
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
An Escape handler inside a popup that takes the key for itself (clearing a field, leaving an
|
|
180
|
+
edit) calls `event.preventDefault()`, and the popup stays open. ui-sdk takes Escape in the popup
|
|
181
|
+
content's own keydown, after the handler, and skips a key whose default is prevented. Stopping
|
|
182
|
+
propagation works too, with the popup in a container on `document.body` as well, but
|
|
183
|
+
`preventDefault()` also tells other listeners the key was used.
|
|
184
184
|
|
|
185
185
|
To drive `open` from the app, bind it, or pass it with an `onOpenChange` that keeps your state:
|
|
186
186
|
`open={shown && !dragging} onOpenChange={(next) => (shown = next)}` follows `dragging` even after
|
package/skills/markdown/SKILL.md
CHANGED
|
@@ -12,7 +12,7 @@ metadata:
|
|
|
12
12
|
patching the DOM, and decide which links and images text from a model may load.
|
|
13
13
|
type: core
|
|
14
14
|
library: '@diegopluna/narvi'
|
|
15
|
-
library_version: '0.5.
|
|
15
|
+
library_version: '0.5.10'
|
|
16
16
|
requires:
|
|
17
17
|
- setup
|
|
18
18
|
sources:
|
|
@@ -74,6 +74,18 @@ código' }}`. The type is `MarkdownLabels`, exported from `@diegopluna/narvi`.
|
|
|
74
74
|
fades in whole. Both are off by default and do nothing once `streaming` is false.
|
|
75
75
|
- `lineNumbers` numbers the lines of code blocks that have a language, and `download` gives
|
|
76
76
|
code blocks a button that saves the code, named by the fence's file name or its language.
|
|
77
|
+
- `previews` gives a finished code block tagged `markdown`, `md` or `html` an eye toggle
|
|
78
|
+
(named "Show rendered", with `aria-pressed`) that shows it rendered: `previews` for both, or
|
|
79
|
+
`previews={['html']}` for one kind. It is off by default, the toggle appears only once the
|
|
80
|
+
fence has closed, blocks start as source, and Copy always copies the source. Markdown is
|
|
81
|
+
drawn by `Markdown` itself with the same options and plugins, minus streaming, tickable tasks
|
|
82
|
+
and nested previews. HTML goes in an `<iframe srcdoc>` sandboxed with only
|
|
83
|
+
`allow-same-origin`: no script runs, nothing loads from the network (a CSP allows only
|
|
84
|
+
`data:` and `blob:` pictures and fonts), and no link in it navigates the frame or the page.
|
|
85
|
+
In Chromium and Firefox a link goes through the link policy (`links.open`, otherwise a new
|
|
86
|
+
tab); Safari runs no listener in a frame that runs no script, so there a link does nothing. The frame fits
|
|
87
|
+
its content up to 32rem, then scrolls. Turn it on for replies where seeing a README or a
|
|
88
|
+
snippet of markup rendered helps; leave it off where every block should read as code.
|
|
77
89
|
- `static` says whether finished blocks are written as markup, not built from parts: about
|
|
78
90
|
twice as fast to show, in a fifth of the memory. Leave it out. Narvi then writes markup for
|
|
79
91
|
text that was whole when the component was made and has not changed since (a reply loaded
|
|
@@ -152,11 +164,11 @@ needs the component's state. Never write a new array in the markup:
|
|
|
152
164
|
<Markdown value={text} streaming={!done} {plugins} />
|
|
153
165
|
```
|
|
154
166
|
|
|
155
|
-
- **`highlight()`** colours code in
|
|
167
|
+
- **`highlight()`** colours code in 190 languages with `@pierre/highlights`. A block that
|
|
156
168
|
streams is tokenized line by line as it arrives, never from the top again. Code takes Narvi's
|
|
157
169
|
syntax colours by default. Pass `highlight({ themes: { light, dark } })` with Zed-compatible
|
|
158
170
|
themes (for example from `@pierre/highlights/themes`) to use an editor theme. Importing the
|
|
159
|
-
module loads about
|
|
171
|
+
module loads about 190 KB (gzipped) of WebAssembly. To keep it out of the first load, import
|
|
160
172
|
it in the browser and add it to the plugins once, when it arrives (see below).
|
|
161
173
|
- **`math()`** turns on formulas (`$x$`, `$$x$$`, `\(x\)`, `\[x\]` and a fenced `math` block)
|
|
162
174
|
and typesets them with KaTeX, which loads on the first formula. Prices and shell variables
|
|
@@ -248,10 +260,17 @@ export const plugins = [
|
|
|
248
260
|
|
|
249
261
|
`url.startsWith('/attachments/')` alone would let `/attachments/../api/logout` through.
|
|
250
262
|
|
|
251
|
-
Tables need no plugin: each has a button, shown on hover or focus,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
263
|
+
Tables need no plugin: each has a button, shown on hover or focus, whose menu copies it as
|
|
264
|
+
Markdown, as text, as HTML, as CSV or as a PNG, or saves a CSV file. "Copy as text" pads the
|
|
265
|
+
columns to line up in a monospace font (two spaces apart, the head underlined with dashes,
|
|
266
|
+
each column aligned as written, CJK and emoji counted as two columns) for terminals and commit
|
|
267
|
+
messages. "Copy as HTML" writes a plain `<table>` as both `text/html` and `text/plain`. "Copy
|
|
268
|
+
as PNG" draws the table as it is on screen, in the current theme, with columns scrolled out of
|
|
269
|
+
view, at the screen's density up to 3x; it is left out where the clipboard can't take images.
|
|
270
|
+
In the CSV, a cell a spreadsheet would run as a formula (one that starts with `=`, `+`, `-` or
|
|
271
|
+
`@`) is written as text. `tableToCsv`, `tableToMarkdown`, `tableToText` and `tableToHtml` from
|
|
272
|
+
`@diegopluna/narvi/markdown` do the same for a `table` node, and `displayWidth(text)` gives the
|
|
273
|
+
monospace columns a string takes.
|
|
255
274
|
|
|
256
275
|
When a plugin needs the component's state, or should load late, build the array in the
|
|
257
276
|
component's script. A new array of the same plugin objects changes nothing, but a new plugin
|
package/skills/setup/SKILL.md
CHANGED
package/skills/styling/SKILL.md
CHANGED
package/skills/theming/SKILL.md
CHANGED