@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,13 +6,28 @@ export type PlanStep = {
|
|
|
6
6
|
};
|
|
7
7
|
export type PlanProps = {
|
|
8
8
|
steps: PlanStep[];
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Over the steps, and what the plan is called. `null` leaves it out where a card of your
|
|
11
|
+
* own already says it is a plan; the plan is still called "Plan", or its `aria-label`.
|
|
12
|
+
*/
|
|
13
|
+
title?: string | null | undefined;
|
|
14
|
+
/** What the plan is called when no title is shown. */
|
|
15
|
+
'aria-label'?: string | undefined;
|
|
10
16
|
/** How the progress is said: "2 of 4". */
|
|
11
17
|
progressLabel?: ((done: number, total: number) => string) | undefined;
|
|
12
18
|
skippedLabel?: string | undefined;
|
|
19
|
+
/** Leaves out its edge and padding, for a plan put in a card of your own. */
|
|
20
|
+
bare?: boolean | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* One row, for the composer's tray: the step under way and how far along the plan is,
|
|
23
|
+
* which opens to every step.
|
|
24
|
+
*/
|
|
25
|
+
fold?: boolean | undefined;
|
|
26
|
+
/** Whether a folded plan shows its steps. Bindable. */
|
|
27
|
+
open?: boolean | undefined;
|
|
13
28
|
sx?: Sx | undefined;
|
|
14
29
|
class?: string | undefined;
|
|
15
30
|
};
|
|
16
|
-
declare const Plan: import("svelte").Component<PlanProps, {}, "">;
|
|
31
|
+
declare const Plan: import("svelte").Component<PlanProps, {}, "open">;
|
|
17
32
|
type Plan = ReturnType<typeof Plan>;
|
|
18
33
|
export default Plan;
|
|
@@ -2,13 +2,18 @@
|
|
|
2
2
|
A message the person sent while the agent was still at work. It waits at
|
|
3
3
|
the foot of the conversation, quieter than a sent message, saying what will
|
|
4
4
|
happen to it, with ways to change that.
|
|
5
|
+
|
|
6
|
+
`compact` makes it one line, for the composer's tray: a grip to drag it
|
|
7
|
+
into place, its words cut to the line, where it stands, and its actions.
|
|
8
|
+
(From Eregion's TrayQueuedRow, c1b599eb.)
|
|
5
9
|
-->
|
|
6
10
|
<script lang="ts" module>
|
|
7
11
|
import * as stylex from '@stylexjs/stylex';
|
|
8
12
|
import type { Snippet } from 'svelte';
|
|
9
13
|
import Glyph, { type GlyphName } from '../../internal/Glyph.svelte';
|
|
10
14
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
11
|
-
import {
|
|
15
|
+
import { visuallyHidden } from '../../visually-hidden.js';
|
|
16
|
+
import { colors, density, font, radius, space } from '../../tokens.stylex.js';
|
|
12
17
|
import Button from '../button/Button.svelte';
|
|
13
18
|
import { text, type MessageTextSize } from '../message/styles.js';
|
|
14
19
|
import * as Tooltip from '../tooltip/index.js';
|
|
@@ -18,8 +23,23 @@
|
|
|
18
23
|
|
|
19
24
|
export type QueuedMessageProps = {
|
|
20
25
|
status?: QueuedMessageStatus | undefined;
|
|
21
|
-
/**
|
|
26
|
+
/** What the status says in place of its own word: one short label, "After setup". */
|
|
22
27
|
statusText?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* What the status means, in full: "Sends once the worktree's setup script succeeds".
|
|
30
|
+
* Shown in a tooltip on the status, and read after it. Each status has its own.
|
|
31
|
+
*/
|
|
32
|
+
detail?: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* One line, for the composer's tray: its words cut to the line beside where it stands
|
|
35
|
+
* and its actions, where a bubble with its status under it takes two.
|
|
36
|
+
*/
|
|
37
|
+
compact?: boolean | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* At the start of the compact row: a grip to drag it into the queue's order, such as a
|
|
40
|
+
* Button with your drag-and-drop library's attachment on it.
|
|
41
|
+
*/
|
|
42
|
+
handle?: Snippet | undefined;
|
|
23
43
|
onedit?: (() => void) | undefined;
|
|
24
44
|
/** Takes the message back into the composer. */
|
|
25
45
|
ontakeback?: (() => void) | undefined;
|
|
@@ -33,27 +53,34 @@
|
|
|
33
53
|
* them, or the ones to hold back by name.
|
|
34
54
|
*/
|
|
35
55
|
disabled?: boolean | QueuedMessageAction[] | undefined;
|
|
36
|
-
/** The size its words are read at, as a Message's `textSize`. */
|
|
56
|
+
/** The size its words are read at, as a Message's `textSize`. The compact row's are 14px. */
|
|
37
57
|
textSize?: MessageTextSize | undefined;
|
|
38
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* What goes with it: its images and files, over the bubble. In the compact row they sit
|
|
60
|
+
* after the words, so keep them small, such as a paperclip and a count.
|
|
61
|
+
*/
|
|
39
62
|
attachments?: Snippet | undefined;
|
|
40
63
|
sx?: Sx | undefined;
|
|
41
64
|
class?: string | undefined;
|
|
42
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* The message's words. With none, only its attachments show, with no bubble. The compact
|
|
67
|
+
* row cuts them to one line, so give it words, not blocks.
|
|
68
|
+
*/
|
|
43
69
|
children?: Snippet | undefined;
|
|
44
70
|
};
|
|
45
71
|
|
|
46
72
|
export type QueuedMessageAction = 'edit' | 'takeBack' | 'steer' | 'send';
|
|
47
73
|
|
|
48
|
-
// One short label each. What
|
|
74
|
+
// One short label each. What it means is said on hover, not strung on with a dot.
|
|
49
75
|
const STATUS: Record<QueuedMessageStatus, string> = {
|
|
50
76
|
queued: 'Queued',
|
|
51
77
|
editing: 'Editing',
|
|
52
78
|
unsent: 'Not sent'
|
|
53
79
|
};
|
|
54
|
-
const DETAIL:
|
|
80
|
+
const DETAIL: Record<QueuedMessageStatus, string> = {
|
|
55
81
|
queued: 'Sends when this turn ends',
|
|
56
|
-
editing: 'Still queued; sends when this turn ends'
|
|
82
|
+
editing: 'Still queued; sends when this turn ends',
|
|
83
|
+
unsent: 'Waits for you to send it'
|
|
57
84
|
};
|
|
58
85
|
|
|
59
86
|
/** A length at the window's density (`density` in the tokens). */
|
|
@@ -103,7 +130,43 @@
|
|
|
103
130
|
color: colors.textSubtle,
|
|
104
131
|
fontSize: font.sizeCaption
|
|
105
132
|
},
|
|
106
|
-
unsent: { color: colors.danger }
|
|
133
|
+
unsent: { color: colors.danger },
|
|
134
|
+
// One line, as tall as its buttons reach, so a list of them scrolls only past what fits
|
|
135
|
+
row: {
|
|
136
|
+
display: 'flex',
|
|
137
|
+
flexDirection: 'row',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
gap: space.x2,
|
|
140
|
+
minWidth: 0,
|
|
141
|
+
height: d('2rem'),
|
|
142
|
+
paddingInline: space.x1,
|
|
143
|
+
borderRadius: radius.control,
|
|
144
|
+
color: colors.textMuted,
|
|
145
|
+
fontSize: font.sizeBody,
|
|
146
|
+
lineHeight: font.leadingSnug
|
|
147
|
+
},
|
|
148
|
+
// Marked while the composer edits it
|
|
149
|
+
editing: { backgroundColor: colors.fillSelected },
|
|
150
|
+
handle: { display: { default: 'flex', ':empty': 'none' }, flexShrink: 0 },
|
|
151
|
+
words: {
|
|
152
|
+
flexGrow: 1,
|
|
153
|
+
minWidth: 0,
|
|
154
|
+
overflow: 'hidden',
|
|
155
|
+
color: colors.text,
|
|
156
|
+
textOverflow: 'ellipsis',
|
|
157
|
+
whiteSpace: 'nowrap'
|
|
158
|
+
},
|
|
159
|
+
rowAttachments: {
|
|
160
|
+
display: { default: 'flex', ':empty': 'none' },
|
|
161
|
+
flexShrink: 0,
|
|
162
|
+
alignItems: 'center',
|
|
163
|
+
gap: space.x1,
|
|
164
|
+
color: colors.textSubtle,
|
|
165
|
+
fontSize: font.sizeCaption,
|
|
166
|
+
fontVariantNumeric: 'tabular-nums'
|
|
167
|
+
},
|
|
168
|
+
rowStatus: { flexShrink: 0, paddingInlineEnd: 0, whiteSpace: 'nowrap' },
|
|
169
|
+
actions: { display: 'flex', flexShrink: 0, alignItems: 'center' }
|
|
107
170
|
});
|
|
108
171
|
</script>
|
|
109
172
|
|
|
@@ -111,6 +174,9 @@
|
|
|
111
174
|
let {
|
|
112
175
|
status = 'queued',
|
|
113
176
|
statusText,
|
|
177
|
+
detail,
|
|
178
|
+
compact = false,
|
|
179
|
+
handle,
|
|
114
180
|
onedit,
|
|
115
181
|
ontakeback,
|
|
116
182
|
onsteer,
|
|
@@ -137,50 +203,113 @@
|
|
|
137
203
|
] as const
|
|
138
204
|
).filter(([, handler]) => handler)
|
|
139
205
|
);
|
|
206
|
+
|
|
207
|
+
const word = $derived(statusText ?? STATUS[status]);
|
|
208
|
+
// A word of the app's own has no meaning of Narvi's to explain it
|
|
209
|
+
const meaning = $derived(detail ?? (statusText ? undefined : DETAIL[status]));
|
|
140
210
|
</script>
|
|
141
211
|
|
|
142
|
-
|
|
143
|
-
{#if
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
212
|
+
{#snippet statusLine(row: boolean)}
|
|
213
|
+
{#if meaning}
|
|
214
|
+
<Tooltip.Root>
|
|
215
|
+
<Tooltip.Trigger>
|
|
216
|
+
{#snippet child({ props })}
|
|
217
|
+
<span
|
|
218
|
+
{...props}
|
|
219
|
+
data-slot="queued-message-status"
|
|
220
|
+
{...stylex.attrs(
|
|
221
|
+
styles.status,
|
|
222
|
+
row && styles.rowStatus,
|
|
223
|
+
status === 'unsent' && styles.unsent
|
|
224
|
+
)}>{word}<span {...stylex.attrs(visuallyHidden)}>, {meaning}</span></span
|
|
225
|
+
>
|
|
226
|
+
{/snippet}
|
|
227
|
+
</Tooltip.Trigger>
|
|
228
|
+
<Tooltip.Content>{meaning}</Tooltip.Content>
|
|
229
|
+
</Tooltip.Root>
|
|
230
|
+
{:else}
|
|
157
231
|
<span
|
|
158
|
-
|
|
159
|
-
{...stylex.attrs(
|
|
160
|
-
|
|
232
|
+
data-slot="queued-message-status"
|
|
233
|
+
{...stylex.attrs(
|
|
234
|
+
styles.status,
|
|
235
|
+
row && styles.rowStatus,
|
|
236
|
+
status === 'unsent' && styles.unsent
|
|
237
|
+
)}>{word}</span
|
|
161
238
|
>
|
|
239
|
+
{/if}
|
|
240
|
+
{/snippet}
|
|
241
|
+
|
|
242
|
+
{#snippet buttons(size: 'xs' | 'sm')}
|
|
243
|
+
{#each actions as [key, handler, icon, fallback] (key)}
|
|
244
|
+
{@const label = labels?.[key] ?? fallback}
|
|
245
|
+
<Tooltip.Root>
|
|
246
|
+
<Tooltip.Trigger>
|
|
247
|
+
{#snippet child({ props })}
|
|
248
|
+
<Button
|
|
249
|
+
{...props}
|
|
250
|
+
variant="ghost"
|
|
251
|
+
{size}
|
|
252
|
+
iconOnly
|
|
253
|
+
aria-label={label}
|
|
254
|
+
disabled={held(key)}
|
|
255
|
+
onclick={() => handler?.()}
|
|
256
|
+
>
|
|
257
|
+
<Glyph name={icon as GlyphName} />
|
|
258
|
+
</Button>
|
|
259
|
+
{/snippet}
|
|
260
|
+
</Tooltip.Trigger>
|
|
261
|
+
<Tooltip.Content>{label}</Tooltip.Content>
|
|
262
|
+
</Tooltip.Root>
|
|
263
|
+
{/each}
|
|
264
|
+
{/snippet}
|
|
265
|
+
|
|
266
|
+
{#if compact}
|
|
267
|
+
<div
|
|
268
|
+
data-slot="queued-message"
|
|
269
|
+
data-status={status}
|
|
270
|
+
data-compact=""
|
|
271
|
+
{...attrs([styles.row, status === 'editing' && styles.editing, sx], className)}
|
|
272
|
+
>
|
|
162
273
|
<TooltipScope>
|
|
163
|
-
{#
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
</Tooltip.Trigger>
|
|
181
|
-
<Tooltip.Content>{label}</Tooltip.Content>
|
|
182
|
-
</Tooltip.Root>
|
|
183
|
-
{/each}
|
|
274
|
+
{#if handle}
|
|
275
|
+
<span data-slot="queued-message-handle" {...stylex.attrs(styles.handle)}>
|
|
276
|
+
{@render handle()}
|
|
277
|
+
</span>
|
|
278
|
+
{/if}
|
|
279
|
+
<span data-slot="queued-message-words" {...stylex.attrs(styles.words)}>
|
|
280
|
+
{@render children?.()}
|
|
281
|
+
</span>
|
|
282
|
+
{#if attachments}
|
|
283
|
+
<span data-slot="queued-message-attachments" {...stylex.attrs(styles.rowAttachments)}>
|
|
284
|
+
{@render attachments()}
|
|
285
|
+
</span>
|
|
286
|
+
{/if}
|
|
287
|
+
{@render statusLine(true)}
|
|
288
|
+
{#if actions.length}
|
|
289
|
+
<span {...stylex.attrs(styles.actions)}>{@render buttons('xs')}</span>
|
|
290
|
+
{/if}
|
|
184
291
|
</TooltipScope>
|
|
185
292
|
</div>
|
|
186
|
-
|
|
293
|
+
{:else}
|
|
294
|
+
<div data-slot="queued-message" data-status={status} {...attrs([styles.root, sx], className)}>
|
|
295
|
+
{#if attachments}
|
|
296
|
+
<div data-slot="queued-message-attachments" {...stylex.attrs(styles.attachments)}>
|
|
297
|
+
{@render attachments()}
|
|
298
|
+
</div>
|
|
299
|
+
{/if}
|
|
300
|
+
{#if children}
|
|
301
|
+
<div
|
|
302
|
+
data-slot="queued-message-bubble"
|
|
303
|
+
{...stylex.attrs(styles.bubble, text[textSize], status !== 'unsent' && styles.waiting)}
|
|
304
|
+
>
|
|
305
|
+
{@render children()}
|
|
306
|
+
</div>
|
|
307
|
+
{/if}
|
|
308
|
+
<div {...stylex.attrs(styles.foot)}>
|
|
309
|
+
<TooltipScope>
|
|
310
|
+
{@render statusLine(false)}
|
|
311
|
+
{@render buttons('sm')}
|
|
312
|
+
</TooltipScope>
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
{/if}
|
|
@@ -4,8 +4,23 @@ import { type MessageTextSize } from '../message/styles.js';
|
|
|
4
4
|
export type QueuedMessageStatus = 'queued' | 'editing' | 'unsent';
|
|
5
5
|
export type QueuedMessageProps = {
|
|
6
6
|
status?: QueuedMessageStatus | undefined;
|
|
7
|
-
/**
|
|
7
|
+
/** What the status says in place of its own word: one short label, "After setup". */
|
|
8
8
|
statusText?: string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* What the status means, in full: "Sends once the worktree's setup script succeeds".
|
|
11
|
+
* Shown in a tooltip on the status, and read after it. Each status has its own.
|
|
12
|
+
*/
|
|
13
|
+
detail?: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* One line, for the composer's tray: its words cut to the line beside where it stands
|
|
16
|
+
* and its actions, where a bubble with its status under it takes two.
|
|
17
|
+
*/
|
|
18
|
+
compact?: boolean | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* At the start of the compact row: a grip to drag it into the queue's order, such as a
|
|
21
|
+
* Button with your drag-and-drop library's attachment on it.
|
|
22
|
+
*/
|
|
23
|
+
handle?: Snippet | undefined;
|
|
9
24
|
onedit?: (() => void) | undefined;
|
|
10
25
|
/** Takes the message back into the composer. */
|
|
11
26
|
ontakeback?: (() => void) | undefined;
|
|
@@ -19,13 +34,19 @@ export type QueuedMessageProps = {
|
|
|
19
34
|
* them, or the ones to hold back by name.
|
|
20
35
|
*/
|
|
21
36
|
disabled?: boolean | QueuedMessageAction[] | undefined;
|
|
22
|
-
/** The size its words are read at, as a Message's `textSize`. */
|
|
37
|
+
/** The size its words are read at, as a Message's `textSize`. The compact row's are 14px. */
|
|
23
38
|
textSize?: MessageTextSize | undefined;
|
|
24
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* What goes with it: its images and files, over the bubble. In the compact row they sit
|
|
41
|
+
* after the words, so keep them small, such as a paperclip and a count.
|
|
42
|
+
*/
|
|
25
43
|
attachments?: Snippet | undefined;
|
|
26
44
|
sx?: Sx | undefined;
|
|
27
45
|
class?: string | undefined;
|
|
28
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* The message's words. With none, only its attachments show, with no bubble. The compact
|
|
48
|
+
* row cuts them to one line, so give it words, not blocks.
|
|
49
|
+
*/
|
|
29
50
|
children?: Snippet | undefined;
|
|
30
51
|
};
|
|
31
52
|
export type QueuedMessageAction = 'edit' | 'takeBack' | 'steer' | 'send';
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
sideways, and keeps the open one in view. A tab with a leading icon shows its
|
|
6
6
|
close button in the icon's place, so no room is kept at its end.
|
|
7
7
|
|
|
8
|
+
A tab can be temporary, as a preview is: in italics, until a double-click or
|
|
9
|
+
the app keeps it. A middle click closes a tab, as it does in a browser. With
|
|
10
|
+
`variant="notch"` the open tab takes the colour of the surface under the
|
|
11
|
+
strip and runs into it, for a strip at the foot of a header.
|
|
12
|
+
|
|
8
13
|
A tab can carry a menu (a right-click, the menu key or a long press), be
|
|
9
14
|
dragged into another place, be renamed where it stands, and hold buttons of
|
|
10
15
|
its own. Each is offered only when its callback or snippet is given.
|
|
@@ -41,6 +46,11 @@
|
|
|
41
46
|
panelId?: string | undefined;
|
|
42
47
|
/** With `onrename`, whether this tab can be renamed. Defaults to true. */
|
|
43
48
|
renamable?: boolean | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* A preview, which the next one opened takes the place of: in italics, and said as
|
|
51
|
+
* "preview" after its name. A double-click calls `onkeep`, ahead of renaming.
|
|
52
|
+
*/
|
|
53
|
+
temporary?: boolean | undefined;
|
|
44
54
|
};
|
|
45
55
|
|
|
46
56
|
export type TabStripProps = Omit<
|
|
@@ -103,6 +113,18 @@
|
|
|
103
113
|
renameLabel?: ((tab: TabStripTab) => string) | undefined;
|
|
104
114
|
/** The id of a tab shown beside the open one, as in a split view: it is lit, as under the pointer. */
|
|
105
115
|
beside?: string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Called on a double-click of a temporary tab, to keep it: it is no longer a preview. A
|
|
118
|
+
* tab that is not temporary renames on a double-click, as before.
|
|
119
|
+
*/
|
|
120
|
+
onkeep?: ((id: string) => void) | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* `fill` marks the open tab with a fill, as the open row of a list has. `notch` gives it
|
|
123
|
+
* the colour of the surface under the strip, `--narvi-tab-surface` (`colors.bgRaised` by
|
|
124
|
+
* default), and runs it down into that surface with a curve each side: for a strip at the
|
|
125
|
+
* foot of a header, in AppShell.Strip, over a band of another colour.
|
|
126
|
+
*/
|
|
127
|
+
variant?: 'fill' | 'notch' | undefined;
|
|
106
128
|
sx?: Sx | undefined;
|
|
107
129
|
};
|
|
108
130
|
|
|
@@ -112,6 +134,16 @@
|
|
|
112
134
|
/** A length at the window's density (`density` in the tokens). */
|
|
113
135
|
const d = (rem: string) => `calc(${rem} * ${density.factor})`;
|
|
114
136
|
|
|
137
|
+
// The notch: the open tab's colour, that of the surface it runs into, which a consumer can set
|
|
138
|
+
const SURFACE = `var(--narvi-tab-surface, ${colors.bgRaised})`;
|
|
139
|
+
// The radius of the curves where the open tab meets the surface
|
|
140
|
+
const NOTCH = '0.5rem';
|
|
141
|
+
// How far over the surface the other tabs stand
|
|
142
|
+
const REACH = '0.375rem';
|
|
143
|
+
// The curve each side: the surface's colour, cut by a circle. A mask, so nothing is graded
|
|
144
|
+
const corner = (at: string) =>
|
|
145
|
+
`radial-gradient(circle at ${at}, transparent ${NOTCH}, #000 calc(${NOTCH} + 0.5px))`;
|
|
146
|
+
|
|
115
147
|
const styles = stylex.create({
|
|
116
148
|
root: {
|
|
117
149
|
display: 'flex',
|
|
@@ -134,6 +166,54 @@
|
|
|
134
166
|
padding: '2px',
|
|
135
167
|
margin: '-2px'
|
|
136
168
|
},
|
|
169
|
+
// The notch: the strip runs the height of what holds it, its tabs standing at its foot
|
|
170
|
+
notchRoot: { alignSelf: 'stretch', alignItems: 'flex-end' },
|
|
171
|
+
notchList: {
|
|
172
|
+
alignSelf: 'stretch',
|
|
173
|
+
alignItems: 'flex-end',
|
|
174
|
+
// Room for the first and last tabs' curves, which the scroller would otherwise clip
|
|
175
|
+
paddingBlock: '2px 0',
|
|
176
|
+
paddingInline: NOTCH,
|
|
177
|
+
marginBlock: 0,
|
|
178
|
+
marginInline: `calc(-1 * ${NOTCH})`
|
|
179
|
+
},
|
|
180
|
+
// The tabs, and the button to add one, a little over the surface, on one line
|
|
181
|
+
notchStanding: { marginBlockEnd: REACH },
|
|
182
|
+
// The open tab is the surface's own colour and runs down into it: no fill of its own, no
|
|
183
|
+
// line and no shadow. It takes the room the others stand over, so its label stays on
|
|
184
|
+
// their line.
|
|
185
|
+
notchOpen: {
|
|
186
|
+
paddingBlockEnd: REACH,
|
|
187
|
+
borderEndStartRadius: 0,
|
|
188
|
+
borderEndEndRadius: 0,
|
|
189
|
+
backgroundColor: { default: SURFACE, [HOVER]: SURFACE },
|
|
190
|
+
color: colors.text,
|
|
191
|
+
'::before': {
|
|
192
|
+
content: '""',
|
|
193
|
+
position: 'absolute',
|
|
194
|
+
bottom: 0,
|
|
195
|
+
right: '100%',
|
|
196
|
+
width: NOTCH,
|
|
197
|
+
height: NOTCH,
|
|
198
|
+
backgroundColor: SURFACE,
|
|
199
|
+
maskImage: corner('0 0'),
|
|
200
|
+
pointerEvents: 'none'
|
|
201
|
+
},
|
|
202
|
+
'::after': {
|
|
203
|
+
content: '""',
|
|
204
|
+
position: 'absolute',
|
|
205
|
+
bottom: 0,
|
|
206
|
+
left: '100%',
|
|
207
|
+
width: NOTCH,
|
|
208
|
+
height: NOTCH,
|
|
209
|
+
backgroundColor: SURFACE,
|
|
210
|
+
maskImage: corner('100% 0'),
|
|
211
|
+
pointerEvents: 'none'
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
// The close button and a mark stay centred on the label, above the room it runs down by
|
|
215
|
+
notchOpenAside: { top: `calc((100% - ${REACH}) / 2)` },
|
|
216
|
+
temporary: { fontStyle: 'italic' },
|
|
137
217
|
// Tabs narrow before the strip scrolls, so a title ends in an ellipsis, not mid-word
|
|
138
218
|
tab: {
|
|
139
219
|
position: 'relative',
|
|
@@ -397,6 +477,8 @@
|
|
|
397
477
|
renaming = $bindable(),
|
|
398
478
|
renameLabel = (tab) => `Name of ${tab.label}`,
|
|
399
479
|
beside,
|
|
480
|
+
onkeep,
|
|
481
|
+
variant = 'fill',
|
|
400
482
|
sx,
|
|
401
483
|
class: className,
|
|
402
484
|
...rest
|
|
@@ -477,6 +559,12 @@
|
|
|
477
559
|
input.select();
|
|
478
560
|
};
|
|
479
561
|
|
|
562
|
+
// A temporary tab is kept on a double-click; any other is renamed
|
|
563
|
+
function doubleClick(tab: TabStripTab) {
|
|
564
|
+
if (tab.temporary && onkeep) onkeep(tab.id);
|
|
565
|
+
else startRename(tab);
|
|
566
|
+
}
|
|
567
|
+
|
|
480
568
|
function open(tab: TabStripTab) {
|
|
481
569
|
if (value === tab.id) return;
|
|
482
570
|
value = tab.id;
|
|
@@ -515,6 +603,7 @@
|
|
|
515
603
|
{@const selected = tab.id === value}
|
|
516
604
|
{@const lifted = !!drag && drag.from === index && !drag.settling}
|
|
517
605
|
{@const editing = renaming === tab.id && renamable(tab)}
|
|
606
|
+
{@const notch = variant === 'notch'}
|
|
518
607
|
{@const { onpointerdown: menuPointerDown, ...triggerRest } = withoutTabStop(trigger)}
|
|
519
608
|
<div
|
|
520
609
|
{...triggerRest}
|
|
@@ -522,16 +611,28 @@
|
|
|
522
611
|
data-tab-id={tab.id}
|
|
523
612
|
data-renaming={editing || undefined}
|
|
524
613
|
data-lifted={lifted || undefined}
|
|
614
|
+
data-temporary={tab.temporary || undefined}
|
|
525
615
|
style:--narvi-tab-offset={drag ? `${tabOffset(drag, index)}px` : undefined}
|
|
526
616
|
onpointerdown={(event) => {
|
|
527
617
|
// The menu's own, which opens it on a long press on a touch screen
|
|
528
618
|
if (typeof menuPointerDown === 'function') menuPointerDown(event);
|
|
529
619
|
if (onmove && !editing) dragging.press(index, event);
|
|
530
620
|
}}
|
|
621
|
+
onmousedown={(event) => {
|
|
622
|
+
// The middle button closes: it neither scrolls the page nor pastes
|
|
623
|
+
if (event.button === 1 && onclose && !editing) event.preventDefault();
|
|
624
|
+
}}
|
|
625
|
+
onauxclick={(event) => {
|
|
626
|
+
// As it does in a browser, wherever on the tab it is pressed
|
|
627
|
+
if (event.button !== 1 || !onclose || editing) return;
|
|
628
|
+
event.preventDefault();
|
|
629
|
+
close(tab);
|
|
630
|
+
}}
|
|
531
631
|
{...stylex.attrs(
|
|
532
632
|
styles.tab,
|
|
533
633
|
tab.id === beside && !selected && styles.beside,
|
|
534
634
|
selected && styles.selected,
|
|
635
|
+
notch && (selected ? styles.notchOpen : styles.notchStanding),
|
|
535
636
|
drag && !lifted && styles.sliding,
|
|
536
637
|
lifted && styles.lifted,
|
|
537
638
|
tabStripTabMarker
|
|
@@ -570,11 +671,7 @@
|
|
|
570
671
|
onfocus={() => {
|
|
571
672
|
if (arrowed && activation === 'automatic') open(tab);
|
|
572
673
|
}}
|
|
573
|
-
ondblclick={() =>
|
|
574
|
-
onauxclick={(event) => {
|
|
575
|
-
// The middle button closes, as it does in a browser
|
|
576
|
-
if (event.button === 1) close(tab);
|
|
577
|
-
}}
|
|
674
|
+
ondblclick={() => doubleClick(tab)}
|
|
578
675
|
onkeydown={(event) => {
|
|
579
676
|
if (moveByKey(tab, event)) return;
|
|
580
677
|
if (event.key === 'F2' && renamable(tab)) {
|
|
@@ -612,7 +709,8 @@
|
|
|
612
709
|
{/if}
|
|
613
710
|
</span>
|
|
614
711
|
{/if}
|
|
615
|
-
<span {...stylex.attrs(styles.text)}>{tab.label}</span
|
|
712
|
+
<span {...stylex.attrs(styles.text, tab.temporary && styles.temporary)}>{tab.label}</span
|
|
713
|
+
>{#if tab.temporary}<span {...stylex.attrs(visuallyHidden)}>, preview</span>{/if}
|
|
616
714
|
{#if tab.mark}<span {...stylex.attrs(visuallyHidden)}
|
|
617
715
|
>, {tab.mark === 'live' ? 'working' : 'unsaved'}</span
|
|
618
716
|
>{/if}
|
|
@@ -627,7 +725,7 @@
|
|
|
627
725
|
>
|
|
628
726
|
{/if}
|
|
629
727
|
{#if leading && onclose}
|
|
630
|
-
<span {...stylex.attrs(styles.start)}>
|
|
728
|
+
<span {...stylex.attrs(styles.start, notch && selected && styles.notchOpenAside)}>
|
|
631
729
|
<button
|
|
632
730
|
type="button"
|
|
633
731
|
tabindex="-1"
|
|
@@ -639,7 +737,7 @@
|
|
|
639
737
|
</button>
|
|
640
738
|
</span>
|
|
641
739
|
{:else if onclose || tab.mark}
|
|
642
|
-
<span {...stylex.attrs(styles.end)}>
|
|
740
|
+
<span {...stylex.attrs(styles.end, notch && selected && styles.notchOpenAside)}>
|
|
643
741
|
{#if tab.mark}
|
|
644
742
|
<span
|
|
645
743
|
aria-hidden="true"
|
|
@@ -668,14 +766,14 @@
|
|
|
668
766
|
data-slot="tab-strip"
|
|
669
767
|
data-dragging={drag ? '' : undefined}
|
|
670
768
|
{...rest}
|
|
671
|
-
{...attrs([styles.root, sx], className)}
|
|
769
|
+
{...attrs([styles.root, variant === 'notch' && styles.notchRoot, sx], className)}
|
|
672
770
|
>
|
|
673
771
|
<div
|
|
674
772
|
bind:this={list}
|
|
675
773
|
role="tablist"
|
|
676
774
|
aria-label={label}
|
|
677
775
|
aria-orientation="horizontal"
|
|
678
|
-
{...stylex.attrs(styles.list)}
|
|
776
|
+
{...stylex.attrs(styles.list, variant === 'notch' && styles.notchList)}
|
|
679
777
|
{@attach roving({ selector: '[role="tab"]', orientation: 'horizontal', wrap: true })}
|
|
680
778
|
onkeydowncapture={onListKeydownCapture}
|
|
681
779
|
>
|
|
@@ -720,7 +818,12 @@
|
|
|
720
818
|
<Menu.Root>
|
|
721
819
|
<Menu.Trigger>
|
|
722
820
|
{#snippet child({ props })}
|
|
723
|
-
<button
|
|
821
|
+
<button
|
|
822
|
+
type="button"
|
|
823
|
+
aria-label={addLabel}
|
|
824
|
+
{...props}
|
|
825
|
+
{...stylex.attrs(styles.add, variant === 'notch' && styles.notchStanding)}
|
|
826
|
+
>
|
|
724
827
|
{@render plus()}
|
|
725
828
|
</button>
|
|
726
829
|
{/snippet}
|
|
@@ -728,7 +831,12 @@
|
|
|
728
831
|
<Menu.Content align="end">{@render addMenu()}</Menu.Content>
|
|
729
832
|
</Menu.Root>
|
|
730
833
|
{:else if onadd}
|
|
731
|
-
<button
|
|
834
|
+
<button
|
|
835
|
+
type="button"
|
|
836
|
+
aria-label={addLabel}
|
|
837
|
+
{...stylex.attrs(styles.add, variant === 'notch' && styles.notchStanding)}
|
|
838
|
+
onclick={onadd}
|
|
839
|
+
>
|
|
732
840
|
{@render plus()}
|
|
733
841
|
</button>
|
|
734
842
|
{/if}
|
|
@@ -14,6 +14,11 @@ export type TabStripTab = {
|
|
|
14
14
|
panelId?: string | undefined;
|
|
15
15
|
/** With `onrename`, whether this tab can be renamed. Defaults to true. */
|
|
16
16
|
renamable?: boolean | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* A preview, which the next one opened takes the place of: in italics, and said as
|
|
19
|
+
* "preview" after its name. A double-click calls `onkeep`, ahead of renaming.
|
|
20
|
+
*/
|
|
21
|
+
temporary?: boolean | undefined;
|
|
17
22
|
};
|
|
18
23
|
export type TabStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onclose' | 'onchange'> & {
|
|
19
24
|
tabs: TabStripTab[];
|
|
@@ -72,6 +77,18 @@ export type TabStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'o
|
|
|
72
77
|
renameLabel?: ((tab: TabStripTab) => string) | undefined;
|
|
73
78
|
/** The id of a tab shown beside the open one, as in a split view: it is lit, as under the pointer. */
|
|
74
79
|
beside?: string | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Called on a double-click of a temporary tab, to keep it: it is no longer a preview. A
|
|
82
|
+
* tab that is not temporary renames on a double-click, as before.
|
|
83
|
+
*/
|
|
84
|
+
onkeep?: ((id: string) => void) | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* `fill` marks the open tab with a fill, as the open row of a list has. `notch` gives it
|
|
87
|
+
* the colour of the surface under the strip, `--narvi-tab-surface` (`colors.bgRaised` by
|
|
88
|
+
* default), and runs it down into that surface with a curve each side: for a strip at the
|
|
89
|
+
* foot of a header, in AppShell.Strip, over a band of another colour.
|
|
90
|
+
*/
|
|
91
|
+
variant?: 'fill' | 'notch' | undefined;
|
|
75
92
|
sx?: Sx | undefined;
|
|
76
93
|
};
|
|
77
94
|
declare const TabStrip: import("svelte").Component<TabStripProps, {}, "value" | "renaming">;
|