@diegopluna/narvi 0.5.7 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/dialog/ConfirmDialog.svelte +15 -4
- package/dist/components/dialog/DialogDescription.svelte +15 -1
- package/dist/components/dialog/DialogRoot.svelte +3 -0
- package/dist/components/dialog/DialogTitle.svelte +13 -1
- package/dist/components/dialog/styles.d.ts +3 -0
- package/dist/components/dialog/styles.js +2 -0
- package/dist/components/input/Input.svelte +156 -15
- package/dist/components/input/Input.svelte.d.ts +17 -3
- package/dist/components/toast/Toaster.svelte +32 -22
- package/dist/components/toast/toasts.svelte.d.ts +14 -1
- package/dist/components/toast/toasts.svelte.js +7 -5
- package/dist/internal/Glyph.svelte +11 -0
- package/dist/internal/Glyph.svelte.d.ts +2 -0
- package/dist/internal/closing.svelte.d.ts +10 -0
- package/dist/internal/closing.svelte.js +43 -0
- package/dist/internal/markers.stylex.d.ts +4 -0
- package/dist/internal/markers.stylex.js +2 -0
- package/dist/markdown/highlight.d.ts +2 -2
- package/dist/markdown/highlight.js +2 -2
- package/package.json +32 -32
- package/skills/building-ui/SKILL.md +7 -7
- package/skills/building-ui/references/components.md +41 -41
- package/skills/markdown/SKILL.md +3 -3
- package/skills/setup/SKILL.md +2 -2
- package/skills/styling/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
|
@@ -154,6 +154,15 @@
|
|
|
154
154
|
$effect(() => {
|
|
155
155
|
if (open) error = undefined;
|
|
156
156
|
});
|
|
157
|
+
|
|
158
|
+
// What it said as it closed, until it has gone: an answer that clears what the dialog is
|
|
159
|
+
// about would otherwise blank its title and take its description away as it fades
|
|
160
|
+
type Words = Pick<ConfirmDialogProps, 'title' | 'description' | 'warning'>;
|
|
161
|
+
let kept = $state.raw<Words>();
|
|
162
|
+
$effect.pre(() => {
|
|
163
|
+
if (open) kept = { title, description, warning };
|
|
164
|
+
});
|
|
165
|
+
const words = $derived<Words>(open || !kept ? { title, description, warning } : kept);
|
|
157
166
|
</script>
|
|
158
167
|
|
|
159
168
|
<!-- While the action runs, nothing but the action closes it: not Escape, not Cancel -->
|
|
@@ -172,13 +181,15 @@
|
|
|
172
181
|
<AlertDialogBackdrop {...stylex.attrs(dialog.overlay, nested && dialog.nested)} />
|
|
173
182
|
<AlertDialogContent {...stylex.attrs(dialog.content, styles.content)}>
|
|
174
183
|
<div {...stylex.attrs(dialog.header, styles.header)}>
|
|
175
|
-
<AlertDialogTitle {...stylex.attrs(dialog.title)}>{title}</AlertDialogTitle>
|
|
176
|
-
{#if description || warning}
|
|
184
|
+
<AlertDialogTitle {...stylex.attrs(dialog.title)}>{words.title}</AlertDialogTitle>
|
|
185
|
+
{#if words.description || words.warning}
|
|
177
186
|
<AlertDialogDescription {...stylex.attrs(styles.describe)}>
|
|
178
187
|
{#snippet render({ props })}
|
|
179
188
|
<div {...props}>
|
|
180
|
-
{#if
|
|
181
|
-
|
|
189
|
+
{#if words.description}
|
|
190
|
+
<p {...stylex.attrs(dialog.description)}>{words.description}</p>
|
|
191
|
+
{/if}
|
|
192
|
+
{#if words.warning}<Notice tone="warning">{words.warning}</Notice>{/if}
|
|
182
193
|
</div>
|
|
183
194
|
{/snippet}
|
|
184
195
|
</AlertDialogDescription>
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
3
|
import { DialogDescription as UiDialogDescription } from '@ui-sdk/svelte/dialog';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
|
+
import * as stylex from '@stylexjs/stylex';
|
|
6
|
+
import { keepWhileClosing, place } from '../../internal/closing.svelte.js';
|
|
5
7
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
8
|
import { dialog } from './styles.js';
|
|
7
9
|
|
|
@@ -15,9 +17,21 @@
|
|
|
15
17
|
|
|
16
18
|
<script lang="ts">
|
|
17
19
|
let { sx, class: className, children, ...rest }: DialogDescriptionProps = $props();
|
|
20
|
+
|
|
21
|
+
let element = $state<HTMLElement>();
|
|
22
|
+
// What it said as the dialog closed, until the dialog has gone
|
|
23
|
+
const kept = keepWhileClosing(() => element);
|
|
18
24
|
</script>
|
|
19
25
|
|
|
20
26
|
<!-- A div, as bits-ui's was, so a description can hold more than a line of text -->
|
|
21
27
|
<UiDialogDescription {...rest} {...attrs([dialog.description, sx], className)}>
|
|
22
|
-
{#snippet render({ props })}
|
|
28
|
+
{#snippet render({ props })}
|
|
29
|
+
<div bind:this={element} {...props}>
|
|
30
|
+
{#if kept()}
|
|
31
|
+
<span {...stylex.attrs(dialog.kept)} {@attach place(kept()!)}></span>
|
|
32
|
+
{:else}
|
|
33
|
+
{@render children?.()}
|
|
34
|
+
{/if}
|
|
35
|
+
</div>
|
|
36
|
+
{/snippet}
|
|
23
37
|
</UiDialogDescription>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
3
|
import { Dialog } from '@ui-sdk/svelte/dialog';
|
|
4
|
+
import { provideDialogOpen } from '../../internal/closing.svelte.js';
|
|
4
5
|
import { usePopupContainer } from '../../internal/popup.js';
|
|
5
6
|
|
|
6
7
|
// No `presentation`: ui-sdk's own sheet moves itself, where Narvi's content is placed and
|
|
@@ -19,6 +20,8 @@
|
|
|
19
20
|
|
|
20
21
|
// The root's container is the backdrop's as well as the content's
|
|
21
22
|
const target = usePopupContainer(() => container);
|
|
23
|
+
// Its title and description keep their text while it closes
|
|
24
|
+
provideDialogOpen(() => open);
|
|
22
25
|
</script>
|
|
23
26
|
|
|
24
27
|
<!--
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
3
|
import { DialogTitle as UiDialogTitle } from '@ui-sdk/svelte/dialog';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
|
+
import * as stylex from '@stylexjs/stylex';
|
|
6
|
+
import { keepWhileClosing, place } from '../../internal/closing.svelte.js';
|
|
5
7
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
8
|
import { dialog } from './styles.js';
|
|
7
9
|
|
|
@@ -17,11 +19,21 @@
|
|
|
17
19
|
|
|
18
20
|
<script lang="ts">
|
|
19
21
|
let { level = 2, sx, class: className, children, ...rest }: DialogTitleProps = $props();
|
|
22
|
+
|
|
23
|
+
let element = $state<HTMLElement>();
|
|
24
|
+
// What it said as the dialog closed, until the dialog has gone
|
|
25
|
+
const kept = keepWhileClosing(() => element);
|
|
20
26
|
</script>
|
|
21
27
|
|
|
22
28
|
<!-- Names the dialog for assistive technology -->
|
|
23
29
|
<UiDialogTitle {...rest} {...attrs([dialog.title, sx], className)}>
|
|
24
30
|
{#snippet render({ props })}
|
|
25
|
-
<svelte:element this={`h${level}`} {...props}>
|
|
31
|
+
<svelte:element this={`h${level}`} bind:this={element} {...props}>
|
|
32
|
+
{#if kept()}
|
|
33
|
+
<span {...stylex.attrs(dialog.kept)} {@attach place(kept()!)}></span>
|
|
34
|
+
{:else}
|
|
35
|
+
{@render children?.()}
|
|
36
|
+
{/if}
|
|
37
|
+
</svelte:element>
|
|
26
38
|
{/snippet}
|
|
27
39
|
</UiDialogTitle>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
2
|
export declare const dialog: Readonly<{
|
|
3
|
+
readonly kept: Readonly<{
|
|
4
|
+
readonly display: stylex.StyleXClassNameFor<"display", "contents">;
|
|
5
|
+
}>;
|
|
3
6
|
readonly overlay: Readonly<{
|
|
4
7
|
readonly position: stylex.StyleXClassNameFor<"position", "fixed">;
|
|
5
8
|
readonly inset: stylex.StyleXClassNameFor<"inset", 0>;
|
|
@@ -8,6 +8,8 @@ const STARTING = ':is([data-starting-style])';
|
|
|
8
8
|
/** A length at the window's density (`density` in the tokens). */
|
|
9
9
|
const d = (rem) => `calc(${rem} * ${density.factor})`;
|
|
10
10
|
export const dialog = stylex.create({
|
|
11
|
+
// What a title or a description keeps while its dialog closes, laid out as its children were
|
|
12
|
+
kept: { display: 'contents' },
|
|
11
13
|
overlay: {
|
|
12
14
|
// ui-sdk opens the backdrop and the dialog in the top layer, the backdrop just below it, so
|
|
13
15
|
// the order of opening stacks them: a menu or a select opened from a dialog is over it
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import * as stylex from '@stylexjs/stylex';
|
|
3
|
-
import
|
|
3
|
+
import { DEV } from 'esm-env';
|
|
4
|
+
import { tick, type Snippet } from 'svelte';
|
|
4
5
|
import type { ClassValue, HTMLInputAttributes } from 'svelte/elements';
|
|
5
6
|
import '../../internal/icons.css';
|
|
6
7
|
import { colors, density } from '../../tokens.stylex.js';
|
|
8
|
+
import { media } from '../../media.stylex.js';
|
|
7
9
|
import { control, type ControlSize } from '../../internal/control.js';
|
|
10
|
+
import Glyph from '../../internal/Glyph.svelte';
|
|
11
|
+
import { inputMarker } from '../../internal/markers.stylex.js';
|
|
8
12
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
13
|
+
import Button from '../button/Button.svelte';
|
|
9
14
|
import { getFieldContext } from '../field/context.js';
|
|
10
15
|
|
|
11
16
|
export type InputSize = ControlSize;
|
|
@@ -20,10 +25,24 @@
|
|
|
20
25
|
* the field itself.
|
|
21
26
|
*/
|
|
22
27
|
icon?: Snippet | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Controls at the end of the field, inside its edge, such as a `Button size="xs" iconOnly
|
|
30
|
+
* variant="ghost"` that clears it. They keep their own names and take the pointer; the
|
|
31
|
+
* text stops before them. With one, `sx` and `class` style the element around the field,
|
|
32
|
+
* as with `icon`.
|
|
33
|
+
*/
|
|
34
|
+
end?: Snippet | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* A password field with an eye at its end that shows and hides what is typed, whatever
|
|
37
|
+
* `type` says. It takes the place of `end`, which is not drawn beside it.
|
|
38
|
+
*/
|
|
39
|
+
reveal?: boolean | undefined;
|
|
40
|
+
/** The eye's name, which stays the same while it is pressed. "Show password" by default. */
|
|
41
|
+
revealLabel?: string | undefined;
|
|
23
42
|
sx?: Sx | undefined;
|
|
24
43
|
/**
|
|
25
|
-
* Styles for the field itself, whether or not there is an `icon`: its text, its
|
|
26
|
-
* its edge. Without
|
|
44
|
+
* Styles for the field itself, whether or not there is an `icon` or an `end`: its text, its
|
|
45
|
+
* fill, its edge. Without either they go after `sx`.
|
|
27
46
|
*/
|
|
28
47
|
inputSx?: Sx | undefined;
|
|
29
48
|
/** Classes for the field itself, as `inputSx`. */
|
|
@@ -31,9 +50,18 @@
|
|
|
31
50
|
ref?: HTMLInputElement | null | undefined;
|
|
32
51
|
};
|
|
33
52
|
|
|
53
|
+
// Hover and focus as they happen, or as the catalog shows them, as in `internal/control.ts`
|
|
54
|
+
const HOVER = ':is(:hover, [data-preview~="hover"])';
|
|
55
|
+
const FOCUS = ':is(:focus-visible, [data-preview~="focus"])';
|
|
56
|
+
|
|
34
57
|
/** A length at the window's density (`density` in the tokens). */
|
|
35
58
|
const d = (rem: string) => `calc(${rem} * ${density.factor})`;
|
|
36
59
|
|
|
60
|
+
// What sits at the end is as wide as it measures; until it has been measured, one xs button
|
|
61
|
+
const END_WIDTH = `var(--narvi-input-end-width, ${d('1.5rem')})`;
|
|
62
|
+
// Between the end of the text and what sits at the end
|
|
63
|
+
const END_GAP = '0.25rem';
|
|
64
|
+
|
|
37
65
|
const styles = stylex.create({
|
|
38
66
|
frame: { position: 'relative', display: 'block', width: '100%', minWidth: 0 },
|
|
39
67
|
// In the field's start padding, where the pointer passes through to the field
|
|
@@ -52,19 +80,57 @@
|
|
|
52
80
|
// gap of 6px, which keep theirs
|
|
53
81
|
besideSm: { paddingInlineStart: `calc(${d('0.5rem')} + 1.25rem)` },
|
|
54
82
|
besideMd: { paddingInlineStart: `calc(${d('0.625rem')} + 1.375rem)` },
|
|
55
|
-
besideLg: { paddingInlineStart: `calc(${d('0.75rem')} + 1.375rem)` }
|
|
83
|
+
besideLg: { paddingInlineStart: `calc(${d('0.75rem')} + 1.375rem)` },
|
|
84
|
+
// Inside the field's end, centred in its height. An xs button (24px) sits as far from the
|
|
85
|
+
// end as from the top and the bottom.
|
|
86
|
+
end: {
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
insetBlock: 0,
|
|
89
|
+
display: 'flex',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
gap: '0.125rem',
|
|
92
|
+
color: colors.textSubtle
|
|
93
|
+
},
|
|
94
|
+
endSm: { '--narvi-icon-size': '0.875rem', insetInlineEnd: d('0.125rem') },
|
|
95
|
+
endMd: { '--narvi-icon-size': '1rem', insetInlineEnd: d('0.3125rem') },
|
|
96
|
+
endLg: { '--narvi-icon-size': '1rem', insetInlineEnd: d('0.5rem') },
|
|
97
|
+
// The text stops before what sits at the end: its inset, its width and a gap
|
|
98
|
+
beforeSm: { paddingInlineEnd: `calc(${d('0.125rem')} + ${END_WIDTH} + ${END_GAP})` },
|
|
99
|
+
beforeMd: { paddingInlineEnd: `calc(${d('0.3125rem')} + ${END_WIDTH} + ${END_GAP})` },
|
|
100
|
+
beforeLg: { paddingInlineEnd: `calc(${d('0.5rem')} + ${END_WIDTH} + ${END_GAP})` },
|
|
101
|
+
// The pointer on a control at the end is still on the field: its edge stays firm
|
|
102
|
+
held: {
|
|
103
|
+
borderColor: {
|
|
104
|
+
default: colors.borderControl,
|
|
105
|
+
[HOVER]: { default: null, [media.hover]: colors.borderControlHover },
|
|
106
|
+
// The ancestor's hover outranks the field's own focus, so focus is said again in it
|
|
107
|
+
[stylex.when.ancestor(':hover', inputMarker)]: {
|
|
108
|
+
default: null,
|
|
109
|
+
[media.hover]: { default: colors.borderControlHover, [FOCUS]: colors.focusRing }
|
|
110
|
+
},
|
|
111
|
+
[FOCUS]: colors.focusRing
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// Edge's own eye in a password field, beside Narvi's
|
|
115
|
+
noNativeReveal: { '::-ms-reveal': { display: 'none' } }
|
|
56
116
|
});
|
|
57
117
|
|
|
58
118
|
const iconStyles = { sm: styles.iconSm, md: styles.iconMd, lg: styles.iconLg };
|
|
59
119
|
const besideStyles = { sm: styles.besideSm, md: styles.besideMd, lg: styles.besideLg };
|
|
120
|
+
const endStyles = { sm: styles.endSm, md: styles.endMd, lg: styles.endLg };
|
|
121
|
+
const beforeStyles = { sm: styles.beforeSm, md: styles.beforeMd, lg: styles.beforeLg };
|
|
60
122
|
</script>
|
|
61
123
|
|
|
62
124
|
<script lang="ts">
|
|
63
125
|
let {
|
|
64
126
|
value = $bindable(),
|
|
65
127
|
size = 'md',
|
|
128
|
+
type,
|
|
66
129
|
invalid,
|
|
67
130
|
icon,
|
|
131
|
+
end,
|
|
132
|
+
reveal = false,
|
|
133
|
+
revealLabel = 'Show password',
|
|
68
134
|
disabled,
|
|
69
135
|
required,
|
|
70
136
|
id,
|
|
@@ -77,31 +143,106 @@
|
|
|
77
143
|
...rest
|
|
78
144
|
}: InputProps = $props();
|
|
79
145
|
|
|
146
|
+
$effect(() => {
|
|
147
|
+
if (DEV && reveal && end) {
|
|
148
|
+
console.warn(
|
|
149
|
+
'Input: `reveal` draws its own eye at the end, so the `end` snippet is not drawn.'
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
80
154
|
const field = getFieldContext();
|
|
81
155
|
const isInvalid = $derived(invalid ?? field?.invalid ?? false);
|
|
156
|
+
const isDisabled = $derived(disabled ?? field?.disabled);
|
|
157
|
+
const inputId = $derived(id ?? field?.id);
|
|
158
|
+
|
|
159
|
+
let shown = $state(false);
|
|
160
|
+
const inputType = $derived(reveal ? (shown ? 'text' : 'password') : type);
|
|
161
|
+
|
|
162
|
+
const hasEnd = $derived(reveal || end !== undefined);
|
|
163
|
+
// Measured once it renders; 0 when the snippet renders nothing, as a clear button does once
|
|
164
|
+
// the field is empty, and the field takes its own padding back
|
|
165
|
+
let endWidth = $state<number | undefined>(undefined);
|
|
166
|
+
const endTaken = $derived(hasEnd && endWidth !== 0);
|
|
167
|
+
|
|
168
|
+
/** Shows or hides the password, keeping the caret and the selection where they were. */
|
|
169
|
+
async function toggle() {
|
|
170
|
+
const input = ref;
|
|
171
|
+
const focused = input !== null && input === document.activeElement;
|
|
172
|
+
const start = input?.selectionStart ?? null;
|
|
173
|
+
const finish = input?.selectionEnd ?? null;
|
|
174
|
+
const direction = input?.selectionDirection ?? undefined;
|
|
175
|
+
shown = !shown;
|
|
176
|
+
if (!focused || start === null || finish === null) return;
|
|
177
|
+
await tick();
|
|
178
|
+
input.setSelectionRange(start, finish, direction);
|
|
179
|
+
}
|
|
82
180
|
</script>
|
|
83
181
|
|
|
84
|
-
{#snippet
|
|
182
|
+
{#snippet textField(own: Sx[], className?: ClassValue | null)}
|
|
85
183
|
<input
|
|
86
184
|
bind:this={ref}
|
|
87
185
|
bind:value
|
|
88
|
-
|
|
89
|
-
|
|
186
|
+
type={inputType}
|
|
187
|
+
id={inputId}
|
|
188
|
+
disabled={isDisabled}
|
|
90
189
|
required={required ?? field?.required}
|
|
91
190
|
aria-invalid={isInvalid ? true : undefined}
|
|
92
191
|
aria-describedby={describedBy ?? field?.describedBy}
|
|
93
192
|
{...rest}
|
|
94
|
-
{...attrs(
|
|
193
|
+
{...attrs(
|
|
194
|
+
[
|
|
195
|
+
control.base,
|
|
196
|
+
control[size],
|
|
197
|
+
hasEnd && styles.held,
|
|
198
|
+
isInvalid && control.invalid,
|
|
199
|
+
reveal && styles.noNativeReveal,
|
|
200
|
+
...own
|
|
201
|
+
],
|
|
202
|
+
className
|
|
203
|
+
)}
|
|
204
|
+
style:--narvi-input-end-width={endWidth === undefined ? undefined : `${endWidth}px`}
|
|
95
205
|
/>
|
|
96
206
|
{/snippet}
|
|
97
207
|
|
|
98
|
-
{#if icon}
|
|
99
|
-
<span data-slot="input" {...attrs([styles.frame, sx], className)}>
|
|
100
|
-
|
|
101
|
-
{
|
|
102
|
-
|
|
103
|
-
|
|
208
|
+
{#if icon || hasEnd}
|
|
209
|
+
<span data-slot="input" {...attrs([styles.frame, hasEnd && inputMarker, sx], className)}>
|
|
210
|
+
{#if icon}
|
|
211
|
+
<span data-icons aria-hidden="true" {...stylex.attrs(styles.icon, iconStyles[size])}>
|
|
212
|
+
{@render icon()}
|
|
213
|
+
</span>
|
|
214
|
+
{/if}
|
|
215
|
+
{@render textField(
|
|
216
|
+
[icon && besideStyles[size], endTaken && beforeStyles[size], inputSx],
|
|
217
|
+
inputClass
|
|
218
|
+
)}
|
|
219
|
+
{#if hasEnd}
|
|
220
|
+
<span
|
|
221
|
+
data-slot="input-end"
|
|
222
|
+
data-icons
|
|
223
|
+
bind:offsetWidth={endWidth}
|
|
224
|
+
{...stylex.attrs(styles.end, endStyles[size])}
|
|
225
|
+
>
|
|
226
|
+
{#if reveal}
|
|
227
|
+
<Button
|
|
228
|
+
size="xs"
|
|
229
|
+
iconOnly
|
|
230
|
+
variant="ghost"
|
|
231
|
+
aria-label={revealLabel}
|
|
232
|
+
aria-controls={inputId}
|
|
233
|
+
pressed={shown}
|
|
234
|
+
disabled={isDisabled}
|
|
235
|
+
onmousedown={(event: MouseEvent) => event.preventDefault()}
|
|
236
|
+
onclick={toggle}
|
|
237
|
+
>
|
|
238
|
+
<Glyph name={shown ? 'conceal' : 'reveal'} size={14} stroke={1.75} />
|
|
239
|
+
</Button>
|
|
240
|
+
{:else}
|
|
241
|
+
{@render end?.()}
|
|
242
|
+
{/if}
|
|
243
|
+
</span>
|
|
244
|
+
{/if}
|
|
104
245
|
</span>
|
|
105
246
|
{:else}
|
|
106
|
-
{@render
|
|
247
|
+
{@render textField([sx, inputSx], [className, inputClass])}
|
|
107
248
|
{/if}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
2
|
import type { ClassValue, HTMLInputAttributes } from 'svelte/elements';
|
|
3
3
|
import '../../internal/icons.css';
|
|
4
4
|
import { type ControlSize } from '../../internal/control.js';
|
|
@@ -14,10 +14,24 @@ export type InputProps = Omit<HTMLInputAttributes, 'size' | 'children'> & {
|
|
|
14
14
|
* the field itself.
|
|
15
15
|
*/
|
|
16
16
|
icon?: Snippet | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Controls at the end of the field, inside its edge, such as a `Button size="xs" iconOnly
|
|
19
|
+
* variant="ghost"` that clears it. They keep their own names and take the pointer; the
|
|
20
|
+
* text stops before them. With one, `sx` and `class` style the element around the field,
|
|
21
|
+
* as with `icon`.
|
|
22
|
+
*/
|
|
23
|
+
end?: Snippet | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A password field with an eye at its end that shows and hides what is typed, whatever
|
|
26
|
+
* `type` says. It takes the place of `end`, which is not drawn beside it.
|
|
27
|
+
*/
|
|
28
|
+
reveal?: boolean | undefined;
|
|
29
|
+
/** The eye's name, which stays the same while it is pressed. "Show password" by default. */
|
|
30
|
+
revealLabel?: string | undefined;
|
|
17
31
|
sx?: Sx | undefined;
|
|
18
32
|
/**
|
|
19
|
-
* Styles for the field itself, whether or not there is an `icon`: its text, its
|
|
20
|
-
* its edge. Without
|
|
33
|
+
* Styles for the field itself, whether or not there is an `icon` or an `end`: its text, its
|
|
34
|
+
* fill, its edge. Without either they go after `sx`.
|
|
21
35
|
*/
|
|
22
36
|
inputSx?: Sx | undefined;
|
|
23
37
|
/** Classes for the field itself, as `inputSx`. */
|
|
@@ -119,6 +119,9 @@
|
|
|
119
119
|
transitionTimingFunction: motion.easeOut
|
|
120
120
|
},
|
|
121
121
|
icon: { display: 'grid', placeItems: 'center', width: '1rem', height: '1.25rem' },
|
|
122
|
+
// An app's own icon grows as wide as it is, at least the glyph's room. It keeps the title's
|
|
123
|
+
// line height, so one taller than the line stays centred on it, spilling into the padding.
|
|
124
|
+
own: { width: 'auto', minWidth: '1rem' },
|
|
122
125
|
dot: {
|
|
123
126
|
width: '0.375rem',
|
|
124
127
|
height: '0.375rem',
|
|
@@ -290,28 +293,35 @@
|
|
|
290
293
|
if (region && typeof region.showPopover === 'function') raise(region);
|
|
291
294
|
}}
|
|
292
295
|
>
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
data.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
296
|
+
{#if data.icon}
|
|
297
|
+
<!-- The title says what it shows; the announcer reads only the title and description -->
|
|
298
|
+
<span aria-hidden="true" {...stylex.attrs(styles.icon, styles.own)}>
|
|
299
|
+
{@render data.icon()}
|
|
300
|
+
</span>
|
|
301
|
+
{:else}
|
|
302
|
+
<span
|
|
303
|
+
{...stylex.attrs(
|
|
304
|
+
styles.icon,
|
|
305
|
+
data.tone === 'info' && styles.info,
|
|
306
|
+
data.tone === 'success' && styles.success,
|
|
307
|
+
data.tone === 'warning' && styles.warning,
|
|
308
|
+
data.tone === 'error' && styles.error,
|
|
309
|
+
(data.tone === 'default' || data.tone === 'loading') && styles.muted
|
|
310
|
+
)}
|
|
311
|
+
>
|
|
312
|
+
{#if data.tone === 'loading'}
|
|
313
|
+
<Spinner size={14} label={null} />
|
|
314
|
+
{:else if data.tone === 'success'}
|
|
315
|
+
<Glyph name="check" stroke={1.75} />
|
|
316
|
+
{:else if data.tone === 'error' || data.tone === 'warning'}
|
|
317
|
+
<Glyph name="alert" />
|
|
318
|
+
{:else if data.tone === 'info'}
|
|
319
|
+
<Glyph name="info" />
|
|
320
|
+
{:else}
|
|
321
|
+
<span {...stylex.attrs(styles.dot)}></span>
|
|
322
|
+
{/if}
|
|
323
|
+
</span>
|
|
324
|
+
{/if}
|
|
315
325
|
<div {...stylex.attrs(styles.text)}>
|
|
316
326
|
<ToastTitle {...stylex.attrs(styles.title)} />
|
|
317
327
|
<ToastDescription {...stylex.attrs(styles.description)} />
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toasts: short notes about something that happened away from where the person
|
|
3
|
+
* is looking. Call `toast()` from anywhere; one <Toaster /> shows them.
|
|
4
|
+
*/
|
|
5
|
+
import type { Snippet } from 'svelte';
|
|
1
6
|
export type ToastTone = 'default' | 'info' | 'success' | 'warning' | 'error' | 'loading';
|
|
2
7
|
/** A toast's id: the one `toast()` returns, or one of your own given as `id`. */
|
|
3
8
|
export type ToastId = string | number;
|
|
@@ -14,6 +19,13 @@ export type ToastOptions = {
|
|
|
14
19
|
id?: ToastId | undefined;
|
|
15
20
|
description?: string | undefined;
|
|
16
21
|
tone?: ToastTone | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Your own icon, drawn in place of the tone's: the avatars of the agents a note is about. It
|
|
24
|
+
* takes the room it needs, centred on the title's first line, and none of the tone's colour.
|
|
25
|
+
* It is not announced, so say in the title what it shows. In `toast.update`, `null` takes it
|
|
26
|
+
* away.
|
|
27
|
+
*/
|
|
28
|
+
icon?: Snippet | null | undefined;
|
|
17
29
|
/** A button in the toast, such as Undo or Retry. */
|
|
18
30
|
action?: ToastAction | undefined;
|
|
19
31
|
/** Milliseconds before it goes. `null` keeps it until dismissed. */
|
|
@@ -26,10 +38,11 @@ export type ToastOptions = {
|
|
|
26
38
|
/** Called when it goes by itself, as its time runs out. */
|
|
27
39
|
onAutoClose?: ((id: ToastId) => void) | undefined;
|
|
28
40
|
};
|
|
29
|
-
/** What the Toaster reads from a toast's `data`: its own id, its tone and its action. */
|
|
41
|
+
/** What the Toaster reads from a toast's `data`: its own id, its tone, its icon and its action. */
|
|
30
42
|
export type ToastData = {
|
|
31
43
|
id: ToastId;
|
|
32
44
|
tone: ToastTone;
|
|
45
|
+
icon?: Snippet | null | undefined;
|
|
33
46
|
action?: ToastAction | undefined;
|
|
34
47
|
};
|
|
35
48
|
/**
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Toasts: short notes about something that happened away from where the person
|
|
3
|
-
* is looking. Call `toast()` from anywhere; one <Toaster /> shows them.
|
|
4
|
-
*/
|
|
5
1
|
import { createToaster } from '@ui-sdk/svelte/toast';
|
|
6
2
|
const DURATION = 5000;
|
|
7
3
|
let next = 1;
|
|
@@ -42,7 +38,12 @@ function put(entry) {
|
|
|
42
38
|
description: entry.description,
|
|
43
39
|
type: entry.tone,
|
|
44
40
|
duration: entry.duration ?? Infinity,
|
|
45
|
-
data: {
|
|
41
|
+
data: {
|
|
42
|
+
id: entry.id,
|
|
43
|
+
tone: entry.tone,
|
|
44
|
+
icon: entry.icon,
|
|
45
|
+
action: entry.action
|
|
46
|
+
},
|
|
46
47
|
onDismiss: (details) => ended(at, details)
|
|
47
48
|
});
|
|
48
49
|
}
|
|
@@ -54,6 +55,7 @@ function show(title, options = {}) {
|
|
|
54
55
|
title,
|
|
55
56
|
tone,
|
|
56
57
|
description: options.description,
|
|
58
|
+
icon: options.icon,
|
|
57
59
|
action: options.action,
|
|
58
60
|
duration: durationFor(tone, options.duration),
|
|
59
61
|
onDismiss: options.onDismiss,
|
|
@@ -26,6 +26,17 @@
|
|
|
26
26
|
'M1.75 8S4 3.75 8 3.75 14.25 8 14.25 8 12 12.25 8 12.25 1.75 8 1.75 8Z',
|
|
27
27
|
'M10 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z'
|
|
28
28
|
],
|
|
29
|
+
// Showing and hiding a password: Lucide's eye and eye-off, on this grid
|
|
30
|
+
reveal: [
|
|
31
|
+
'M1.37 8.23a.67.67 0 0 1 0-.46 7.17 7.17 0 0 1 13.26 0 .67.67 0 0 1 0 .46 7.17 7.17 0 0 1-13.26 0',
|
|
32
|
+
'M10 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z'
|
|
33
|
+
],
|
|
34
|
+
conceal: [
|
|
35
|
+
'M7.16 3.38a7.16 7.16 0 0 1 7.47 4.39.67.67 0 0 1 0 .46 7.16 7.16 0 0 1-.96 1.66',
|
|
36
|
+
'M9.39 9.44a2 2 0 0 1-2.83-2.83',
|
|
37
|
+
'M11.65 11.67a7.17 7.17 0 0 1-10.28-3.44.67.67 0 0 1 0-.46 7.17 7.17 0 0 1 2.96-3.43',
|
|
38
|
+
'M1.33 1.33l13.34 13.34'
|
|
39
|
+
],
|
|
29
40
|
globe: [
|
|
30
41
|
'M14 8A6 6 0 1 1 2 8a6 6 0 0 1 12 0Z',
|
|
31
42
|
'M2 8h12',
|
|
@@ -13,6 +13,8 @@ declare const paths: {
|
|
|
13
13
|
readonly terminal: readonly ["M3.5 4.5l3 3.25-3 3.25", "M8 11.5h4.5"];
|
|
14
14
|
readonly pencil: readonly ["M10.5 3.5 12.5 5.5", "M3 13l.5-2.5 7.75-7.75a1.4 1.4 0 0 1 2 2L5.5 12.5Z"];
|
|
15
15
|
readonly eye: readonly ["M1.75 8S4 3.75 8 3.75 14.25 8 14.25 8 12 12.25 8 12.25 1.75 8 1.75 8Z", "M10 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z"];
|
|
16
|
+
readonly reveal: readonly ["M1.37 8.23a.67.67 0 0 1 0-.46 7.17 7.17 0 0 1 13.26 0 .67.67 0 0 1 0 .46 7.17 7.17 0 0 1-13.26 0", "M10 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z"];
|
|
17
|
+
readonly conceal: readonly ["M7.16 3.38a7.16 7.16 0 0 1 7.47 4.39.67.67 0 0 1 0 .46 7.16 7.16 0 0 1-.96 1.66", "M9.39 9.44a2 2 0 0 1-2.83-2.83", "M11.65 11.67a7.17 7.17 0 0 1-10.28-3.44.67.67 0 0 1 0-.46 7.17 7.17 0 0 1 2.96-3.43", "M1.33 1.33l13.34 13.34"];
|
|
16
18
|
readonly globe: readonly ["M14 8A6 6 0 1 1 2 8a6 6 0 0 1 12 0Z", "M2 8h12", "M8 2c1.7 1.7 2.5 3.7 2.5 6S9.7 12.3 8 14C6.3 12.3 5.5 10.3 5.5 8S6.3 3.7 8 2Z"];
|
|
17
19
|
readonly sparkle: readonly ["M8 2.5 9.4 6.6 13.5 8 9.4 9.4 8 13.5 6.6 9.4 2.5 8 6.6 6.6Z"];
|
|
18
20
|
readonly squarePen: readonly ["M8 2.75H4.25C3.56 2.75 3 3.31 3 4v7.75c0 .69.56 1.25 1.25 1.25H12c.69 0 1.25-.56 1.25-1.25V8", "M12.25 1.75a.67.67 0 0 1 2 2L8.24 9.76a1.33 1.33 0 0 1-.57.34l-1.92.56a.33.33 0 0 1-.41-.41l.56-1.92a1.33 1.33 0 0 1 .34-.57Z"];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Tells the titles and descriptions inside a dialog whether it is open. Call it in its root. */
|
|
2
|
+
export declare function provideDialogOpen(open: () => boolean): void;
|
|
3
|
+
/**
|
|
4
|
+
* The nodes a title or a description keeps while its dialog closes, or undefined while it shows
|
|
5
|
+
* its children. Call it in the part's script, before its markup, so it reads the element before
|
|
6
|
+
* the children change: `element` is the part's own element.
|
|
7
|
+
*/
|
|
8
|
+
export declare function keepWhileClosing(element: () => Element | undefined): () => Node[] | undefined;
|
|
9
|
+
/** Puts the kept nodes in an element. */
|
|
10
|
+
export declare const place: (nodes: Node[]) => (element: Element) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a dialog's title and description do as the dialog closes.
|
|
3
|
+
*
|
|
4
|
+
* A confirm dialog's answer often clears what the dialog is about: `open={target !== null}`,
|
|
5
|
+
* a title that names the target, a description shown only while there is one. The same update
|
|
6
|
+
* then closes the dialog, blanks its title and takes its description away.
|
|
7
|
+
*
|
|
8
|
+
* - The text is kept. Once the dialog's `open` turns false, its title and description show what
|
|
9
|
+
* they showed until the dialog has gone, so it does not read "Revoke ?" as it fades. Opened
|
|
10
|
+
* again, they follow their content again.
|
|
11
|
+
*/
|
|
12
|
+
import { getContext, setContext, untrack } from 'svelte';
|
|
13
|
+
const OPEN = Symbol('narvi.dialog-open');
|
|
14
|
+
/** Tells the titles and descriptions inside a dialog whether it is open. Call it in its root. */
|
|
15
|
+
export function provideDialogOpen(open) {
|
|
16
|
+
setContext(OPEN, open);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The nodes a title or a description keeps while its dialog closes, or undefined while it shows
|
|
20
|
+
* its children. Call it in the part's script, before its markup, so it reads the element before
|
|
21
|
+
* the children change: `element` is the part's own element.
|
|
22
|
+
*/
|
|
23
|
+
export function keepWhileClosing(element) {
|
|
24
|
+
const open = getContext(OPEN);
|
|
25
|
+
let kept = $state.raw();
|
|
26
|
+
if (!open)
|
|
27
|
+
return () => undefined;
|
|
28
|
+
// Only a close is kept: content kept mounted while closed has nothing to keep at first
|
|
29
|
+
let was = untrack(open);
|
|
30
|
+
$effect.pre(() => {
|
|
31
|
+
const now = open();
|
|
32
|
+
if (was && !now) {
|
|
33
|
+
const shown = untrack(element);
|
|
34
|
+
kept = shown ? Array.from(shown.childNodes, (node) => node.cloneNode(true)) : undefined;
|
|
35
|
+
}
|
|
36
|
+
else if (now)
|
|
37
|
+
kept = undefined;
|
|
38
|
+
was = now;
|
|
39
|
+
});
|
|
40
|
+
return () => kept;
|
|
41
|
+
}
|
|
42
|
+
/** Puts the kept nodes in an element. */
|
|
43
|
+
export const place = (nodes) => (element) => element.replaceChildren(...nodes);
|
|
@@ -24,3 +24,7 @@ export declare const tabStripTabMarker: Readonly<{
|
|
|
24
24
|
export declare const appShellStripMarker: Readonly<{
|
|
25
25
|
readonly marker: stylex.StyleXClassNameFor<"marker", symbol>;
|
|
26
26
|
}>;
|
|
27
|
+
/** Placed around an Input with content at its end, so the field's edge stays firm while the pointer is on that content. */
|
|
28
|
+
export declare const inputMarker: Readonly<{
|
|
29
|
+
readonly marker: stylex.StyleXClassNameFor<"marker", symbol>;
|
|
30
|
+
}>;
|
|
@@ -14,3 +14,5 @@ export const sidebarItemMarker = stylex.defineMarker();
|
|
|
14
14
|
export const tabStripTabMarker = stylex.defineMarker();
|
|
15
15
|
/** Placed on AppShell.Strip, so the header that holds it takes a band's colour and no line. */
|
|
16
16
|
export const appShellStripMarker = stylex.defineMarker();
|
|
17
|
+
/** Placed around an Input with content at its end, so the field's edge stays firm while the pointer is on that content. */
|
|
18
|
+
export const inputMarker = stylex.defineMarker();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Syntax highlighting for Narvi's Markdown, with Pierre's Highlights: a WebAssembly
|
|
3
|
-
* highlighter with
|
|
3
|
+
* highlighter with 190 languages that can tokenize code as it streams.
|
|
4
4
|
*
|
|
5
5
|
* import { highlight } from '@diegopluna/narvi/markdown/highlight';
|
|
6
6
|
* <Markdown value={text} plugins={[highlight()]} />
|
|
7
7
|
*
|
|
8
|
-
* Importing this module loads the highlighter (about
|
|
8
|
+
* Importing this module loads the highlighter (about 190 KB gzipped), so import it where
|
|
9
9
|
* Markdown with code is shown, or with a dynamic `import()` to keep it out of the first load.
|
|
10
10
|
*/
|
|
11
11
|
import { type Theme } from '@pierre/highlights';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Syntax highlighting for Narvi's Markdown, with Pierre's Highlights: a WebAssembly
|
|
3
|
-
* highlighter with
|
|
3
|
+
* highlighter with 190 languages that can tokenize code as it streams.
|
|
4
4
|
*
|
|
5
5
|
* import { highlight } from '@diegopluna/narvi/markdown/highlight';
|
|
6
6
|
* <Markdown value={text} plugins={[highlight()]} />
|
|
7
7
|
*
|
|
8
|
-
* Importing this module loads the highlighter (about
|
|
8
|
+
* Importing this module loads the highlighter (about 190 KB gzipped), so import it where
|
|
9
9
|
* Markdown with code is shown, or with a dynamic `import()` to keep it out of the first load.
|
|
10
10
|
*/
|
|
11
11
|
import { StreamTokenizer, codeToTokens, isSupportedLanguage } from '@pierre/highlights';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegopluna/narvi",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"packageManager": "pnpm@12.18.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -112,13 +112,13 @@
|
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@codemirror/autocomplete": "^6.20.4",
|
|
115
|
-
"@codemirror/commands": "^6.11.
|
|
115
|
+
"@codemirror/commands": "^6.11.2",
|
|
116
116
|
"@codemirror/lang-css": "^6.3.1",
|
|
117
117
|
"@codemirror/lang-html": "^6.4.12",
|
|
118
118
|
"@codemirror/lang-javascript": "^6.2.5",
|
|
119
119
|
"@codemirror/language": "^6.13.1",
|
|
120
120
|
"@codemirror/state": "^6.7.6",
|
|
121
|
-
"@codemirror/view": "^6.
|
|
121
|
+
"@codemirror/view": "^6.44.2",
|
|
122
122
|
"@eslint/js": "^10.0.1",
|
|
123
123
|
"@fontsource-variable/fraunces": "^5.3.0",
|
|
124
124
|
"@fontsource-variable/geist": "^5.3.0",
|
|
@@ -130,34 +130,34 @@
|
|
|
130
130
|
"@fontsource/ibm-plex-sans": "^5.3.0",
|
|
131
131
|
"@fontsource/instrument-serif": "^5.3.0",
|
|
132
132
|
"@humanspeak/svelte-markdown": "2.2.0",
|
|
133
|
-
"@lezer/common": "^1.5.
|
|
133
|
+
"@lezer/common": "^1.5.7",
|
|
134
134
|
"@lezer/highlight": "^1.2.5",
|
|
135
|
-
"@lezer/javascript": "^1.5.
|
|
136
|
-
"@lezer/lr": "^1.4.
|
|
135
|
+
"@lezer/javascript": "^1.5.7",
|
|
136
|
+
"@lezer/lr": "^1.4.13",
|
|
137
137
|
"@replit/codemirror-lang-svelte": "^6.0.0",
|
|
138
138
|
"@sveltejs/adapter-static": "^4.0.1",
|
|
139
|
-
"@sveltejs/kit": "^3.
|
|
139
|
+
"@sveltejs/kit": "^3.4.1",
|
|
140
140
|
"@sveltejs/package": "^2.5.8",
|
|
141
|
-
"@sveltejs/vite-plugin-svelte": "^7.2
|
|
141
|
+
"@sveltejs/vite-plugin-svelte": "^7.3.2",
|
|
142
142
|
"@tanstack/intent": "0.5.6",
|
|
143
143
|
"@types/markdown-it": "14.2.0",
|
|
144
|
-
"@types/node": "^24",
|
|
144
|
+
"@types/node": "^24.19.4",
|
|
145
145
|
"@types/react": "19.2.14",
|
|
146
146
|
"@types/react-dom": "19.2.3",
|
|
147
|
-
"@vitest/browser-playwright": "^4.1.
|
|
148
|
-
"axe-core": "^4.14.
|
|
149
|
-
"eslint": "^10.
|
|
150
|
-
"eslint-config-prettier": "^10.1.
|
|
151
|
-
"eslint-plugin-svelte": "^3.
|
|
152
|
-
"globals": "^17.
|
|
147
|
+
"@vitest/browser-playwright": "^4.1.12",
|
|
148
|
+
"axe-core": "^4.14.1",
|
|
149
|
+
"eslint": "^10.16.0",
|
|
150
|
+
"eslint-config-prettier": "^10.1.9",
|
|
151
|
+
"eslint-plugin-svelte": "^3.24.1",
|
|
152
|
+
"globals": "^17.14.0",
|
|
153
153
|
"markdown-it": "15.0.3",
|
|
154
154
|
"marked": "18.1.2",
|
|
155
155
|
"micromark": "4.0.3",
|
|
156
156
|
"micromark-extension-gfm": "3.0.0",
|
|
157
|
-
"playwright": "^1.
|
|
158
|
-
"prettier": "^3.
|
|
159
|
-
"prettier-plugin-svelte": "
|
|
160
|
-
"publint": "^0.3.
|
|
157
|
+
"playwright": "^1.65.1",
|
|
158
|
+
"prettier": "^3.10.1",
|
|
159
|
+
"prettier-plugin-svelte": "4.1.1",
|
|
160
|
+
"publint": "^0.3.25",
|
|
161
161
|
"react": "19.2.9",
|
|
162
162
|
"react-dom": "19.2.9",
|
|
163
163
|
"rehype-stringify": "10.0.1",
|
|
@@ -166,30 +166,30 @@
|
|
|
166
166
|
"remark-rehype": "11.1.2",
|
|
167
167
|
"shiki": "^4.6.0",
|
|
168
168
|
"streamdown": "2.7.1",
|
|
169
|
-
"svelte": "^5.
|
|
170
|
-
"svelte-check": "^4.
|
|
169
|
+
"svelte": "^5.59.2",
|
|
170
|
+
"svelte-check": "^4.7.8",
|
|
171
171
|
"svelte-exmarkdown": "5.0.2",
|
|
172
172
|
"svelte-streamdown": "5.0.0",
|
|
173
173
|
"typescript": "^6.0.3",
|
|
174
|
-
"typescript-eslint": "^8.
|
|
174
|
+
"typescript-eslint": "^8.74.0",
|
|
175
175
|
"unified": "11.0.5",
|
|
176
|
-
"vite": "^8.
|
|
177
|
-
"vitest": "^4.1.
|
|
178
|
-
"vitest-browser-svelte": "^2.
|
|
179
|
-
"wrangler": "^4.
|
|
176
|
+
"vite": "^8.4.0",
|
|
177
|
+
"vitest": "^4.1.12",
|
|
178
|
+
"vitest-browser-svelte": "^2.2.1",
|
|
179
|
+
"wrangler": "^4.169.1"
|
|
180
180
|
},
|
|
181
181
|
"peerDependencies": {
|
|
182
182
|
"svelte": "^5.20.0",
|
|
183
183
|
"vite": ">=6"
|
|
184
184
|
},
|
|
185
185
|
"dependencies": {
|
|
186
|
-
"@pierre/highlights": "0.
|
|
187
|
-
"@stylexjs/stylex": "0.19.
|
|
188
|
-
"@stylexjs/unplugin": "0.19.
|
|
189
|
-
"@ui-sdk/core": "0.1.0-beta.
|
|
190
|
-
"@ui-sdk/svelte": "0.1.0-beta.
|
|
186
|
+
"@pierre/highlights": "0.6.0",
|
|
187
|
+
"@stylexjs/stylex": "0.19.2",
|
|
188
|
+
"@stylexjs/unplugin": "0.19.2",
|
|
189
|
+
"@ui-sdk/core": "0.1.0-beta.23",
|
|
190
|
+
"@ui-sdk/svelte": "0.1.0-beta.23",
|
|
191
191
|
"decode-named-character-reference": "1.3.0",
|
|
192
|
-
"dompurify": "3.
|
|
192
|
+
"dompurify": "3.5.0",
|
|
193
193
|
"esm-env": "^1.2.2",
|
|
194
194
|
"katex": "0.19.1",
|
|
195
195
|
"lightningcss": "^1.33.0",
|
|
@@ -12,7 +12,7 @@ metadata:
|
|
|
12
12
|
Grid, and Narvi's conventions for colour, labels and copy.
|
|
13
13
|
type: core
|
|
14
14
|
library: '@diegopluna/narvi'
|
|
15
|
-
library_version: '0.5.
|
|
15
|
+
library_version: '0.5.9'
|
|
16
16
|
requires:
|
|
17
17
|
- setup
|
|
18
18
|
sources:
|
|
@@ -29,6 +29,7 @@ sources:
|
|
|
29
29
|
- src/lib/components/dialog/ConfirmDialog.svelte
|
|
30
30
|
- src/lib/components/notice/Notice.svelte
|
|
31
31
|
- src/lib/components/field/Field.svelte
|
|
32
|
+
- src/lib/components/input/Input.svelte
|
|
32
33
|
- src/lib/components/list/ListRoot.svelte
|
|
33
34
|
- src/lib/components/table/*
|
|
34
35
|
- src/lib/components/choice-cards/ChoiceCards.svelte
|
|
@@ -153,7 +154,7 @@ For a yes/no confirmation, use `ConfirmDialog`. It takes a `title` that asks the
|
|
|
153
154
|
`confirmLabel` that names the action. If `onconfirm` returns a promise, the dialog waits for it
|
|
154
155
|
and shows the error when it rejects. Say what will be lost with `warning` (a string), not a
|
|
155
156
|
`Notice` of your own in its children: the warning is read with the description as it opens.
|
|
156
|
-
Children that render nothing (an `{#if}` that is false) leave no empty body.
|
|
157
|
+
Children that render nothing (an `{#if}` that is false) leave no empty body. Its title and description, and a `Dialog`'s, keep their text while it closes, so the answer may clear what `open` and the text read (`open={target !== null}`).
|
|
157
158
|
|
|
158
159
|
### Forms
|
|
159
160
|
|
|
@@ -175,9 +176,8 @@ wires up `id`, `aria-describedby` and `aria-invalid`. Don't hand-write their `<l
|
|
|
175
176
|
- `group` makes the Field a fieldset named by its legend, for several controls under one label
|
|
176
177
|
(radios, a start and an end). The help and the error describe the group; its controls take
|
|
177
178
|
no id from it.
|
|
178
|
-
- `Input` takes an `icon` snippet at its start,
|
|
179
|
-
|
|
180
|
-
an icon, `sx` styles the element around the field; `inputSx` and `inputClass` style the field.
|
|
179
|
+
- `Input` takes an `icon` snippet at its start, an `end` snippet for your controls inside its
|
|
180
|
+
end (a clear `Button size="xs" iconOnly variant="ghost"`), or `reveal` for a password's eye.
|
|
181
181
|
- For one choice among a few that each need a line of detail, use `ChoiceCards`
|
|
182
182
|
(`options: { value, label, detail?, icon?, disabled? }[]`, `bind:value`, `aria-label`).
|
|
183
183
|
|
|
@@ -312,7 +312,7 @@ and `Kbd` inline, `Link` inside text, `Button href` for a link that looks like a
|
|
|
312
312
|
});
|
|
313
313
|
```
|
|
314
314
|
|
|
315
|
-
- Errors and work under way stay until dismissed, and every toast has a Dismiss button.
|
|
315
|
+
- Errors and work under way stay until dismissed, and every toast has a Dismiss button. An `icon` (a `Snippet`) is drawn in place of the tone's glyph, such as a stack of avatars, as wide as it is. It is not announced, so the title says what it shows. `toast.update` keeps it unless given one; `icon: null` takes it away.
|
|
316
316
|
- `Tooltip.Root` needs a `Tooltip.Provider` near the root, whose delay and hand-off Narvi's own
|
|
317
317
|
tooltips (Button, Rail, Tabs) take too. An icon button needs an `aria-label` as well.
|
|
318
318
|
- Use `Notice` for a note in place (`tone`: neutral, info, success, warning, danger; `raised`
|
|
@@ -480,7 +480,7 @@ Parts of a thread that are easy to redraw by hand, and shouldn't be:
|
|
|
480
480
|
- **MEDIUM: a raw `<label>` beside an Input.** It misses Field's description and error wiring.
|
|
481
481
|
- **HIGH: `Dialog.Content size="lg"` written for 44rem.** Since the sizes gained `lg` 36rem,
|
|
482
482
|
`xl` 44 and `2xl` 56, the old `lg` is `xl`.
|
|
483
|
-
- **MEDIUM: an
|
|
483
|
+
- **MEDIUM: an icon, a clear button or an eye placed beside an Input.** Use `icon`, `end` or `reveal`.
|
|
484
484
|
- **MEDIUM: a toast's `onDismiss` alone for "Undo, or else forget".** A toast that runs out of
|
|
485
485
|
time calls `onAutoClose`, not `onDismiss`, so the forgetting never happens. Pass both.
|
|
486
486
|
- **MEDIUM: a SettingsRow's `<label for>` on a group.** A `SegmentedControl` or a set of radios
|
|
@@ -66,27 +66,27 @@ Markdown's table styles: Markdown's tables and this one share their look.
|
|
|
66
66
|
|
|
67
67
|
## Controls and forms
|
|
68
68
|
|
|
69
|
-
| Component | Use it for
|
|
70
|
-
| --------------------------- |
|
|
71
|
-
| `Button` | An action; `href` makes it a link; `variant` (12, from `primary` to `success-outline`), `size` (`micro` to `lg`), `shape`, `justify`, `loading`, `iconOnly`, `pressed`, `tooltip`
|
|
72
|
-
| `Field` | Label, help text and error around one control
|
|
73
|
-
| `Input` | One line of text
|
|
74
|
-
| `Textarea` | Several lines of text
|
|
75
|
-
| `Select` | One choice from a short list (`options: { value, label, icon?, detail?, detailMono?, group? }[]`, `align`, `optionIcon`)
|
|
76
|
-
| `Checkbox` | An option on or off, or several from a list
|
|
77
|
-
| `ChoiceCards` | One choice among a few, each a card with a title and a line of detail
|
|
78
|
-
| `Switch` | A setting that takes effect at once
|
|
79
|
-
| `SegmentedControl` | One of a few options, all visible (`options: { value, label, title? }[]`, `onchange`)
|
|
80
|
-
| `Slider` | A value or a range along a track
|
|
81
|
-
| `ColorField` | A colour: a swatch that opens Narvi's picker, beside a hex field (`label`, `bind:value`, `onchange`, `size`, `labels`)
|
|
82
|
-
| `SplitButton` | A main action joined to a menu of how to do it (`menu`, `menuLabel`, `label`, `variant` incl. `ghost`, `shape`, `mainDisabled`, `mainSx`/`menuSx`, `menuMinWidth`)
|
|
83
|
-
| `Toggle` | A button that stays pressed (`tone`: `accent`, or `neutral` for toolbar icons)
|
|
84
|
-
| `ToggleGroup.Root`, `.Item` | Toggles that belong together: one pressed, or any number; toggle buttons (`aria-pressed`) either way, never radios
|
|
85
|
-
| `SettingsGroup` | A titled group of settings: a heading, an action, the rows on one card
|
|
86
|
-
| `SettingsRow` | One setting: what it is, beside its control (`leading`, `dimmed`, `mono`)
|
|
87
|
-
| `Tabs` | Views that share one place (`tabs: TabItem[]`, `label`, `bind:value`; `activation="manual"` for a slow panel)
|
|
88
|
-
| `SearchButton` | Looks like a search field and opens search (`label`, `shortcut`): for a window's bar
|
|
89
|
-
| `TabStrip` | Tabs for what is open in a pane: closable, addable, scrolling (`tabs`, `bind:value`, `onclose`, `onadd`); `menu`, `onmove`, `onrename`, `onkeep`, `trailing`, `variant`. The panels are yours
|
|
69
|
+
| Component | Use it for | Docs slug |
|
|
70
|
+
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- |
|
|
71
|
+
| `Button` | An action; `href` makes it a link; `variant` (12, from `primary` to `success-outline`), `size` (`micro` to `lg`), `shape`, `justify`, `loading`, `iconOnly`, `pressed`, `tooltip` | `button` |
|
|
72
|
+
| `Field` | Label, help text and error around one control | `field` |
|
|
73
|
+
| `Input` | One line of text; an `icon` at its start, controls in an `end` snippet, or `reveal` for a password with an eye (`revealLabel`, "Show password"); with either, `inputSx` and `inputClass` style the field itself | `input` |
|
|
74
|
+
| `Textarea` | Several lines of text | `textarea` |
|
|
75
|
+
| `Select` | One choice from a short list (`options: { value, label, icon?, detail?, detailMono?, group? }[]`, `align`, `optionIcon`) | `select` |
|
|
76
|
+
| `Checkbox` | An option on or off, or several from a list | `checkbox` |
|
|
77
|
+
| `ChoiceCards` | One choice among a few, each a card with a title and a line of detail | `choice-cards` |
|
|
78
|
+
| `Switch` | A setting that takes effect at once | `switch` |
|
|
79
|
+
| `SegmentedControl` | One of a few options, all visible (`options: { value, label, title? }[]`, `onchange`) | `segmented-control` |
|
|
80
|
+
| `Slider` | A value or a range along a track | `slider` |
|
|
81
|
+
| `ColorField` | A colour: a swatch that opens Narvi's picker, beside a hex field (`label`, `bind:value`, `onchange`, `size`, `labels`) | `color-field` |
|
|
82
|
+
| `SplitButton` | A main action joined to a menu of how to do it (`menu`, `menuLabel`, `label`, `variant` incl. `ghost`, `shape`, `mainDisabled`, `mainSx`/`menuSx`, `menuMinWidth`) | `split-button` |
|
|
83
|
+
| `Toggle` | A button that stays pressed (`tone`: `accent`, or `neutral` for toolbar icons) | `toggle` |
|
|
84
|
+
| `ToggleGroup.Root`, `.Item` | Toggles that belong together: one pressed, or any number; toggle buttons (`aria-pressed`) either way, never radios | `toggle-group` |
|
|
85
|
+
| `SettingsGroup` | A titled group of settings: a heading, an action, the rows on one card | `settings-group` |
|
|
86
|
+
| `SettingsRow` | One setting: what it is, beside its control (`leading`, `dimmed`, `mono`) | `settings-row` |
|
|
87
|
+
| `Tabs` | Views that share one place (`tabs: TabItem[]`, `label`, `bind:value`; `activation="manual"` for a slow panel) | `tabs` |
|
|
88
|
+
| `SearchButton` | Looks like a search field and opens search (`label`, `shortcut`): for a window's bar | `search-button` |
|
|
89
|
+
| `TabStrip` | Tabs for what is open in a pane: closable, addable, scrolling (`tabs`, `bind:value`, `onclose`, `onadd`); `menu`, `onmove`, `onrename`, `onkeep`, `trailing`, `variant`. The panels are yours | `tab-strip` |
|
|
90
90
|
|
|
91
91
|
### Tab strips
|
|
92
92
|
|
|
@@ -176,11 +176,11 @@ browser; a `container` on a Root or a Content still wins, and the popups inside
|
|
|
176
176
|
{@render children()}
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
179
|
+
An Escape handler inside a popup that takes the key for itself (clearing a field, leaving an
|
|
180
|
+
edit) calls `event.preventDefault()`, and the popup stays open. ui-sdk takes Escape in the popup
|
|
181
|
+
content's own keydown, after the handler, and skips a key whose default is prevented. Stopping
|
|
182
|
+
propagation works too, with the popup in a container on `document.body` as well, but
|
|
183
|
+
`preventDefault()` also tells other listeners the key was used.
|
|
184
184
|
|
|
185
185
|
To drive `open` from the app, bind it, or pass it with an `onOpenChange` that keeps your state:
|
|
186
186
|
`open={shown && !dragging} onOpenChange={(next) => (shown = next)}` follows `dragging` even after
|
|
@@ -216,21 +216,21 @@ errors with an `Announcer` too.
|
|
|
216
216
|
|
|
217
217
|
## Feedback and status
|
|
218
218
|
|
|
219
|
-
| Component | Use it for
|
|
220
|
-
| ------------------------------------ |
|
|
221
|
-
| `Toaster`, `toast()` | Short notes about something that happened; one Toaster at the root. Toasts stay over the page and a modal dialog; a menu or popover opened later is over them, a new toast over everything | `toast` |
|
|
222
|
-
| `Notice` | A note in place: what is happening or went wrong, and what to do
|
|
223
|
-
| `EmptyState` | An empty place: what it is for and how to fill it (`title`, `level`, `description`, `media`, `actions`)
|
|
224
|
-
| `Badge` | A status, category or count (`tone`, `info` among them; `color` for a label's own dot)
|
|
225
|
-
| `StatusIndicator` | Where a run, thread or machine stands, by shape and colour
|
|
226
|
-
| `StatusDot` | A small dot of status colour (`tone`, `shape`), beside a name or on a mark
|
|
227
|
-
| `Progress` | How far along a task is
|
|
228
|
-
| `Spinner` | Something in progress
|
|
229
|
-
| `Skeleton` | A stand-in for content on its way
|
|
230
|
-
| `Shimmer` | Text that says work is under way (`tone` `neutral` by default, or `accent` for the one live thing)
|
|
231
|
-
| `RollingText` | A phrase that rolls to its next value ("Reading…", "Running…")
|
|
232
|
-
| `Announcer` | Says a short message to screen readers without showing anything
|
|
233
|
-
| `Avatar.Root`, `.Image`, `.Fallback` | A person: a picture, or initials (`size` `xs` is 20px; `label={null}` beside a written name)
|
|
219
|
+
| Component | Use it for | Docs slug |
|
|
220
|
+
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
|
|
221
|
+
| `Toaster`, `toast()` | Short notes about something that happened; one Toaster at the root. Toasts stay over the page and a modal dialog; a menu or popover opened later is over them, a new toast over everything. `icon` (a snippet) draws an app's own, such as avatars, in place of the tone's glyph | `toast` |
|
|
222
|
+
| `Notice` | A note in place: what is happening or went wrong, and what to do | `notice` |
|
|
223
|
+
| `EmptyState` | An empty place: what it is for and how to fill it (`title`, `level`, `description`, `media`, `actions`) | `empty-state` |
|
|
224
|
+
| `Badge` | A status, category or count (`tone`, `info` among them; `color` for a label's own dot) | `badge` |
|
|
225
|
+
| `StatusIndicator` | Where a run, thread or machine stands, by shape and colour | `status-indicator` |
|
|
226
|
+
| `StatusDot` | A small dot of status colour (`tone`, `shape`), beside a name or on a mark | `status-indicator` |
|
|
227
|
+
| `Progress` | How far along a task is | `progress` |
|
|
228
|
+
| `Spinner` | Something in progress | `spinner` |
|
|
229
|
+
| `Skeleton` | A stand-in for content on its way | `skeleton` |
|
|
230
|
+
| `Shimmer` | Text that says work is under way (`tone` `neutral` by default, or `accent` for the one live thing) | `shimmer` |
|
|
231
|
+
| `RollingText` | A phrase that rolls to its next value ("Reading…", "Running…") | none |
|
|
232
|
+
| `Announcer` | Says a short message to screen readers without showing anything | `announcer` |
|
|
233
|
+
| `Avatar.Root`, `.Image`, `.Fallback` | A person: a picture, or initials (`size` `xs` is 20px; `label={null}` beside a written name) | `avatar` |
|
|
234
234
|
|
|
235
235
|
## App shell
|
|
236
236
|
|
package/skills/markdown/SKILL.md
CHANGED
|
@@ -12,7 +12,7 @@ metadata:
|
|
|
12
12
|
patching the DOM, and decide which links and images text from a model may load.
|
|
13
13
|
type: core
|
|
14
14
|
library: '@diegopluna/narvi'
|
|
15
|
-
library_version: '0.5.
|
|
15
|
+
library_version: '0.5.9'
|
|
16
16
|
requires:
|
|
17
17
|
- setup
|
|
18
18
|
sources:
|
|
@@ -152,11 +152,11 @@ needs the component's state. Never write a new array in the markup:
|
|
|
152
152
|
<Markdown value={text} streaming={!done} {plugins} />
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
- **`highlight()`** colours code in
|
|
155
|
+
- **`highlight()`** colours code in 190 languages with `@pierre/highlights`. A block that
|
|
156
156
|
streams is tokenized line by line as it arrives, never from the top again. Code takes Narvi's
|
|
157
157
|
syntax colours by default. Pass `highlight({ themes: { light, dark } })` with Zed-compatible
|
|
158
158
|
themes (for example from `@pierre/highlights/themes`) to use an editor theme. Importing the
|
|
159
|
-
module loads about
|
|
159
|
+
module loads about 190 KB (gzipped) of WebAssembly. To keep it out of the first load, import
|
|
160
160
|
it in the browser and add it to the plugins once, when it arrives (see below).
|
|
161
161
|
- **`math()`** turns on formulas (`$x$`, `$$x$$`, `\(x\)`, `\[x\]` and a fenced `math` block)
|
|
162
162
|
and typesets them with KaTeX, which loads on the first formula. Prices and shell variables
|
package/skills/setup/SKILL.md
CHANGED
|
@@ -11,7 +11,7 @@ metadata:
|
|
|
11
11
|
4 when the app uses it.
|
|
12
12
|
type: lifecycle
|
|
13
13
|
library: '@diegopluna/narvi'
|
|
14
|
-
library_version: '0.5.
|
|
14
|
+
library_version: '0.5.9'
|
|
15
15
|
sources:
|
|
16
16
|
- src/lib/vite.ts
|
|
17
17
|
- src/lib/base.css
|
|
@@ -36,7 +36,7 @@ Narvi is below 1.0, so a minor release can change an API. Pin the version you bu
|
|
|
36
36
|
1. Install the package, with StyleX for your own styles:
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
|
-
pnpm add @diegopluna/narvi @stylexjs/stylex@0.19.
|
|
39
|
+
pnpm add @diegopluna/narvi @stylexjs/stylex@0.19.2
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
`@stylexjs/stylex` is only needed to import it in your own files. Keep it at the version Narvi
|
package/skills/styling/SKILL.md
CHANGED
package/skills/theming/SKILL.md
CHANGED