@diegopluna/narvi 0.5.1 → 0.5.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/dist/components/collapsible/CollapsibleRoot.svelte +7 -1
- package/dist/components/command/CommandDialog.svelte +20 -3
- package/dist/components/command/CommandStatus.svelte +15 -0
- package/dist/components/command/CommandStatus.svelte.d.ts +7 -0
- package/dist/components/command/index.d.ts +2 -4
- package/dist/components/command/index.js +1 -4
- package/dist/components/composer/ComposerModelPicker.svelte +3 -0
- package/dist/components/dialog/ConfirmDialog.svelte +7 -2
- package/dist/components/dialog/DialogContent.svelte +9 -2
- package/dist/components/dialog/DialogRoot.svelte +20 -2
- package/dist/components/dialog/styles.d.ts +3 -0
- package/dist/components/dialog/styles.js +5 -0
- package/dist/components/hover-card/HoverCardContent.svelte +7 -1
- package/dist/components/hover-card/HoverCardRoot.svelte +17 -1
- package/dist/components/menu/ContextMenuContent.svelte +11 -1
- package/dist/components/menu/MenuContent.svelte +7 -1
- package/dist/components/menu/MenuRoot.svelte +27 -0
- package/dist/components/menu/MenuRoot.svelte.d.ts +7 -0
- package/dist/components/menu/MenuSub.svelte +26 -0
- package/dist/components/menu/MenuSub.svelte.d.ts +7 -0
- package/dist/components/menu/context-menu.d.ts +2 -3
- package/dist/components/menu/context-menu.js +2 -4
- package/dist/components/menu/index.d.ts +4 -4
- package/dist/components/menu/index.js +2 -7
- package/dist/components/popover/PopoverContent.svelte +7 -1
- package/dist/components/popover/PopoverRoot.svelte +27 -0
- package/dist/components/popover/PopoverRoot.svelte.d.ts +7 -0
- package/dist/components/popover/index.d.ts +2 -3
- package/dist/components/popover/index.js +1 -5
- package/dist/components/select/Select.svelte +4 -1
- package/dist/components/sheet/SheetContent.svelte +8 -1
- package/dist/components/split-button/SplitButton.svelte +10 -1
- package/dist/components/tooltip/TooltipContent.svelte +7 -1
- package/dist/components/tooltip/TooltipRoot.svelte +12 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +4 -0
- package/dist/internal/popup.d.ts +24 -0
- package/dist/internal/popup.js +56 -0
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +4 -4
- package/skills/building-ui/references/components.md +23 -0
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +3 -1
- package/skills/styling/SKILL.md +1 -1
- package/skills/theming/SKILL.md +1 -1
|
@@ -38,8 +38,14 @@
|
|
|
38
38
|
});
|
|
39
39
|
</script>
|
|
40
40
|
|
|
41
|
+
<!-- `open` is written back only when the app has not followed (`internal/popup.ts`) -->
|
|
41
42
|
<Collapsible
|
|
42
|
-
bind:open
|
|
43
|
+
bind:open={
|
|
44
|
+
() => open,
|
|
45
|
+
(next) => {
|
|
46
|
+
if (open !== next) open = next;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
43
49
|
{...rest}
|
|
44
50
|
{...attrs([styles.root, sx], className)}
|
|
45
51
|
{@attach (element: HTMLElement) => {
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import { Dialog, DialogBackdrop, DialogContent, DialogTitle } from '@ui-sdk/svelte/dialog';
|
|
7
7
|
import * as stylex from '@stylexjs/stylex';
|
|
8
8
|
import type { Snippet } from 'svelte';
|
|
9
|
+
import { nestDialog, popupContainer } from '../../internal/popup.js';
|
|
9
10
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
11
|
+
import { dialog } from '../dialog/styles.js';
|
|
10
12
|
import { visuallyHidden } from '../../visually-hidden.js';
|
|
11
13
|
import { provideDialogLabel } from './context.js';
|
|
12
14
|
import { command } from './styles.js';
|
|
@@ -51,6 +53,9 @@
|
|
|
51
53
|
|
|
52
54
|
provideDialogLabel(() => label);
|
|
53
55
|
|
|
56
|
+
const container = popupContainer();
|
|
57
|
+
const nested = nestDialog();
|
|
58
|
+
|
|
54
59
|
// Heard on its way up to the document, where ui-sdk closes the dialog: an Escape the search
|
|
55
60
|
// used to clear itself comes prevented, and one the caller prevents here keeps it open. A
|
|
56
61
|
// menu open inside the palette, in a popover of its own, takes its own Escape.
|
|
@@ -62,9 +67,21 @@
|
|
|
62
67
|
};
|
|
63
68
|
</script>
|
|
64
69
|
|
|
65
|
-
<!--
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
<!--
|
|
71
|
+
In the top layer, in place unless the app gives a container. `open` is written back only when
|
|
72
|
+
the app has not followed (`internal/popup.ts`).
|
|
73
|
+
-->
|
|
74
|
+
<Dialog
|
|
75
|
+
bind:open={
|
|
76
|
+
() => open,
|
|
77
|
+
(next) => {
|
|
78
|
+
if (open !== next) open = next;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
container={container()}
|
|
82
|
+
onOpenChange={(next) => onopenchange?.(next)}
|
|
83
|
+
>
|
|
84
|
+
<DialogBackdrop {...stylex.attrs(command.overlay, nested && dialog.nested)} />
|
|
68
85
|
<DialogContent
|
|
69
86
|
finalFocus={restoreFocus ? undefined : 'none'}
|
|
70
87
|
onkeydown={escape}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { CommandStatus as UiCommandStatus } from '@ui-sdk/svelte/command';
|
|
4
|
+
|
|
5
|
+
// ui-sdk's part, with nothing to style, under props of its own names: ui-sdk's take any
|
|
6
|
+
// attribute at all, which would let a misspelled prop through (`internal/loose.ts`)
|
|
7
|
+
export interface CommandStatusProps extends Loose<PartProps<typeof UiCommandStatus>> {}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
let props: CommandStatusProps = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<!-- Says how many items are listed, or that they are loading, from the root's `status` -->
|
|
15
|
+
<UiCommandStatus {...props} />
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { CommandStatus as UiCommandStatus } from '@ui-sdk/svelte/command';
|
|
3
|
+
export interface CommandStatusProps extends Loose<PartProps<typeof UiCommandStatus>> {
|
|
4
|
+
}
|
|
5
|
+
declare const CommandStatus: import("svelte").Component<CommandStatusProps, {}, "">;
|
|
6
|
+
type CommandStatus = ReturnType<typeof CommandStatus>;
|
|
7
|
+
export default CommandStatus;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { CommandStatus } from '@ui-sdk/svelte/command';
|
|
2
|
-
import { type Loosened } from '../../internal/loose.js';
|
|
3
1
|
import Dialog from './CommandDialog.svelte';
|
|
4
2
|
import Empty from './CommandEmpty.svelte';
|
|
5
3
|
import Footer from './CommandFooter.svelte';
|
|
@@ -9,8 +7,7 @@ import Item from './CommandItem.svelte';
|
|
|
9
7
|
import List from './CommandList.svelte';
|
|
10
8
|
import Root from './CommandRoot.svelte';
|
|
11
9
|
import Separator from './CommandSeparator.svelte';
|
|
12
|
-
|
|
13
|
-
declare const Status: Loosened<typeof CommandStatus>;
|
|
10
|
+
import Status from './CommandStatus.svelte';
|
|
14
11
|
export { Dialog, Root, Input, List, Group, Item, Empty, Separator, Status, Footer };
|
|
15
12
|
export type { CommandDialogProps } from './CommandDialog.svelte';
|
|
16
13
|
export type { CommandEmptyProps } from './CommandEmpty.svelte';
|
|
@@ -21,3 +18,4 @@ export type { CommandItemProps } from './CommandItem.svelte';
|
|
|
21
18
|
export type { CommandListProps } from './CommandList.svelte';
|
|
22
19
|
export type { CommandRootProps } from './CommandRoot.svelte';
|
|
23
20
|
export type { CommandSeparatorProps } from './CommandSeparator.svelte';
|
|
21
|
+
export type { CommandStatusProps } from './CommandStatus.svelte';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { CommandStatus } from '@ui-sdk/svelte/command';
|
|
2
|
-
import { loose } from '../../internal/loose.js';
|
|
3
1
|
import Dialog from './CommandDialog.svelte';
|
|
4
2
|
import Empty from './CommandEmpty.svelte';
|
|
5
3
|
import Footer from './CommandFooter.svelte';
|
|
@@ -9,6 +7,5 @@ import Item from './CommandItem.svelte';
|
|
|
9
7
|
import List from './CommandList.svelte';
|
|
10
8
|
import Root from './CommandRoot.svelte';
|
|
11
9
|
import Separator from './CommandSeparator.svelte';
|
|
12
|
-
|
|
13
|
-
const Status = loose(CommandStatus);
|
|
10
|
+
import Status from './CommandStatus.svelte';
|
|
14
11
|
export { Dialog, Root, Input, List, Group, Item, Empty, Separator, Status, Footer };
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import Glyph from '../../internal/Glyph.svelte';
|
|
21
21
|
import type { IconComponent } from '../../internal/icon.js';
|
|
22
22
|
import '../../internal/icons.css';
|
|
23
|
+
import { popupContainer } from '../../internal/popup.js';
|
|
23
24
|
import { visuallyHidden } from '../../visually-hidden.js';
|
|
24
25
|
import { shared } from '../../internal/shared.js';
|
|
25
26
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
@@ -557,6 +558,7 @@
|
|
|
557
558
|
type Details = { reason: string; event?: Event | undefined; cancel: () => void };
|
|
558
559
|
|
|
559
560
|
const composer = getComposerContext();
|
|
561
|
+
const container = popupContainer();
|
|
560
562
|
|
|
561
563
|
let content = $state<HTMLElement | null>(null);
|
|
562
564
|
let field = $state<HTMLInputElement | null>(null);
|
|
@@ -886,6 +888,7 @@
|
|
|
886
888
|
multiple={several}
|
|
887
889
|
value={picked}
|
|
888
890
|
bind:open={() => open && !empty, setOpen}
|
|
891
|
+
container={container()}
|
|
889
892
|
bind:query
|
|
890
893
|
filter={false}
|
|
891
894
|
loop={false}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import { colors, density, font, space } from '../../tokens.stylex.js';
|
|
23
23
|
import Button from '../button/Button.svelte';
|
|
24
24
|
import Notice from '../notice/Notice.svelte';
|
|
25
|
+
import { nestDialog, popupContainer } from '../../internal/popup.js';
|
|
25
26
|
import { dialog } from './styles.js';
|
|
26
27
|
|
|
27
28
|
export type ConfirmDialogProps = {
|
|
@@ -105,6 +106,9 @@
|
|
|
105
106
|
children
|
|
106
107
|
}: ConfirmDialogProps = $props();
|
|
107
108
|
|
|
109
|
+
const container = popupContainer();
|
|
110
|
+
const nested = nestDialog();
|
|
111
|
+
|
|
108
112
|
let busy = $state(false);
|
|
109
113
|
// Whether the children rendered anything. A block of content always reaches the dialog as
|
|
110
114
|
// children, even one whose `{#if}` is false, and an empty body would leave a gap.
|
|
@@ -155,6 +159,7 @@
|
|
|
155
159
|
<!-- While the action runs, nothing but the action closes it: not Escape, not Cancel -->
|
|
156
160
|
<AlertDialog
|
|
157
161
|
bind:open
|
|
162
|
+
container={container()}
|
|
158
163
|
dismissible={!busy}
|
|
159
164
|
onOpenChange={(next, details) => {
|
|
160
165
|
if (busy && !next) details.cancel();
|
|
@@ -163,8 +168,8 @@
|
|
|
163
168
|
{#if trigger}
|
|
164
169
|
<AlertDialogTrigger render={trigger} />
|
|
165
170
|
{/if}
|
|
166
|
-
<!-- In
|
|
167
|
-
<AlertDialogBackdrop {...stylex.attrs(dialog.overlay)} />
|
|
171
|
+
<!-- In the top layer, in place unless the app gives a container -->
|
|
172
|
+
<AlertDialogBackdrop {...stylex.attrs(dialog.overlay, nested && dialog.nested)} />
|
|
168
173
|
<AlertDialogContent {...stylex.attrs(dialog.content, styles.content)}>
|
|
169
174
|
<div {...stylex.attrs(dialog.header, styles.header)}>
|
|
170
175
|
<AlertDialogTitle {...stylex.attrs(dialog.title)}>{title}</AlertDialogTitle>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { nestDialog, usePopupContainer } from '../../internal/popup.js';
|
|
3
4
|
import {
|
|
4
5
|
DialogBackdrop,
|
|
5
6
|
DialogClose,
|
|
@@ -41,16 +42,22 @@
|
|
|
41
42
|
side,
|
|
42
43
|
as = 'div',
|
|
43
44
|
closeLabel = 'Close',
|
|
45
|
+
container,
|
|
44
46
|
sx,
|
|
45
47
|
class: className,
|
|
46
48
|
children,
|
|
47
49
|
...rest
|
|
48
50
|
}: DialogContentProps = $props();
|
|
51
|
+
|
|
52
|
+
// In the container around it, or its own; the popups inside it follow
|
|
53
|
+
const target = usePopupContainer(() => container);
|
|
54
|
+
const nested = nestDialog();
|
|
49
55
|
</script>
|
|
50
56
|
|
|
51
|
-
<!-- In
|
|
52
|
-
<DialogBackdrop {...stylex.attrs(dialog.overlay)} />
|
|
57
|
+
<!-- In the top layer, in place unless given a container. The backdrop opens just below it. -->
|
|
58
|
+
<DialogBackdrop {...stylex.attrs(dialog.overlay, nested && dialog.nested)} />
|
|
53
59
|
<UiDialogContent
|
|
60
|
+
container={target()}
|
|
54
61
|
{...rest}
|
|
55
62
|
{...attrs(
|
|
56
63
|
[dialog.content, side ? [sheet.sheet, sheet.md, sheet[side]] : dialog[size], sx],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
3
|
import { Dialog } from '@ui-sdk/svelte/dialog';
|
|
4
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
4
5
|
|
|
5
6
|
// No `presentation`: ui-sdk's own sheet moves itself, where Narvi's content is placed and
|
|
6
7
|
// animated by its styles. `Sheet` is Narvi's sheet.
|
|
@@ -12,9 +13,26 @@
|
|
|
12
13
|
defaultOpen,
|
|
13
14
|
open = $bindable(defaultOpen ?? false),
|
|
14
15
|
persistentElements,
|
|
16
|
+
container,
|
|
15
17
|
...rest
|
|
16
18
|
}: DialogRootProps = $props();
|
|
19
|
+
|
|
20
|
+
// The root's container is the backdrop's as well as the content's
|
|
21
|
+
const target = usePopupContainer(() => container);
|
|
17
22
|
</script>
|
|
18
23
|
|
|
19
|
-
<!--
|
|
20
|
-
|
|
24
|
+
<!--
|
|
25
|
+
Behaviour only. ui-sdk's toast region stays above it and usable while it is open. `open` is
|
|
26
|
+
written back only when the app has not followed (`internal/popup.ts`).
|
|
27
|
+
-->
|
|
28
|
+
<Dialog
|
|
29
|
+
bind:open={
|
|
30
|
+
() => open,
|
|
31
|
+
(next) => {
|
|
32
|
+
if (open !== next) open = next;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
container={target()}
|
|
36
|
+
{persistentElements}
|
|
37
|
+
{...rest}
|
|
38
|
+
/>
|
|
@@ -9,6 +9,9 @@ export declare const dialog: Readonly<{
|
|
|
9
9
|
readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
|
|
10
10
|
readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
|
|
11
11
|
}>;
|
|
12
|
+
readonly nested: Readonly<{
|
|
13
|
+
readonly display: stylex.StyleXClassNameFor<"display", "none" | null>;
|
|
14
|
+
}>;
|
|
12
15
|
readonly content: Readonly<{
|
|
13
16
|
readonly position: stylex.StyleXClassNameFor<"position", "fixed">;
|
|
14
17
|
readonly insetInline: stylex.StyleXClassNameFor<"insetInline", 0>;
|
|
@@ -19,6 +19,11 @@ export const dialog = stylex.create({
|
|
|
19
19
|
transitionDuration: { default: motion.base, [CLOSED]: motion.fast },
|
|
20
20
|
transitionTimingFunction: motion.easeOut
|
|
21
21
|
},
|
|
22
|
+
// A dialog opened from another drops its backdrop as soon as it closes. ui-sdk swallows a
|
|
23
|
+
// press on the backdrop of a dialog on its way out, so a click on the scrim that closed it
|
|
24
|
+
// does not land on the page, but this one covers the dialog under it, whose controls would
|
|
25
|
+
// ignore presses until the exit had played. The scrim of the dialog under it stays.
|
|
26
|
+
nested: { display: { default: null, [CLOSED]: 'none' } },
|
|
22
27
|
// Centred, and never past the window: 2rem of margin, the body scrolls inside
|
|
23
28
|
content: {
|
|
24
29
|
position: 'fixed',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
3
4
|
import { HoverCardContent as UiHoverCardContent } from '@ui-sdk/svelte/hover-card';
|
|
4
5
|
import * as stylex from '@stylexjs/stylex';
|
|
5
6
|
import { density } from '../../tokens.stylex.js';
|
|
@@ -46,15 +47,20 @@
|
|
|
46
47
|
layout = 'block',
|
|
47
48
|
padding = 'default',
|
|
48
49
|
ref = $bindable(null),
|
|
50
|
+
container,
|
|
49
51
|
sx,
|
|
50
52
|
class: className,
|
|
51
53
|
children,
|
|
52
54
|
...rest
|
|
53
55
|
}: HoverCardContentProps = $props();
|
|
56
|
+
|
|
57
|
+
// In the container around it, or its own; the popups inside it follow
|
|
58
|
+
const target = usePopupContainer(() => container);
|
|
54
59
|
</script>
|
|
55
60
|
|
|
56
|
-
<!-- In
|
|
61
|
+
<!-- In the top layer, in place unless the app or the part gives a container -->
|
|
57
62
|
<UiHoverCardContent
|
|
63
|
+
container={target()}
|
|
58
64
|
{side}
|
|
59
65
|
{sideOffset}
|
|
60
66
|
{collisionPadding}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
3
|
import { HoverCard } from '@ui-sdk/svelte/hover-card';
|
|
4
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
4
5
|
|
|
5
6
|
export interface HoverCardRootProps extends Loose<PartProps<typeof HoverCard>> {}
|
|
6
7
|
</script>
|
|
@@ -13,11 +14,26 @@
|
|
|
13
14
|
open = $bindable(),
|
|
14
15
|
delay = 500,
|
|
15
16
|
closeDelay = 150,
|
|
17
|
+
container,
|
|
16
18
|
children,
|
|
17
19
|
...rest
|
|
18
20
|
}: HoverCardRootProps = $props();
|
|
21
|
+
|
|
22
|
+
const target = usePopupContainer(() => container);
|
|
19
23
|
</script>
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
<!-- `open` is written back only when the app has not followed (`internal/popup.ts`) -->
|
|
26
|
+
<HoverCard
|
|
27
|
+
bind:open={
|
|
28
|
+
() => open,
|
|
29
|
+
(next) => {
|
|
30
|
+
if (open !== next) open = next;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
container={target()}
|
|
34
|
+
{delay}
|
|
35
|
+
{closeDelay}
|
|
36
|
+
{...rest}
|
|
37
|
+
>
|
|
22
38
|
{@render children?.()}
|
|
23
39
|
</HoverCard>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
3
4
|
import { MenuContent } from '@ui-sdk/svelte/menu';
|
|
4
5
|
import * as stylex from '@stylexjs/stylex';
|
|
5
6
|
import type { Snippet } from 'svelte';
|
|
@@ -24,13 +25,22 @@
|
|
|
24
25
|
<script lang="ts">
|
|
25
26
|
let {
|
|
26
27
|
collisionPadding = 8,
|
|
28
|
+
container,
|
|
27
29
|
sx,
|
|
28
30
|
class: className,
|
|
29
31
|
children,
|
|
30
32
|
...rest
|
|
31
33
|
}: ContextMenuContentProps = $props();
|
|
34
|
+
|
|
35
|
+
// In the container around it, or its own; the popups inside it follow
|
|
36
|
+
const target = usePopupContainer(() => container);
|
|
32
37
|
</script>
|
|
33
38
|
|
|
34
|
-
<MenuContent
|
|
39
|
+
<MenuContent
|
|
40
|
+
{collisionPadding}
|
|
41
|
+
container={target()}
|
|
42
|
+
{...rest}
|
|
43
|
+
{...attrs([layer.surface, styles.width, sx], className)}
|
|
44
|
+
>
|
|
35
45
|
{@render children?.()}
|
|
36
46
|
</MenuContent>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
3
4
|
import { MenuContent as UiMenuContent } from '@ui-sdk/svelte/menu';
|
|
4
5
|
import type { Snippet } from 'svelte';
|
|
5
6
|
import { layer, widthStyle } from '../../internal/layer.js';
|
|
@@ -31,15 +32,20 @@
|
|
|
31
32
|
minWidth,
|
|
32
33
|
style,
|
|
33
34
|
align = 'start',
|
|
35
|
+
container,
|
|
34
36
|
sx,
|
|
35
37
|
class: className,
|
|
36
38
|
children,
|
|
37
39
|
...rest
|
|
38
40
|
}: MenuContentProps = $props();
|
|
41
|
+
|
|
42
|
+
// In the container around it, or its own; the popups inside it follow
|
|
43
|
+
const target = usePopupContainer(() => container);
|
|
39
44
|
</script>
|
|
40
45
|
|
|
41
|
-
<!-- In
|
|
46
|
+
<!-- In the top layer, in place unless the app or the part gives a container -->
|
|
42
47
|
<UiMenuContent
|
|
48
|
+
container={target()}
|
|
43
49
|
{sideOffset}
|
|
44
50
|
{collisionPadding}
|
|
45
51
|
{align}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { Menu } from '@ui-sdk/svelte/menu';
|
|
4
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
5
|
+
|
|
6
|
+
export interface MenuRootProps extends Loose<PartProps<typeof Menu>> {}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
let { open = $bindable(), container, children, ...rest }: MenuRootProps = $props();
|
|
11
|
+
|
|
12
|
+
const target = usePopupContainer(() => container);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<!-- Behaviour only. `open` is written back only when the app has not followed (`internal/popup.ts`). -->
|
|
16
|
+
<Menu
|
|
17
|
+
bind:open={
|
|
18
|
+
() => open,
|
|
19
|
+
(next) => {
|
|
20
|
+
if (open !== next) open = next;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
container={target()}
|
|
24
|
+
{...rest}
|
|
25
|
+
>
|
|
26
|
+
{@render children?.()}
|
|
27
|
+
</Menu>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { Menu } from '@ui-sdk/svelte/menu';
|
|
3
|
+
export interface MenuRootProps extends Loose<PartProps<typeof Menu>> {
|
|
4
|
+
}
|
|
5
|
+
declare const MenuRoot: import("svelte").Component<MenuRootProps, {}, "open">;
|
|
6
|
+
type MenuRoot = ReturnType<typeof MenuRoot>;
|
|
7
|
+
export default MenuRoot;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { MenuSub as UiMenuSub } from '@ui-sdk/svelte/menu';
|
|
4
|
+
|
|
5
|
+
export interface MenuSubProps extends Loose<PartProps<typeof UiMenuSub>> {}
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
let { open = $bindable(), children, ...rest }: MenuSubProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<!--
|
|
13
|
+
Behaviour only, in the container of the menu it is in. `open` is written back only when the app
|
|
14
|
+
has not followed (`internal/popup.ts`).
|
|
15
|
+
-->
|
|
16
|
+
<UiMenuSub
|
|
17
|
+
bind:open={
|
|
18
|
+
() => open,
|
|
19
|
+
(next) => {
|
|
20
|
+
if (open !== next) open = next;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
{@render children?.()}
|
|
26
|
+
</UiMenuSub>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { MenuSub as UiMenuSub } from '@ui-sdk/svelte/menu';
|
|
3
|
+
export interface MenuSubProps extends Loose<PartProps<typeof UiMenuSub>> {
|
|
4
|
+
}
|
|
5
|
+
declare const MenuSub: import("svelte").Component<MenuSubProps, {}, "open">;
|
|
6
|
+
type MenuSub = ReturnType<typeof MenuSub>;
|
|
7
|
+
export default MenuSub;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { Menu } from '@ui-sdk/svelte/menu';
|
|
2
|
-
import { type Loosened } from '../../internal/loose.js';
|
|
3
1
|
import Content from './ContextMenuContent.svelte';
|
|
2
|
+
import Root from './MenuRoot.svelte';
|
|
4
3
|
import Trigger from './ContextMenuTrigger.svelte';
|
|
5
4
|
/**
|
|
6
5
|
* A menu that opens over a region on right-click, or from the keyboard with
|
|
7
6
|
* Shift+F10 or the Menu key. Fill it with the parts of Menu: Menu.Item,
|
|
8
7
|
* Menu.Group, Menu.Separator and the rest.
|
|
9
8
|
*/
|
|
10
|
-
declare const Root: Loosened<typeof Menu>;
|
|
11
9
|
export { Root, Trigger, Content };
|
|
12
10
|
export type { ContextMenuContentProps } from './ContextMenuContent.svelte';
|
|
13
11
|
export type { ContextMenuTriggerProps } from './ContextMenuTrigger.svelte';
|
|
12
|
+
export type { MenuRootProps as ContextMenuRootProps } from './MenuRoot.svelte';
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { Menu } from '@ui-sdk/svelte/menu';
|
|
2
|
-
import { loose } from '../../internal/loose.js';
|
|
3
1
|
import Content from './ContextMenuContent.svelte';
|
|
2
|
+
import Root from './MenuRoot.svelte';
|
|
4
3
|
import Trigger from './ContextMenuTrigger.svelte';
|
|
5
4
|
/**
|
|
6
5
|
* A menu that opens over a region on right-click, or from the keyboard with
|
|
7
6
|
* Shift+F10 or the Menu key. Fill it with the parts of Menu: Menu.Item,
|
|
8
7
|
* Menu.Group, Menu.Separator and the rest.
|
|
9
8
|
*/
|
|
10
|
-
// One
|
|
11
|
-
const Root = loose(Menu);
|
|
9
|
+
// One Menu, opened from a context area rather than a button
|
|
12
10
|
export { Root, Trigger, Content };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Menu, MenuSub } from '@ui-sdk/svelte/menu';
|
|
2
|
-
import { type Loosened } from '../../internal/loose.js';
|
|
3
1
|
import CheckboxItem from './MenuCheckboxItem.svelte';
|
|
4
2
|
import Content from './MenuContent.svelte';
|
|
5
3
|
import Group from './MenuGroup.svelte';
|
|
@@ -7,12 +5,12 @@ import Item from './MenuItem.svelte';
|
|
|
7
5
|
import Label from './MenuLabel.svelte';
|
|
8
6
|
import RadioGroup from './MenuRadioGroup.svelte';
|
|
9
7
|
import RadioItem from './MenuRadioItem.svelte';
|
|
8
|
+
import Root from './MenuRoot.svelte';
|
|
10
9
|
import Separator from './MenuSeparator.svelte';
|
|
10
|
+
import Sub from './MenuSub.svelte';
|
|
11
11
|
import SubContent from './MenuSubContent.svelte';
|
|
12
12
|
import SubTrigger from './MenuSubTrigger.svelte';
|
|
13
13
|
import Trigger from './MenuTrigger.svelte';
|
|
14
|
-
declare const Root: Loosened<typeof Menu>;
|
|
15
|
-
declare const Sub: Loosened<typeof MenuSub>;
|
|
16
14
|
export { Root, Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, Group, Label, Separator, Sub, SubTrigger, SubContent };
|
|
17
15
|
export type { MenuCheckboxItemProps } from './MenuCheckboxItem.svelte';
|
|
18
16
|
export type { MenuContentProps } from './MenuContent.svelte';
|
|
@@ -21,7 +19,9 @@ export type { MenuItemProps } from './MenuItem.svelte';
|
|
|
21
19
|
export type { MenuLabelProps } from './MenuLabel.svelte';
|
|
22
20
|
export type { MenuRadioGroupProps } from './MenuRadioGroup.svelte';
|
|
23
21
|
export type { MenuRadioItemProps } from './MenuRadioItem.svelte';
|
|
22
|
+
export type { MenuRootProps } from './MenuRoot.svelte';
|
|
24
23
|
export type { MenuSeparatorProps } from './MenuSeparator.svelte';
|
|
24
|
+
export type { MenuSubProps } from './MenuSub.svelte';
|
|
25
25
|
export type { MenuSubContentProps } from './MenuSubContent.svelte';
|
|
26
26
|
export type { MenuSubTriggerProps } from './MenuSubTrigger.svelte';
|
|
27
27
|
export type { MenuTriggerProps } from './MenuTrigger.svelte';
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Menu, MenuSub } from '@ui-sdk/svelte/menu';
|
|
2
|
-
import { loose } from '../../internal/loose.js';
|
|
3
1
|
import CheckboxItem from './MenuCheckboxItem.svelte';
|
|
4
2
|
import Content from './MenuContent.svelte';
|
|
5
3
|
import Group from './MenuGroup.svelte';
|
|
@@ -7,13 +5,10 @@ import Item from './MenuItem.svelte';
|
|
|
7
5
|
import Label from './MenuLabel.svelte';
|
|
8
6
|
import RadioGroup from './MenuRadioGroup.svelte';
|
|
9
7
|
import RadioItem from './MenuRadioItem.svelte';
|
|
8
|
+
import Root from './MenuRoot.svelte';
|
|
10
9
|
import Separator from './MenuSeparator.svelte';
|
|
10
|
+
import Sub from './MenuSub.svelte';
|
|
11
11
|
import SubContent from './MenuSubContent.svelte';
|
|
12
12
|
import SubTrigger from './MenuSubTrigger.svelte';
|
|
13
13
|
import Trigger from './MenuTrigger.svelte';
|
|
14
|
-
// Behaviour only, with nothing to style: ui-sdk's own parts, typed to take `undefined` for
|
|
15
|
-
// each optional prop (`internal/loose.ts`). Their type is named, so svelte-package writes
|
|
16
|
-
// this module's declarations (it leaves them out without a word on TS2883).
|
|
17
|
-
const Root = loose(Menu);
|
|
18
|
-
const Sub = loose(MenuSub);
|
|
19
14
|
export { Root, Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, Group, Label, Separator, Sub, SubTrigger, SubContent };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
3
4
|
import { PopoverContent as UiPopoverContent } from '@ui-sdk/svelte/popover';
|
|
4
5
|
import * as stylex from '@stylexjs/stylex';
|
|
5
6
|
import { density } from '../../tokens.stylex.js';
|
|
@@ -47,15 +48,20 @@
|
|
|
47
48
|
layout = 'block',
|
|
48
49
|
width,
|
|
49
50
|
style,
|
|
51
|
+
container,
|
|
50
52
|
sx,
|
|
51
53
|
class: className,
|
|
52
54
|
children,
|
|
53
55
|
...rest
|
|
54
56
|
}: PopoverContentProps = $props();
|
|
57
|
+
|
|
58
|
+
// In the container around it, or its own; the popups inside it follow
|
|
59
|
+
const target = usePopupContainer(() => container);
|
|
55
60
|
</script>
|
|
56
61
|
|
|
57
|
-
<!-- In
|
|
62
|
+
<!-- In the top layer, in place unless the app or the part gives a container -->
|
|
58
63
|
<UiPopoverContent
|
|
64
|
+
container={target()}
|
|
59
65
|
{sideOffset}
|
|
60
66
|
{collisionPadding}
|
|
61
67
|
{align}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { Popover } from '@ui-sdk/svelte/popover';
|
|
4
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
5
|
+
|
|
6
|
+
export interface PopoverRootProps extends Loose<PartProps<typeof Popover>> {}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
let { open = $bindable(), container, children, ...rest }: PopoverRootProps = $props();
|
|
11
|
+
|
|
12
|
+
const target = usePopupContainer(() => container);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<!-- Behaviour only. `open` is written back only when the app has not followed (`internal/popup.ts`). -->
|
|
16
|
+
<Popover
|
|
17
|
+
bind:open={
|
|
18
|
+
() => open,
|
|
19
|
+
(next) => {
|
|
20
|
+
if (open !== next) open = next;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
container={target()}
|
|
24
|
+
{...rest}
|
|
25
|
+
>
|
|
26
|
+
{@render children?.()}
|
|
27
|
+
</Popover>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { Popover } from '@ui-sdk/svelte/popover';
|
|
3
|
+
export interface PopoverRootProps extends Loose<PartProps<typeof Popover>> {
|
|
4
|
+
}
|
|
5
|
+
declare const PopoverRoot: import("svelte").Component<PopoverRootProps, {}, "open">;
|
|
6
|
+
type PopoverRoot = ReturnType<typeof PopoverRoot>;
|
|
7
|
+
export default PopoverRoot;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Popover } from '@ui-sdk/svelte/popover';
|
|
2
|
-
import { type Loosened } from '../../internal/loose.js';
|
|
3
1
|
import Close from './PopoverClose.svelte';
|
|
4
2
|
import Content from './PopoverContent.svelte';
|
|
3
|
+
import Root from './PopoverRoot.svelte';
|
|
5
4
|
import Trigger from './PopoverTrigger.svelte';
|
|
6
|
-
declare const Root: Loosened<typeof Popover>;
|
|
7
5
|
export { Root, Trigger, Content, Close };
|
|
8
6
|
export type { PopoverCloseProps } from './PopoverClose.svelte';
|
|
9
7
|
export type { PopoverContentProps } from './PopoverContent.svelte';
|
|
8
|
+
export type { PopoverRootProps } from './PopoverRoot.svelte';
|
|
10
9
|
export type { PopoverTriggerProps } from './PopoverTrigger.svelte';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { Popover } from '@ui-sdk/svelte/popover';
|
|
2
|
-
import { loose } from '../../internal/loose.js';
|
|
3
1
|
import Close from './PopoverClose.svelte';
|
|
4
2
|
import Content from './PopoverContent.svelte';
|
|
3
|
+
import Root from './PopoverRoot.svelte';
|
|
5
4
|
import Trigger from './PopoverTrigger.svelte';
|
|
6
|
-
// Behaviour only, with nothing to style: ui-sdk's own part, typed to take `undefined` for each
|
|
7
|
-
// optional prop (`internal/loose.ts`)
|
|
8
|
-
const Root = loose(Popover);
|
|
9
5
|
export { Root, Trigger, Content, Close };
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import Glyph from '../../internal/Glyph.svelte';
|
|
19
19
|
import { control, type ControlSize } from '../../internal/control.js';
|
|
20
20
|
import { layer } from '../../internal/layer.js';
|
|
21
|
+
import { popupContainer } from '../../internal/popup.js';
|
|
21
22
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
22
23
|
import { colors, font } from '../../tokens.stylex.js';
|
|
23
24
|
import { getFieldContext } from '../field/context.js';
|
|
@@ -171,6 +172,7 @@
|
|
|
171
172
|
}: SelectProps = $props();
|
|
172
173
|
|
|
173
174
|
const field = getFieldContext();
|
|
175
|
+
const container = popupContainer();
|
|
174
176
|
const selected = $derived(options.find((option) => option.value === value));
|
|
175
177
|
const groups = $derived(grouped(options));
|
|
176
178
|
const detailed = $derived(options.some((option) => option.detail));
|
|
@@ -180,6 +182,7 @@
|
|
|
180
182
|
items={listed(groups)}
|
|
181
183
|
bind:value={() => value ?? null, (next) => (value = next ?? undefined)}
|
|
182
184
|
bind:open={() => open && options.length > 0, (next) => (open = next && options.length > 0)}
|
|
185
|
+
container={container()}
|
|
183
186
|
onValueChange={(next) => {
|
|
184
187
|
if (next !== null) onchange?.(next);
|
|
185
188
|
}}
|
|
@@ -205,7 +208,7 @@
|
|
|
205
208
|
</span>
|
|
206
209
|
<span {...stylex.attrs(styles.selector)}><Glyph name="selector" size={14} /></span>
|
|
207
210
|
</SelectTrigger>
|
|
208
|
-
<!-- In
|
|
211
|
+
<!-- In the top layer, in place unless the app gives a container. The list scrolls in the surface. With
|
|
209
212
|
no options it stays shut, rather than open as an empty sliver. -->
|
|
210
213
|
<SelectContent {align} sideOffset={6} collisionPadding={8} {...stylex.attrs(layer.surface)}>
|
|
211
214
|
{#each groups as group, index (index)}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { nestDialog, usePopupContainer } from '../../internal/popup.js';
|
|
3
4
|
import { DialogBackdrop, DialogClose, DialogContent } from '@ui-sdk/svelte/dialog';
|
|
4
5
|
import * as stylex from '@stylexjs/stylex';
|
|
5
6
|
import type { Snippet } from 'svelte';
|
|
@@ -41,12 +42,17 @@
|
|
|
41
42
|
closeLabel = 'Close',
|
|
42
43
|
focusOnOpen = 'sheet',
|
|
43
44
|
initialFocus,
|
|
45
|
+
container,
|
|
44
46
|
sx,
|
|
45
47
|
class: className,
|
|
46
48
|
children,
|
|
47
49
|
...rest
|
|
48
50
|
}: SheetContentProps = $props();
|
|
49
51
|
|
|
52
|
+
// In the container around it, or its own; the popups inside it follow
|
|
53
|
+
const target = usePopupContainer(() => container);
|
|
54
|
+
const nested = nestDialog();
|
|
55
|
+
|
|
50
56
|
const across = $derived(side === 'start' || side === 'end');
|
|
51
57
|
</script>
|
|
52
58
|
|
|
@@ -54,8 +60,9 @@
|
|
|
54
60
|
A dialog along an edge, on ui-sdk's Dialog rather than its Drawer: a drawer moves itself, by
|
|
55
61
|
drag and snap points, where a sheet slides in on Narvi's own transition and stays put.
|
|
56
62
|
-->
|
|
57
|
-
<DialogBackdrop {...stylex.attrs(dialog.overlay)} />
|
|
63
|
+
<DialogBackdrop {...stylex.attrs(dialog.overlay, nested && dialog.nested)} />
|
|
58
64
|
<DialogContent
|
|
65
|
+
container={target()}
|
|
59
66
|
data-side={side}
|
|
60
67
|
initialFocus={initialFocus ?? (focusOnOpen === 'first' ? 'auto' : 'content')}
|
|
61
68
|
{...rest}
|
|
@@ -183,7 +183,16 @@
|
|
|
183
183
|
<span {...stylex.attrs(styles.label)}>{@render children?.()}</span>
|
|
184
184
|
</Button>
|
|
185
185
|
{#if menu}
|
|
186
|
-
|
|
186
|
+
<!-- `open` is written back only when the app has not followed (`internal/popup.ts`) -->
|
|
187
|
+
<Menu.Root
|
|
188
|
+
bind:open={
|
|
189
|
+
() => open,
|
|
190
|
+
(next) => {
|
|
191
|
+
if (open !== next) open = next;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
onOpenChange={onopenchange}
|
|
195
|
+
>
|
|
187
196
|
<Menu.Trigger disabled={disabled || loading}>
|
|
188
197
|
{#snippet child({ props })}
|
|
189
198
|
<Button
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
3
4
|
import { TooltipContent as UiTooltipContent } from '@ui-sdk/svelte/tooltip';
|
|
4
5
|
import * as stylex from '@stylexjs/stylex';
|
|
5
6
|
import type { Snippet } from 'svelte';
|
|
@@ -83,16 +84,21 @@
|
|
|
83
84
|
collisionPadding = 8,
|
|
84
85
|
shortcut,
|
|
85
86
|
layout = 'row',
|
|
87
|
+
container,
|
|
86
88
|
sx,
|
|
87
89
|
class: className,
|
|
88
90
|
children,
|
|
89
91
|
...rest
|
|
90
92
|
}: TooltipContentProps = $props();
|
|
93
|
+
|
|
94
|
+
// In the container around it, or its own; the popups inside it follow
|
|
95
|
+
const target = usePopupContainer(() => container);
|
|
91
96
|
</script>
|
|
92
97
|
|
|
93
|
-
<!-- In
|
|
98
|
+
<!-- In the top layer, in place unless given a container, and in the page while closed, hidden, so it names or describes
|
|
94
99
|
its trigger before focus reaches it -->
|
|
95
100
|
<UiTooltipContent
|
|
101
|
+
container={target()}
|
|
96
102
|
{sideOffset}
|
|
97
103
|
{collisionPadding}
|
|
98
104
|
{...rest}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { setContext, type Snippet } from 'svelte';
|
|
5
5
|
import { arrivedByKeyboard, listenForNavigation } from './intent.js';
|
|
6
6
|
import { tooltipDefaults } from './TooltipProvider.svelte';
|
|
7
|
+
import { usePopupContainer } from '../../internal/popup.js';
|
|
7
8
|
|
|
8
9
|
export interface TooltipRootProps extends Loose<
|
|
9
10
|
Omit<PartProps<typeof Tooltip>, 'children'> & {
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
disabled,
|
|
38
39
|
type = 'description',
|
|
39
40
|
onOpenChange,
|
|
41
|
+
container,
|
|
40
42
|
children,
|
|
41
43
|
...rest
|
|
42
44
|
}: TooltipRootProps = $props();
|
|
@@ -47,10 +49,19 @@
|
|
|
47
49
|
|
|
48
50
|
let triggerDisabled = $state.raw<() => boolean>(() => false);
|
|
49
51
|
setContext<TriggerRegistry>(TRIGGER_KEY, (get) => (triggerDisabled = get));
|
|
52
|
+
|
|
53
|
+
const target = usePopupContainer(() => container);
|
|
50
54
|
</script>
|
|
51
55
|
|
|
56
|
+
<!-- `open` is written back only when the app has not followed (`internal/popup.ts`) -->
|
|
52
57
|
<Tooltip
|
|
53
|
-
bind:open
|
|
58
|
+
bind:open={
|
|
59
|
+
() => open,
|
|
60
|
+
(next) => {
|
|
61
|
+
if (open !== next) open = next;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
container={target()}
|
|
54
65
|
delay={delay ?? provided?.delay}
|
|
55
66
|
closeDelay={closeDelay ?? provided?.closeDelay}
|
|
56
67
|
disabled={(disabled ?? provided?.disabled ?? false) || triggerDisabled()}
|
package/dist/index.d.ts
CHANGED
|
@@ -30,12 +30,12 @@ export type { ColorFieldLabels, ColorFieldProps, ColorFieldSize } from './compon
|
|
|
30
30
|
export * as Collapsible from './components/collapsible/index.js';
|
|
31
31
|
export type { CollapsibleContentProps, CollapsibleRootProps, CollapsibleTriggerProps } from './components/collapsible/index.js';
|
|
32
32
|
export * as Command from './components/command/index.js';
|
|
33
|
-
export type { CommandDialogProps, CommandEmptyProps, CommandFooterProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandRootProps, CommandSeparatorProps } from './components/command/index.js';
|
|
33
|
+
export type { CommandDialogProps, CommandEmptyProps, CommandFooterProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandRootProps, CommandSeparatorProps, CommandStatusProps } from './components/command/index.js';
|
|
34
34
|
export * as Composer from './components/composer/index.js';
|
|
35
35
|
export { getComposerContext } from './components/composer/index.js';
|
|
36
36
|
export type { ComposerAttachButtonProps, ComposerAttachmentProps, ComposerAttachmentsProps, ComposerContext, ComposerMessage, ComposerModel, ComposerModelPickerProps, ComposerModelProvider, ComposerRejection, ComposerRootProps, ComposerStatus, ComposerSubmitProps, ComposerTextareaProps, ComposerToggleProps, ComposerToolbarProps, ComposerTrayProps } from './components/composer/index.js';
|
|
37
37
|
export * as ContextMenu from './components/menu/context-menu.js';
|
|
38
|
-
export type { ContextMenuContentProps, ContextMenuTriggerProps } from './components/menu/context-menu.js';
|
|
38
|
+
export type { ContextMenuContentProps, ContextMenuRootProps, ContextMenuTriggerProps } from './components/menu/context-menu.js';
|
|
39
39
|
export * as Conversation from './components/conversation/index.js';
|
|
40
40
|
export { getConversationContext } from './components/conversation/index.js';
|
|
41
41
|
export type { ConversationContentProps, ConversationContext, ConversationMode, ConversationEmptyProps, ConversationRootProps, ConversationScrollButtonProps } from './components/conversation/index.js';
|
|
@@ -67,7 +67,7 @@ export type { KbdProps } from './components/kbd/Kbd.svelte';
|
|
|
67
67
|
export { default as Link } from './components/link/Link.svelte';
|
|
68
68
|
export type { LinkProps } from './components/link/Link.svelte';
|
|
69
69
|
export * as Menu from './components/menu/index.js';
|
|
70
|
-
export type { MenuCheckboxItemProps, MenuContentProps, MenuGroupProps, MenuItemProps, MenuLabelProps, MenuRadioGroupProps, MenuRadioItemProps, MenuSeparatorProps, MenuSubContentProps, MenuSubTriggerProps, MenuTriggerProps } from './components/menu/index.js';
|
|
70
|
+
export type { MenuCheckboxItemProps, MenuContentProps, MenuGroupProps, MenuItemProps, MenuLabelProps, MenuRadioGroupProps, MenuRadioItemProps, MenuRootProps, MenuSeparatorProps, MenuSubProps, MenuSubContentProps, MenuSubTriggerProps, MenuTriggerProps } from './components/menu/index.js';
|
|
71
71
|
export * as Message from './components/message/index.js';
|
|
72
72
|
export type { MessageActionProps, MessageActionsProps, MessageBubbleProps, MessageContentProps, MessageCopyProps, MessageFrom, MessageHeaderProps, MessagePendingProps, MessageRootProps, MessageTextSize, MessageTimeProps } from './components/message/index.js';
|
|
73
73
|
export { default as Markdown } from './components/markdown/Markdown.svelte';
|
|
@@ -84,7 +84,7 @@ export type { PlanProps, PlanStep, PlanStepStatus } from './components/plan/Plan
|
|
|
84
84
|
export { default as Progress } from './components/progress/Progress.svelte';
|
|
85
85
|
export type { ProgressProps } from './components/progress/Progress.svelte';
|
|
86
86
|
export * as Popover from './components/popover/index.js';
|
|
87
|
-
export type { PopoverCloseProps, PopoverContentProps, PopoverTriggerProps } from './components/popover/index.js';
|
|
87
|
+
export type { PopoverCloseProps, PopoverContentProps, PopoverRootProps, PopoverTriggerProps } from './components/popover/index.js';
|
|
88
88
|
export { default as Questionnaire } from './components/questionnaire/Questionnaire.svelte';
|
|
89
89
|
export type { Question, QuestionAnswer, QuestionnaireAnswers, QuestionnaireProps } from './components/questionnaire/Questionnaire.svelte';
|
|
90
90
|
export { default as QueuedMessage } from './components/queued-message/QueuedMessage.svelte';
|
|
@@ -170,6 +170,8 @@ export type { ThemeOverrides, ThemeProps, ThemeScheme } from './components/theme
|
|
|
170
170
|
export { default as WorkFold } from './components/work-fold/WorkFold.svelte';
|
|
171
171
|
export type { WorkFoldProps } from './components/work-fold/WorkFold.svelte';
|
|
172
172
|
export { setPageHidden, whileVisible } from './internal/visible.js';
|
|
173
|
+
export { providePopupContainer } from './internal/popup.js';
|
|
174
|
+
export type { PopupContainer } from './internal/popup.js';
|
|
173
175
|
export { resolveColor, resolveRgba } from './color.js';
|
|
174
176
|
export type { ResolveColorOptions, Rgba } from './color.js';
|
|
175
177
|
export { classes, sx } from './internal/sx.js';
|
package/dist/index.js
CHANGED
|
@@ -133,6 +133,10 @@ export { default as WorkFold } from './components/work-fold/WorkFold.svelte';
|
|
|
133
133
|
// Skeleton, Progress and Markdown's caret use it. `setPageHidden` is the host's word that the
|
|
134
134
|
// page is out of sight where the document cannot tell, such as a minimized Electron window.
|
|
135
135
|
export { setPageHidden, whileVisible } from './internal/visible.js';
|
|
136
|
+
// Where popups render: in place by default. `providePopupContainer(() => document.body)` in the
|
|
137
|
+
// root layout's script renders every menu, popover, select, card, tooltip, dialog and sheet
|
|
138
|
+
// inside it there, out of a text editor or a clickable row that would take their text and presses.
|
|
139
|
+
export { providePopupContainer } from './internal/popup.js';
|
|
136
140
|
// The colour a token paints as, for a <canvas>, WebGL or a chart library, which
|
|
137
141
|
// cannot read `var()` or `light-dark()` themselves.
|
|
138
142
|
export { resolveColor, resolveRgba } from './color.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** An element a popup renders into, or nothing, for in place. */
|
|
2
|
+
export type PopupContainer = Element | DocumentFragment | null | undefined;
|
|
3
|
+
type Getter = () => PopupContainer;
|
|
4
|
+
/**
|
|
5
|
+
* Renders every Narvi popup inside the calling component into `container` rather than in place:
|
|
6
|
+
* menus, popovers, selects, hover cards, tooltips, dialogs and sheets. Call it in the script of
|
|
7
|
+
* the app's root layout, with a getter where the element exists only in the browser:
|
|
8
|
+
* `providePopupContainer(() => document.body)`. A popup's own `container`, on its root or its
|
|
9
|
+
* content, still wins, and the popups inside it follow it there.
|
|
10
|
+
*/
|
|
11
|
+
export declare function providePopupContainer(container: PopupContainer | Getter): void;
|
|
12
|
+
/**
|
|
13
|
+
* The container a root or a content renders into: its own `container`, else the nearest one
|
|
14
|
+
* around it. Handed on to the popups inside it. Call it in the component's script.
|
|
15
|
+
*/
|
|
16
|
+
export declare function usePopupContainer(own: () => PopupContainer): Getter;
|
|
17
|
+
/** The container around a component that renders a ui-sdk root and its content itself. */
|
|
18
|
+
export declare function popupContainer(): Getter;
|
|
19
|
+
/**
|
|
20
|
+
* Marks what is inside a dialog's content as inside a dialog, and says whether this content is
|
|
21
|
+
* itself inside another. Call it in a dialog content's script.
|
|
22
|
+
*/
|
|
23
|
+
export declare function nestDialog(): boolean;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every popup root and content shares: where it renders, and whether it sits in a dialog.
|
|
3
|
+
*
|
|
4
|
+
* ui-sdk renders a popup in place, in the browser's top layer. Its element stays where it was
|
|
5
|
+
* declared in the document, so inside a text editor its text is the editor's, and inside a
|
|
6
|
+
* clickable row a press on it is a press on the row. ui-sdk takes a `container` per root and per
|
|
7
|
+
* content, and hands one down to the popups inside, but keeps the function that sets one for a
|
|
8
|
+
* whole tree to itself. `providePopupContainer` is Narvi's: each root and content reads it and
|
|
9
|
+
* passes it on as its `container`, under one of its own.
|
|
10
|
+
*
|
|
11
|
+
* Each root also binds ui-sdk's `open` with a setter that reads its own `open` first, and writes
|
|
12
|
+
* only when it differs. ui-sdk calls `onOpenChange` before it writes, so an app that keeps `open`
|
|
13
|
+
* in its own state (`open={shown && !dragging}` with an `onOpenChange` that sets `shown`) has
|
|
14
|
+
* followed already. Writing anyway would shadow the app's value with Svelte's local copy of the
|
|
15
|
+
* prop, and when the app's expression came back to what Svelte last read, no change would reach
|
|
16
|
+
* the popup: opened by its trigger, it could never be closed by the app again.
|
|
17
|
+
*/
|
|
18
|
+
import { getContext, setContext } from 'svelte';
|
|
19
|
+
const CONTAINER = Symbol('narvi.popup-container');
|
|
20
|
+
const IN_DIALOG = Symbol('narvi.in-dialog');
|
|
21
|
+
/**
|
|
22
|
+
* Renders every Narvi popup inside the calling component into `container` rather than in place:
|
|
23
|
+
* menus, popovers, selects, hover cards, tooltips, dialogs and sheets. Call it in the script of
|
|
24
|
+
* the app's root layout, with a getter where the element exists only in the browser:
|
|
25
|
+
* `providePopupContainer(() => document.body)`. A popup's own `container`, on its root or its
|
|
26
|
+
* content, still wins, and the popups inside it follow it there.
|
|
27
|
+
*/
|
|
28
|
+
export function providePopupContainer(container) {
|
|
29
|
+
const own = typeof container === 'function' ? container : () => container;
|
|
30
|
+
const around = getContext(CONTAINER);
|
|
31
|
+
setContext(CONTAINER, () => own() ?? around?.());
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The container a root or a content renders into: its own `container`, else the nearest one
|
|
35
|
+
* around it. Handed on to the popups inside it. Call it in the component's script.
|
|
36
|
+
*/
|
|
37
|
+
export function usePopupContainer(own) {
|
|
38
|
+
const around = getContext(CONTAINER);
|
|
39
|
+
const target = () => own() ?? around?.();
|
|
40
|
+
setContext(CONTAINER, target);
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
43
|
+
/** The container around a component that renders a ui-sdk root and its content itself. */
|
|
44
|
+
export function popupContainer() {
|
|
45
|
+
const around = getContext(CONTAINER);
|
|
46
|
+
return () => around?.();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Marks what is inside a dialog's content as inside a dialog, and says whether this content is
|
|
50
|
+
* itself inside another. Call it in a dialog content's script.
|
|
51
|
+
*/
|
|
52
|
+
export function nestDialog() {
|
|
53
|
+
const nested = getContext(IN_DIALOG) ?? false;
|
|
54
|
+
setContext(IN_DIALOG, true);
|
|
55
|
+
return nested;
|
|
56
|
+
}
|
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.5.
|
|
15
|
+
library_version: '0.5.2'
|
|
16
16
|
requires:
|
|
17
17
|
- setup
|
|
18
18
|
sources:
|
|
@@ -47,6 +47,7 @@ sources:
|
|
|
47
47
|
- src/lib/components/tooltip/TooltipProvider.svelte
|
|
48
48
|
- src/lib/components/command/*.svelte
|
|
49
49
|
- src/lib/components/menu/MenuContent.svelte
|
|
50
|
+
- src/lib/internal/popup.ts
|
|
50
51
|
---
|
|
51
52
|
|
|
52
53
|
# Build interfaces with Narvi
|
|
@@ -409,9 +410,8 @@ Parts of the shell that are easy to redraw by hand, and shouldn't be:
|
|
|
409
410
|
`hideCovered`, `edgeLabel` and `edgeTitle` see the [catalogue](references/components.md#panels).
|
|
410
411
|
- **A palette** is `Command.Root`: don't work round its keys, highlight, footer or field by hand
|
|
411
412
|
(the [catalogue](references/components.md#palettes) says what each does).
|
|
412
|
-
- **A Sheet** focuses itself as it opens (`focusOnOpen="sheet"`), so a Rail or a list in it
|
|
413
|
-
|
|
414
|
-
holds a form.
|
|
413
|
+
- **A Sheet** focuses itself as it opens (`focusOnOpen="sheet"`), so a Rail or a list in it shows
|
|
414
|
+
no focus ring until the keys move in. Pass `focusOnOpen="first"` for a sheet that holds a form.
|
|
415
415
|
- `AppShell.Header` draws a line under itself; `divider={false}` leaves it out where the page
|
|
416
416
|
runs on under the header; an `AppShell.Strip` in it runs its height, for a notch TabStrip.
|
|
417
417
|
|
|
@@ -160,6 +160,29 @@ a closed one in the page. Change callbacks get `(value, details)`: `details.reas
|
|
|
160
160
|
`details.cancel()` refuses it. A popup's room is `--available-height`, `--available-width` and
|
|
161
161
|
`--anchor-width`.
|
|
162
162
|
|
|
163
|
+
In place means the popup's element stays where it is declared: inside a text editor its text is
|
|
164
|
+
the editor's, and inside a clickable row a press on it is a press on the row. Render them all out
|
|
165
|
+
of it with `providePopupContainer` in the root layout's script, as a getter so it runs only in the
|
|
166
|
+
browser; a `container` on a Root or a Content still wins, and the popups inside follow it:
|
|
167
|
+
|
|
168
|
+
```svelte
|
|
169
|
+
<script lang="ts">
|
|
170
|
+
import { providePopupContainer } from '@diegopluna/narvi';
|
|
171
|
+
|
|
172
|
+
let { children } = $props();
|
|
173
|
+
providePopupContainer(() => document.body);
|
|
174
|
+
</script>
|
|
175
|
+
|
|
176
|
+
{@render children()}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
To drive `open` from the app, bind it, or pass it with an `onOpenChange` that keeps your state:
|
|
180
|
+
`open={shown && !dragging} onOpenChange={(next) => (shown = next)}` follows `dragging` even after
|
|
181
|
+
the trigger opened it. An `open` passed with neither is only where it starts, as any Svelte prop
|
|
182
|
+
is. Import popups from Narvi rather than `@ui-sdk/svelte`: ui-sdk's own parts take a prop of any
|
|
183
|
+
name, so a misspelled or renamed one (`openDelay` for `delay`) passes svelte-check and does
|
|
184
|
+
nothing; Narvi's name theirs.
|
|
185
|
+
|
|
163
186
|
| Component | Use it for | Docs slug |
|
|
164
187
|
| --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
|
|
165
188
|
| `Dialog.Root`, `.Trigger`, `.Content` (`size`, `side`, `as`), `.Header`, `.Title`, `.Description`, `.Body`, `.Footer`, `.Close` | A focused task over the page | `dialog` |
|
package/skills/markdown/SKILL.md
CHANGED
package/skills/setup/SKILL.md
CHANGED
|
@@ -11,7 +11,7 @@ metadata:
|
|
|
11
11
|
4 when the app uses it.
|
|
12
12
|
type: lifecycle
|
|
13
13
|
library: '@diegopluna/narvi'
|
|
14
|
-
library_version: '0.5.
|
|
14
|
+
library_version: '0.5.2'
|
|
15
15
|
sources:
|
|
16
16
|
- src/lib/vite.ts
|
|
17
17
|
- src/lib/base.css
|
|
@@ -130,6 +130,8 @@ Narvi lists both naming styles, so neither needs a theme override.
|
|
|
130
130
|
Narvi's types work with `exactOptionalPropertyTypes`. Every optional prop takes `undefined`, so
|
|
131
131
|
`<Notice detail={maybe}>` and `<Tooltip.Content side={maybe}>` type-check as they are, with no
|
|
132
132
|
need to spread a prop only when it is set. That holds for the parts Narvi takes from ui-sdk too.
|
|
133
|
+
Every part names its props, so a misspelled or renamed one is a type error; ui-sdk's own parts,
|
|
134
|
+
imported from `@ui-sdk/svelte`, take a prop of any name and let it through.
|
|
133
135
|
|
|
134
136
|
## With Tailwind CSS 4
|
|
135
137
|
|
package/skills/styling/SKILL.md
CHANGED
package/skills/theming/SKILL.md
CHANGED