@diegopluna/narvi 0.3.2 → 0.3.4
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/activity/ActivityIcon.svelte +54 -0
- package/dist/components/activity/ActivityIcon.svelte.d.ts +24 -0
- package/dist/components/activity/ActivityStep.svelte +47 -13
- package/dist/components/activity/ActivityStep.svelte.d.ts +13 -4
- package/dist/components/activity/ActivityThought.svelte +24 -5
- package/dist/components/activity/ActivityThought.svelte.d.ts +12 -2
- package/dist/components/activity/index.d.ts +3 -1
- package/dist/components/activity/index.js +2 -1
- package/dist/components/app-shell/AppShellHeader.svelte +18 -4
- package/dist/components/app-shell/AppShellHeader.svelte.d.ts +5 -0
- package/dist/components/app-shell/AppShellMain.svelte +14 -2
- package/dist/components/app-shell/AppShellPanel.svelte +77 -12
- package/dist/components/app-shell/AppShellPanel.svelte.d.ts +11 -1
- package/dist/components/app-shell/AppShellSheet.svelte +11 -1
- package/dist/components/app-shell/context.d.ts +8 -0
- package/dist/components/app-shell/context.js +7 -0
- package/dist/components/approval/Approval.svelte +14 -1
- package/dist/components/approval/Approval.svelte.d.ts +5 -0
- package/dist/components/avatar/AvatarRoot.svelte +20 -7
- package/dist/components/avatar/AvatarRoot.svelte.d.ts +10 -3
- package/dist/components/badge/Badge.svelte +3 -1
- package/dist/components/badge/Badge.svelte.d.ts +1 -1
- package/dist/components/button/Button.svelte +28 -6
- package/dist/components/button/Button.svelte.d.ts +7 -0
- package/dist/components/composer/ComposerModelPicker.svelte +80 -13
- package/dist/components/composer/ComposerModelPicker.svelte.d.ts +23 -6
- package/dist/components/composer/ComposerRoot.svelte +51 -12
- package/dist/components/composer/ComposerRoot.svelte.d.ts +16 -0
- package/dist/components/composer/ComposerSubmit.svelte +19 -5
- package/dist/components/composer/ComposerSubmit.svelte.d.ts +3 -1
- package/dist/components/composer/ComposerToggle.svelte +18 -4
- package/dist/components/composer/ComposerToggle.svelte.d.ts +2 -0
- package/dist/components/composer/ComposerTray.svelte +17 -3
- package/dist/components/composer/ComposerTray.svelte.d.ts +5 -0
- package/dist/components/composer/context.d.ts +4 -1
- package/dist/components/dialog/DialogContent.svelte +22 -12
- package/dist/components/dialog/DialogContent.svelte.d.ts +10 -0
- package/dist/components/divider/Divider.svelte +56 -14
- package/dist/components/divider/Divider.svelte.d.ts +13 -3
- package/dist/components/empty-state/EmptyState.svelte +12 -2
- package/dist/components/empty-state/EmptyState.svelte.d.ts +6 -0
- package/dist/components/heading/Heading.svelte +15 -0
- package/dist/components/heading/Heading.svelte.d.ts +6 -0
- package/dist/components/hover-card/HoverCardContent.svelte +18 -2
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -0
- package/dist/components/input/Input.svelte +13 -3
- package/dist/components/input/Input.svelte.d.ts +10 -2
- package/dist/components/markdown/Markdown.svelte +22 -2
- package/dist/components/markdown/MarkdownDiagram.svelte +33 -2
- package/dist/components/markdown/MarkdownFile.svelte +56 -10
- package/dist/components/markdown/MarkdownMath.svelte +6 -0
- package/dist/components/markdown/MarkdownTable.svelte +3 -4
- package/dist/components/markdown/context.d.ts +6 -0
- package/dist/components/markdown/labels.d.ts +7 -0
- package/dist/components/markdown/labels.js +2 -0
- package/dist/components/menu/MenuCheckboxItem.svelte +44 -7
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +12 -2
- package/dist/components/menu/MenuContent.svelte +10 -2
- package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
- package/dist/components/menu/MenuItem.svelte +17 -2
- package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
- package/dist/components/menu/MenuSubContent.svelte +10 -2
- package/dist/components/menu/MenuSubContent.svelte.d.ts +10 -0
- package/dist/components/menu/MenuSubTrigger.svelte +19 -2
- package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -0
- package/dist/components/message/MessageBubble.svelte +40 -0
- package/dist/components/message/MessageBubble.svelte.d.ts +12 -0
- package/dist/components/message/MessageContent.svelte +23 -14
- package/dist/components/message/MessageContent.svelte.d.ts +6 -0
- package/dist/components/message/MessageCopy.svelte +27 -15
- package/dist/components/message/MessageCopy.svelte.d.ts +9 -2
- package/dist/components/message/MessageRoot.svelte +20 -3
- package/dist/components/message/MessageRoot.svelte.d.ts +6 -0
- package/dist/components/message/context.d.ts +2 -0
- package/dist/components/message/index.d.ts +4 -1
- package/dist/components/message/index.js +3 -2
- package/dist/components/message/styles.d.ts +30 -0
- package/dist/components/message/styles.js +24 -0
- package/dist/components/notice/Notice.svelte +3 -3
- package/dist/components/popover/PopoverContent.svelte +27 -3
- package/dist/components/popover/PopoverContent.svelte.d.ts +18 -0
- package/dist/components/questionnaire/Questionnaire.svelte +103 -19
- package/dist/components/questionnaire/Questionnaire.svelte.d.ts +13 -1
- package/dist/components/queued-message/QueuedMessage.svelte +44 -6
- package/dist/components/queued-message/QueuedMessage.svelte.d.ts +12 -1
- package/dist/components/segmented/SegmentedControl.svelte +12 -1
- package/dist/components/segmented/SegmentedControl.svelte.d.ts +3 -1
- package/dist/components/select/Select.svelte +43 -6
- package/dist/components/select/Select.svelte.d.ts +14 -0
- package/dist/components/settings-row/SettingsRow.svelte +87 -37
- package/dist/components/settings-row/SettingsRow.svelte.d.ts +13 -0
- package/dist/components/split-button/SplitButton.svelte +137 -0
- package/dist/components/split-button/SplitButton.svelte.d.ts +29 -0
- package/dist/components/tab-strip/TabStrip.svelte +337 -93
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +36 -1
- package/dist/components/tab-strip/drag.svelte.d.ts +31 -0
- package/dist/components/tab-strip/drag.svelte.js +148 -0
- package/dist/components/toast/Toaster.svelte +1 -1
- package/dist/components/toggle/Toggle.svelte +12 -2
- package/dist/components/toggle/Toggle.svelte.d.ts +11 -1
- package/dist/components/toggle-group/ToggleGroupItem.svelte +10 -1
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +7 -1
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +3 -1
- package/dist/components/toggle-group/context.d.ts +2 -1
- package/dist/components/tooltip/TooltipContent.svelte +13 -1
- package/dist/components/tooltip/TooltipContent.svelte.d.ts +10 -0
- package/dist/components/work-fold/WorkFold.svelte +13 -4
- package/dist/components/work-fold/WorkFold.svelte.d.ts +2 -1
- package/dist/focus-ring.d.ts +29 -0
- package/dist/focus-ring.js +42 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +8 -2
- package/dist/internal/Collapse.svelte +15 -2
- package/dist/internal/Glyph.svelte +28 -0
- package/dist/internal/Glyph.svelte.d.ts +5 -0
- package/dist/internal/Tile.svelte +3 -2
- package/dist/internal/layer.d.ts +23 -0
- package/dist/internal/layer.js +19 -0
- package/dist/internal/toggle.d.ts +8 -1
- package/dist/internal/toggle.js +20 -2
- package/dist/markdown/file-paths.d.ts +7 -0
- package/dist/markdown/file-paths.js +29 -0
- package/dist/markdown/files.d.ts +22 -2
- package/dist/markdown/files.js +45 -14
- package/dist/tokens.stylex.d.ts +3 -0
- package/dist/tokens.stylex.js +5 -1
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +77 -5
- package/skills/building-ui/references/components.md +51 -50
- package/skills/markdown/SKILL.md +22 -6
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +10 -3
- package/skills/theming/SKILL.md +11 -4
|
@@ -21,6 +21,16 @@
|
|
|
21
21
|
/** The files attached so far. Bindable. */
|
|
22
22
|
files?: File[] | undefined;
|
|
23
23
|
status?: ComposerStatus | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Set while a message is on its way and cannot be stopped yet. Nothing more is sent
|
|
26
|
+
* meanwhile, and Composer.Submit shows a spinner in place of its arrow.
|
|
27
|
+
*/
|
|
28
|
+
sending?: boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Whether there is something to send. Narvi works it out from `value` and `files`; set
|
|
31
|
+
* it when the text is kept by an editor of your own, put where Composer.Textarea would go.
|
|
32
|
+
*/
|
|
33
|
+
hasContent?: boolean | undefined;
|
|
24
34
|
disabled?: boolean | undefined;
|
|
25
35
|
/** File types to take, as in an input's `accept`, such as `image/*,.pdf`. */
|
|
26
36
|
accept?: string | undefined;
|
|
@@ -43,6 +53,12 @@
|
|
|
43
53
|
* queued with a QueuedMessage; the composer is cleared unless this returns `false`.
|
|
44
54
|
*/
|
|
45
55
|
onqueue?: ((message: ComposerMessage, event: SubmitEvent) => unknown) | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Called with the files the person attaches, by picking, dropping or pasting, once the
|
|
58
|
+
* ones the composer does not accept are turned away. They join `files` unless this
|
|
59
|
+
* returns `false`: return it to keep them on a list of your own.
|
|
60
|
+
*/
|
|
61
|
+
onfiles?: ((files: File[]) => unknown) | undefined;
|
|
46
62
|
/** Called with the files that were turned away, and why. */
|
|
47
63
|
onreject?: ((rejections: ComposerRejection[]) => void) | undefined;
|
|
48
64
|
sx?: Sx | undefined;
|
|
@@ -51,6 +67,18 @@
|
|
|
51
67
|
children?: Snippet | undefined;
|
|
52
68
|
};
|
|
53
69
|
|
|
70
|
+
const EDITABLE = '[contenteditable]:not([contenteditable="false"])';
|
|
71
|
+
const FIELD_FOCUS = `:has(textarea:focus-visible, ${EDITABLE}:focus-visible, [data-composer-field]:focus-within)`;
|
|
72
|
+
|
|
73
|
+
/** The text field: the composer's textarea, or an editor of the app's own put in its place. */
|
|
74
|
+
function findField(form: HTMLFormElement | null): HTMLElement | null {
|
|
75
|
+
if (!form) return null;
|
|
76
|
+
const marked = form.querySelector<HTMLElement>('[data-composer-field]');
|
|
77
|
+
if (marked && !marked.matches(EDITABLE) && marked.tabIndex < 0)
|
|
78
|
+
return marked.querySelector<HTMLElement>(`textarea, ${EDITABLE}`) ?? marked;
|
|
79
|
+
return marked ?? form.querySelector<HTMLElement>(EDITABLE);
|
|
80
|
+
}
|
|
81
|
+
|
|
54
82
|
const styles = stylex.create({
|
|
55
83
|
root: {
|
|
56
84
|
position: 'relative',
|
|
@@ -69,10 +97,11 @@
|
|
|
69
97
|
fontFamily: font.body,
|
|
70
98
|
cursor: 'text',
|
|
71
99
|
// Focus in the text field is shown as on every text field: the ring and its halo.
|
|
72
|
-
// Not for the buttons inside, which show their own.
|
|
100
|
+
// Not for the buttons inside, which show their own. An editor of your own shows it too,
|
|
101
|
+
// when it is editable content or is marked `data-composer-field`.
|
|
73
102
|
boxShadow: {
|
|
74
103
|
default: `inset 0 0 0 1px ${colors.border}`,
|
|
75
|
-
|
|
104
|
+
[FIELD_FOCUS]: `inset 0 0 0 1px ${colors.focusRing}, 0 0 0 3px ${colors.focusHalo}`
|
|
76
105
|
},
|
|
77
106
|
// In forced colours the shadow is gone; the outline is the edge, and thickens with focus
|
|
78
107
|
outlineWidth: {
|
|
@@ -118,6 +147,8 @@
|
|
|
118
147
|
value = $bindable(''),
|
|
119
148
|
files = $bindable([]),
|
|
120
149
|
status = 'ready',
|
|
150
|
+
sending = false,
|
|
151
|
+
hasContent,
|
|
121
152
|
disabled = false,
|
|
122
153
|
accept,
|
|
123
154
|
maxFiles,
|
|
@@ -126,6 +157,7 @@
|
|
|
126
157
|
onsubmit,
|
|
127
158
|
onstop,
|
|
128
159
|
onqueue,
|
|
160
|
+
onfiles,
|
|
129
161
|
onreject,
|
|
130
162
|
sx,
|
|
131
163
|
class: className,
|
|
@@ -144,6 +176,11 @@
|
|
|
144
176
|
|
|
145
177
|
const busy = $derived(status === 'submitted' || status === 'streaming');
|
|
146
178
|
const attachable = $derived(attachments > 0 && !disabled);
|
|
179
|
+
const filled = $derived(hasContent ?? (value.trim().length > 0 || files.length > 0));
|
|
180
|
+
|
|
181
|
+
function focusField() {
|
|
182
|
+
(textarea ?? findField(ref))?.focus();
|
|
183
|
+
}
|
|
147
184
|
|
|
148
185
|
function addFiles(incoming: Iterable<File>) {
|
|
149
186
|
const taken: File[] = [];
|
|
@@ -157,7 +194,7 @@
|
|
|
157
194
|
else taken.push(file);
|
|
158
195
|
}
|
|
159
196
|
if (taken.length) {
|
|
160
|
-
files = [...files, ...taken];
|
|
197
|
+
if (onfiles?.(taken) !== false) files = [...files, ...taken];
|
|
161
198
|
announcement =
|
|
162
199
|
taken.length === 1 ? `Attached ${taken[0].name}` : `Attached ${taken.length} files`;
|
|
163
200
|
}
|
|
@@ -166,9 +203,9 @@
|
|
|
166
203
|
|
|
167
204
|
function handleSubmit(event: SubmitEvent) {
|
|
168
205
|
event.preventDefault();
|
|
169
|
-
if (disabled) return;
|
|
206
|
+
if (disabled || sending) return;
|
|
170
207
|
const text = value.trim();
|
|
171
|
-
const empty = !
|
|
208
|
+
const empty = !filled;
|
|
172
209
|
if (busy) {
|
|
173
210
|
// The Stop button stops; Enter in the text, with something written, queues
|
|
174
211
|
const stopping = !!(event.submitter as HTMLElement | null)?.closest(
|
|
@@ -212,9 +249,11 @@
|
|
|
212
249
|
get busy() {
|
|
213
250
|
return busy;
|
|
214
251
|
},
|
|
252
|
+
get sending() {
|
|
253
|
+
return sending;
|
|
254
|
+
},
|
|
215
255
|
get canSend() {
|
|
216
|
-
|
|
217
|
-
return !disabled && something && (!busy || !!onqueue);
|
|
256
|
+
return !disabled && !sending && filled && (!busy || !!onqueue);
|
|
218
257
|
},
|
|
219
258
|
get attachable() {
|
|
220
259
|
return attachable;
|
|
@@ -230,7 +269,7 @@
|
|
|
230
269
|
picker?.click();
|
|
231
270
|
},
|
|
232
271
|
focus() {
|
|
233
|
-
|
|
272
|
+
focusField();
|
|
234
273
|
},
|
|
235
274
|
announce(message) {
|
|
236
275
|
announcement = message;
|
|
@@ -250,6 +289,7 @@
|
|
|
250
289
|
bind:this={ref}
|
|
251
290
|
data-slot="composer"
|
|
252
291
|
data-status={status}
|
|
292
|
+
data-sending={sending || undefined}
|
|
253
293
|
data-disabled={disabled || undefined}
|
|
254
294
|
data-dragging={depth > 0 || undefined}
|
|
255
295
|
{...rest}
|
|
@@ -259,8 +299,7 @@
|
|
|
259
299
|
onclick?.(event);
|
|
260
300
|
// A click on the frame, not on a control inside it, goes to the text
|
|
261
301
|
const target = event.target as HTMLElement;
|
|
262
|
-
if (target === event.currentTarget || target.dataset.slot === 'composer-toolbar')
|
|
263
|
-
textarea?.focus();
|
|
302
|
+
if (target === event.currentTarget || target.dataset.slot === 'composer-toolbar') focusField();
|
|
264
303
|
}}
|
|
265
304
|
ondragenter={(event) => {
|
|
266
305
|
if (!attachable || !carriesFiles(event)) return;
|
|
@@ -280,7 +319,7 @@
|
|
|
280
319
|
event.preventDefault();
|
|
281
320
|
depth = 0;
|
|
282
321
|
addFiles(event.dataTransfer?.files ?? []);
|
|
283
|
-
|
|
322
|
+
focusField();
|
|
284
323
|
}}
|
|
285
324
|
>
|
|
286
325
|
{@render children?.()}
|
|
@@ -298,7 +337,7 @@
|
|
|
298
337
|
const input = event.currentTarget;
|
|
299
338
|
addFiles(input.files ?? []);
|
|
300
339
|
input.value = '';
|
|
301
|
-
|
|
340
|
+
focusField();
|
|
302
341
|
}}
|
|
303
342
|
/>
|
|
304
343
|
|
|
@@ -8,6 +8,16 @@ export type ComposerRootProps = Omit<HTMLFormAttributes, 'children' | 'onsubmit'
|
|
|
8
8
|
/** The files attached so far. Bindable. */
|
|
9
9
|
files?: File[] | undefined;
|
|
10
10
|
status?: ComposerStatus | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Set while a message is on its way and cannot be stopped yet. Nothing more is sent
|
|
13
|
+
* meanwhile, and Composer.Submit shows a spinner in place of its arrow.
|
|
14
|
+
*/
|
|
15
|
+
sending?: boolean | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Whether there is something to send. Narvi works it out from `value` and `files`; set
|
|
18
|
+
* it when the text is kept by an editor of your own, put where Composer.Textarea would go.
|
|
19
|
+
*/
|
|
20
|
+
hasContent?: boolean | undefined;
|
|
11
21
|
disabled?: boolean | undefined;
|
|
12
22
|
/** File types to take, as in an input's `accept`, such as `image/*,.pdf`. */
|
|
13
23
|
accept?: string | undefined;
|
|
@@ -30,6 +40,12 @@ export type ComposerRootProps = Omit<HTMLFormAttributes, 'children' | 'onsubmit'
|
|
|
30
40
|
* queued with a QueuedMessage; the composer is cleared unless this returns `false`.
|
|
31
41
|
*/
|
|
32
42
|
onqueue?: ((message: ComposerMessage, event: SubmitEvent) => unknown) | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Called with the files the person attaches, by picking, dropping or pasting, once the
|
|
45
|
+
* ones the composer does not accept are turned away. They join `files` unless this
|
|
46
|
+
* returns `false`: return it to keep them on a list of your own.
|
|
47
|
+
*/
|
|
48
|
+
onfiles?: ((files: File[]) => unknown) | undefined;
|
|
33
49
|
/** Called with the files that were turned away, and why. */
|
|
34
50
|
onreject?: ((rejections: ComposerRejection[]) => void) | undefined;
|
|
35
51
|
sx?: Sx | undefined;
|
|
@@ -11,12 +11,22 @@
|
|
|
11
11
|
|
|
12
12
|
export type ComposerSubmitProps = Omit<
|
|
13
13
|
ButtonProps,
|
|
14
|
-
|
|
14
|
+
| 'children'
|
|
15
|
+
| 'type'
|
|
16
|
+
| 'variant'
|
|
17
|
+
| 'iconOnly'
|
|
18
|
+
| 'href'
|
|
19
|
+
| 'ref'
|
|
20
|
+
| 'sx'
|
|
21
|
+
| 'loading'
|
|
22
|
+
| 'loadingLabel'
|
|
15
23
|
> & {
|
|
16
24
|
/** Accessible name while it sends. */
|
|
17
25
|
sendLabel?: string | undefined;
|
|
18
26
|
/** Accessible name while a reply is on its way and pressing it stops the reply. */
|
|
19
27
|
stopLabel?: string | undefined;
|
|
28
|
+
/** Accessible name while the composer is `sending`: the message is on its way and cannot be stopped. */
|
|
29
|
+
sendingLabel?: string | undefined;
|
|
20
30
|
sx?: Sx | undefined;
|
|
21
31
|
ref?: HTMLButtonElement | null | undefined;
|
|
22
32
|
};
|
|
@@ -69,6 +79,7 @@
|
|
|
69
79
|
let {
|
|
70
80
|
sendLabel = 'Send',
|
|
71
81
|
stopLabel = 'Stop',
|
|
82
|
+
sendingLabel = 'Sending',
|
|
72
83
|
disabled,
|
|
73
84
|
sx,
|
|
74
85
|
ref = $bindable(null),
|
|
@@ -76,8 +87,9 @@
|
|
|
76
87
|
}: ComposerSubmitProps = $props();
|
|
77
88
|
|
|
78
89
|
const composer = useComposer('Submit');
|
|
79
|
-
const
|
|
80
|
-
const
|
|
90
|
+
const sending = $derived(composer.sending);
|
|
91
|
+
const busy = $derived(composer.busy && !sending);
|
|
92
|
+
const idle = $derived(!busy && !sending && !composer.canSend);
|
|
81
93
|
</script>
|
|
82
94
|
|
|
83
95
|
<Button
|
|
@@ -85,10 +97,12 @@
|
|
|
85
97
|
type="submit"
|
|
86
98
|
variant="primary"
|
|
87
99
|
iconOnly
|
|
88
|
-
aria-label={busy ? stopLabel : sendLabel}
|
|
89
|
-
disabled={disabled ?? (composer.disabled || (!busy && !composer.canSend))}
|
|
100
|
+
aria-label={sending ? sendingLabel : busy ? stopLabel : sendLabel}
|
|
101
|
+
disabled={disabled ?? (composer.disabled || (!busy && !sending && !composer.canSend))}
|
|
102
|
+
loading={sending}
|
|
90
103
|
data-slot="composer-submit"
|
|
91
104
|
data-status={composer.status}
|
|
105
|
+
data-sending={sending || undefined}
|
|
92
106
|
{...rest}
|
|
93
107
|
sx={[styles.button, idle && styles.idle, sx]}
|
|
94
108
|
>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Sx } from '../../internal/sx.js';
|
|
2
2
|
import { type ButtonProps } from '../button/Button.svelte';
|
|
3
|
-
export type ComposerSubmitProps = Omit<ButtonProps, 'children' | 'type' | 'variant' | 'iconOnly' | 'href' | 'ref' | 'sx'> & {
|
|
3
|
+
export type ComposerSubmitProps = Omit<ButtonProps, 'children' | 'type' | 'variant' | 'iconOnly' | 'href' | 'ref' | 'sx' | 'loading' | 'loadingLabel'> & {
|
|
4
4
|
/** Accessible name while it sends. */
|
|
5
5
|
sendLabel?: string | undefined;
|
|
6
6
|
/** Accessible name while a reply is on its way and pressing it stops the reply. */
|
|
7
7
|
stopLabel?: string | undefined;
|
|
8
|
+
/** Accessible name while the composer is `sending`: the message is on its way and cannot be stopped. */
|
|
9
|
+
sendingLabel?: string | undefined;
|
|
8
10
|
sx?: Sx | undefined;
|
|
9
11
|
ref?: HTMLButtonElement | null | undefined;
|
|
10
12
|
};
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
7
|
import { colors, font, motion, radius } from '../../tokens.stylex.js';
|
|
8
8
|
import { media } from '../../media.stylex.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getComposerContext } from './context.js';
|
|
10
10
|
|
|
11
11
|
export type ComposerToggleProps = Omit<HTMLButtonAttributes, 'children'> & {
|
|
12
12
|
/** Whether it is on. Bindable. */
|
|
13
13
|
pressed?: boolean | undefined;
|
|
14
|
+
/** How it shows it is on: lit in the `accent`, or `neutral`, in the fill of what is chosen. */
|
|
15
|
+
tone?: 'accent' | 'neutral' | undefined;
|
|
14
16
|
sx?: Sx | undefined;
|
|
15
17
|
ref?: HTMLButtonElement | null | undefined;
|
|
16
18
|
/** A 16px icon and a short label, such as "Search". */
|
|
@@ -64,6 +66,10 @@
|
|
|
64
66
|
':hover': { default: null, [media.hover]: colors.focusHalo }
|
|
65
67
|
},
|
|
66
68
|
color: { default: colors.accent, ':hover': colors.accent, [media.forcedColors]: 'Highlight' }
|
|
69
|
+
},
|
|
70
|
+
onNeutral: {
|
|
71
|
+
backgroundColor: colors.fillSelected,
|
|
72
|
+
color: { default: colors.text, [media.forcedColors]: 'Highlight' }
|
|
67
73
|
}
|
|
68
74
|
});
|
|
69
75
|
</script>
|
|
@@ -71,6 +77,7 @@
|
|
|
71
77
|
<script lang="ts">
|
|
72
78
|
let {
|
|
73
79
|
pressed = $bindable(false),
|
|
80
|
+
tone = 'accent',
|
|
74
81
|
disabled,
|
|
75
82
|
sx,
|
|
76
83
|
class: className,
|
|
@@ -80,19 +87,26 @@
|
|
|
80
87
|
...rest
|
|
81
88
|
}: ComposerToggleProps = $props();
|
|
82
89
|
|
|
83
|
-
|
|
90
|
+
// Works outside a Composer.Root too, such as in a toolbar of the app's own
|
|
91
|
+
const composer = getComposerContext();
|
|
84
92
|
</script>
|
|
85
93
|
|
|
86
94
|
<button
|
|
87
95
|
bind:this={ref}
|
|
88
96
|
type="button"
|
|
89
97
|
aria-pressed={pressed}
|
|
90
|
-
disabled={disabled ?? composer
|
|
98
|
+
disabled={disabled ?? composer?.disabled}
|
|
91
99
|
data-slot="composer-toggle"
|
|
92
100
|
data-state={pressed ? 'on' : 'off'}
|
|
93
101
|
{...rest}
|
|
94
102
|
{...attrs(
|
|
95
|
-
[
|
|
103
|
+
[
|
|
104
|
+
styles.toggle,
|
|
105
|
+
shared.focusable,
|
|
106
|
+
styles.withIcon,
|
|
107
|
+
pressed && (tone === 'neutral' ? styles.onNeutral : styles.on),
|
|
108
|
+
sx
|
|
109
|
+
],
|
|
96
110
|
className
|
|
97
111
|
)}
|
|
98
112
|
onclick={(event) => {
|
|
@@ -4,6 +4,8 @@ import { type Sx } from '../../internal/sx.js';
|
|
|
4
4
|
export type ComposerToggleProps = Omit<HTMLButtonAttributes, 'children'> & {
|
|
5
5
|
/** Whether it is on. Bindable. */
|
|
6
6
|
pressed?: boolean | undefined;
|
|
7
|
+
/** How it shows it is on: lit in the `accent`, or `neutral`, in the fill of what is chosen. */
|
|
8
|
+
tone?: 'accent' | 'neutral' | undefined;
|
|
7
9
|
sx?: Sx | undefined;
|
|
8
10
|
ref?: HTMLButtonElement | null | undefined;
|
|
9
11
|
/** A 16px icon and a short label, such as "Search". */
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
label?: string | undefined;
|
|
20
20
|
/** What is waiting on the person: an Approval, a Questionnaire, QueuedMessages. */
|
|
21
21
|
pending?: Snippet | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Whether anything is waiting. Narvi shows the shelf while `pending` puts an element in
|
|
24
|
+
* it with something inside; set this when what is inside hides itself some other way.
|
|
25
|
+
*/
|
|
26
|
+
waiting?: boolean | undefined;
|
|
22
27
|
sx?: Sx | undefined;
|
|
23
28
|
/** The Composer.Root. */
|
|
24
29
|
children?: Snippet | undefined;
|
|
@@ -27,9 +32,10 @@
|
|
|
27
32
|
const styles = stylex.create({
|
|
28
33
|
tray: { display: 'flex', flexDirection: 'column', minWidth: 0 },
|
|
29
34
|
// A flat fill whose foot tucks in behind the composer by the composer's own radius, so
|
|
30
|
-
// the two read as one piece. It is there only while something is in it
|
|
35
|
+
// the two read as one piece. It is there only while something is in it: an element
|
|
36
|
+
// that holds something and is not hidden.
|
|
31
37
|
pending: {
|
|
32
|
-
display: { default: 'none', ':has(>
|
|
38
|
+
display: { default: 'none', ':has(> :not(:empty, [hidden], template))': 'flex' },
|
|
33
39
|
flexDirection: 'column',
|
|
34
40
|
gap: '0.375rem',
|
|
35
41
|
padding: '0.375rem',
|
|
@@ -43,6 +49,8 @@
|
|
|
43
49
|
outlineColor: 'transparent',
|
|
44
50
|
outlineOffset: '-1px'
|
|
45
51
|
},
|
|
52
|
+
shown: { display: 'flex' },
|
|
53
|
+
gone: { display: 'none' },
|
|
46
54
|
// The composer stands in front of the shelf
|
|
47
55
|
front: {
|
|
48
56
|
position: 'relative',
|
|
@@ -58,6 +66,7 @@
|
|
|
58
66
|
let {
|
|
59
67
|
label = 'Waiting for you',
|
|
60
68
|
pending,
|
|
69
|
+
waiting,
|
|
61
70
|
sx,
|
|
62
71
|
class: className,
|
|
63
72
|
children,
|
|
@@ -70,7 +79,12 @@
|
|
|
70
79
|
role="group"
|
|
71
80
|
aria-label={label}
|
|
72
81
|
data-slot="composer-tray-pending"
|
|
73
|
-
{
|
|
82
|
+
data-waiting={waiting}
|
|
83
|
+
{...stylex.attrs(
|
|
84
|
+
styles.pending,
|
|
85
|
+
waiting === true && styles.shown,
|
|
86
|
+
waiting === false && styles.gone
|
|
87
|
+
)}
|
|
74
88
|
>
|
|
75
89
|
{@render pending?.()}
|
|
76
90
|
</div>
|
|
@@ -6,6 +6,11 @@ export type ComposerTrayProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>
|
|
|
6
6
|
label?: string | undefined;
|
|
7
7
|
/** What is waiting on the person: an Approval, a Questionnaire, QueuedMessages. */
|
|
8
8
|
pending?: Snippet | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Whether anything is waiting. Narvi shows the shelf while `pending` puts an element in
|
|
11
|
+
* it with something inside; set this when what is inside hides itself some other way.
|
|
12
|
+
*/
|
|
13
|
+
waiting?: boolean | undefined;
|
|
9
14
|
sx?: Sx | undefined;
|
|
10
15
|
/** The Composer.Root. */
|
|
11
16
|
children?: Snippet | undefined;
|
|
@@ -23,8 +23,10 @@ export type ComposerContext = {
|
|
|
23
23
|
readonly disabled: boolean;
|
|
24
24
|
/** True while a reply is on its way. Submitting stops it instead of sending. */
|
|
25
25
|
readonly busy: boolean;
|
|
26
|
+
/** True while a message is on its way and cannot be stopped: nothing can be sent or stopped. */
|
|
27
|
+
readonly sending: boolean;
|
|
26
28
|
/**
|
|
27
|
-
* Something to send, text or files, and nothing in the way of sending it.
|
|
29
|
+
* Something to send, text or files (or `hasContent`), and nothing in the way of sending it.
|
|
28
30
|
* While a reply is under way, true only if the composer can queue.
|
|
29
31
|
*/
|
|
30
32
|
readonly canSend: boolean;
|
|
@@ -37,6 +39,7 @@ export type ComposerContext = {
|
|
|
37
39
|
browse(): void;
|
|
38
40
|
/** True once a Composer.Attachments is placed: only then are dropped or pasted files taken. */
|
|
39
41
|
readonly attachable: boolean;
|
|
42
|
+
/** Focuses the text field: the textarea, or an editor of your own marked `data-composer-field`. */
|
|
40
43
|
focus(): void;
|
|
41
44
|
/** Reads a short message out to assistive technology, such as "Attached report.pdf". */
|
|
42
45
|
announce(message: string): void;
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
size?: DialogSize | undefined;
|
|
18
18
|
/** Opens as a sheet along one edge of the window, the full height of it. */
|
|
19
19
|
side?: 'start' | 'end' | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The element it is: `form` makes the dialog the form itself, so its fields and the
|
|
22
|
+
* footer's buttons are one form, and Enter in a field submits it. Give it `onsubmit`.
|
|
23
|
+
*/
|
|
24
|
+
as?: 'div' | 'form' | undefined;
|
|
20
25
|
/** Accessible name of the close button in the corner. `null` leaves it out. */
|
|
21
26
|
closeLabel?: string | null | undefined;
|
|
22
27
|
sx?: Sx | undefined;
|
|
@@ -30,6 +35,7 @@
|
|
|
30
35
|
let {
|
|
31
36
|
size = 'md',
|
|
32
37
|
side,
|
|
38
|
+
as = 'div',
|
|
33
39
|
closeLabel = 'Close',
|
|
34
40
|
sx,
|
|
35
41
|
class: className,
|
|
@@ -48,17 +54,21 @@
|
|
|
48
54
|
className
|
|
49
55
|
)}
|
|
50
56
|
>
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
{#snippet child({ props })}
|
|
58
|
+
<svelte:element this={as} {...props}>
|
|
59
|
+
{@render children?.()}
|
|
60
|
+
{#if closeLabel}
|
|
61
|
+
<span {...stylex.attrs(dialog.close)}>
|
|
62
|
+
<Dialog.Close>
|
|
63
|
+
{#snippet child({ props: close })}
|
|
64
|
+
<Button {...close} variant="ghost" size="sm" iconOnly aria-label={closeLabel}>
|
|
65
|
+
<Glyph name="close" />
|
|
66
|
+
</Button>
|
|
67
|
+
{/snippet}
|
|
68
|
+
</Dialog.Close>
|
|
69
|
+
</span>
|
|
70
|
+
{/if}
|
|
71
|
+
</svelte:element>
|
|
72
|
+
{/snippet}
|
|
63
73
|
</Dialog.Content>
|
|
64
74
|
</Dialog.Portal>
|
|
@@ -8,6 +8,11 @@ export type DialogContentProps = Loose<Omit<Dialog.ContentProps, 'children' | 'c
|
|
|
8
8
|
size?: DialogSize | undefined;
|
|
9
9
|
/** Opens as a sheet along one edge of the window, the full height of it. */
|
|
10
10
|
side?: 'start' | 'end' | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* The element it is: `form` makes the dialog the form itself, so its fields and the
|
|
13
|
+
* footer's buttons are one form, and Enter in a field submits it. Give it `onsubmit`.
|
|
14
|
+
*/
|
|
15
|
+
as?: 'div' | 'form' | undefined;
|
|
11
16
|
/** Accessible name of the close button in the corner. `null` leaves it out. */
|
|
12
17
|
closeLabel?: string | null | undefined;
|
|
13
18
|
sx?: Sx | undefined;
|
|
@@ -19,6 +24,11 @@ declare const DialogContent: import("svelte").Component<Loose<Omit<Dialog.Conten
|
|
|
19
24
|
size?: DialogSize | undefined;
|
|
20
25
|
/** Opens as a sheet along one edge of the window, the full height of it. */
|
|
21
26
|
side?: "start" | "end" | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The element it is: `form` makes the dialog the form itself, so its fields and the
|
|
29
|
+
* footer's buttons are one form, and Enter in a field submits it. Give it `onsubmit`.
|
|
30
|
+
*/
|
|
31
|
+
as?: "div" | "form" | undefined;
|
|
22
32
|
/** Accessible name of the close button in the corner. `null` leaves it out. */
|
|
23
33
|
closeLabel?: string | null | undefined;
|
|
24
34
|
sx?: Sx | undefined;
|
|
@@ -1,42 +1,84 @@
|
|
|
1
|
-
<!--
|
|
1
|
+
<!--
|
|
2
|
+
A labelled break in a timeline: a new day, or "Context compacted". Its words wrap
|
|
3
|
+
between the rules when they run long, and the rules keep a little of their length.
|
|
4
|
+
-->
|
|
2
5
|
<script lang="ts" module>
|
|
3
6
|
import * as stylex from '@stylexjs/stylex';
|
|
4
7
|
import type { Snippet } from 'svelte';
|
|
8
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
9
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
|
-
import { colors, font } from '../../tokens.stylex.js';
|
|
10
|
+
import { colors, font, space } from '../../tokens.stylex.js';
|
|
7
11
|
|
|
8
|
-
export type DividerProps = {
|
|
9
|
-
|
|
12
|
+
export type DividerProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'role'> & {
|
|
13
|
+
/** Its words. With `children` too, the name a separator is read by. */
|
|
14
|
+
label?: string | undefined;
|
|
15
|
+
/** A 14px icon before the words. */
|
|
10
16
|
icon?: Snippet | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* `separator` (the default for a `label` alone) is read as a break, by its label.
|
|
19
|
+
* `status` reads the words out as they change, such as "Compacting…" turning to
|
|
20
|
+
* "Context compacted". `none` leaves the words as text, for words with a link in them.
|
|
21
|
+
*/
|
|
22
|
+
role?: 'separator' | 'status' | 'none' | undefined;
|
|
11
23
|
sx?: Sx | undefined;
|
|
12
|
-
|
|
24
|
+
/** Words of your own in place of `label`: a link to where it came from, a time. */
|
|
25
|
+
children?: Snippet | undefined;
|
|
13
26
|
};
|
|
14
27
|
|
|
15
28
|
const styles = stylex.create({
|
|
16
29
|
divider: {
|
|
17
30
|
display: 'flex',
|
|
18
31
|
alignItems: 'center',
|
|
19
|
-
gap:
|
|
32
|
+
gap: space.x3,
|
|
20
33
|
color: colors.textSubtle,
|
|
21
34
|
fontSize: font.sizeCaption,
|
|
22
35
|
fontWeight: font.weightMedium,
|
|
23
|
-
|
|
24
|
-
'::before': {
|
|
25
|
-
|
|
36
|
+
lineHeight: font.leadingSnug,
|
|
37
|
+
'::before': {
|
|
38
|
+
content: '""',
|
|
39
|
+
flexGrow: 1,
|
|
40
|
+
minWidth: space.x3,
|
|
41
|
+
height: '1px',
|
|
42
|
+
backgroundColor: colors.border
|
|
43
|
+
},
|
|
44
|
+
'::after': {
|
|
45
|
+
content: '""',
|
|
46
|
+
flexGrow: 1,
|
|
47
|
+
minWidth: space.x3,
|
|
48
|
+
height: '1px',
|
|
49
|
+
backgroundColor: colors.border
|
|
50
|
+
}
|
|
26
51
|
},
|
|
27
|
-
label: {
|
|
52
|
+
label: {
|
|
53
|
+
display: 'inline-flex',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
gap: '0.375rem',
|
|
56
|
+
minWidth: 0,
|
|
57
|
+
textAlign: 'center',
|
|
58
|
+
textWrap: 'balance',
|
|
59
|
+
overflowWrap: 'anywhere'
|
|
60
|
+
},
|
|
61
|
+
icon: { '--narvi-icon-size': '0.875rem', display: 'grid', flexShrink: 0 }
|
|
28
62
|
});
|
|
29
63
|
</script>
|
|
30
64
|
|
|
31
65
|
<script lang="ts">
|
|
32
|
-
let { label, icon, sx, class: className }: DividerProps = $props();
|
|
66
|
+
let { label, icon, role, sx, class: className, children, ...rest }: DividerProps = $props();
|
|
67
|
+
|
|
68
|
+
// A label alone is a break, read by its label. Words of your own are read as they stand.
|
|
69
|
+
const resolved = $derived(role ?? (children ? 'none' : 'separator'));
|
|
70
|
+
const separator = $derived(resolved === 'separator');
|
|
33
71
|
</script>
|
|
34
72
|
|
|
35
73
|
<div
|
|
36
|
-
role=
|
|
37
|
-
aria-label={label}
|
|
74
|
+
role={resolved === 'none' ? undefined : resolved}
|
|
75
|
+
aria-label={separator ? label : undefined}
|
|
38
76
|
data-slot="divider"
|
|
77
|
+
{...rest}
|
|
39
78
|
{...attrs([styles.divider, sx], className)}
|
|
40
79
|
>
|
|
41
|
-
<span aria-hidden=
|
|
80
|
+
<span aria-hidden={separator || undefined} {...stylex.attrs(styles.label)}>
|
|
81
|
+
{#if icon}<span data-icons {...stylex.attrs(styles.icon)}>{@render icon()}</span>{/if}
|
|
82
|
+
{#if children}{@render children()}{:else}{label}{/if}
|
|
83
|
+
</span>
|
|
42
84
|
</div>
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
3
|
import { type Sx } from '../../internal/sx.js';
|
|
3
|
-
export type DividerProps = {
|
|
4
|
-
|
|
4
|
+
export type DividerProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'role'> & {
|
|
5
|
+
/** Its words. With `children` too, the name a separator is read by. */
|
|
6
|
+
label?: string | undefined;
|
|
7
|
+
/** A 14px icon before the words. */
|
|
5
8
|
icon?: Snippet | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* `separator` (the default for a `label` alone) is read as a break, by its label.
|
|
11
|
+
* `status` reads the words out as they change, such as "Compacting…" turning to
|
|
12
|
+
* "Context compacted". `none` leaves the words as text, for words with a link in them.
|
|
13
|
+
*/
|
|
14
|
+
role?: 'separator' | 'status' | 'none' | undefined;
|
|
6
15
|
sx?: Sx | undefined;
|
|
7
|
-
|
|
16
|
+
/** Words of your own in place of `label`: a link to where it came from, a time. */
|
|
17
|
+
children?: Snippet | undefined;
|
|
8
18
|
};
|
|
9
19
|
declare const Divider: import("svelte").Component<DividerProps, {}, "">;
|
|
10
20
|
type Divider = ReturnType<typeof Divider>;
|