@diegopluna/narvi 0.3.12 → 0.4.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/dist/components/app-shell/AppShellHeader.svelte +15 -2
- package/dist/components/app-shell/AppShellStrip.svelte +41 -0
- package/dist/components/app-shell/AppShellStrip.svelte.d.ts +10 -0
- package/dist/components/app-shell/index.d.ts +3 -1
- package/dist/components/app-shell/index.js +2 -1
- package/dist/components/approval/Approval.svelte +147 -13
- package/dist/components/approval/Approval.svelte.d.ts +22 -0
- package/dist/components/avatar/AvatarFallback.svelte +2 -1
- package/dist/components/avatar/AvatarRoot.svelte +9 -6
- package/dist/components/composer/ComposerTray.svelte +150 -10
- package/dist/components/composer/ComposerTray.svelte.d.ts +15 -3
- package/dist/components/heading/Heading.svelte +2 -1
- package/dist/components/kbd/Kbd.svelte +2 -0
- package/dist/components/markdown/MarkdownHtml.svelte +7 -3
- package/dist/components/markdown/MarkdownTable.svelte +19 -5
- package/dist/components/markdown/styles.d.ts +0 -17
- package/dist/components/markdown/styles.js +4 -20
- package/dist/components/plan/Plan.svelte +146 -28
- package/dist/components/plan/Plan.svelte.d.ts +17 -2
- package/dist/components/queued-message/QueuedMessage.svelte +178 -49
- package/dist/components/queued-message/QueuedMessage.svelte.d.ts +25 -4
- package/dist/components/tab-strip/TabStrip.svelte +120 -12
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +17 -0
- package/dist/components/table/TableBody.svelte +27 -0
- package/dist/components/table/TableBody.svelte.d.ts +10 -0
- package/dist/components/table/TableCell.svelte +54 -0
- package/dist/components/table/TableCell.svelte.d.ts +17 -0
- package/dist/components/table/TableFoot.svelte +39 -0
- package/dist/components/table/TableFoot.svelte.d.ts +10 -0
- package/dist/components/table/TableHead.svelte +33 -0
- package/dist/components/table/TableHead.svelte.d.ts +10 -0
- package/dist/components/table/TableHeaderCell.svelte +61 -0
- package/dist/components/table/TableHeaderCell.svelte.d.ts +17 -0
- package/dist/components/table/TableRoot.svelte +144 -0
- package/dist/components/table/TableRoot.svelte.d.ts +22 -0
- package/dist/components/table/TableRow.svelte +59 -0
- package/dist/components/table/TableRow.svelte.d.ts +12 -0
- package/dist/components/table/context.d.ts +14 -0
- package/dist/components/table/context.js +15 -0
- package/dist/components/table/index.d.ts +16 -0
- package/dist/components/table/index.js +8 -0
- package/dist/components/table/styles.d.ts +56 -0
- package/dist/components/table/styles.js +44 -0
- package/dist/components/text/Text.svelte +19 -4
- package/dist/components/text/Text.svelte.d.ts +4 -2
- package/dist/components/work-fold/WorkFold.svelte +26 -1
- package/dist/components/work-fold/WorkFold.svelte.d.ts +5 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +7 -1
- package/dist/internal/markers.stylex.d.ts +4 -0
- package/dist/internal/markers.stylex.js +2 -0
- package/dist/internal/table.d.ts +29 -0
- package/dist/internal/table.js +34 -0
- package/dist/tokens.stylex.d.ts +2 -0
- package/dist/tokens.stylex.js +9 -3
- package/dist/typography.d.ts +40 -1
- package/dist/typography.js +42 -2
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +22 -22
- package/skills/building-ui/references/components.md +196 -42
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +21 -5
- package/skills/theming/SKILL.md +1 -1
|
@@ -6,22 +6,46 @@
|
|
|
6
6
|
The tray is a shelf that rises behind the composer. With nothing waiting it
|
|
7
7
|
takes no room and draws nothing, so the composer does not move when work
|
|
8
8
|
arrives or is answered.
|
|
9
|
+
|
|
10
|
+
What waits behind the request, the plan and the queue, goes in `queue`, over
|
|
11
|
+
it: a region of its own that scrolls once it is taller than `queueMaxHeight`,
|
|
12
|
+
so a long queue leaves the conversation its room and the request in sight.
|
|
13
|
+
(From Eregion's TrayWaiting, c1b599eb.)
|
|
14
|
+
|
|
15
|
+
Whether something waits is measured, not guessed from the markup: a part that
|
|
16
|
+
renders an empty wrapper, one with no size, opens no shelf. Shut, the shelf is
|
|
17
|
+
still laid out, out of the flow and unseen, so what is in it can be measured;
|
|
18
|
+
it opens once something in it has height, before that frame is painted.
|
|
9
19
|
-->
|
|
10
20
|
<script lang="ts" module>
|
|
11
21
|
import * as stylex from '@stylexjs/stylex';
|
|
22
|
+
import { DEV } from 'esm-env';
|
|
12
23
|
import type { Snippet } from 'svelte';
|
|
13
24
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
14
25
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
15
|
-
import { colors, density, radius } from '../../tokens.stylex.js';
|
|
26
|
+
import { colors, density, motion, radius } from '../../tokens.stylex.js';
|
|
27
|
+
import { media } from '../../media.stylex.js';
|
|
16
28
|
|
|
17
29
|
export type ComposerTrayProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
18
30
|
/** Names what is waiting, for assistive technology. */
|
|
19
31
|
label?: string | undefined;
|
|
20
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* What the agent asks of the person, nearest the composer: an Approval, a
|
|
34
|
+
* Questionnaire.
|
|
35
|
+
*/
|
|
21
36
|
pending?: Snippet | undefined;
|
|
22
37
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
38
|
+
* What waits behind the request, over it: a folded Plan, compact QueuedMessages. It
|
|
39
|
+
* scrolls in a region of its own once taller than `queueMaxHeight`, with room at its
|
|
40
|
+
* edges for its buttons' focus rings and hit areas.
|
|
41
|
+
*/
|
|
42
|
+
queue?: Snippet | undefined;
|
|
43
|
+
/** How tall `queue` grows before it scrolls: a CSS length. About a folded plan and four rows. */
|
|
44
|
+
queueMaxHeight?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Whether anything is waiting. Narvi opens the shelf while something in `pending` or
|
|
47
|
+
* `queue` has height, and only then; set this to say so yourself, `true` to hold it
|
|
48
|
+
* open and `false` to keep it shut.
|
|
25
49
|
*/
|
|
26
50
|
waiting?: boolean | undefined;
|
|
27
51
|
sx?: Sx | undefined;
|
|
@@ -32,13 +56,27 @@
|
|
|
32
56
|
/** A length at the window's density (`density` in the tokens). */
|
|
33
57
|
const d = (rem: string) => `calc(${rem} * ${density.factor})`;
|
|
34
58
|
|
|
59
|
+
// The room round the queue that its rows' buttons reach into: a focus ring, 4px out, and a
|
|
60
|
+
// hit area 40px tall about a compact row 2rem tall at the window's density
|
|
61
|
+
const REACH = `max(0.25rem, calc((2.5rem - ${d('2rem')}) / 2))`;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Whether an element takes up room: some height of its own, or, for a `display: contents`
|
|
65
|
+
* wrapper, which has no box, some in what it holds.
|
|
66
|
+
*/
|
|
67
|
+
function sized(element: Element): boolean {
|
|
68
|
+
if (element.getBoundingClientRect().height > 0) return true;
|
|
69
|
+
if (getComputedStyle(element).display !== 'contents') return false;
|
|
70
|
+
return [...element.children].some(sized);
|
|
71
|
+
}
|
|
72
|
+
|
|
35
73
|
const styles = stylex.create({
|
|
36
|
-
|
|
74
|
+
// The shelf is placed against it while shut
|
|
75
|
+
tray: { position: 'relative', display: 'flex', flexDirection: 'column', minWidth: 0 },
|
|
37
76
|
// A flat fill whose foot tucks in behind the composer by the composer's own radius, so
|
|
38
|
-
// the two read as one piece.
|
|
39
|
-
// that holds something and is not hidden.
|
|
77
|
+
// the two read as one piece.
|
|
40
78
|
pending: {
|
|
41
|
-
display:
|
|
79
|
+
display: 'flex',
|
|
42
80
|
flexDirection: 'column',
|
|
43
81
|
gap: d('0.375rem'),
|
|
44
82
|
padding: d('0.375rem'),
|
|
@@ -52,8 +90,43 @@
|
|
|
52
90
|
outlineColor: 'transparent',
|
|
53
91
|
outlineOffset: '-1px'
|
|
54
92
|
},
|
|
55
|
-
|
|
93
|
+
// Shut: out of the flow and unseen, taking no room and drawing nothing, but still laid
|
|
94
|
+
// out at the tray's width, so what arrives in it can be measured. It goes at once.
|
|
95
|
+
shut: {
|
|
96
|
+
position: 'absolute',
|
|
97
|
+
insetInline: 0,
|
|
98
|
+
bottom: 0,
|
|
99
|
+
visibility: 'hidden',
|
|
100
|
+
pointerEvents: 'none',
|
|
101
|
+
opacity: 0,
|
|
102
|
+
translate: { default: null, [media.motion]: '0 0.375rem' },
|
|
103
|
+
transitionDuration: '0s'
|
|
104
|
+
},
|
|
105
|
+
// Open: it rises into place as it fades in
|
|
106
|
+
open: {
|
|
107
|
+
opacity: 1,
|
|
108
|
+
translate: { default: null, [media.motion]: '0 0' },
|
|
109
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, translate' },
|
|
110
|
+
transitionDuration: motion.slow,
|
|
111
|
+
transitionTimingFunction: motion.easeOut
|
|
112
|
+
},
|
|
113
|
+
// Open at the first measure, as the page is first painted: there, not arriving
|
|
114
|
+
still: { transitionDuration: '0s' },
|
|
56
115
|
gone: { display: 'none' },
|
|
116
|
+
// Scrolls past its height. Its padding is the room its buttons reach into, and its
|
|
117
|
+
// margin takes that back, so its rows line up with the request under them.
|
|
118
|
+
queue: {
|
|
119
|
+
display: 'flex',
|
|
120
|
+
flexDirection: 'column',
|
|
121
|
+
gap: d('0.25rem'),
|
|
122
|
+
flexShrink: 0,
|
|
123
|
+
padding: REACH,
|
|
124
|
+
margin: `calc(-1 * ${REACH})`,
|
|
125
|
+
overflowY: 'auto',
|
|
126
|
+
overscrollBehavior: 'contain'
|
|
127
|
+
},
|
|
128
|
+
// Nothing in it has height: it takes none either, but stays laid out to be measured
|
|
129
|
+
queueEmpty: { gap: 0, padding: 0, margin: 0 },
|
|
57
130
|
// The composer stands in front of the shelf
|
|
58
131
|
front: {
|
|
59
132
|
position: 'relative',
|
|
@@ -69,26 +142,93 @@
|
|
|
69
142
|
let {
|
|
70
143
|
label = 'Waiting for you',
|
|
71
144
|
pending,
|
|
145
|
+
queue,
|
|
146
|
+
queueMaxHeight = d('12rem'),
|
|
72
147
|
waiting,
|
|
73
148
|
sx,
|
|
74
149
|
class: className,
|
|
75
150
|
children,
|
|
76
151
|
...rest
|
|
77
152
|
}: ComposerTrayProps = $props();
|
|
153
|
+
|
|
154
|
+
let shelf = $state<HTMLElement | null>(null);
|
|
155
|
+
let region = $state<HTMLElement | null>(null);
|
|
156
|
+
// Measured: whether something in the shelf, or in the queue, has height
|
|
157
|
+
let filled = $state(false);
|
|
158
|
+
let queued = $state(false);
|
|
159
|
+
let measured = $state(false);
|
|
160
|
+
// Set a frame after the first measure, so only what arrives later moves
|
|
161
|
+
let settled = $state(false);
|
|
162
|
+
|
|
163
|
+
const open = $derived(waiting ?? filled);
|
|
164
|
+
|
|
165
|
+
function measure() {
|
|
166
|
+
if (!shelf) return;
|
|
167
|
+
queued = !!region && [...region.children].some(sized);
|
|
168
|
+
filled = [...shelf.children].some((child) => (child === region ? queued : sized(child)));
|
|
169
|
+
if (!measured) {
|
|
170
|
+
measured = true;
|
|
171
|
+
requestAnimationFrame(() => (settled = true));
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Its contents change size as they arrive and go, and the shelf's own box with them, shut
|
|
176
|
+
// or open. The observer reports after layout and before paint, so the shelf opens or
|
|
177
|
+
// shuts in the same frame as what it holds changes.
|
|
178
|
+
$effect(() => {
|
|
179
|
+
if (!shelf) return;
|
|
180
|
+
const observer = new ResizeObserver(measure);
|
|
181
|
+
observer.observe(shelf);
|
|
182
|
+
if (region) observer.observe(region);
|
|
183
|
+
return () => observer.disconnect();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Held open with nothing in it to see: say so while developing, once until it fills
|
|
187
|
+
let warned = false;
|
|
188
|
+
$effect(() => {
|
|
189
|
+
if (!DEV || !measured) return;
|
|
190
|
+
if (open && !filled) {
|
|
191
|
+
if (warned) return;
|
|
192
|
+
warned = true;
|
|
193
|
+
console.warn(
|
|
194
|
+
`Composer.Tray "${label}": the shelf is open, but what is in it measures 0px tall, ` +
|
|
195
|
+
'so it shows as an empty fill over the composer. Check that `pending` and `queue` ' +
|
|
196
|
+
'render nothing while nothing waits, rather than a wrapper that is empty or holds ' +
|
|
197
|
+
'only whitespace, comments or empty elements, and that `waiting` is not set to ' +
|
|
198
|
+
'true while nothing does.'
|
|
199
|
+
);
|
|
200
|
+
} else if (filled) {
|
|
201
|
+
warned = false;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
78
204
|
</script>
|
|
79
205
|
|
|
80
206
|
<div data-slot="composer-tray" {...rest} {...attrs([styles.tray, sx], className)}>
|
|
81
207
|
<div
|
|
208
|
+
bind:this={shelf}
|
|
82
209
|
role="group"
|
|
83
210
|
aria-label={label}
|
|
84
211
|
data-slot="composer-tray-pending"
|
|
85
212
|
data-waiting={waiting}
|
|
213
|
+
data-open={open || undefined}
|
|
86
214
|
{...stylex.attrs(
|
|
87
215
|
styles.pending,
|
|
88
|
-
|
|
216
|
+
open ? styles.open : styles.shut,
|
|
217
|
+
!settled && styles.still,
|
|
89
218
|
waiting === false && styles.gone
|
|
90
219
|
)}
|
|
91
220
|
>
|
|
221
|
+
{#if queue}
|
|
222
|
+
<div
|
|
223
|
+
bind:this={region}
|
|
224
|
+
data-slot="composer-tray-queue"
|
|
225
|
+
data-empty={!queued || undefined}
|
|
226
|
+
style:max-height="calc({queueMaxHeight} + 2 * {REACH})"
|
|
227
|
+
{...stylex.attrs(styles.queue, !queued && styles.queueEmpty)}
|
|
228
|
+
>
|
|
229
|
+
{@render queue()}
|
|
230
|
+
</div>
|
|
231
|
+
{/if}
|
|
92
232
|
{@render pending?.()}
|
|
93
233
|
</div>
|
|
94
234
|
<div {...stylex.attrs(styles.front)}>{@render children?.()}</div>
|
|
@@ -4,11 +4,23 @@ import { type Sx } from '../../internal/sx.js';
|
|
|
4
4
|
export type ComposerTrayProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
5
5
|
/** Names what is waiting, for assistive technology. */
|
|
6
6
|
label?: string | undefined;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* What the agent asks of the person, nearest the composer: an Approval, a
|
|
9
|
+
* Questionnaire.
|
|
10
|
+
*/
|
|
8
11
|
pending?: Snippet | undefined;
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
13
|
+
* What waits behind the request, over it: a folded Plan, compact QueuedMessages. It
|
|
14
|
+
* scrolls in a region of its own once taller than `queueMaxHeight`, with room at its
|
|
15
|
+
* edges for its buttons' focus rings and hit areas.
|
|
16
|
+
*/
|
|
17
|
+
queue?: Snippet | undefined;
|
|
18
|
+
/** How tall `queue` grows before it scrolls: a CSS length. About a folded plan and four rows. */
|
|
19
|
+
queueMaxHeight?: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Whether anything is waiting. Narvi opens the shelf while something in `pending` or
|
|
22
|
+
* `queue` has height, and only then; set this to say so yourself, `true` to hold it
|
|
23
|
+
* open and `false` to keep it shut.
|
|
12
24
|
*/
|
|
13
25
|
waiting?: boolean | undefined;
|
|
14
26
|
sx?: Sx | undefined;
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
const sizes = stylex.create({
|
|
64
64
|
sm: { fontSize: font.sizeBody },
|
|
65
65
|
md: { fontSize: font.sizeReading },
|
|
66
|
-
|
|
66
|
+
// The title role's size, so a detail page's heading and a dialog's title agree
|
|
67
|
+
lg: { fontSize: font.sizeTitle, letterSpacing: '-0.01em' },
|
|
67
68
|
xl: { fontSize: '1.625rem' },
|
|
68
69
|
'2xl': { fontSize: '2.125rem' },
|
|
69
70
|
'3xl': { fontSize: '2.75rem' },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!-- Raw HTML that the allowlist kept, as real elements. -->
|
|
2
2
|
<script lang="ts" module>
|
|
3
3
|
import { attrs } from '../../internal/sx.js';
|
|
4
|
+
import { tableStyles } from '../../internal/table.js';
|
|
4
5
|
import { VOID, imageOf, type HtmlNode } from '../../markdown/sanitize.js';
|
|
5
6
|
import MarkdownInlines from './MarkdownInlines.svelte';
|
|
6
7
|
import MarkdownLink, { wordsOf } from './MarkdownLink.svelte';
|
|
@@ -25,8 +26,8 @@
|
|
|
25
26
|
blockquote: prose.blockquote,
|
|
26
27
|
details: prose.details,
|
|
27
28
|
summary: prose.summary,
|
|
28
|
-
th: [
|
|
29
|
-
td: [prose.cell, prose.rawCell]
|
|
29
|
+
th: [tableStyles.cell, prose.cell, tableStyles.headCell, prose.rawCell],
|
|
30
|
+
td: [tableStyles.cell, prose.cell, prose.rawCell]
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
/** Whether a table's first row is of plain cells, not headings. */
|
|
@@ -58,7 +59,10 @@
|
|
|
58
59
|
{:else if node.tag === 'table'}
|
|
59
60
|
<!-- In the frame a Markdown table has, so a wide one scrolls rather than pushing the reply wide -->
|
|
60
61
|
<div use:scrollable {...attrs([prose.block, prose.tableFrame])}>
|
|
61
|
-
<table
|
|
62
|
+
<table
|
|
63
|
+
{...node.attrs}
|
|
64
|
+
{...attrs([tableStyles.table, prose.table, headless(node) && prose.rawTableHeadless])}
|
|
65
|
+
>
|
|
62
66
|
<Self nodes={node.children} />
|
|
63
67
|
</table>
|
|
64
68
|
</div>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import Glyph, { glyphHtml } from '../../internal/Glyph.svelte';
|
|
8
8
|
import { markdownTableMarker } from '../../internal/markers.stylex.js';
|
|
9
9
|
import { attrs, classes } from '../../internal/sx.js';
|
|
10
|
+
import { tableStyles } from '../../internal/table.js';
|
|
10
11
|
import { escapeHtml } from '../../markdown/html.js';
|
|
11
12
|
import type { Table } from '../../markdown/ast.js';
|
|
12
13
|
import { groupInlineHtml } from '../../markdown/sanitize.js';
|
|
@@ -75,7 +76,12 @@
|
|
|
75
76
|
const key = `${head}:${align}`;
|
|
76
77
|
let name = cellClass.get(key);
|
|
77
78
|
if (name === undefined) {
|
|
78
|
-
name = classes(
|
|
79
|
+
name = classes(
|
|
80
|
+
tableStyles.cell,
|
|
81
|
+
prose.cell,
|
|
82
|
+
head && tableStyles.headCell,
|
|
83
|
+
align && alignment[align]
|
|
84
|
+
);
|
|
79
85
|
cellClass.set(key, name);
|
|
80
86
|
}
|
|
81
87
|
return name;
|
|
@@ -105,7 +111,7 @@
|
|
|
105
111
|
'</tr>';
|
|
106
112
|
return (
|
|
107
113
|
`<div data-markdown-table="true" data-markdown-block="${node.id}" class="${classes(prose.block, styles.wrap, markdownTableMarker)}">` +
|
|
108
|
-
`<div data-markdown-scroll class="${classes(prose.tableFrame)}"><table class="${classes(prose.table)}">` +
|
|
114
|
+
`<div data-markdown-scroll class="${classes(prose.tableFrame)}"><table class="${classes(tableStyles.table, prose.table)}">` +
|
|
109
115
|
(head ? `<thead>${row(head, 'th')}</thead>` : '') +
|
|
110
116
|
(body.length > 0 ? `<tbody>${body.map((cells) => row(cells, 'td')).join('')}</tbody>` : '') +
|
|
111
117
|
'</table></div>' +
|
|
@@ -170,7 +176,7 @@
|
|
|
170
176
|
{...attrs([prose.block, styles.wrap, markdownTableMarker, enter && prose.enter])}
|
|
171
177
|
>
|
|
172
178
|
<div use:scrollable {...attrs([prose.tableFrame])}>
|
|
173
|
-
<table {...attrs([prose.table])}>
|
|
179
|
+
<table {...attrs([tableStyles.table, prose.table])}>
|
|
174
180
|
{#if head}
|
|
175
181
|
<thead>
|
|
176
182
|
<tr>
|
|
@@ -179,7 +185,12 @@
|
|
|
179
185
|
<th
|
|
180
186
|
scope="col"
|
|
181
187
|
dir="auto"
|
|
182
|
-
{...attrs([
|
|
188
|
+
{...attrs([
|
|
189
|
+
tableStyles.cell,
|
|
190
|
+
prose.cell,
|
|
191
|
+
tableStyles.headCell,
|
|
192
|
+
align && alignment[align]
|
|
193
|
+
])}
|
|
183
194
|
>
|
|
184
195
|
<MarkdownInlines nodes={groupInlineHtml(cell.children, md.urls)} />
|
|
185
196
|
</th>
|
|
@@ -193,7 +204,10 @@
|
|
|
193
204
|
<tr>
|
|
194
205
|
{#each row.children as cell, i (i)}
|
|
195
206
|
{@const align = node.align[i]}
|
|
196
|
-
<td
|
|
207
|
+
<td
|
|
208
|
+
dir="auto"
|
|
209
|
+
{...attrs([tableStyles.cell, prose.cell, align && alignment[align]])}
|
|
210
|
+
>
|
|
197
211
|
<MarkdownInlines nodes={groupInlineHtml(cell.children, md.urls)} />
|
|
198
212
|
</td>
|
|
199
213
|
{/each}
|
|
@@ -243,29 +243,12 @@ export declare const prose: Readonly<{
|
|
|
243
243
|
readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "-1px">;
|
|
244
244
|
}>;
|
|
245
245
|
readonly table: Readonly<{
|
|
246
|
-
readonly width: stylex.StyleXClassNameFor<"width", "max-content">;
|
|
247
|
-
readonly minWidth: stylex.StyleXClassNameFor<"minWidth", "100%">;
|
|
248
246
|
readonly borderCollapse: stylex.StyleXClassNameFor<"borderCollapse", "collapse">;
|
|
249
247
|
readonly fontSize: stylex.StyleXClassNameFor<"fontSize", "0.9375em">;
|
|
250
|
-
readonly fontVariantNumeric: stylex.StyleXClassNameFor<"fontVariantNumeric", "tabular-nums">;
|
|
251
248
|
}>;
|
|
252
249
|
readonly cell: Readonly<{
|
|
253
250
|
readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", "0.4375em">;
|
|
254
251
|
readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", "0.75em">;
|
|
255
|
-
readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "start">;
|
|
256
|
-
readonly verticalAlign: stylex.StyleXClassNameFor<"verticalAlign", "top">;
|
|
257
|
-
readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "24rem">;
|
|
258
|
-
readonly overflowWrap: stylex.StyleXClassNameFor<"overflowWrap", "break-word">;
|
|
259
|
-
readonly borderBlockStartWidth: stylex.StyleXClassNameFor<"borderBlockStartWidth", "1px">;
|
|
260
|
-
readonly borderBlockStartStyle: stylex.StyleXClassNameFor<"borderBlockStartStyle", "solid">;
|
|
261
|
-
readonly borderBlockStartColor: stylex.StyleXClassNameFor<"borderBlockStartColor", string>;
|
|
262
|
-
}>;
|
|
263
|
-
readonly headCell: Readonly<{
|
|
264
|
-
readonly borderBlockStartWidth: stylex.StyleXClassNameFor<"borderBlockStartWidth", 0>;
|
|
265
|
-
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
|
|
266
|
-
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
267
|
-
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
|
268
|
-
readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
|
|
269
252
|
}>;
|
|
270
253
|
readonly rawCell: Readonly<{
|
|
271
254
|
readonly textAlign: stylex.StyleXClassNameFor<"textAlign", null>;
|
|
@@ -222,31 +222,15 @@ export const prose = stylex.create({
|
|
|
222
222
|
outlineColor: 'transparent',
|
|
223
223
|
outlineOffset: '-1px'
|
|
224
224
|
},
|
|
225
|
+
// Over `tableStyles.table`, `cell` and `headCell` from `internal/table.ts`, which `Table`
|
|
226
|
+
// shares: what Markdown adds is its room and size, in `em`
|
|
225
227
|
table: {
|
|
226
|
-
width: 'max-content',
|
|
227
|
-
minWidth: '100%',
|
|
228
228
|
borderCollapse: 'collapse',
|
|
229
|
-
fontSize: '0.9375em'
|
|
230
|
-
fontVariantNumeric: 'tabular-nums'
|
|
229
|
+
fontSize: '0.9375em'
|
|
231
230
|
},
|
|
232
231
|
cell: {
|
|
233
232
|
paddingBlock: '0.4375em',
|
|
234
|
-
paddingInline: '0.75em'
|
|
235
|
-
textAlign: 'start',
|
|
236
|
-
verticalAlign: 'top',
|
|
237
|
-
// A cell of prose wraps at 24rem; a table of short cells stays as narrow as its content
|
|
238
|
-
maxWidth: '24rem',
|
|
239
|
-
overflowWrap: 'break-word',
|
|
240
|
-
borderBlockStartWidth: { default: '1px', ':first-child': '1px' },
|
|
241
|
-
borderBlockStartStyle: 'solid',
|
|
242
|
-
borderBlockStartColor: colors.border
|
|
243
|
-
},
|
|
244
|
-
headCell: {
|
|
245
|
-
borderBlockStartWidth: 0,
|
|
246
|
-
backgroundColor: colors.fillSunken,
|
|
247
|
-
color: colors.text,
|
|
248
|
-
fontWeight: font.weightMedium,
|
|
249
|
-
whiteSpace: 'nowrap'
|
|
233
|
+
paddingInline: '0.75em'
|
|
250
234
|
},
|
|
251
235
|
// A table written as HTML: its cells keep the alignment they ask for, and when its first
|
|
252
236
|
// row is not a heading, that row's top line sits under the frame's own edge
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<!--
|
|
1
|
+
<!--
|
|
2
|
+
What the agent means to do, ticked off as it goes. Only the latest plan is shown.
|
|
3
|
+
|
|
4
|
+
`fold` makes it one row for the composer's tray: the step under way and how far
|
|
5
|
+
along it is, which opens to every step. (From Eregion's TrayPlan, c1b599eb.)
|
|
6
|
+
-->
|
|
2
7
|
<script lang="ts" module>
|
|
3
8
|
import { visuallyHidden } from '../../visually-hidden.js';
|
|
4
9
|
import * as stylex from '@stylexjs/stylex';
|
|
@@ -8,16 +13,32 @@
|
|
|
8
13
|
import { colors, density, font, motion, radius } from '../../tokens.stylex.js';
|
|
9
14
|
import { media } from '../../media.stylex.js';
|
|
10
15
|
import Spinner from '../spinner/Spinner.svelte';
|
|
16
|
+
import * as Collapsible from '../collapsible/index.js';
|
|
11
17
|
|
|
12
18
|
export type PlanStepStatus = 'pending' | 'active' | 'done' | 'skipped';
|
|
13
19
|
export type PlanStep = { label: string; status: PlanStepStatus };
|
|
14
20
|
|
|
15
21
|
export type PlanProps = {
|
|
16
22
|
steps: PlanStep[];
|
|
17
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Over the steps, and what the plan is called. `null` leaves it out where a card of your
|
|
25
|
+
* own already says it is a plan; the plan is still called "Plan", or its `aria-label`.
|
|
26
|
+
*/
|
|
27
|
+
title?: string | null | undefined;
|
|
28
|
+
/** What the plan is called when no title is shown. */
|
|
29
|
+
'aria-label'?: string | undefined;
|
|
18
30
|
/** How the progress is said: "2 of 4". */
|
|
19
31
|
progressLabel?: ((done: number, total: number) => string) | undefined;
|
|
20
32
|
skippedLabel?: string | undefined;
|
|
33
|
+
/** Leaves out its edge and padding, for a plan put in a card of your own. */
|
|
34
|
+
bare?: boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* One row, for the composer's tray: the step under way and how far along the plan is,
|
|
37
|
+
* which opens to every step.
|
|
38
|
+
*/
|
|
39
|
+
fold?: boolean | undefined;
|
|
40
|
+
/** Whether a folded plan shows its steps. Bindable. */
|
|
41
|
+
open?: boolean | undefined;
|
|
21
42
|
sx?: Sx | undefined;
|
|
22
43
|
class?: string | undefined;
|
|
23
44
|
};
|
|
@@ -36,6 +57,49 @@
|
|
|
36
57
|
borderRadius: radius.panel,
|
|
37
58
|
boxShadow: `inset 0 0 0 1px ${colors.border}`
|
|
38
59
|
},
|
|
60
|
+
bare: {
|
|
61
|
+
paddingTop: 0,
|
|
62
|
+
paddingBottom: 0,
|
|
63
|
+
paddingInline: 0,
|
|
64
|
+
borderRadius: 0,
|
|
65
|
+
boxShadow: 'none'
|
|
66
|
+
},
|
|
67
|
+
// Folded, on the tray's shelf: a raised fill, as the approval's, not an edge
|
|
68
|
+
fold: {
|
|
69
|
+
gap: 0,
|
|
70
|
+
paddingTop: 0,
|
|
71
|
+
paddingBottom: 0,
|
|
72
|
+
paddingInline: 0,
|
|
73
|
+
backgroundColor: colors.bgRaised,
|
|
74
|
+
boxShadow: 'none'
|
|
75
|
+
},
|
|
76
|
+
foldBare: { backgroundColor: 'transparent', borderRadius: 0 },
|
|
77
|
+
trigger: {
|
|
78
|
+
display: 'flex',
|
|
79
|
+
alignSelf: 'stretch',
|
|
80
|
+
gap: d('0.625rem'),
|
|
81
|
+
minWidth: 0,
|
|
82
|
+
minHeight: d('2.25rem'),
|
|
83
|
+
paddingInline: d('0.875rem'),
|
|
84
|
+
borderRadius: radius.panel,
|
|
85
|
+
color: colors.text
|
|
86
|
+
},
|
|
87
|
+
triggerBare: { paddingInline: d('0.375rem') },
|
|
88
|
+
current: {
|
|
89
|
+
flexGrow: 1,
|
|
90
|
+
minWidth: 0,
|
|
91
|
+
overflow: 'hidden',
|
|
92
|
+
textOverflow: 'ellipsis',
|
|
93
|
+
whiteSpace: 'nowrap'
|
|
94
|
+
},
|
|
95
|
+
foldContent: {
|
|
96
|
+
display: 'flex',
|
|
97
|
+
flexDirection: 'column',
|
|
98
|
+
gap: d('0.625rem'),
|
|
99
|
+
paddingInline: d('0.5rem'),
|
|
100
|
+
paddingBottom: d('0.5rem')
|
|
101
|
+
},
|
|
102
|
+
foldContentBare: { paddingInline: 0, paddingBottom: 0 },
|
|
39
103
|
head: {
|
|
40
104
|
display: 'flex',
|
|
41
105
|
alignItems: 'baseline',
|
|
@@ -44,6 +108,8 @@
|
|
|
44
108
|
margin: 0,
|
|
45
109
|
paddingInline: d('0.375rem')
|
|
46
110
|
},
|
|
111
|
+
// With no title, the count stands at the end of its line
|
|
112
|
+
headEnd: { justifyContent: 'flex-end' },
|
|
47
113
|
title: {
|
|
48
114
|
color: colors.text,
|
|
49
115
|
fontSize: font.sizeMeta,
|
|
@@ -129,21 +195,52 @@
|
|
|
129
195
|
let {
|
|
130
196
|
steps,
|
|
131
197
|
title = 'Plan',
|
|
198
|
+
'aria-label': ariaLabel,
|
|
132
199
|
progressLabel = (done, total) => `${done} of ${total}`,
|
|
133
200
|
skippedLabel = 'skipped',
|
|
201
|
+
bare = false,
|
|
202
|
+
fold = false,
|
|
203
|
+
open = $bindable(false),
|
|
134
204
|
sx,
|
|
135
205
|
class: className
|
|
136
206
|
}: PlanProps = $props();
|
|
137
207
|
|
|
138
208
|
const uid = $props.id();
|
|
139
209
|
const done = $derived(steps.filter((step) => step.status === 'done').length);
|
|
210
|
+
const progress = $derived(progressLabel(done, steps.length));
|
|
211
|
+
const name = $derived(title ?? ariaLabel ?? 'Plan');
|
|
212
|
+
// The step under way, or else the next to do, or the last once all are done
|
|
213
|
+
const current = $derived(
|
|
214
|
+
steps.find((step) => step.status === 'active') ??
|
|
215
|
+
steps.find((step) => step.status === 'pending') ??
|
|
216
|
+
steps.at(-1)
|
|
217
|
+
);
|
|
140
218
|
</script>
|
|
141
219
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
<span
|
|
145
|
-
|
|
146
|
-
|
|
220
|
+
{#snippet icon(status: PlanStepStatus)}
|
|
221
|
+
{#key status}
|
|
222
|
+
<span
|
|
223
|
+
{...stylex.attrs(
|
|
224
|
+
styles.icon,
|
|
225
|
+
status === 'active' && styles.iconActive,
|
|
226
|
+
status === 'done' && styles.iconDone,
|
|
227
|
+
status === 'skipped' && styles.iconSkipped
|
|
228
|
+
)}
|
|
229
|
+
>
|
|
230
|
+
{#if status === 'active'}
|
|
231
|
+
<Spinner size={14} label={null} />
|
|
232
|
+
{:else if status === 'done'}
|
|
233
|
+
<Glyph name="check" size={11} stroke={2.25} />
|
|
234
|
+
{:else if status === 'skipped'}
|
|
235
|
+
<Glyph name="minus" size={10} stroke={1.75} />
|
|
236
|
+
{:else}
|
|
237
|
+
<Glyph name="dashed" size={16} stroke={1.25} />
|
|
238
|
+
{/if}
|
|
239
|
+
</span>
|
|
240
|
+
{/key}
|
|
241
|
+
{/snippet}
|
|
242
|
+
|
|
243
|
+
{#snippet body()}
|
|
147
244
|
<div aria-hidden="true" {...stylex.attrs(styles.track)}>
|
|
148
245
|
{#each steps as step, index (index)}
|
|
149
246
|
<span
|
|
@@ -165,26 +262,7 @@
|
|
|
165
262
|
step.status === 'done' && styles.done
|
|
166
263
|
)}
|
|
167
264
|
>
|
|
168
|
-
{
|
|
169
|
-
<span
|
|
170
|
-
{...stylex.attrs(
|
|
171
|
-
styles.icon,
|
|
172
|
-
step.status === 'active' && styles.iconActive,
|
|
173
|
-
step.status === 'done' && styles.iconDone,
|
|
174
|
-
step.status === 'skipped' && styles.iconSkipped
|
|
175
|
-
)}
|
|
176
|
-
>
|
|
177
|
-
{#if step.status === 'active'}
|
|
178
|
-
<Spinner size={14} label={null} />
|
|
179
|
-
{:else if step.status === 'done'}
|
|
180
|
-
<Glyph name="check" size={11} stroke={2.25} />
|
|
181
|
-
{:else if step.status === 'skipped'}
|
|
182
|
-
<Glyph name="minus" size={10} stroke={1.75} />
|
|
183
|
-
{:else}
|
|
184
|
-
<Glyph name="dashed" size={16} stroke={1.25} />
|
|
185
|
-
{/if}
|
|
186
|
-
</span>
|
|
187
|
-
{/key}
|
|
265
|
+
{@render icon(step.status)}
|
|
188
266
|
<span>
|
|
189
267
|
{step.label}{#if step.status === 'skipped'}<span {...stylex.attrs(styles.skipped)}
|
|
190
268
|
>{skippedLabel}</span
|
|
@@ -195,4 +273,44 @@
|
|
|
195
273
|
</li>
|
|
196
274
|
{/each}
|
|
197
275
|
</ol>
|
|
198
|
-
|
|
276
|
+
{/snippet}
|
|
277
|
+
|
|
278
|
+
{#if fold}
|
|
279
|
+
<Collapsible.Root
|
|
280
|
+
bind:open
|
|
281
|
+
data-slot="plan"
|
|
282
|
+
data-fold=""
|
|
283
|
+
sx={[styles.plan, styles.fold, bare && styles.foldBare, sx]}
|
|
284
|
+
class={className}
|
|
285
|
+
>
|
|
286
|
+
<Collapsible.Trigger
|
|
287
|
+
aria-label={open || !current
|
|
288
|
+
? `${name}, ${progress}`
|
|
289
|
+
: `${name}: ${current.label}, ${progress}`}
|
|
290
|
+
sx={[styles.trigger, bare && styles.triggerBare]}
|
|
291
|
+
>
|
|
292
|
+
{#if current}{@render icon(current.status)}{/if}
|
|
293
|
+
<!-- Open, the steps under it say which is under way; the row says what they are -->
|
|
294
|
+
<span {...stylex.attrs(styles.current)}>
|
|
295
|
+
{#if open || !current}{name}{:else}{current.label}{/if}
|
|
296
|
+
</span>
|
|
297
|
+
<span {...stylex.attrs(shared.eyebrow)}>{progress}</span>
|
|
298
|
+
</Collapsible.Trigger>
|
|
299
|
+
<Collapsible.Content sx={[styles.foldContent, bare && styles.foldContentBare]}>
|
|
300
|
+
{@render body()}
|
|
301
|
+
</Collapsible.Content>
|
|
302
|
+
</Collapsible.Root>
|
|
303
|
+
{:else}
|
|
304
|
+
<section
|
|
305
|
+
aria-labelledby={title === null ? undefined : `${uid}-title`}
|
|
306
|
+
aria-label={title === null ? name : undefined}
|
|
307
|
+
data-slot="plan"
|
|
308
|
+
{...attrs([styles.plan, bare && styles.bare, sx], className)}
|
|
309
|
+
>
|
|
310
|
+
<p {...stylex.attrs(styles.head, title === null && styles.headEnd)}>
|
|
311
|
+
{#if title !== null}<span id="{uid}-title" {...stylex.attrs(styles.title)}>{title}</span>{/if}
|
|
312
|
+
<span {...stylex.attrs(shared.eyebrow)}>{progress}</span>
|
|
313
|
+
</p>
|
|
314
|
+
{@render body()}
|
|
315
|
+
</section>
|
|
316
|
+
{/if}
|