@diegopluna/narvi 0.3.6 → 0.3.8
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/ActivityStep.svelte +86 -6
- package/dist/components/activity/ActivityStep.svelte.d.ts +17 -2
- package/dist/components/activity/index.d.ts +1 -1
- package/dist/components/app-shell/AppShellMain.svelte +62 -2
- package/dist/components/app-shell/AppShellMain.svelte.d.ts +1 -1
- package/dist/components/app-shell/AppShellPanel.svelte +37 -11
- package/dist/components/app-shell/AppShellPanel.svelte.d.ts +13 -0
- package/dist/components/app-shell/AppShellSidebar.svelte +30 -10
- package/dist/components/command/CommandDialog.svelte +9 -2
- package/dist/components/command/CommandDialog.svelte.d.ts +4 -0
- package/dist/components/command/CommandEmpty.svelte +38 -4
- package/dist/components/command/CommandEmpty.svelte.d.ts +18 -2
- package/dist/components/command/CommandFooter.svelte +5 -7
- package/dist/components/command/CommandFooter.svelte.d.ts +4 -1
- package/dist/components/command/CommandInput.svelte +13 -1
- package/dist/components/command/CommandInput.svelte.d.ts +11 -0
- package/dist/components/command/CommandItem.svelte +32 -6
- package/dist/components/command/CommandItem.svelte.d.ts +20 -0
- package/dist/components/command/CommandRoot.svelte +68 -9
- package/dist/components/command/CommandRoot.svelte.d.ts +13 -3
- package/dist/components/command/styles.d.ts +50 -8
- package/dist/components/command/styles.js +50 -8
- package/dist/components/markdown/Markdown.svelte +14 -4
- package/dist/components/menu/MenuContent.svelte +7 -1
- package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
- package/dist/components/sidebar/SidebarFolder.svelte +2 -1
- package/dist/components/sidebar/SidebarGroup.svelte +2 -1
- package/dist/components/sidebar/SidebarItem.svelte +34 -4
- package/dist/components/split-button/SplitButton.svelte +54 -15
- package/dist/components/split-button/SplitButton.svelte.d.ts +21 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/internal/Collapse.svelte +16 -1
- package/dist/internal/Collapse.svelte.d.ts +2 -0
- package/dist/internal/fold-shown.d.ts +3 -0
- package/dist/internal/fold-shown.js +14 -0
- package/dist/internal/layer.d.ts +6 -3
- package/dist/internal/layer.js +13 -6
- package/dist/internal/visible.d.ts +24 -1
- package/dist/internal/visible.js +25 -1
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +15 -15
- package/skills/building-ui/references/components.md +79 -15
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +7 -1
- package/skills/theming/SKILL.md +1 -1
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
-->
|
|
6
6
|
<script lang="ts" module>
|
|
7
7
|
import * as stylex from '@stylexjs/stylex';
|
|
8
|
-
import type
|
|
8
|
+
import { untrack, type Snippet } from 'svelte';
|
|
9
9
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
10
10
|
import { emphasis, KIND_GLYPHS, type ActionKind } from '../../internal/kinds.js';
|
|
11
11
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
12
|
+
import { getFoldShown } from '../../internal/fold-shown.js';
|
|
12
13
|
import Tile from '../../internal/Tile.svelte';
|
|
13
14
|
import { colors, font, radius } from '../../tokens.stylex.js';
|
|
15
|
+
import Button from '../button/Button.svelte';
|
|
14
16
|
import Spinner from '../spinner/Spinner.svelte';
|
|
15
17
|
|
|
16
18
|
export type ActivityStepKind = ActionKind;
|
|
@@ -24,6 +26,14 @@
|
|
|
24
26
|
|
|
25
27
|
type Badged = 'failed' | 'declined' | 'blocked' | 'neutral';
|
|
26
28
|
|
|
29
|
+
/** Words for the control under a long output. */
|
|
30
|
+
export type ActivityStepOutputLabels = {
|
|
31
|
+
/** "Show all output" by default. */
|
|
32
|
+
showAll?: string | undefined;
|
|
33
|
+
/** "Show less" by default. */
|
|
34
|
+
showLess?: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
27
37
|
export type ActivityStepProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
28
38
|
kind?: ActivityStepKind | undefined;
|
|
29
39
|
/** The command, the path, the query: shown as code. Cut to one line, unless `wrap`. */
|
|
@@ -37,6 +47,14 @@
|
|
|
37
47
|
output?: string | undefined;
|
|
38
48
|
/** How much of the output to keep, from the end, in characters. */
|
|
39
49
|
tail?: number | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Shows all of an output longer than `tail`, not only its end. A control under the output
|
|
52
|
+
* turns it on and off. Bindable: keep it where the conversation is drawn again, or set it
|
|
53
|
+
* when a find of your own finds something in the part cut off.
|
|
54
|
+
*/
|
|
55
|
+
showAll?: boolean | undefined;
|
|
56
|
+
/** Words for that control. */
|
|
57
|
+
outputLabels?: ActivityStepOutputLabels | undefined;
|
|
40
58
|
/** Words for the statuses that need them. */
|
|
41
59
|
statusLabels?: Partial<Record<Badged, string>> | undefined;
|
|
42
60
|
/** Anything else: images, a diff. */
|
|
@@ -107,6 +125,7 @@
|
|
|
107
125
|
minWidth: 0
|
|
108
126
|
},
|
|
109
127
|
reason: { margin: 0, color: colors.textMuted, fontSize: font.sizeMeta },
|
|
128
|
+
more: { alignSelf: 'flex-start' },
|
|
110
129
|
output: {
|
|
111
130
|
margin: 0,
|
|
112
131
|
maxHeight: '10rem',
|
|
@@ -134,6 +153,8 @@
|
|
|
134
153
|
reason,
|
|
135
154
|
output,
|
|
136
155
|
tail = 4000,
|
|
156
|
+
showAll = $bindable(false),
|
|
157
|
+
outputLabels,
|
|
137
158
|
statusLabels,
|
|
138
159
|
wrap = false,
|
|
139
160
|
children,
|
|
@@ -142,20 +163,60 @@
|
|
|
142
163
|
...rest
|
|
143
164
|
}: ActivityStepProps = $props();
|
|
144
165
|
|
|
145
|
-
const
|
|
166
|
+
const cut = $derived(output !== undefined && output.length > tail);
|
|
167
|
+
const shown = $derived(cut && !showAll ? `…${output!.slice(-tail)}` : output);
|
|
146
168
|
const parts = $derived(emphasis(kind, label));
|
|
147
169
|
const bad = $derived(status === 'failed' || status === 'declined' || status === 'blocked');
|
|
148
170
|
const badged = $derived(bad || status === 'neutral');
|
|
171
|
+
const uid = $props.id();
|
|
172
|
+
const outputId = `${uid}-output`;
|
|
173
|
+
|
|
174
|
+
// Long output opens at its end, where the result is, and stays there as more is printed,
|
|
175
|
+
// unless the reader has scrolled up to read. Its box is measured only while it is shown: not
|
|
176
|
+
// in a shut fold, whose content is never laid out just to be read, and not before it has a
|
|
177
|
+
// size, as in a tab or a thread out of sight. Shown again, it goes back to the end.
|
|
178
|
+
const foldShown = getFoldShown();
|
|
179
|
+
let box = $state<HTMLPreElement | null>(null);
|
|
180
|
+
let atEnd = true;
|
|
181
|
+
const showing = (element: HTMLElement) => untrack(foldShown) && element.clientHeight > 0;
|
|
182
|
+
|
|
183
|
+
function end() {
|
|
184
|
+
if (box && atEnd && showing(box)) box.scrollTop = box.scrollHeight;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
$effect(() => {
|
|
188
|
+
if (box && foldShown()) untrack(end);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
function follow(element: HTMLPreElement) {
|
|
192
|
+
const scrolled = () => {
|
|
193
|
+
// A box out of sight scrolls nowhere: that is not the reader leaving the end
|
|
194
|
+
if (!showing(element)) return;
|
|
195
|
+
atEnd = element.scrollHeight - element.clientHeight - element.scrollTop < 2;
|
|
196
|
+
};
|
|
197
|
+
element.addEventListener('scroll', scrolled, { passive: true });
|
|
198
|
+
const resized = new ResizeObserver(end);
|
|
199
|
+
resized.observe(element);
|
|
200
|
+
const printed = new MutationObserver(end);
|
|
201
|
+
printed.observe(element, { characterData: true, childList: true, subtree: true });
|
|
202
|
+
return () => {
|
|
203
|
+
element.removeEventListener('scroll', scrolled);
|
|
204
|
+
resized.disconnect();
|
|
205
|
+
printed.disconnect();
|
|
206
|
+
};
|
|
207
|
+
}
|
|
149
208
|
|
|
150
|
-
//
|
|
151
|
-
function
|
|
152
|
-
|
|
209
|
+
// All of it, or its end again, with the end in view either way
|
|
210
|
+
function toggleAll() {
|
|
211
|
+
atEnd = true;
|
|
212
|
+
showAll = !showAll;
|
|
153
213
|
}
|
|
154
214
|
</script>
|
|
155
215
|
|
|
156
216
|
<div
|
|
157
217
|
data-slot="activity-step"
|
|
158
218
|
data-status={status}
|
|
219
|
+
data-output-cut={(cut && !showAll) || undefined}
|
|
159
220
|
{...rest}
|
|
160
221
|
{...attrs([styles.step, sx], className)}
|
|
161
222
|
>
|
|
@@ -183,7 +244,26 @@
|
|
|
183
244
|
{#if reason}<p {...stylex.attrs(styles.reason)}>{reason}</p>{/if}
|
|
184
245
|
{#if shown}
|
|
185
246
|
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
186
|
-
<pre
|
|
247
|
+
<pre
|
|
248
|
+
bind:this={box}
|
|
249
|
+
id={outputId}
|
|
250
|
+
tabindex="0"
|
|
251
|
+
{...stylex.attrs(styles.output)}
|
|
252
|
+
{@attach follow}>{shown}</pre>
|
|
253
|
+
{#if cut}
|
|
254
|
+
<Button
|
|
255
|
+
variant="link"
|
|
256
|
+
size="xs"
|
|
257
|
+
sx={styles.more}
|
|
258
|
+
aria-expanded={showAll}
|
|
259
|
+
aria-controls={outputId}
|
|
260
|
+
data-activity-step-toggle
|
|
261
|
+
onclick={toggleAll}
|
|
262
|
+
>{showAll
|
|
263
|
+
? (outputLabels?.showLess ?? 'Show less')
|
|
264
|
+
: (outputLabels?.showAll ?? 'Show all output')}</Button
|
|
265
|
+
>
|
|
266
|
+
{/if}
|
|
187
267
|
{/if}
|
|
188
268
|
{@render children?.()}
|
|
189
269
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import { type ActionKind } from '../../internal/kinds.js';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
@@ -10,6 +10,13 @@ export type ActivityStepKind = ActionKind;
|
|
|
10
10
|
*/
|
|
11
11
|
export type ActivityStepStatus = 'running' | 'done' | 'failed' | 'declined' | 'blocked' | 'neutral';
|
|
12
12
|
type Badged = 'failed' | 'declined' | 'blocked' | 'neutral';
|
|
13
|
+
/** Words for the control under a long output. */
|
|
14
|
+
export type ActivityStepOutputLabels = {
|
|
15
|
+
/** "Show all output" by default. */
|
|
16
|
+
showAll?: string | undefined;
|
|
17
|
+
/** "Show less" by default. */
|
|
18
|
+
showLess?: string | undefined;
|
|
19
|
+
};
|
|
13
20
|
export type ActivityStepProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
14
21
|
kind?: ActivityStepKind | undefined;
|
|
15
22
|
/** The command, the path, the query: shown as code. Cut to one line, unless `wrap`. */
|
|
@@ -23,6 +30,14 @@ export type ActivityStepProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'
|
|
|
23
30
|
output?: string | undefined;
|
|
24
31
|
/** How much of the output to keep, from the end, in characters. */
|
|
25
32
|
tail?: number | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Shows all of an output longer than `tail`, not only its end. A control under the output
|
|
35
|
+
* turns it on and off. Bindable: keep it where the conversation is drawn again, or set it
|
|
36
|
+
* when a find of your own finds something in the part cut off.
|
|
37
|
+
*/
|
|
38
|
+
showAll?: boolean | undefined;
|
|
39
|
+
/** Words for that control. */
|
|
40
|
+
outputLabels?: ActivityStepOutputLabels | undefined;
|
|
26
41
|
/** Words for the statuses that need them. */
|
|
27
42
|
statusLabels?: Partial<Record<Badged, string>> | undefined;
|
|
28
43
|
/** Anything else: images, a diff. */
|
|
@@ -30,6 +45,6 @@ export type ActivityStepProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'
|
|
|
30
45
|
sx?: Sx | undefined;
|
|
31
46
|
class?: string | undefined;
|
|
32
47
|
};
|
|
33
|
-
declare const ActivityStep: import("svelte").Component<ActivityStepProps, {}, "">;
|
|
48
|
+
declare const ActivityStep: import("svelte").Component<ActivityStepProps, {}, "showAll">;
|
|
34
49
|
type ActivityStep = ReturnType<typeof ActivityStep>;
|
|
35
50
|
export default ActivityStep;
|
|
@@ -8,6 +8,6 @@ export { Root, Trigger, Content, Step, Thought, Icon };
|
|
|
8
8
|
export type { ActivityContentProps } from './ActivityContent.svelte';
|
|
9
9
|
export type { ActivityIconProps, ActivityIconTone } from './ActivityIcon.svelte';
|
|
10
10
|
export type { ActivityRootProps } from './ActivityRoot.svelte';
|
|
11
|
-
export type { ActivityStepKind, ActivityStepProps, ActivityStepStatus } from './ActivityStep.svelte';
|
|
11
|
+
export type { ActivityStepKind, ActivityStepOutputLabels, ActivityStepProps, ActivityStepStatus } from './ActivityStep.svelte';
|
|
12
12
|
export type { ActivityThoughtProps } from './ActivityThought.svelte';
|
|
13
13
|
export type { ActivityTriggerProps } from './ActivityTrigger.svelte';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import * as stylex from '@stylexjs/stylex';
|
|
3
|
-
import type
|
|
3
|
+
import { untrack, type Snippet } from 'svelte';
|
|
4
4
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
5
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
|
-
import { getAppShellSheetContext } from './context.js';
|
|
6
|
+
import { getAppShellContext, getAppShellSheetContext } from './context.js';
|
|
7
7
|
|
|
8
8
|
export type AppShellMainProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
9
9
|
sx?: Sx | undefined;
|
|
@@ -27,19 +27,79 @@
|
|
|
27
27
|
// scroll and what is typed in it are as they were when the panel is restored
|
|
28
28
|
covered: { visibility: 'hidden' }
|
|
29
29
|
});
|
|
30
|
+
|
|
31
|
+
// `motion.slow` and `motion.easeInOut`, as the sidebar's column slides with
|
|
32
|
+
const GLIDE: KeyframeAnimationOptions = {
|
|
33
|
+
duration: 200,
|
|
34
|
+
easing: 'cubic-bezier(0.77, 0, 0.175, 1)',
|
|
35
|
+
id: 'narvi-glide'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The sidebar beside the page shows or hides at once, so the page is laid out once at its
|
|
40
|
+
* new width rather than on every frame. What is under the page's header then glides from
|
|
41
|
+
* where its centre was to where it is, by half the sidebar's width: a conversation down
|
|
42
|
+
* the middle moves as it would if the page were widening, while the sidebar slides over
|
|
43
|
+
* the edge. The header takes its place at once: its start is under the sidebar as it
|
|
44
|
+
* comes or goes, and its end does not move. So does a panel in a row of the page's own,
|
|
45
|
+
* with its edge: only what is beside it glides.
|
|
46
|
+
*/
|
|
47
|
+
function glide(main: HTMLElement, sidebar: HTMLElement, open: boolean) {
|
|
48
|
+
if (!matchMedia('(prefers-reduced-motion: no-preference)').matches) return;
|
|
49
|
+
const width = sidebar.firstElementChild?.getBoundingClientRect().width ?? 0;
|
|
50
|
+
if (width === 0) return;
|
|
51
|
+
const rtl = getComputedStyle(main).direction === 'rtl';
|
|
52
|
+
const shift = ((open ? -1 : 1) * (rtl ? -1 : 1) * width) / 2;
|
|
53
|
+
for (const child of gliders(main)) {
|
|
54
|
+
// Shown again before the last glide has ended: from wherever it has got to
|
|
55
|
+
const gliding = child.getAnimations().filter((animation) => animation.id === GLIDE.id);
|
|
56
|
+
const from = gliding.length > 0 ? parseFloat(getComputedStyle(child).translate) || 0 : 0;
|
|
57
|
+
for (const animation of gliding) animation.cancel();
|
|
58
|
+
child.animate([{ translate: `${from + shift}px 0` }, { translate: '0 0' }], GLIDE);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const STAYS = new Set(['app-shell-header', 'app-shell-panel', 'resize-handle']);
|
|
63
|
+
|
|
64
|
+
// What glides: the page's parts under its header, and in a row that holds a panel, the
|
|
65
|
+
// parts beside the panel
|
|
66
|
+
function gliders(parent: Element): HTMLElement[] {
|
|
67
|
+
return [...parent.children].flatMap((child) => {
|
|
68
|
+
if (!(child instanceof HTMLElement) || STAYS.has(child.dataset.slot ?? '')) return [];
|
|
69
|
+
return child.querySelector('[data-slot="app-shell-panel"]') ? gliders(child) : [child];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
30
72
|
</script>
|
|
31
73
|
|
|
32
74
|
<script lang="ts">
|
|
33
75
|
let { sx, class: className, children, ...rest }: AppShellMainProps = $props();
|
|
34
76
|
|
|
77
|
+
const shell = getAppShellContext();
|
|
35
78
|
const sheet = getAppShellSheetContext();
|
|
36
79
|
const covered = $derived(sheet?.covered ?? false);
|
|
80
|
+
let element = $state<HTMLElement | null>(null);
|
|
81
|
+
|
|
82
|
+
// Each time the sidebar beside this page shows or hides; not when a narrow window makes it
|
|
83
|
+
// a drawer over the page, or takes it back
|
|
84
|
+
let last: { open: boolean; narrow: boolean } | undefined;
|
|
85
|
+
$effect(() => {
|
|
86
|
+
if (!shell || !element) return;
|
|
87
|
+
const now = { open: shell.open, narrow: shell.narrow };
|
|
88
|
+
const before = last;
|
|
89
|
+
last = now;
|
|
90
|
+
if (!before || before.narrow || now.narrow || before.open === now.open) return;
|
|
91
|
+
const sidebar = element.parentElement?.querySelector<HTMLElement>(
|
|
92
|
+
':scope > [data-slot="app-shell-sidebar"]'
|
|
93
|
+
);
|
|
94
|
+
if (sidebar) untrack(() => glide(element!, sidebar, now.open));
|
|
95
|
+
});
|
|
37
96
|
</script>
|
|
38
97
|
|
|
39
98
|
<!-- Not focusable by default: with `tabindex="-1"` a click on plain text in the page would move
|
|
40
99
|
focus to the whole of it, away from a panel that keeps its own, such as a find bar. Pass a
|
|
41
100
|
`tabindex` to make it the target of a skip link. -->
|
|
42
101
|
<main
|
|
102
|
+
bind:this={element}
|
|
43
103
|
data-slot="app-shell-main"
|
|
44
104
|
inert={covered || undefined}
|
|
45
105
|
{...rest}
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
It can also stand in a row of your own inside AppShell.Main, beside a thread
|
|
10
10
|
rather than beside the page: a flex row with `position: relative`. It then
|
|
11
11
|
measures that row, and narrow or maximized it lies over the row, whose other
|
|
12
|
-
children are inert underneath.
|
|
12
|
+
children are inert underneath, and with `hideCovered` out of sight too.
|
|
13
|
+
|
|
14
|
+
It is raised wherever it stands, so in a row of your own it keeps the sheet's
|
|
15
|
+
colour beside a page of another.
|
|
13
16
|
-->
|
|
14
17
|
<script lang="ts" module>
|
|
15
18
|
import * as stylex from '@stylexjs/stylex';
|
|
@@ -23,6 +26,13 @@
|
|
|
23
26
|
export type AppShellPanelProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
24
27
|
/** Names the region: "Changes", "Files". */
|
|
25
28
|
label: string;
|
|
29
|
+
/**
|
|
30
|
+
* Names the edge that resizes it, for assistive technology. "Resize the changes panel"
|
|
31
|
+
* by default, from `label`.
|
|
32
|
+
*/
|
|
33
|
+
edgeLabel?: string | undefined;
|
|
34
|
+
/** A tooltip on that edge, for the pointer: "Drag to resize, double-click to reset". */
|
|
35
|
+
edgeTitle?: string | undefined;
|
|
26
36
|
/** Its width in pixels. Bindable; store it if it should be remembered. */
|
|
27
37
|
width?: number | undefined;
|
|
28
38
|
minWidth?: number | undefined;
|
|
@@ -39,6 +49,12 @@
|
|
|
39
49
|
* stays in reach.
|
|
40
50
|
*/
|
|
41
51
|
maximized?: boolean | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* In a row of your own, also hides what the panel lies over, as the page is hidden under
|
|
54
|
+
* a maximized panel: out of sight and of find-in-page, still laid out, so its scroll is
|
|
55
|
+
* kept. Without it, what is underneath is only inert.
|
|
56
|
+
*/
|
|
57
|
+
hideCovered?: boolean | undefined;
|
|
42
58
|
sx?: Sx | undefined;
|
|
43
59
|
children?: Snippet | undefined;
|
|
44
60
|
};
|
|
@@ -54,6 +70,7 @@
|
|
|
54
70
|
minWidth: 0,
|
|
55
71
|
minHeight: 0,
|
|
56
72
|
overflow: 'clip',
|
|
73
|
+
backgroundColor: colors.bgRaised,
|
|
57
74
|
borderInlineStartWidth: '1px',
|
|
58
75
|
borderInlineStartStyle: 'solid',
|
|
59
76
|
borderInlineStartColor: colors.border,
|
|
@@ -70,8 +87,7 @@
|
|
|
70
87
|
insetInlineEnd: 0,
|
|
71
88
|
zIndex: 5,
|
|
72
89
|
width: 'auto',
|
|
73
|
-
borderInlineStartWidth: 0
|
|
74
|
-
backgroundColor: colors.bgRaised
|
|
90
|
+
borderInlineStartWidth: 0
|
|
75
91
|
},
|
|
76
92
|
// Under the page's header, which stays in reach with the sidebar's toggle
|
|
77
93
|
narrow: { insetBlockStart: '3rem' },
|
|
@@ -87,11 +103,14 @@
|
|
|
87
103
|
<script lang="ts">
|
|
88
104
|
let {
|
|
89
105
|
label,
|
|
106
|
+
edgeLabel,
|
|
107
|
+
edgeTitle,
|
|
90
108
|
width = $bindable(560),
|
|
91
109
|
minWidth = 320,
|
|
92
110
|
defaultWidth = 560,
|
|
93
111
|
mainMinWidth = 352,
|
|
94
112
|
maximized = false,
|
|
113
|
+
hideCovered = false,
|
|
95
114
|
sx,
|
|
96
115
|
class: className,
|
|
97
116
|
children,
|
|
@@ -141,17 +160,23 @@
|
|
|
141
160
|
});
|
|
142
161
|
|
|
143
162
|
// In a row of the caller's own, what the panel lies over is out of reach underneath:
|
|
144
|
-
// its siblings are inert, and come back as they were
|
|
163
|
+
// its siblings are inert, and hidden if asked, and come back as they were
|
|
145
164
|
$effect(() => {
|
|
146
165
|
const parent = element?.parentElement;
|
|
147
166
|
if (inSheet || !over || !parent || !element) return;
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
for (const child of covered)
|
|
167
|
+
const hide = hideCovered;
|
|
168
|
+
const covered = [...parent.children]
|
|
169
|
+
.filter((child): child is HTMLElement => child instanceof HTMLElement && child !== element)
|
|
170
|
+
.map((child) => ({ child, inert: child.inert, visibility: child.style.visibility }));
|
|
171
|
+
for (const { child } of covered) {
|
|
172
|
+
child.inert = true;
|
|
173
|
+
if (hide) child.style.visibility = 'hidden';
|
|
174
|
+
}
|
|
153
175
|
return () => {
|
|
154
|
-
for (const child of covered)
|
|
176
|
+
for (const { child, inert, visibility } of covered) {
|
|
177
|
+
child.inert = inert;
|
|
178
|
+
if (hide) child.style.visibility = visibility;
|
|
179
|
+
}
|
|
155
180
|
};
|
|
156
181
|
});
|
|
157
182
|
|
|
@@ -177,7 +202,8 @@
|
|
|
177
202
|
edge="start"
|
|
178
203
|
target={element}
|
|
179
204
|
property="--narvi-panel-width"
|
|
180
|
-
label=
|
|
205
|
+
label={edgeLabel ?? `Resize the ${label.toLowerCase()} panel`}
|
|
206
|
+
title={edgeTitle}
|
|
181
207
|
sx={styles.handle}
|
|
182
208
|
/>
|
|
183
209
|
{/if}
|
|
@@ -4,6 +4,13 @@ import { type Sx } from '../../internal/sx.js';
|
|
|
4
4
|
export type AppShellPanelProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
|
|
5
5
|
/** Names the region: "Changes", "Files". */
|
|
6
6
|
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* Names the edge that resizes it, for assistive technology. "Resize the changes panel"
|
|
9
|
+
* by default, from `label`.
|
|
10
|
+
*/
|
|
11
|
+
edgeLabel?: string | undefined;
|
|
12
|
+
/** A tooltip on that edge, for the pointer: "Drag to resize, double-click to reset". */
|
|
13
|
+
edgeTitle?: string | undefined;
|
|
7
14
|
/** Its width in pixels. Bindable; store it if it should be remembered. */
|
|
8
15
|
width?: number | undefined;
|
|
9
16
|
minWidth?: number | undefined;
|
|
@@ -20,6 +27,12 @@ export type AppShellPanelProps = Omit<HTMLAttributes<HTMLElement>, 'children'> &
|
|
|
20
27
|
* stays in reach.
|
|
21
28
|
*/
|
|
22
29
|
maximized?: boolean | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* In a row of your own, also hides what the panel lies over, as the page is hidden under
|
|
32
|
+
* a maximized panel: out of sight and of find-in-page, still laid out, so its scroll is
|
|
33
|
+
* kept. Without it, what is underneath is only inert.
|
|
34
|
+
*/
|
|
35
|
+
hideCovered?: boolean | undefined;
|
|
23
36
|
sx?: Sx | undefined;
|
|
24
37
|
children?: Snippet | undefined;
|
|
25
38
|
};
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
overflow: 'clip',
|
|
34
34
|
color: colors.text
|
|
35
35
|
},
|
|
36
|
+
// Beside the page, its room is given or taken back at once, and it is the column that
|
|
37
|
+
// moves: it slides on a transform, over the page, so the page is laid out once for each
|
|
38
|
+
// show or hide rather than on every frame of the slide. The column overflows the room
|
|
39
|
+
// it no longer has while it slides away, and the sheet clips it.
|
|
36
40
|
wide: {
|
|
37
41
|
width: 'var(--narvi-sidebar-width)',
|
|
38
|
-
|
|
39
|
-
backgroundColor: 'var(--narvi-sidebar-surface, transparent)',
|
|
40
|
-
transitionProperty: { default: 'none', [media.motion]: 'width' },
|
|
41
|
-
transitionDuration: motion.slow,
|
|
42
|
-
transitionTimingFunction: motion.easeInOut
|
|
42
|
+
overflow: 'visible'
|
|
43
43
|
},
|
|
44
44
|
collapsed: { width: 0 },
|
|
45
45
|
// Narrow: a drawer over the page, from the start edge, after the rail
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
transitionDuration: motion.slow,
|
|
79
79
|
transitionTimingFunction: motion.easeOut
|
|
80
80
|
},
|
|
81
|
-
// The column keeps its width
|
|
82
|
-
//
|
|
83
|
-
//
|
|
81
|
+
// The column keeps its width whatever room the sidebar has, so its rows are never
|
|
82
|
+
// squeezed or reflowed. The hairline that divides it from the page is on the column,
|
|
83
|
+
// so it goes when the sidebar does.
|
|
84
84
|
column: {
|
|
85
85
|
boxSizing: 'border-box',
|
|
86
86
|
display: 'flex',
|
|
@@ -92,7 +92,22 @@
|
|
|
92
92
|
borderInlineEndStyle: 'solid',
|
|
93
93
|
borderInlineEndColor: colors.border
|
|
94
94
|
},
|
|
95
|
-
columnDrawer: { width: '100%', borderInlineEndWidth: 0 }
|
|
95
|
+
columnDrawer: { width: '100%', borderInlineEndWidth: 0 },
|
|
96
|
+
// It slides over the page, so it is never see-through: a flush sheet gives it the page's
|
|
97
|
+
// colour, and a sheet with an edge its own
|
|
98
|
+
columnWide: {
|
|
99
|
+
backgroundColor: `var(--narvi-sidebar-surface, ${colors.bgRaised})`,
|
|
100
|
+
// Shown at once when it opens, hidden only once it has slid away
|
|
101
|
+
transitionProperty: { default: 'visibility', [media.motion]: 'translate, visibility' },
|
|
102
|
+
transitionDuration: { default: '0s', [media.motion]: `${motion.slow}, 0s` },
|
|
103
|
+
transitionDelay: { default: '0s', [media.motion]: '0s, 0s' },
|
|
104
|
+
transitionTimingFunction: motion.easeInOut
|
|
105
|
+
},
|
|
106
|
+
columnAway: {
|
|
107
|
+
translate: { default: '-100% 0', ':dir(rtl)': '100% 0' },
|
|
108
|
+
visibility: 'hidden',
|
|
109
|
+
transitionDelay: { default: '0s', [media.motion]: `0s, ${motion.slow}` }
|
|
110
|
+
}
|
|
96
111
|
});
|
|
97
112
|
</script>
|
|
98
113
|
|
|
@@ -162,7 +177,12 @@
|
|
|
162
177
|
className
|
|
163
178
|
)}
|
|
164
179
|
>
|
|
165
|
-
<div
|
|
180
|
+
<div
|
|
181
|
+
{...stylex.attrs(
|
|
182
|
+
styles.column,
|
|
183
|
+
shell.narrow ? styles.columnDrawer : [styles.columnWide, !shell.open && styles.columnAway]
|
|
184
|
+
)}
|
|
185
|
+
>
|
|
166
186
|
{@render children?.()}
|
|
167
187
|
</div>
|
|
168
188
|
</aside>
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
import { Dialog } from 'bits-ui';
|
|
7
7
|
import * as stylex from '@stylexjs/stylex';
|
|
8
8
|
import type { Snippet } from 'svelte';
|
|
9
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
10
|
+
import { visuallyHidden } from '../../visually-hidden.js';
|
|
9
11
|
import { command } from './styles.js';
|
|
10
12
|
|
|
11
13
|
export type CommandDialogProps = {
|
|
@@ -25,6 +27,9 @@
|
|
|
25
27
|
restoreFocus?: boolean | undefined;
|
|
26
28
|
/** What the palette is, for assistive technology. */
|
|
27
29
|
label?: string | undefined;
|
|
30
|
+
/** On the palette's box: its place, its width, how tall it may grow. */
|
|
31
|
+
sx?: Sx | undefined;
|
|
32
|
+
class?: string | undefined;
|
|
28
33
|
/** A Command.Root with its Input, List and Footer. */
|
|
29
34
|
children?: Snippet | undefined;
|
|
30
35
|
};
|
|
@@ -37,6 +42,8 @@
|
|
|
37
42
|
onopenchange,
|
|
38
43
|
onescape,
|
|
39
44
|
restoreFocus = true,
|
|
45
|
+
sx,
|
|
46
|
+
class: className,
|
|
40
47
|
children
|
|
41
48
|
}: CommandDialogProps = $props();
|
|
42
49
|
</script>
|
|
@@ -50,9 +57,9 @@
|
|
|
50
57
|
onCloseAutoFocus={(event) => {
|
|
51
58
|
if (!restoreFocus) event.preventDefault();
|
|
52
59
|
}}
|
|
53
|
-
{...
|
|
60
|
+
{...attrs([command.dialog, sx], className)}
|
|
54
61
|
>
|
|
55
|
-
<Dialog.Title {...stylex.attrs(
|
|
62
|
+
<Dialog.Title {...stylex.attrs(visuallyHidden)}>{label}</Dialog.Title>
|
|
56
63
|
{@render children?.()}
|
|
57
64
|
</Dialog.Content>
|
|
58
65
|
</Dialog.Portal>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type Sx } from '../../internal/sx.js';
|
|
2
3
|
export type CommandDialogProps = {
|
|
3
4
|
/** Whether it is open. Bindable. */
|
|
4
5
|
open?: boolean | undefined;
|
|
@@ -16,6 +17,9 @@ export type CommandDialogProps = {
|
|
|
16
17
|
restoreFocus?: boolean | undefined;
|
|
17
18
|
/** What the palette is, for assistive technology. */
|
|
18
19
|
label?: string | undefined;
|
|
20
|
+
/** On the palette's box: its place, its width, how tall it may grow. */
|
|
21
|
+
sx?: Sx | undefined;
|
|
22
|
+
class?: string | undefined;
|
|
19
23
|
/** A Command.Root with its Input, List and Footer. */
|
|
20
24
|
children?: Snippet | undefined;
|
|
21
25
|
};
|
|
@@ -1,23 +1,57 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
What the list says in place of items: that nothing matches, that results are on
|
|
3
|
+
their way, or that they could not be had. It shows only while the list has no
|
|
4
|
+
items, so results still listed stay as they are while new ones load.
|
|
5
|
+
-->
|
|
1
6
|
<script lang="ts" module>
|
|
2
7
|
import type { Loose } from '../../internal/loose.js';
|
|
3
8
|
import { Command } from 'bits-ui';
|
|
4
9
|
import type { Snippet } from 'svelte';
|
|
5
10
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
11
|
+
import Spinner from '../spinner/Spinner.svelte';
|
|
6
12
|
import { command } from './styles.js';
|
|
7
13
|
|
|
8
14
|
export type CommandEmptyProps = Loose<
|
|
9
15
|
Omit<Command.EmptyProps, 'children' | 'child'> & {
|
|
16
|
+
/**
|
|
17
|
+
* Why there are no items: `loading`, with a spinner, while they are on their way, or
|
|
18
|
+
* `error`, in the danger colour, when they could not be had. Without it, nothing matches.
|
|
19
|
+
*/
|
|
20
|
+
status?: 'loading' | 'error' | undefined;
|
|
10
21
|
sx?: Sx | undefined;
|
|
11
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* What to say. For no match, say what was searched for and what to try; for an error,
|
|
24
|
+
* what went wrong and what to do.
|
|
25
|
+
*/
|
|
12
26
|
children?: Snippet | undefined;
|
|
13
27
|
}
|
|
14
28
|
>;
|
|
29
|
+
|
|
30
|
+
const fallback = {
|
|
31
|
+
empty: 'Nothing matches.',
|
|
32
|
+
loading: 'Searching…',
|
|
33
|
+
error: 'The results could not be loaded.'
|
|
34
|
+
} as const;
|
|
15
35
|
</script>
|
|
16
36
|
|
|
17
37
|
<script lang="ts">
|
|
18
|
-
let { sx, class: className, children, ...rest }: CommandEmptyProps = $props();
|
|
38
|
+
let { status, sx, class: className, children, ...rest }: CommandEmptyProps = $props();
|
|
19
39
|
</script>
|
|
20
40
|
|
|
21
|
-
<Command.Empty
|
|
22
|
-
|
|
41
|
+
<Command.Empty
|
|
42
|
+
data-slot="command-empty"
|
|
43
|
+
data-status={status}
|
|
44
|
+
{...rest}
|
|
45
|
+
{...attrs(
|
|
46
|
+
[
|
|
47
|
+
command.empty,
|
|
48
|
+
status === 'loading' && command.emptyLoading,
|
|
49
|
+
status === 'error' && command.emptyError,
|
|
50
|
+
sx
|
|
51
|
+
],
|
|
52
|
+
className
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
{#if status === 'loading'}<Spinner size={16} label={null} />{/if}
|
|
56
|
+
{#if children}{@render children()}{:else}{fallback[status ?? 'empty']}{/if}
|
|
23
57
|
</Command.Empty>
|
|
@@ -3,13 +3,29 @@ import { Command } from 'bits-ui';
|
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
5
|
export type CommandEmptyProps = Loose<Omit<Command.EmptyProps, 'children' | 'child'> & {
|
|
6
|
+
/**
|
|
7
|
+
* Why there are no items: `loading`, with a spinner, while they are on their way, or
|
|
8
|
+
* `error`, in the danger colour, when they could not be had. Without it, nothing matches.
|
|
9
|
+
*/
|
|
10
|
+
status?: 'loading' | 'error' | undefined;
|
|
6
11
|
sx?: Sx | undefined;
|
|
7
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* What to say. For no match, say what was searched for and what to try; for an error,
|
|
14
|
+
* what went wrong and what to do.
|
|
15
|
+
*/
|
|
8
16
|
children?: Snippet | undefined;
|
|
9
17
|
}>;
|
|
10
18
|
declare const CommandEmpty: import("svelte").Component<Loose<Omit<Command.EmptyProps, "children" | "child"> & {
|
|
19
|
+
/**
|
|
20
|
+
* Why there are no items: `loading`, with a spinner, while they are on their way, or
|
|
21
|
+
* `error`, in the danger colour, when they could not be had. Without it, nothing matches.
|
|
22
|
+
*/
|
|
23
|
+
status?: "loading" | "error" | undefined;
|
|
11
24
|
sx?: Sx | undefined;
|
|
12
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* What to say. For no match, say what was searched for and what to try; for an error,
|
|
27
|
+
* what went wrong and what to do.
|
|
28
|
+
*/
|
|
13
29
|
children?: Snippet | undefined;
|
|
14
30
|
}>, {}, "">;
|
|
15
31
|
type CommandEmpty = ReturnType<typeof CommandEmpty>;
|