@diegopluna/narvi 0.3.0 → 0.3.2
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/README.md +3 -1
- package/dist/components/app-shell/AppShellMain.svelte +5 -1
- package/dist/components/badge/Badge.svelte +16 -1
- package/dist/components/badge/Badge.svelte.d.ts +3 -0
- package/dist/components/button/Button.svelte +46 -7
- package/dist/components/hover-card/HoverCardContent.svelte +1 -1
- package/dist/components/menu/ContextMenuTrigger.svelte +14 -2
- package/dist/components/menu/ContextMenuTrigger.svelte.d.ts +10 -0
- package/dist/components/menu/MenuCheckboxItem.svelte +8 -2
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +6 -0
- package/dist/components/menu/MenuGroup.svelte +16 -0
- package/dist/components/menu/MenuGroup.svelte.d.ts +6 -0
- package/dist/components/menu/MenuLabel.svelte +22 -8
- package/dist/components/menu/MenuRadioGroup.svelte +16 -0
- package/dist/components/menu/MenuRadioGroup.svelte.d.ts +6 -0
- package/dist/components/menu/group.d.ts +2 -0
- package/dist/components/menu/group.js +9 -0
- package/dist/components/menu/index.d.ts +4 -2
- package/dist/components/menu/index.js +2 -2
- package/dist/components/settings-row/SettingsRow.svelte +13 -2
- package/dist/components/settings-row/SettingsRow.svelte.d.ts +7 -1
- package/dist/components/sidebar/SidebarContent.svelte +59 -13
- package/dist/components/sidebar/SidebarContent.svelte.d.ts +6 -0
- package/dist/components/sidebar/SidebarFolder.svelte +44 -12
- package/dist/components/sidebar/SidebarGroup.svelte +50 -7
- package/dist/components/sidebar/SidebarGroup.svelte.d.ts +10 -1
- package/dist/components/sidebar/SidebarItem.svelte +139 -24
- package/dist/components/sidebar/SidebarItem.svelte.d.ts +22 -2
- package/dist/components/sidebar/SidebarSwitcher.svelte +18 -2
- package/dist/components/sidebar/SidebarSwitcher.svelte.d.ts +2 -0
- package/dist/components/sidebar/depth.d.ts +8 -6
- package/dist/components/sidebar/depth.js +7 -5
- package/dist/components/sidebar/fold.d.ts +12 -0
- package/dist/components/sidebar/fold.js +8 -0
- package/dist/components/status-indicator/StatusDot.svelte +90 -0
- package/dist/components/status-indicator/StatusDot.svelte.d.ts +18 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -0
- package/dist/vite.d.ts +15 -6
- package/dist/vite.js +38 -0
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +42 -8
- package/skills/building-ui/references/components.md +7 -6
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +9 -11
- package/skills/styling/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -135,7 +135,9 @@ publish succeeds, so a failed run can be run again.
|
|
|
135
135
|
- **The Vite plugin** in `src/lib/vite.ts` is a preset over `@stylexjs/unplugin`. It puts every
|
|
136
136
|
style in one cascade layer, `narvi`, so unlayered CSS beats it, and declares `narvi.base` first
|
|
137
137
|
inside it, so `base.css` stays below the components whichever stylesheet loads first. `narvi({ tailwind: true })`
|
|
138
|
-
orders that layer between Tailwind's `base` and its `components` and `utilities
|
|
138
|
+
orders that layer between Tailwind's `base` and its `components` and `utilities`, and starts
|
|
139
|
+
every stylesheet that names one of those layers with the order, so it holds whichever loads
|
|
140
|
+
first. It also says so
|
|
139
141
|
when it is listed before the Svelte plugin, and targets browsers that have `light-dark()`, so
|
|
140
142
|
Vite does not rewrite it in the app's own stylesheet.
|
|
141
143
|
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
flexGrow: 1,
|
|
20
20
|
minWidth: 0,
|
|
21
21
|
minHeight: 0,
|
|
22
|
+
// Focused from a skip link, it is the page that is reached, not a control
|
|
22
23
|
outlineStyle: 'none'
|
|
23
24
|
}
|
|
24
25
|
});
|
|
@@ -28,6 +29,9 @@
|
|
|
28
29
|
let { sx, class: className, children, ...rest }: AppShellMainProps = $props();
|
|
29
30
|
</script>
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
<!-- Not focusable by default: with `tabindex="-1"` a click on plain text in the page would move
|
|
33
|
+
focus to the whole of it, away from a panel that keeps its own, such as a find bar. Pass a
|
|
34
|
+
`tabindex` to make it the target of a skip link. -->
|
|
35
|
+
<main data-slot="app-shell-main" {...rest} {...attrs([styles.main, sx], className)}>
|
|
32
36
|
{@render children?.()}
|
|
33
37
|
</main>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { shared } from '../../internal/shared.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
7
|
import { colors, font, radius } from '../../tokens.stylex.js';
|
|
8
|
+
import '../../internal/icons.css';
|
|
8
9
|
|
|
9
10
|
export type BadgeTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
|
|
10
11
|
|
|
@@ -16,12 +17,16 @@
|
|
|
16
17
|
* text colour, which holds its contrast on a badge's own surface.
|
|
17
18
|
*/
|
|
18
19
|
plain?: boolean | undefined;
|
|
20
|
+
/** `sm` is as tall as a sidebar row's line, 18px, to sit in a row without growing it. */
|
|
21
|
+
size?: 'sm' | 'md' | undefined;
|
|
19
22
|
sx?: Sx | undefined;
|
|
20
23
|
children?: Snippet | undefined;
|
|
21
24
|
};
|
|
22
25
|
|
|
23
26
|
const styles = stylex.create({
|
|
24
27
|
base: {
|
|
28
|
+
// An icon put in it, beside the words, is 12px (`internal/icons.css`)
|
|
29
|
+
'--narvi-icon-size': '0.75rem',
|
|
25
30
|
display: 'inline-flex',
|
|
26
31
|
alignItems: 'center',
|
|
27
32
|
gap: '0.375rem',
|
|
@@ -47,6 +52,7 @@
|
|
|
47
52
|
borderRadius: radius.pill,
|
|
48
53
|
forcedColorAdjust: 'none'
|
|
49
54
|
},
|
|
55
|
+
sm: { gap: '0.25rem', minHeight: '1.125rem', paddingInline: '0.375rem' },
|
|
50
56
|
lit: { color: colors.text }
|
|
51
57
|
});
|
|
52
58
|
|
|
@@ -72,6 +78,7 @@
|
|
|
72
78
|
let {
|
|
73
79
|
tone = 'neutral',
|
|
74
80
|
plain = false,
|
|
81
|
+
size = 'md',
|
|
75
82
|
sx,
|
|
76
83
|
class: className,
|
|
77
84
|
children,
|
|
@@ -80,9 +87,17 @@
|
|
|
80
87
|
</script>
|
|
81
88
|
|
|
82
89
|
<span
|
|
90
|
+
data-icons
|
|
83
91
|
{...rest}
|
|
84
92
|
{...attrs(
|
|
85
|
-
[
|
|
93
|
+
[
|
|
94
|
+
styles.base,
|
|
95
|
+
size === 'sm' && styles.sm,
|
|
96
|
+
shared.edged,
|
|
97
|
+
tone === 'accent' && styles.lit,
|
|
98
|
+
plain && words[tone],
|
|
99
|
+
sx
|
|
100
|
+
],
|
|
86
101
|
className
|
|
87
102
|
)}
|
|
88
103
|
>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import { type Sx } from '../../internal/sx.js';
|
|
4
|
+
import '../../internal/icons.css';
|
|
4
5
|
export type BadgeTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
|
|
5
6
|
export type BadgeProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
|
|
6
7
|
/** Colour of the dot. The words stay in the text colour, so they are always readable. */
|
|
@@ -10,6 +11,8 @@ export type BadgeProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children'> & {
|
|
|
10
11
|
* text colour, which holds its contrast on a badge's own surface.
|
|
11
12
|
*/
|
|
12
13
|
plain?: boolean | undefined;
|
|
14
|
+
/** `sm` is as tall as a sidebar row's line, 18px, to sit in a row without growing it. */
|
|
15
|
+
size?: 'sm' | 'md' | undefined;
|
|
13
16
|
sx?: Sx | undefined;
|
|
14
17
|
children?: Snippet | undefined;
|
|
15
18
|
};
|
|
@@ -138,11 +138,49 @@
|
|
|
138
138
|
borderRadius: radius.panel,
|
|
139
139
|
fontSize: font.sizeReading
|
|
140
140
|
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
// Square. Last in a slot that lines its controls up by their marks (one that sets
|
|
142
|
+
// `--narvi-icon-flush: 1`, as a sidebar group's actions do), the button reaches out by the
|
|
143
|
+
// room around its icon, so the icon, not the box, ends on the line.
|
|
144
|
+
iconMicro: {
|
|
145
|
+
width: '1.25rem',
|
|
146
|
+
paddingInline: 0,
|
|
147
|
+
marginInlineEnd: {
|
|
148
|
+
default: null,
|
|
149
|
+
':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.75rem - 1.25rem) / 2)'
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
iconXs: {
|
|
153
|
+
width: '1.5rem',
|
|
154
|
+
paddingInline: 0,
|
|
155
|
+
marginInlineEnd: {
|
|
156
|
+
default: null,
|
|
157
|
+
':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.875rem - 1.5rem) / 2)'
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
iconSm: {
|
|
161
|
+
width: '1.75rem',
|
|
162
|
+
paddingInline: 0,
|
|
163
|
+
marginInlineEnd: {
|
|
164
|
+
default: null,
|
|
165
|
+
':last-child': 'calc(var(--narvi-icon-flush, 0) * (0.875rem - 1.75rem) / 2)'
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
iconMd: {
|
|
169
|
+
width: '2rem',
|
|
170
|
+
paddingInline: 0,
|
|
171
|
+
marginInlineEnd: {
|
|
172
|
+
default: null,
|
|
173
|
+
':last-child': 'calc(var(--narvi-icon-flush, 0) * (1rem - 2rem) / 2)'
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
iconLg: {
|
|
177
|
+
width: '2.5rem',
|
|
178
|
+
paddingInline: 0,
|
|
179
|
+
marginInlineEnd: {
|
|
180
|
+
default: null,
|
|
181
|
+
':last-child': 'calc(var(--narvi-icon-flush, 0) * (1.125rem - 2.5rem) / 2)'
|
|
182
|
+
}
|
|
183
|
+
},
|
|
146
184
|
|
|
147
185
|
pill: { borderRadius: radius.pill },
|
|
148
186
|
|
|
@@ -382,7 +420,8 @@
|
|
|
382
420
|
}
|
|
383
421
|
const contentClass = classes(styles.content);
|
|
384
422
|
|
|
385
|
-
// The spinner beside a loading label, as large as an icon in a
|
|
423
|
+
// The spinner, beside a loading label or in place of the content, as large as an icon in a
|
|
424
|
+
// button of that size
|
|
386
425
|
const SPINNER = { micro: 12, xs: 14, sm: 14, md: 16, lg: 18 } as const;
|
|
387
426
|
</script>
|
|
388
427
|
|
|
@@ -437,7 +476,7 @@
|
|
|
437
476
|
{/if}
|
|
438
477
|
{#if loading && !loadingLabel}
|
|
439
478
|
<span {...stylex.attrs(styles.spinner)}>
|
|
440
|
-
<Spinner size={
|
|
479
|
+
<Spinner size={SPINNER[size]} label="Loading" />
|
|
441
480
|
</span>
|
|
442
481
|
{/if}
|
|
443
482
|
{/snippet}
|
|
@@ -9,19 +9,31 @@
|
|
|
9
9
|
sx?: Sx | undefined;
|
|
10
10
|
/** The region a right-click opens the menu over. */
|
|
11
11
|
children?: Snippet | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Opens the menu from Shift+F10 and the Menu key at the focused element. Pass `false`
|
|
14
|
+
* where the list's own keys already open it, or it would open twice.
|
|
15
|
+
*/
|
|
16
|
+
menuKey?: boolean | undefined;
|
|
12
17
|
}
|
|
13
18
|
>;
|
|
14
19
|
</script>
|
|
15
20
|
|
|
16
21
|
<script lang="ts">
|
|
17
|
-
let {
|
|
22
|
+
let {
|
|
23
|
+
sx,
|
|
24
|
+
class: className,
|
|
25
|
+
children,
|
|
26
|
+
onkeydown,
|
|
27
|
+
menuKey = true,
|
|
28
|
+
...rest
|
|
29
|
+
}: ContextMenuTriggerProps = $props();
|
|
18
30
|
|
|
19
31
|
// bits-ui opens a context menu only on the `contextmenu` event. Shift+F10 and
|
|
20
32
|
// the Menu key send one on Windows and Linux, but a Mac has neither, so the
|
|
21
33
|
// event is sent here, at the focused element, from the keyboard.
|
|
22
34
|
function openFromKeyboard(event: KeyboardEvent & { currentTarget: HTMLDivElement }) {
|
|
23
35
|
onkeydown?.(event);
|
|
24
|
-
if (event.defaultPrevented) return;
|
|
36
|
+
if (!menuKey || event.defaultPrevented) return;
|
|
25
37
|
if (!(event.key === 'ContextMenu' || (event.key === 'F10' && event.shiftKey))) return;
|
|
26
38
|
event.preventDefault();
|
|
27
39
|
const target = (document.activeElement as HTMLElement | null) ?? event.currentTarget;
|
|
@@ -6,11 +6,21 @@ export type ContextMenuTriggerProps = Loose<Omit<ContextMenu.TriggerProps, 'chil
|
|
|
6
6
|
sx?: Sx | undefined;
|
|
7
7
|
/** The region a right-click opens the menu over. */
|
|
8
8
|
children?: Snippet | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Opens the menu from Shift+F10 and the Menu key at the focused element. Pass `false`
|
|
11
|
+
* where the list's own keys already open it, or it would open twice.
|
|
12
|
+
*/
|
|
13
|
+
menuKey?: boolean | undefined;
|
|
9
14
|
}>;
|
|
10
15
|
declare const ContextMenuTrigger: import("svelte").Component<Loose<Omit<ContextMenu.TriggerProps, "children"> & {
|
|
11
16
|
sx?: Sx | undefined;
|
|
12
17
|
/** The region a right-click opens the menu over. */
|
|
13
18
|
children?: Snippet | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Opens the menu from Shift+F10 and the Menu key at the focused element. Pass `false`
|
|
21
|
+
* where the list's own keys already open it, or it would open twice.
|
|
22
|
+
*/
|
|
23
|
+
menuKey?: boolean | undefined;
|
|
14
24
|
}>, {}, "">;
|
|
15
25
|
type ContextMenuTrigger = ReturnType<typeof ContextMenuTrigger>;
|
|
16
26
|
export default ContextMenuTrigger;
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
export type MenuCheckboxItemProps = Loose<
|
|
11
11
|
Omit<DropdownMenu.CheckboxItemProps, 'children' | 'child'> & {
|
|
12
|
+
/** The keys that do the same, shown at the end, such as "⌘D". */
|
|
12
13
|
shortcut?: string | undefined;
|
|
14
|
+
/** A 16px icon before the label, after the tick. */
|
|
15
|
+
icon?: Snippet | undefined;
|
|
13
16
|
sx?: Sx | undefined;
|
|
14
17
|
children?: Snippet | undefined;
|
|
15
18
|
}
|
|
@@ -20,7 +23,10 @@
|
|
|
20
23
|
let {
|
|
21
24
|
checked = $bindable(false),
|
|
22
25
|
shortcut,
|
|
23
|
-
|
|
26
|
+
icon,
|
|
27
|
+
// Picking it closes the menu, as a radio item's does: one left open takes the next click
|
|
28
|
+
// that was meant for the page. Pass `false` for a menu of settings set several at a time.
|
|
29
|
+
closeOnSelect = true,
|
|
24
30
|
sx,
|
|
25
31
|
class: className,
|
|
26
32
|
children: label,
|
|
@@ -28,7 +34,6 @@
|
|
|
28
34
|
}: MenuCheckboxItemProps = $props();
|
|
29
35
|
</script>
|
|
30
36
|
|
|
31
|
-
<!-- Stays open by default, so several can be set in one visit -->
|
|
32
37
|
<DropdownMenu.CheckboxItem
|
|
33
38
|
bind:checked
|
|
34
39
|
{closeOnSelect}
|
|
@@ -40,6 +45,7 @@
|
|
|
40
45
|
<span {...stylex.attrs(layer.icon)}>
|
|
41
46
|
{#if checked}<Glyph name="check" stroke={1.75} />{/if}
|
|
42
47
|
</span>
|
|
48
|
+
{#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
|
|
43
49
|
<span {...stylex.attrs(layer.label)}>{@render label?.()}</span>
|
|
44
50
|
{#if shortcut}<span {...stylex.attrs(layer.trailing)}>{shortcut}</span>{/if}
|
|
45
51
|
{/snippet}
|
|
@@ -3,12 +3,18 @@ import { DropdownMenu } from 'bits-ui';
|
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
5
|
export type MenuCheckboxItemProps = Loose<Omit<DropdownMenu.CheckboxItemProps, 'children' | 'child'> & {
|
|
6
|
+
/** The keys that do the same, shown at the end, such as "⌘D". */
|
|
6
7
|
shortcut?: string | undefined;
|
|
8
|
+
/** A 16px icon before the label, after the tick. */
|
|
9
|
+
icon?: Snippet | undefined;
|
|
7
10
|
sx?: Sx | undefined;
|
|
8
11
|
children?: Snippet | undefined;
|
|
9
12
|
}>;
|
|
10
13
|
declare const MenuCheckboxItem: import("svelte").Component<Loose<Omit<DropdownMenu.CheckboxItemProps, "children" | "child"> & {
|
|
14
|
+
/** The keys that do the same, shown at the end, such as "⌘D". */
|
|
11
15
|
shortcut?: string | undefined;
|
|
16
|
+
/** A 16px icon before the label, after the tick. */
|
|
17
|
+
icon?: Snippet | undefined;
|
|
12
18
|
sx?: Sx | undefined;
|
|
13
19
|
children?: Snippet | undefined;
|
|
14
20
|
}>, {}, "checked">;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Loose } from '../../internal/loose.js';
|
|
3
|
+
import { DropdownMenu } from 'bits-ui';
|
|
4
|
+
import { markMenuGroup } from './group.js';
|
|
5
|
+
|
|
6
|
+
export type MenuGroupProps = Loose<DropdownMenu.GroupProps>;
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
let { children, ...rest }: MenuGroupProps = $props();
|
|
11
|
+
|
|
12
|
+
// A Menu.Label in it names it
|
|
13
|
+
markMenuGroup();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<DropdownMenu.Group {...rest}>{@render children?.()}</DropdownMenu.Group>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Loose } from '../../internal/loose.js';
|
|
2
|
+
import { DropdownMenu } from 'bits-ui';
|
|
3
|
+
export type MenuGroupProps = Loose<DropdownMenu.GroupProps>;
|
|
4
|
+
declare const MenuGroup: import("svelte").Component<Loose<DropdownMenu.GroupProps>, {}, "">;
|
|
5
|
+
type MenuGroup = ReturnType<typeof MenuGroup>;
|
|
6
|
+
export default MenuGroup;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import { layer } from '../../internal/layer.js';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
7
|
+
import { inMenuGroup } from './group.js';
|
|
7
8
|
|
|
8
9
|
export type MenuLabelProps = Loose<
|
|
9
10
|
Omit<DropdownMenu.GroupHeadingProps, 'children' | 'child'> & {
|
|
@@ -15,13 +16,26 @@
|
|
|
15
16
|
|
|
16
17
|
<script lang="ts">
|
|
17
18
|
let { sx, class: className, children, ...rest }: MenuLabelProps = $props();
|
|
19
|
+
|
|
20
|
+
const grouped = inMenuGroup();
|
|
18
21
|
</script>
|
|
19
22
|
|
|
20
|
-
<!--
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
<!-- In a Menu.Group it names the group. On its own it is a heading only to the eye, with nothing
|
|
24
|
+
to name, so it is plain text there rather than an error. -->
|
|
25
|
+
{#if grouped}
|
|
26
|
+
<DropdownMenu.GroupHeading
|
|
27
|
+
data-slot="menu-label"
|
|
28
|
+
{...rest}
|
|
29
|
+
{...attrs([layer.heading, sx], className)}
|
|
30
|
+
>
|
|
31
|
+
{@render children?.()}
|
|
32
|
+
</DropdownMenu.GroupHeading>
|
|
33
|
+
{:else}
|
|
34
|
+
<div
|
|
35
|
+
data-slot="menu-label"
|
|
36
|
+
{...rest as Record<string, unknown>}
|
|
37
|
+
{...attrs([layer.heading, sx], className)}
|
|
38
|
+
>
|
|
39
|
+
{@render children?.()}
|
|
40
|
+
</div>
|
|
41
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Loose } from '../../internal/loose.js';
|
|
3
|
+
import { DropdownMenu } from 'bits-ui';
|
|
4
|
+
import { markMenuGroup } from './group.js';
|
|
5
|
+
|
|
6
|
+
export type MenuRadioGroupProps = Loose<DropdownMenu.RadioGroupProps>;
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
let { value = $bindable(''), children, ...rest }: MenuRadioGroupProps = $props();
|
|
11
|
+
|
|
12
|
+
// A Menu.Label in it names it
|
|
13
|
+
markMenuGroup();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<DropdownMenu.RadioGroup bind:value {...rest}>{@render children?.()}</DropdownMenu.RadioGroup>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Loose } from '../../internal/loose.js';
|
|
2
|
+
import { DropdownMenu } from 'bits-ui';
|
|
3
|
+
export type MenuRadioGroupProps = Loose<DropdownMenu.RadioGroupProps>;
|
|
4
|
+
declare const MenuRadioGroup: import("svelte").Component<Loose<DropdownMenu.RadioGroupProps>, {}, "value">;
|
|
5
|
+
type MenuRadioGroup = ReturnType<typeof MenuRadioGroup>;
|
|
6
|
+
export default MenuRadioGroup;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
// Whether a Menu.Label sits in a Menu.Group or Menu.RadioGroup, which bits-ui's heading needs
|
|
3
|
+
const KEY = Symbol('narvi.menu-group');
|
|
4
|
+
export function markMenuGroup() {
|
|
5
|
+
setContext(KEY, true);
|
|
6
|
+
}
|
|
7
|
+
export function inMenuGroup() {
|
|
8
|
+
return getContext(KEY) === true;
|
|
9
|
+
}
|
|
@@ -2,22 +2,24 @@ import { DropdownMenu } from 'bits-ui';
|
|
|
2
2
|
import { type Loosened } from '../../internal/loose.js';
|
|
3
3
|
import CheckboxItem from './MenuCheckboxItem.svelte';
|
|
4
4
|
import Content from './MenuContent.svelte';
|
|
5
|
+
import Group from './MenuGroup.svelte';
|
|
5
6
|
import Item from './MenuItem.svelte';
|
|
6
7
|
import Label from './MenuLabel.svelte';
|
|
8
|
+
import RadioGroup from './MenuRadioGroup.svelte';
|
|
7
9
|
import RadioItem from './MenuRadioItem.svelte';
|
|
8
10
|
import Separator from './MenuSeparator.svelte';
|
|
9
11
|
import SubContent from './MenuSubContent.svelte';
|
|
10
12
|
import SubTrigger from './MenuSubTrigger.svelte';
|
|
11
13
|
declare const Root: Loosened<typeof DropdownMenu.Root>;
|
|
12
14
|
declare const Trigger: Loosened<typeof DropdownMenu.Trigger>;
|
|
13
|
-
declare const Group: Loosened<typeof DropdownMenu.Group>;
|
|
14
|
-
declare const RadioGroup: Loosened<typeof DropdownMenu.RadioGroup>;
|
|
15
15
|
declare const Sub: Loosened<typeof DropdownMenu.Sub>;
|
|
16
16
|
export { Root, Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, Group, Label, Separator, Sub, SubTrigger, SubContent };
|
|
17
17
|
export type { MenuCheckboxItemProps } from './MenuCheckboxItem.svelte';
|
|
18
18
|
export type { MenuContentProps } from './MenuContent.svelte';
|
|
19
|
+
export type { MenuGroupProps } from './MenuGroup.svelte';
|
|
19
20
|
export type { MenuItemProps } from './MenuItem.svelte';
|
|
20
21
|
export type { MenuLabelProps } from './MenuLabel.svelte';
|
|
22
|
+
export type { MenuRadioGroupProps } from './MenuRadioGroup.svelte';
|
|
21
23
|
export type { MenuRadioItemProps } from './MenuRadioItem.svelte';
|
|
22
24
|
export type { MenuSeparatorProps } from './MenuSeparator.svelte';
|
|
23
25
|
export type { MenuSubContentProps } from './MenuSubContent.svelte';
|
|
@@ -2,8 +2,10 @@ import { DropdownMenu } from 'bits-ui';
|
|
|
2
2
|
import { loose } from '../../internal/loose.js';
|
|
3
3
|
import CheckboxItem from './MenuCheckboxItem.svelte';
|
|
4
4
|
import Content from './MenuContent.svelte';
|
|
5
|
+
import Group from './MenuGroup.svelte';
|
|
5
6
|
import Item from './MenuItem.svelte';
|
|
6
7
|
import Label from './MenuLabel.svelte';
|
|
8
|
+
import RadioGroup from './MenuRadioGroup.svelte';
|
|
7
9
|
import RadioItem from './MenuRadioItem.svelte';
|
|
8
10
|
import Separator from './MenuSeparator.svelte';
|
|
9
11
|
import SubContent from './MenuSubContent.svelte';
|
|
@@ -13,7 +15,5 @@ import SubTrigger from './MenuSubTrigger.svelte';
|
|
|
13
15
|
// this module's declarations (it leaves them out without a word on TS2883).
|
|
14
16
|
const Root = loose(DropdownMenu.Root);
|
|
15
17
|
const Trigger = loose(DropdownMenu.Trigger);
|
|
16
|
-
const Group = loose(DropdownMenu.Group);
|
|
17
|
-
const RadioGroup = loose(DropdownMenu.RadioGroup);
|
|
18
18
|
const Sub = loose(DropdownMenu.Sub);
|
|
19
19
|
export { Root, Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, Group, Label, Separator, Sub, SubTrigger, SubContent };
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { getSettingsGroupContext } from '../settings-group/context.js';
|
|
19
19
|
|
|
20
20
|
export type SettingsRowControl = {
|
|
21
|
-
/** For the control's `id`, which the label's `for` names. */
|
|
21
|
+
/** For the control's `id`, which the label's `for` names: `controlId` when it is set. */
|
|
22
22
|
id: string;
|
|
23
23
|
/** The label's id: a group's `aria-labelledby` when `labelFor` is off. */
|
|
24
24
|
labelId: string;
|
|
@@ -46,6 +46,12 @@
|
|
|
46
46
|
* its own label does; the label is then plain text, and its id is `labelId`.
|
|
47
47
|
*/
|
|
48
48
|
labelFor?: boolean | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The control's id, when the app names it: one that search, a link or a test finds it by.
|
|
51
|
+
* The label's `for` names it, and the row hands it to the control as `id`. Without it the
|
|
52
|
+
* row makes one.
|
|
53
|
+
*/
|
|
54
|
+
controlId?: string | undefined;
|
|
49
55
|
/** Lights the row, as when search lands on it. */
|
|
50
56
|
highlighted?: boolean | undefined;
|
|
51
57
|
/** Shown under the row, announced at once. */
|
|
@@ -125,6 +131,7 @@
|
|
|
125
131
|
description,
|
|
126
132
|
stacked = false,
|
|
127
133
|
labelFor = true,
|
|
134
|
+
controlId,
|
|
128
135
|
highlighted = false,
|
|
129
136
|
error,
|
|
130
137
|
warning,
|
|
@@ -142,7 +149,11 @@
|
|
|
142
149
|
.filter(Boolean)
|
|
143
150
|
.join(' ') || undefined
|
|
144
151
|
);
|
|
145
|
-
const control = $derived({
|
|
152
|
+
const control = $derived({
|
|
153
|
+
id: controlId ?? `${uid}-control`,
|
|
154
|
+
labelId: `${uid}-label`,
|
|
155
|
+
describedBy
|
|
156
|
+
});
|
|
146
157
|
</script>
|
|
147
158
|
|
|
148
159
|
<div
|
|
@@ -2,7 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import { type Sx } from '../../internal/sx.js';
|
|
4
4
|
export type SettingsRowControl = {
|
|
5
|
-
/** For the control's `id`, which the label's `for` names. */
|
|
5
|
+
/** For the control's `id`, which the label's `for` names: `controlId` when it is set. */
|
|
6
6
|
id: string;
|
|
7
7
|
/** The label's id: a group's `aria-labelledby` when `labelFor` is off. */
|
|
8
8
|
labelId: string;
|
|
@@ -29,6 +29,12 @@ export type SettingsRowProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' |
|
|
|
29
29
|
* its own label does; the label is then plain text, and its id is `labelId`.
|
|
30
30
|
*/
|
|
31
31
|
labelFor?: boolean | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The control's id, when the app names it: one that search, a link or a test finds it by.
|
|
34
|
+
* The label's `for` names it, and the row hands it to the control as `id`. Without it the
|
|
35
|
+
* row makes one.
|
|
36
|
+
*/
|
|
37
|
+
controlId?: string | undefined;
|
|
32
38
|
/** Lights the row, as when search lands on it. */
|
|
33
39
|
highlighted?: boolean | undefined;
|
|
34
40
|
/** Shown under the row, announced at once. */
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
sx?: Sx | undefined;
|
|
13
13
|
/** Sidebar.Group and Sidebar.Item. */
|
|
14
14
|
children?: Snippet | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Groups held at the foot of the list, below what scrolls, such as shelves of settled
|
|
17
|
+
* threads. They are part of the same list: one tab stop, and the arrow keys run on into
|
|
18
|
+
* them. Opened, they take at most 40% of the height and scroll on their own.
|
|
19
|
+
*/
|
|
20
|
+
pinned?: Snippet | undefined;
|
|
15
21
|
};
|
|
16
22
|
|
|
17
23
|
const styles = stylex.create({
|
|
@@ -27,12 +33,29 @@
|
|
|
27
33
|
// The list fades at an edge with more beyond it
|
|
28
34
|
maskImage:
|
|
29
35
|
'linear-gradient(to bottom, transparent, #000 var(--narvi-fade-start, 0px), #000 calc(100% - var(--narvi-fade-end, 0px)), transparent)'
|
|
36
|
+
},
|
|
37
|
+
// With pinned groups, the list is a column: what scrolls, then what stays at its foot
|
|
38
|
+
split: {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
flexDirection: 'column',
|
|
41
|
+
flexGrow: 1,
|
|
42
|
+
minHeight: 0
|
|
43
|
+
},
|
|
44
|
+
pinned: {
|
|
45
|
+
flexShrink: 0,
|
|
46
|
+
maxHeight: '40%',
|
|
47
|
+
overflowY: 'auto',
|
|
48
|
+
overscrollBehavior: 'contain',
|
|
49
|
+
paddingInline: '0.5rem',
|
|
50
|
+
paddingBottom: '0.5rem',
|
|
51
|
+
scrollbarWidth: 'thin',
|
|
52
|
+
scrollbarColor: `${colors.borderStrong} transparent`
|
|
30
53
|
}
|
|
31
54
|
});
|
|
32
55
|
</script>
|
|
33
56
|
|
|
34
57
|
<script lang="ts">
|
|
35
|
-
let { label, sx, class: className, children, ...rest }: SidebarContentProps = $props();
|
|
58
|
+
let { label, sx, class: className, children, pinned, ...rest }: SidebarContentProps = $props();
|
|
36
59
|
|
|
37
60
|
let fadeStart = $state(0);
|
|
38
61
|
let fadeEnd = $state(0);
|
|
@@ -56,15 +79,38 @@
|
|
|
56
79
|
</script>
|
|
57
80
|
|
|
58
81
|
<!-- One tab stop for every row in every group; the arrow keys move between them -->
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
{#if pinned}
|
|
83
|
+
<nav
|
|
84
|
+
aria-label={label}
|
|
85
|
+
data-slot="sidebar-content"
|
|
86
|
+
{...rest}
|
|
87
|
+
{...attrs([styles.split, sx], className)}
|
|
88
|
+
{@attach roving({ selector: '[data-sidebar-row]' })}
|
|
89
|
+
>
|
|
90
|
+
<div
|
|
91
|
+
data-slot="sidebar-content-scroll"
|
|
92
|
+
style:--narvi-fade-start="{fadeStart}px"
|
|
93
|
+
style:--narvi-fade-end="{fadeEnd}px"
|
|
94
|
+
{...stylex.attrs(styles.content)}
|
|
95
|
+
{@attach measure}
|
|
96
|
+
>
|
|
97
|
+
<div>{@render children?.()}</div>
|
|
98
|
+
</div>
|
|
99
|
+
<div data-slot="sidebar-content-pinned" {...stylex.attrs(styles.pinned)}>
|
|
100
|
+
{@render pinned()}
|
|
101
|
+
</div>
|
|
102
|
+
</nav>
|
|
103
|
+
{:else}
|
|
104
|
+
<nav
|
|
105
|
+
aria-label={label}
|
|
106
|
+
data-slot="sidebar-content"
|
|
107
|
+
style:--narvi-fade-start="{fadeStart}px"
|
|
108
|
+
style:--narvi-fade-end="{fadeEnd}px"
|
|
109
|
+
{...rest}
|
|
110
|
+
{...attrs([styles.content, sx], className)}
|
|
111
|
+
{@attach measure}
|
|
112
|
+
{@attach roving({ selector: '[data-sidebar-row]' })}
|
|
113
|
+
>
|
|
114
|
+
<div>{@render children?.()}</div>
|
|
115
|
+
</nav>
|
|
116
|
+
{/if}
|
|
@@ -7,6 +7,12 @@ export type SidebarContentProps = Omit<HTMLAttributes<HTMLElement>, 'children'>
|
|
|
7
7
|
sx?: Sx | undefined;
|
|
8
8
|
/** Sidebar.Group and Sidebar.Item. */
|
|
9
9
|
children?: Snippet | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Groups held at the foot of the list, below what scrolls, such as shelves of settled
|
|
12
|
+
* threads. They are part of the same list: one tab stop, and the arrow keys run on into
|
|
13
|
+
* them. Opened, they take at most 40% of the height and scroll on their own.
|
|
14
|
+
*/
|
|
15
|
+
pinned?: Snippet | undefined;
|
|
10
16
|
};
|
|
11
17
|
declare const SidebarContent: import("svelte").Component<SidebarContentProps, {}, "">;
|
|
12
18
|
type SidebarContent = ReturnType<typeof SidebarContent>;
|