@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
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
end steps aside for them. Its fills (under the pointer, open, picked) lie on a
|
|
5
5
|
layer of their own, over the row's background, so a background given in `sx`
|
|
6
6
|
is the row's resting fill and the fills still show over it.
|
|
7
|
+
|
|
8
|
+
A row out of sight is not laid out or painted (`content-visibility: auto`), so a
|
|
9
|
+
list of a thousand threads costs what the dozen in view do. It keeps the size it
|
|
10
|
+
was last drawn at, or a row's of one or two lines until then, so the scrollbar
|
|
11
|
+
does not jump. Nothing it draws reaches past its box, focus rings included, so
|
|
12
|
+
the containment never clips them and never has to come off.
|
|
7
13
|
-->
|
|
8
14
|
<script lang="ts" module>
|
|
9
15
|
import * as stylex from '@stylexjs/stylex';
|
|
@@ -75,7 +81,15 @@
|
|
|
75
81
|
':is([data-state="open"], :has([data-slot="sidebar-item-actions"] [aria-expanded="true"]))';
|
|
76
82
|
|
|
77
83
|
const styles = stylex.create({
|
|
78
|
-
item: {
|
|
84
|
+
item: {
|
|
85
|
+
position: 'relative',
|
|
86
|
+
listStyleType: 'none',
|
|
87
|
+
contentVisibility: 'auto',
|
|
88
|
+
// Two lines: 50px
|
|
89
|
+
containIntrinsicSize: 'auto 3.125rem'
|
|
90
|
+
},
|
|
91
|
+
// One line: 30px
|
|
92
|
+
itemOneLine: { containIntrinsicSize: 'auto 1.875rem' },
|
|
79
93
|
// Its group or folder is folded, and this is not the open row
|
|
80
94
|
foldedAway: { display: 'none' },
|
|
81
95
|
row: {
|
|
@@ -187,9 +201,11 @@
|
|
|
187
201
|
trailHides: {
|
|
188
202
|
opacity: {
|
|
189
203
|
default: 1,
|
|
204
|
+
// Repeated inside: the media query outranks a condition outside it
|
|
190
205
|
[media.hover]: {
|
|
191
206
|
default: 1,
|
|
192
207
|
[stylex.when.ancestor(':hover', sidebarItemMarker)]: 0,
|
|
208
|
+
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 0,
|
|
193
209
|
[stylex.when.ancestor(OPEN, sidebarItemMarker)]: 0
|
|
194
210
|
},
|
|
195
211
|
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 0,
|
|
@@ -213,7 +229,9 @@
|
|
|
213
229
|
},
|
|
214
230
|
// The tray sits 1px inside the row, so its radius is the row's less 1px. Narvi's small
|
|
215
231
|
// buttons reach past their own edges to be easy to hit; here that would reach into the
|
|
216
|
-
// rows above and below, so the tray clips them, and shows the focus ring itself
|
|
232
|
+
// rows above and below, so the tray clips them, and shows the focus ring itself: over
|
|
233
|
+
// its hairline and out to the row's edge, no further, so the row's containment never
|
|
234
|
+
// clips it.
|
|
217
235
|
actions: {
|
|
218
236
|
position: 'absolute',
|
|
219
237
|
top: '1px',
|
|
@@ -227,12 +245,15 @@
|
|
|
227
245
|
outlineStyle: 'solid',
|
|
228
246
|
outlineWidth: { default: 0, ':focus-within': '2px' },
|
|
229
247
|
outlineColor: colors.focusRing,
|
|
230
|
-
outlineOffset: '1px',
|
|
248
|
+
outlineOffset: '-1px',
|
|
231
249
|
opacity: {
|
|
232
250
|
default: 1,
|
|
251
|
+
// Repeated inside: the media query outranks a condition outside it, and keyboard
|
|
252
|
+
// focus on a computer with a mouse would show no actions
|
|
233
253
|
[media.hover]: {
|
|
234
254
|
default: 0,
|
|
235
255
|
[stylex.when.ancestor(':hover', sidebarItemMarker)]: 1,
|
|
256
|
+
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 1,
|
|
236
257
|
[stylex.when.ancestor(OPEN, sidebarItemMarker)]: 1
|
|
237
258
|
},
|
|
238
259
|
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 1,
|
|
@@ -243,6 +264,7 @@
|
|
|
243
264
|
[media.hover]: {
|
|
244
265
|
default: 'none',
|
|
245
266
|
[stylex.when.ancestor(':hover', sidebarItemMarker)]: 'auto',
|
|
267
|
+
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 'auto',
|
|
246
268
|
[stylex.when.ancestor(OPEN, sidebarItemMarker)]: 'auto'
|
|
247
269
|
},
|
|
248
270
|
[stylex.when.ancestor(':focus-within', sidebarItemMarker)]: 'auto',
|
|
@@ -332,7 +354,15 @@
|
|
|
332
354
|
style:--narvi-sidebar-depth={depth || undefined}
|
|
333
355
|
{...itemProps}
|
|
334
356
|
data-slot="sidebar-item"
|
|
335
|
-
{...attrs(
|
|
357
|
+
{...attrs(
|
|
358
|
+
[
|
|
359
|
+
styles.item,
|
|
360
|
+
(compact || !meta) && styles.itemOneLine,
|
|
361
|
+
away && styles.foldedAway,
|
|
362
|
+
sidebarItemMarker
|
|
363
|
+
],
|
|
364
|
+
itemProps?.class
|
|
365
|
+
)}
|
|
336
366
|
>
|
|
337
367
|
{#if href !== undefined}
|
|
338
368
|
<a
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
A button and, joined to its end, a second that opens a menu of how to do it, or
|
|
3
3
|
of what else there is to do: Merge, and the ways to merge. The two are one
|
|
4
|
-
group, disabled together
|
|
5
|
-
|
|
4
|
+
group, disabled together, or with `mainDisabled` only the main one, so the
|
|
5
|
+
menu's other ways stay in reach. Without a menu the button stands alone,
|
|
6
|
+
rounded at both ends, so a menu that is offered only sometimes does not change
|
|
7
|
+
the markup.
|
|
6
8
|
-->
|
|
7
9
|
<script lang="ts" module>
|
|
8
10
|
import * as stylex from '@stylexjs/stylex';
|
|
9
11
|
import type { Snippet } from 'svelte';
|
|
10
12
|
import Glyph from '../../internal/Glyph.svelte';
|
|
11
13
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
12
|
-
import Button, { type ButtonProps } from '../button/Button.svelte';
|
|
14
|
+
import Button, { type ButtonProps, type ButtonShape } from '../button/Button.svelte';
|
|
15
|
+
import { colors, space } from '../../tokens.stylex.js';
|
|
13
16
|
import * as Menu from '../menu/index.js';
|
|
14
17
|
|
|
15
18
|
export type SplitButtonProps = Omit<
|
|
16
19
|
ButtonProps,
|
|
17
|
-
'variant' | 'iconOnly' | 'href' | '
|
|
20
|
+
'variant' | 'iconOnly' | 'href' | 'pressed' | 'sx' | 'justify'
|
|
18
21
|
> & {
|
|
19
|
-
/**
|
|
20
|
-
|
|
22
|
+
/**
|
|
23
|
+
* `secondary`, an edge round both halves; `primary`, the one solid, with a line between
|
|
24
|
+
* them; `ghost`, quiet, for a bar of them: no edge, a fill only under the pointer, and a
|
|
25
|
+
* short line between the halves. Give a ghost pair a fill of its own with `sx`.
|
|
26
|
+
*/
|
|
27
|
+
variant?: 'primary' | 'secondary' | 'ghost' | undefined;
|
|
28
|
+
/** `pill` rounds the pair's two outer ends fully. */
|
|
29
|
+
shape?: ButtonShape | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Disables the main button alone. The menu stays open to the person: its other ways may
|
|
32
|
+
* still apply, or it may say why the main one cannot.
|
|
33
|
+
*/
|
|
34
|
+
mainDisabled?: boolean | undefined;
|
|
21
35
|
/** Names the pair as a group, where the button's own words do not say it all: "Merge". */
|
|
22
36
|
label?: string | undefined;
|
|
23
37
|
/** Names the button that opens the menu: "Choose how to merge", "More for GitHub". */
|
|
@@ -31,6 +45,8 @@
|
|
|
31
45
|
align?: 'start' | 'center' | 'end' | undefined;
|
|
32
46
|
/** A width of its own for the menu, such as `16rem`. */
|
|
33
47
|
menuWidth?: string | undefined;
|
|
48
|
+
/** How wide the menu is at least, such as `16rem`; it still fits its items. */
|
|
49
|
+
menuMinWidth?: string | undefined;
|
|
34
50
|
/** Whether the menu is open. Bindable. */
|
|
35
51
|
open?: boolean | undefined;
|
|
36
52
|
/** Called as the menu opens or closes: to fetch what it lists as it opens, say. */
|
|
@@ -42,6 +58,10 @@
|
|
|
42
58
|
menuTooltip?: string | Snippet | undefined;
|
|
43
59
|
/** On the group, which holds both halves. */
|
|
44
60
|
sx?: Sx | undefined;
|
|
61
|
+
/** On the main button, after the pair's own styles. */
|
|
62
|
+
mainSx?: Sx | undefined;
|
|
63
|
+
/** On the button that opens the menu, after the pair's own styles. */
|
|
64
|
+
menuSx?: Sx | undefined;
|
|
45
65
|
/** The main button's label, and its icon if it has one. */
|
|
46
66
|
children?: Snippet | undefined;
|
|
47
67
|
};
|
|
@@ -71,6 +91,18 @@
|
|
|
71
91
|
pointerEvents: 'none'
|
|
72
92
|
}
|
|
73
93
|
},
|
|
94
|
+
// Quiet halves are divided by a short hairline, inset from the pair's ends
|
|
95
|
+
moreGhost: {
|
|
96
|
+
'::before': {
|
|
97
|
+
content: '""',
|
|
98
|
+
position: 'absolute',
|
|
99
|
+
insetInlineStart: 0,
|
|
100
|
+
insetBlock: space.x1_5,
|
|
101
|
+
width: '1px',
|
|
102
|
+
backgroundColor: colors.border,
|
|
103
|
+
pointerEvents: 'none'
|
|
104
|
+
}
|
|
105
|
+
},
|
|
74
106
|
// The chevron's button is a little narrower than a square: it is the lesser half
|
|
75
107
|
moreWidth: { paddingInline: '0.375rem' }
|
|
76
108
|
});
|
|
@@ -85,6 +117,9 @@
|
|
|
85
117
|
menu,
|
|
86
118
|
align = 'end',
|
|
87
119
|
menuWidth,
|
|
120
|
+
menuMinWidth,
|
|
121
|
+
shape = 'default',
|
|
122
|
+
mainDisabled = false,
|
|
88
123
|
open = $bindable(false),
|
|
89
124
|
onopenchange,
|
|
90
125
|
menuTooltip,
|
|
@@ -92,6 +127,8 @@
|
|
|
92
127
|
disabled = false,
|
|
93
128
|
loading = false,
|
|
94
129
|
sx,
|
|
130
|
+
mainSx,
|
|
131
|
+
menuSx,
|
|
95
132
|
class: className,
|
|
96
133
|
ref = $bindable(null),
|
|
97
134
|
children,
|
|
@@ -99,6 +136,11 @@
|
|
|
99
136
|
}: SplitButtonProps = $props();
|
|
100
137
|
|
|
101
138
|
const glyph = { micro: 10, xs: 12, sm: 12, md: 14, lg: 16 } as const;
|
|
139
|
+
const divider = {
|
|
140
|
+
primary: styles.morePrimary,
|
|
141
|
+
secondary: styles.moreSecondary,
|
|
142
|
+
ghost: styles.moreGhost
|
|
143
|
+
} as const;
|
|
102
144
|
</script>
|
|
103
145
|
|
|
104
146
|
<div
|
|
@@ -112,10 +154,11 @@
|
|
|
112
154
|
{...rest}
|
|
113
155
|
{variant}
|
|
114
156
|
{size}
|
|
115
|
-
{
|
|
157
|
+
{shape}
|
|
158
|
+
disabled={disabled || mainDisabled}
|
|
116
159
|
{loading}
|
|
117
160
|
{tooltipSide}
|
|
118
|
-
sx={[styles.half, menu && styles.main]}
|
|
161
|
+
sx={[styles.half, menu && styles.main, mainSx]}
|
|
119
162
|
>
|
|
120
163
|
{@render children?.()}
|
|
121
164
|
</Button>
|
|
@@ -127,22 +170,18 @@
|
|
|
127
170
|
{...props}
|
|
128
171
|
{variant}
|
|
129
172
|
{size}
|
|
173
|
+
{shape}
|
|
130
174
|
disabled={disabled || loading}
|
|
131
175
|
aria-label={menuLabel}
|
|
132
176
|
tooltip={menuTooltip}
|
|
133
177
|
{tooltipSide}
|
|
134
|
-
sx={[
|
|
135
|
-
styles.half,
|
|
136
|
-
styles.more,
|
|
137
|
-
styles.moreWidth,
|
|
138
|
-
variant === 'primary' ? styles.morePrimary : styles.moreSecondary
|
|
139
|
-
]}
|
|
178
|
+
sx={[styles.half, styles.more, styles.moreWidth, divider[variant], menuSx]}
|
|
140
179
|
>
|
|
141
180
|
<Glyph name="chevron" size={glyph[size]} />
|
|
142
181
|
</Button>
|
|
143
182
|
{/snippet}
|
|
144
183
|
</Menu.Trigger>
|
|
145
|
-
<Menu.Content {align} width={menuWidth}>
|
|
184
|
+
<Menu.Content {align} width={menuWidth} minWidth={menuMinWidth}>
|
|
146
185
|
{@render menu()}
|
|
147
186
|
</Menu.Content>
|
|
148
187
|
</Menu.Root>
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import { type Sx } from '../../internal/sx.js';
|
|
3
|
-
import { type ButtonProps } from '../button/Button.svelte';
|
|
4
|
-
export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href' | '
|
|
5
|
-
/**
|
|
6
|
-
|
|
3
|
+
import { type ButtonProps, type ButtonShape } from '../button/Button.svelte';
|
|
4
|
+
export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href' | 'pressed' | 'sx' | 'justify'> & {
|
|
5
|
+
/**
|
|
6
|
+
* `secondary`, an edge round both halves; `primary`, the one solid, with a line between
|
|
7
|
+
* them; `ghost`, quiet, for a bar of them: no edge, a fill only under the pointer, and a
|
|
8
|
+
* short line between the halves. Give a ghost pair a fill of its own with `sx`.
|
|
9
|
+
*/
|
|
10
|
+
variant?: 'primary' | 'secondary' | 'ghost' | undefined;
|
|
11
|
+
/** `pill` rounds the pair's two outer ends fully. */
|
|
12
|
+
shape?: ButtonShape | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Disables the main button alone. The menu stays open to the person: its other ways may
|
|
15
|
+
* still apply, or it may say why the main one cannot.
|
|
16
|
+
*/
|
|
17
|
+
mainDisabled?: boolean | undefined;
|
|
7
18
|
/** Names the pair as a group, where the button's own words do not say it all: "Merge". */
|
|
8
19
|
label?: string | undefined;
|
|
9
20
|
/** Names the button that opens the menu: "Choose how to merge", "More for GitHub". */
|
|
@@ -17,6 +28,8 @@ export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href'
|
|
|
17
28
|
align?: 'start' | 'center' | 'end' | undefined;
|
|
18
29
|
/** A width of its own for the menu, such as `16rem`. */
|
|
19
30
|
menuWidth?: string | undefined;
|
|
31
|
+
/** How wide the menu is at least, such as `16rem`; it still fits its items. */
|
|
32
|
+
menuMinWidth?: string | undefined;
|
|
20
33
|
/** Whether the menu is open. Bindable. */
|
|
21
34
|
open?: boolean | undefined;
|
|
22
35
|
/** Called as the menu opens or closes: to fetch what it lists as it opens, say. */
|
|
@@ -28,6 +41,10 @@ export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href'
|
|
|
28
41
|
menuTooltip?: string | Snippet | undefined;
|
|
29
42
|
/** On the group, which holds both halves. */
|
|
30
43
|
sx?: Sx | undefined;
|
|
44
|
+
/** On the main button, after the pair's own styles. */
|
|
45
|
+
mainSx?: Sx | undefined;
|
|
46
|
+
/** On the button that opens the menu, after the pair's own styles. */
|
|
47
|
+
menuSx?: Sx | undefined;
|
|
31
48
|
/** The main button's label, and its icon if it has one. */
|
|
32
49
|
children?: Snippet | undefined;
|
|
33
50
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * as AppShell from './components/app-shell/index.js';
|
|
|
4
4
|
export { getAppShellContext } from './components/app-shell/index.js';
|
|
5
5
|
export type { AppShellBarProps, AppShellContext, AppShellHeaderProps, AppShellMainProps, AppShellPanelProps, AppShellPanesProps, AppShellRailProps, AppShellRootProps, AppShellSheetProps, AppShellSidebarProps, AppShellToggleProps } from './components/app-shell/index.js';
|
|
6
6
|
export * as Activity from './components/activity/index.js';
|
|
7
|
-
export type { ActivityContentProps, ActivityIconProps, ActivityIconTone, ActivityRootProps, ActivityStepKind, ActivityStepProps, ActivityStepStatus, ActivityThoughtProps, ActivityTriggerProps } from './components/activity/index.js';
|
|
7
|
+
export type { ActivityContentProps, ActivityIconProps, ActivityIconTone, ActivityRootProps, ActivityStepKind, ActivityStepOutputLabels, ActivityStepProps, ActivityStepStatus, ActivityThoughtProps, ActivityTriggerProps } from './components/activity/index.js';
|
|
8
8
|
export { default as Announcer } from './components/announcer/Announcer.svelte';
|
|
9
9
|
export type { AnnouncerProps } from './components/announcer/Announcer.svelte';
|
|
10
10
|
export * as Avatar from './components/avatar/index.js';
|
|
@@ -164,7 +164,7 @@ export { default as Theme } from './components/theme/Theme.svelte';
|
|
|
164
164
|
export type { ThemeOverrides, ThemeProps, ThemeScheme } from './components/theme/Theme.svelte';
|
|
165
165
|
export { default as WorkFold } from './components/work-fold/WorkFold.svelte';
|
|
166
166
|
export type { WorkFoldProps } from './components/work-fold/WorkFold.svelte';
|
|
167
|
-
export { whileVisible } from './internal/visible.js';
|
|
167
|
+
export { setPageHidden, whileVisible } from './internal/visible.js';
|
|
168
168
|
export { resolveColor, resolveRgba } from './color.js';
|
|
169
169
|
export type { ResolveColorOptions, Rgba } from './color.js';
|
|
170
170
|
export { classes, sx } from './internal/sx.js';
|
package/dist/index.js
CHANGED
|
@@ -123,8 +123,9 @@ export { default as Theme } from './components/theme/Theme.svelte';
|
|
|
123
123
|
export { default as WorkFold } from './components/work-fold/WorkFold.svelte';
|
|
124
124
|
// For an animation of your own that never ends: `whileVisible` runs it only while it can be
|
|
125
125
|
// seen, with `animationPlayState: play.whileVisible` from the tokens. Spinner, Shimmer,
|
|
126
|
-
// Skeleton and
|
|
127
|
-
|
|
126
|
+
// Skeleton, Progress and Markdown's caret use it. `setPageHidden` is the host's word that the
|
|
127
|
+
// page is out of sight where the document cannot tell, such as a minimized Electron window.
|
|
128
|
+
export { setPageHidden, whileVisible } from './internal/visible.js';
|
|
128
129
|
// The colour a token paints as, for a <canvas>, WebGL or a chart library, which
|
|
129
130
|
// cannot read `var()` or `light-dark()` themselves.
|
|
130
131
|
export { resolveColor, resolveRgba } from './color.js';
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { attrs, type Sx } from './sx.js';
|
|
13
13
|
import { motion } from '../tokens.stylex.js';
|
|
14
14
|
import { media } from '../media.stylex.js';
|
|
15
|
+
import { getFoldShown, setFoldShown } from './fold-shown.js';
|
|
15
16
|
|
|
16
17
|
const styles = stylex.create({
|
|
17
18
|
region: {
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
<script lang="ts">
|
|
48
49
|
let {
|
|
49
50
|
open,
|
|
51
|
+
lazy = true,
|
|
50
52
|
sx,
|
|
51
53
|
innerSx,
|
|
52
54
|
innerClass,
|
|
@@ -55,17 +57,30 @@
|
|
|
55
57
|
...rest
|
|
56
58
|
}: Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
57
59
|
open: boolean;
|
|
60
|
+
/** Builds the content the first time it opens. Off, it is built while shut too. */
|
|
61
|
+
lazy?: boolean | undefined;
|
|
58
62
|
sx?: Sx | undefined;
|
|
59
63
|
innerSx?: Sx | undefined;
|
|
60
64
|
innerClass?: ClassValue | null | undefined;
|
|
61
65
|
children?: Snippet | undefined;
|
|
62
66
|
} = $props();
|
|
67
|
+
|
|
68
|
+
// What is inside is shown while this is open and every fold around it is
|
|
69
|
+
const outerShown = getFoldShown();
|
|
70
|
+
setFoldShown(() => open && outerShown());
|
|
71
|
+
|
|
72
|
+
// Once open, it stays built. A plain variable: it only ever turns true, and only with `open`.
|
|
73
|
+
let opened = false;
|
|
74
|
+
const built = $derived.by(() => {
|
|
75
|
+
if (open) opened = true;
|
|
76
|
+
return opened || !lazy;
|
|
77
|
+
});
|
|
63
78
|
</script>
|
|
64
79
|
|
|
65
80
|
<div inert={!open} {...rest} {...attrs([styles.region, open && styles.open, sx], className)}>
|
|
66
81
|
<div {...stylex.attrs(styles.inner, open && styles.innerOpen)}>
|
|
67
82
|
<div {...attrs([innerSx], innerClass)}>
|
|
68
|
-
{@render children?.()}
|
|
83
|
+
{#if built}{@render children?.()}{/if}
|
|
69
84
|
</div>
|
|
70
85
|
</div>
|
|
71
86
|
</div>
|
|
@@ -3,6 +3,8 @@ import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
|
3
3
|
import { type Sx } from './sx.js';
|
|
4
4
|
type $$ComponentProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
5
5
|
open: boolean;
|
|
6
|
+
/** Builds the content the first time it opens. Off, it is built while shut too. */
|
|
7
|
+
lazy?: boolean | undefined;
|
|
6
8
|
sx?: Sx | undefined;
|
|
7
9
|
innerSx?: Sx | undefined;
|
|
8
10
|
innerClass?: ClassValue | null | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether what is inside a fold is shown: open, in every fold around it. A part that reads its
|
|
3
|
+
* own size, such as a step's output scrolling to its end, reads it only while this is true, so
|
|
4
|
+
* a shut fold's content is never laid out just to be measured.
|
|
5
|
+
*/
|
|
6
|
+
import { getContext, setContext } from 'svelte';
|
|
7
|
+
const KEY = Symbol('narvi.fold-shown');
|
|
8
|
+
/** True outside any fold. Reactive where it is read in an effect or a template. */
|
|
9
|
+
export function getFoldShown() {
|
|
10
|
+
return getContext(KEY) ?? (() => true);
|
|
11
|
+
}
|
|
12
|
+
export function setFoldShown(shown) {
|
|
13
|
+
setContext(KEY, shown);
|
|
14
|
+
}
|
package/dist/internal/layer.d.ts
CHANGED
|
@@ -7,13 +7,16 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as stylex from '@stylexjs/stylex';
|
|
9
9
|
import './icons.css';
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The `style` that gives a floating surface a `width`, or a least width, of its own, with any
|
|
12
|
+
* `style` given too.
|
|
13
|
+
*/
|
|
14
|
+
export declare function widthStyle(width: string | undefined, style: unknown, minWidth?: string | undefined): string | undefined;
|
|
12
15
|
export declare const layer: Readonly<{
|
|
13
16
|
readonly surface: Readonly<{
|
|
14
17
|
readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
|
|
15
18
|
readonly zIndex: stylex.StyleXClassNameFor<"zIndex", 55>;
|
|
16
|
-
readonly minWidth: stylex.StyleXClassNameFor<"minWidth", "max(12rem, var(--bits-floating-anchor-width, 0px))">;
|
|
19
|
+
readonly minWidth: stylex.StyleXClassNameFor<"minWidth", "max(var(--narvi-layer-min-width, 12rem), var(--bits-floating-anchor-width, 0px))">;
|
|
17
20
|
readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "min(22rem, var(--bits-floating-available-width, 100vw))">;
|
|
18
21
|
readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "var(--bits-floating-available-height, 80vh)">;
|
|
19
22
|
readonly overflowY: stylex.StyleXClassNameFor<"overflowY", "auto">;
|
package/dist/internal/layer.js
CHANGED
|
@@ -12,12 +12,18 @@ import './icons.css';
|
|
|
12
12
|
const CLOSED = ':is([data-state="closed"])';
|
|
13
13
|
const HIGHLIGHTED = ':is([data-highlighted])';
|
|
14
14
|
const DISABLED = ':is([data-disabled])';
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The `style` that gives a floating surface a `width`, or a least width, of its own, with any
|
|
17
|
+
* `style` given too.
|
|
18
|
+
*/
|
|
19
|
+
export function widthStyle(width, style, minWidth) {
|
|
17
20
|
const own = typeof style === 'string' && style ? style : undefined;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const parts = [
|
|
22
|
+
width && `--narvi-layer-width: ${width}`,
|
|
23
|
+
minWidth && `--narvi-layer-min-width: ${minWidth}`,
|
|
24
|
+
own
|
|
25
|
+
].filter(Boolean);
|
|
26
|
+
return parts.length ? parts.join('; ') : undefined;
|
|
21
27
|
}
|
|
22
28
|
export const layer = stylex.create({
|
|
23
29
|
surface: {
|
|
@@ -25,7 +31,8 @@ export const layer = stylex.create({
|
|
|
25
31
|
// Over a dialog (50 and 51) and a sheet, which are where a popup opens while one is up:
|
|
26
32
|
// a modal makes the page behind it inert. Under a tooltip (60) and the toasts (the top layer).
|
|
27
33
|
zIndex: 55,
|
|
28
|
-
|
|
34
|
+
// From 12rem, or a least width of its own, or the trigger's width if that is wider
|
|
35
|
+
minWidth: 'max(var(--narvi-layer-min-width, 12rem), var(--bits-floating-anchor-width, 0px))',
|
|
29
36
|
maxWidth: 'min(22rem, var(--bits-floating-available-width, 100vw))',
|
|
30
37
|
// Never taller than the room left in the window; it scrolls inside instead
|
|
31
38
|
maxHeight: 'var(--bits-floating-available-height, 80vh)',
|
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
* screens up the conversation, or in a window behind another, is paid for and
|
|
6
6
|
* never looked at. So every one of Narvi's reads its play state from a custom
|
|
7
7
|
* property, and this sets that property: running while the element is in the
|
|
8
|
-
* viewport and the
|
|
8
|
+
* viewport and the page is showing, paused otherwise.
|
|
9
|
+
*
|
|
10
|
+
* The page is showing unless the document says it is hidden or the host does. A
|
|
11
|
+
* desktop app that keeps its window running in the background, such as an Electron
|
|
12
|
+
* one with background throttling off, is never hidden to the document: minimized or
|
|
13
|
+
* closed to the tray, it still counts as showing. The host knows better, and says so
|
|
14
|
+
* with `setPageHidden`.
|
|
9
15
|
*
|
|
10
16
|
* The animations themselves are stepped (`steps(30)` over two seconds, say), so
|
|
11
17
|
* the compositor draws a handful of frames a second, not one for every refresh
|
|
@@ -29,4 +35,21 @@
|
|
|
29
35
|
* ```
|
|
30
36
|
*/
|
|
31
37
|
import type { Attachment } from 'svelte/attachments';
|
|
38
|
+
/**
|
|
39
|
+
* Tells Narvi whether the host has hidden the page, where the document cannot tell: an
|
|
40
|
+
* Electron window minimized or closed to the tray with background throttling off, a view
|
|
41
|
+
* kept alive out of sight. While it is hidden, every animation that never ends pauses: the
|
|
42
|
+
* spinners, shimmers, skeletons, progress bars and carets, and your own that use
|
|
43
|
+
* `whileVisible`. They run again once it is shown, where they can be seen.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { setPageHidden } from '@diegopluna/narvi';
|
|
47
|
+
*
|
|
48
|
+
* // However the host tells the page: here, a bridge from an Electron preload script
|
|
49
|
+
* bridge.onWindowAway((away) => setPageHidden(away));
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* The document's own `hidden` still counts: this only adds to it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function setPageHidden(hidden: boolean): void;
|
|
32
55
|
export declare const whileVisible: Attachment<HTMLElement | SVGElement>;
|
package/dist/internal/visible.js
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
const watched = new Map();
|
|
2
2
|
let observer = null;
|
|
3
|
+
// Hidden by the host's word, whatever the document says
|
|
4
|
+
let hiddenByHost = false;
|
|
3
5
|
function apply(item) {
|
|
4
|
-
const running = item.inView && !document.hidden;
|
|
6
|
+
const running = item.inView && !document.hidden && !hiddenByHost;
|
|
5
7
|
item.element.style.setProperty('--narvi-play', running ? 'running' : 'paused');
|
|
6
8
|
}
|
|
7
9
|
function applyAll() {
|
|
8
10
|
for (const item of watched.values())
|
|
9
11
|
apply(item);
|
|
10
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Tells Narvi whether the host has hidden the page, where the document cannot tell: an
|
|
15
|
+
* Electron window minimized or closed to the tray with background throttling off, a view
|
|
16
|
+
* kept alive out of sight. While it is hidden, every animation that never ends pauses: the
|
|
17
|
+
* spinners, shimmers, skeletons, progress bars and carets, and your own that use
|
|
18
|
+
* `whileVisible`. They run again once it is shown, where they can be seen.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { setPageHidden } from '@diegopluna/narvi';
|
|
22
|
+
*
|
|
23
|
+
* // However the host tells the page: here, a bridge from an Electron preload script
|
|
24
|
+
* bridge.onWindowAway((away) => setPageHidden(away));
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The document's own `hidden` still counts: this only adds to it.
|
|
28
|
+
*/
|
|
29
|
+
export function setPageHidden(hidden) {
|
|
30
|
+
if (hiddenByHost === hidden)
|
|
31
|
+
return;
|
|
32
|
+
hiddenByHost = hidden;
|
|
33
|
+
applyAll();
|
|
34
|
+
}
|
|
11
35
|
export const whileVisible = (element) => {
|
|
12
36
|
// Nothing to watch with: leave the animation running, as it would without this
|
|
13
37
|
if (typeof IntersectionObserver === 'undefined')
|
package/package.json
CHANGED
|
@@ -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.3.
|
|
15
|
+
library_version: '0.3.8'
|
|
16
16
|
requires:
|
|
17
17
|
- setup
|
|
18
18
|
sources:
|
|
@@ -34,11 +34,13 @@ sources:
|
|
|
34
34
|
- src/lib/components/dialog/DialogContent.svelte
|
|
35
35
|
- src/lib/components/tab-strip/TabStrip.svelte
|
|
36
36
|
- src/lib/components/split-button/SplitButton.svelte
|
|
37
|
-
- src/lib/components/app-shell
|
|
37
|
+
- src/lib/components/app-shell/*.svelte
|
|
38
38
|
- src/lib/components/composer/ComposerModelPicker.svelte
|
|
39
39
|
- src/lib/components/questionnaire/Questionnaire.svelte
|
|
40
40
|
- src/lib/components/button/Button.svelte
|
|
41
41
|
- src/lib/components/tooltip/TooltipProvider.svelte
|
|
42
|
+
- src/lib/components/command/*.svelte
|
|
43
|
+
- src/lib/components/menu/MenuContent.svelte
|
|
42
44
|
---
|
|
43
45
|
|
|
44
46
|
# Build interfaces with Narvi
|
|
@@ -328,16 +330,16 @@ line, `lines={2}` for several). Use `Code` and `Kbd` inline, and
|
|
|
328
330
|
sends the last to the end. `variant="link"` sits in a sentence. An open ghost, bare, secondary
|
|
329
331
|
or floating trigger holds an open look by bits-ui's `aria-expanded`, and `pressed` makes a
|
|
330
332
|
toggle button (`aria-pressed`) in that look: style neither.
|
|
331
|
-
- A main action with a menu of how to do it (Merge, Sign in) is a `SplitButton
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
- A main action with a menu of how to do it (Merge, Sign in) is a `SplitButton`; don't join two
|
|
334
|
+
Buttons by hand, or retheme its tokens to restyle a half. Its props are in the
|
|
335
|
+
[catalogue](references/components.md#split-buttons).
|
|
334
336
|
- `Toggle` and `ToggleGroup.Root` take `tone="neutral"`: pressed, a toolbar's icon takes the fill
|
|
335
337
|
of what is chosen, not the accent.
|
|
336
338
|
- `Menu.Item`, `Menu.SubTrigger`, `Menu.CheckboxItem` and `Menu.RadioItem` take a
|
|
337
339
|
`description` (a line under the label): a string, or a snippet whose icon is 12px and lies in
|
|
338
340
|
the line; say in words what the icon stands for. All but the SubTrigger take `trailing`. A `Menu.CheckboxItem` with an
|
|
339
341
|
`icon` puts its tick at the end, so its icon lines up with the others'. `Menu.Content` takes a
|
|
340
|
-
`width` (`'18rem'`) in place of fitting its items, up to 22rem
|
|
342
|
+
`width` (`'18rem'`) in place of fitting its items, up to 22rem, or a `minWidth`.
|
|
341
343
|
- `Popover.Content` takes `padding="none"`, `layout="column"` and a `width`;
|
|
342
344
|
`HoverCard.Content` takes `layout="column"` and `padding`; `Tooltip.Content` takes
|
|
343
345
|
`layout="column"` for a title over a line that says more.
|
|
@@ -391,17 +393,15 @@ Parts of the shell that are easy to redraw by hand, and shouldn't be:
|
|
|
391
393
|
what scrolls, in the same tab stop and arrow-key order. Don't add a second `Sidebar.Content`.
|
|
392
394
|
- **A mark with a badge** in a row's `meta` may overhang it; the line clips only far past its end.
|
|
393
395
|
- `AppShell.Main` is not focusable, so a press on text in the page leaves focus where it was.
|
|
394
|
-
- **TabStrip** tabs narrow to an ellipsis before the strip scrolls
|
|
395
|
-
tab's close button takes the icon's place
|
|
396
|
-
|
|
397
|
-
a long press), `onmove(id, index)` (drag, or Alt+Shift+arrow), `onrename(id, label)` with
|
|
398
|
-
`bind:renaming` (double-click, F2, or a menu's Rename), `trailing` for a tab's own buttons,
|
|
399
|
-
`beside` for the tab shown in a split, and per tab `tabId`, `panelId`, `title`, `renamable`.
|
|
400
|
-
Arrows open the tab they reach (`activation="manual"` only moves focus); `onchange(id)`; a
|
|
401
|
-
name cleared comes as `''`; `addMenu` (Menu parts) makes the add button open a menu.
|
|
396
|
+
- **TabStrip** tabs narrow to an ellipsis before the strip scrolls; with a `leading` icon, a
|
|
397
|
+
tab's close button takes the icon's place. A side panel's tabs are a TabStrip too, with menus,
|
|
398
|
+
dragging, renaming and an add menu: see the [catalogue](references/components.md#tab-strips).
|
|
402
399
|
- **AppShell.Panel** goes narrow by its row, not the window; `maximized` lays it over the page,
|
|
403
400
|
kept inert, so give it an `AppShell.Header` with `AppShell.Toggle when="closed"`. Beside a
|
|
404
|
-
thread, put it in a flex row of yours (`position: relative`) inside `AppShell.Main
|
|
401
|
+
thread, put it in a flex row of yours (`position: relative`) inside `AppShell.Main`; for
|
|
402
|
+
`hideCovered`, `edgeLabel` and `edgeTitle` see the [catalogue](references/components.md#panels).
|
|
403
|
+
- **A palette** is `Command.Root`: don't work round its keys, highlight, footer or field by hand
|
|
404
|
+
(the [catalogue](references/components.md#palettes) says what each does).
|
|
405
405
|
- **A Sheet** focuses itself as it opens (`focusOnOpen="sheet"`), so a Rail or a list in it
|
|
406
406
|
shows no focus ring until the keys move in. Pass `focusOnOpen="first"` for a sheet that
|
|
407
407
|
holds a form.
|