@diegopluna/narvi 0.4.0 → 0.5.0
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/base.css +3 -0
- package/dist/components/button/Button.svelte +29 -17
- package/dist/components/checkbox/Checkbox.svelte +106 -54
- package/dist/components/checkbox/Checkbox.svelte.d.ts +22 -8
- package/dist/components/choice-cards/ChoiceCards.svelte +68 -39
- package/dist/components/choice-cards/ChoiceCards.svelte.d.ts +12 -8
- package/dist/components/collapsible/CollapsibleContent.svelte +71 -17
- package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +14 -10
- package/dist/components/collapsible/CollapsibleRoot.svelte +13 -9
- package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +8 -9
- package/dist/components/collapsible/CollapsibleTrigger.svelte +24 -15
- package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +10 -14
- package/dist/components/color-field/ColorField.svelte +13 -7
- package/dist/components/command/CommandDialog.svelte +30 -20
- package/dist/components/command/CommandDialog.svelte.d.ts +4 -3
- package/dist/components/command/CommandEmpty.svelte +11 -9
- package/dist/components/command/CommandEmpty.svelte.d.ts +6 -17
- package/dist/components/command/CommandGroup.svelte +32 -11
- package/dist/components/command/CommandGroup.svelte.d.ts +7 -11
- package/dist/components/command/CommandInput.svelte +25 -10
- package/dist/components/command/CommandInput.svelte.d.ts +8 -12
- package/dist/components/command/CommandItem.svelte +67 -29
- package/dist/components/command/CommandItem.svelte.d.ts +6 -32
- package/dist/components/command/CommandList.svelte +8 -10
- package/dist/components/command/CommandList.svelte.d.ts +6 -8
- package/dist/components/command/CommandRoot.svelte +247 -57
- package/dist/components/command/CommandRoot.svelte.d.ts +14 -28
- package/dist/components/command/CommandSeparator.svelte +18 -0
- package/dist/components/command/CommandSeparator.svelte.d.ts +7 -0
- package/dist/components/command/context.d.ts +27 -0
- package/dist/components/command/context.js +16 -0
- package/dist/components/command/index.d.ts +6 -4
- package/dist/components/command/index.js +5 -4
- package/dist/components/command/score.d.ts +27 -0
- package/dist/components/command/score.js +77 -0
- package/dist/components/command/styles.d.ts +32 -9
- package/dist/components/command/styles.js +42 -14
- package/dist/components/composer/ComposerModelPicker.svelte +365 -347
- package/dist/components/composer/ComposerModelPicker.svelte.d.ts +6 -3
- package/dist/components/composer/ComposerRoot.svelte.d.ts +1 -1
- package/dist/components/dialog/ConfirmDialog.svelte +73 -53
- package/dist/components/dialog/DialogClose.svelte +17 -0
- package/dist/components/dialog/DialogClose.svelte.d.ts +10 -0
- package/dist/components/dialog/DialogContent.svelte +35 -33
- package/dist/components/dialog/DialogContent.svelte.d.ts +6 -20
- package/dist/components/dialog/DialogDescription.svelte +9 -12
- package/dist/components/dialog/DialogDescription.svelte.d.ts +6 -8
- package/dist/components/dialog/DialogRoot.svelte +20 -0
- package/dist/components/dialog/DialogRoot.svelte.d.ts +7 -0
- package/dist/components/dialog/DialogTitle.svelte +12 -8
- package/dist/components/dialog/DialogTitle.svelte.d.ts +8 -8
- package/dist/components/dialog/DialogTrigger.svelte +17 -0
- package/dist/components/dialog/DialogTrigger.svelte.d.ts +10 -0
- package/dist/components/dialog/index.d.ts +6 -5
- package/dist/components/dialog/index.js +3 -6
- package/dist/components/dialog/styles.d.ts +1 -2
- package/dist/components/dialog/styles.js +11 -8
- package/dist/components/hover-card/HoverCardContent.svelte +35 -29
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -12
- package/dist/components/hover-card/HoverCardRoot.svelte +7 -7
- package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -4
- package/dist/components/hover-card/HoverCardTrigger.svelte +18 -0
- package/dist/components/hover-card/HoverCardTrigger.svelte.d.ts +10 -0
- package/dist/components/hover-card/index.d.ts +2 -3
- package/dist/components/hover-card/index.js +1 -5
- package/dist/components/input/Input.svelte.d.ts +1 -1
- package/dist/components/markdown/MarkdownBlock.svelte +6 -3
- package/dist/components/markdown/MarkdownTable.svelte +15 -7
- package/dist/components/menu/ContextMenuContent.svelte +15 -15
- package/dist/components/menu/ContextMenuContent.svelte.d.ts +6 -9
- package/dist/components/menu/ContextMenuTrigger.svelte +14 -16
- package/dist/components/menu/ContextMenuTrigger.svelte.d.ts +8 -14
- package/dist/components/menu/MenuCheckboxItem.svelte +22 -11
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +8 -22
- package/dist/components/menu/MenuContent.svelte +16 -18
- package/dist/components/menu/MenuContent.svelte.d.ts +6 -18
- package/dist/components/menu/MenuGroup.svelte +4 -4
- package/dist/components/menu/MenuGroup.svelte.d.ts +5 -4
- package/dist/components/menu/MenuItem.svelte +25 -12
- package/dist/components/menu/MenuItem.svelte.d.ts +6 -21
- package/dist/components/menu/MenuLabel.svelte +7 -11
- package/dist/components/menu/MenuLabel.svelte.d.ts +6 -8
- package/dist/components/menu/MenuRadioGroup.svelte +4 -4
- package/dist/components/menu/MenuRadioGroup.svelte.d.ts +5 -4
- package/dist/components/menu/MenuRadioItem.svelte +16 -14
- package/dist/components/menu/MenuRadioItem.svelte.d.ts +6 -19
- package/dist/components/menu/MenuSeparator.svelte +6 -10
- package/dist/components/menu/MenuSeparator.svelte.d.ts +6 -7
- package/dist/components/menu/MenuSubContent.svelte +22 -19
- package/dist/components/menu/MenuSubContent.svelte.d.ts +8 -15
- package/dist/components/menu/MenuSubTrigger.svelte +7 -11
- package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -15
- package/dist/components/menu/MenuTrigger.svelte +17 -0
- package/dist/components/menu/MenuTrigger.svelte.d.ts +10 -0
- package/dist/components/menu/context-menu.d.ts +2 -2
- package/dist/components/menu/context-menu.js +3 -2
- package/dist/components/menu/group.js +1 -1
- package/dist/components/menu/index.d.ts +5 -4
- package/dist/components/menu/index.js +5 -5
- package/dist/components/menu/row.d.ts +20 -0
- package/dist/components/menu/row.js +12 -0
- package/dist/components/popover/PopoverClose.svelte +17 -0
- package/dist/components/popover/PopoverClose.svelte.d.ts +10 -0
- package/dist/components/popover/PopoverContent.svelte +30 -29
- package/dist/components/popover/PopoverContent.svelte.d.ts +6 -17
- package/dist/components/popover/PopoverTrigger.svelte +17 -0
- package/dist/components/popover/PopoverTrigger.svelte.d.ts +10 -0
- package/dist/components/popover/index.d.ts +6 -4
- package/dist/components/popover/index.js +6 -5
- package/dist/components/progress/Progress.svelte +16 -22
- package/dist/components/progress/Progress.svelte.d.ts +6 -5
- package/dist/components/queued-message/QueuedMessage.svelte +10 -3
- package/dist/components/queued-message/QueuedMessage.svelte.d.ts +2 -1
- package/dist/components/rail/RailItem.svelte +20 -6
- package/dist/components/reasoning/ReasoningRoot.svelte.d.ts +1 -1
- package/dist/components/segmented/SegmentedControl.svelte +100 -91
- package/dist/components/segmented/SegmentedControl.svelte.d.ts +6 -4
- package/dist/components/select/Select.svelte +97 -59
- package/dist/components/select/Select.svelte.d.ts +3 -2
- package/dist/components/sheet/SheetContent.svelte +31 -38
- package/dist/components/sheet/SheetContent.svelte.d.ts +7 -22
- package/dist/components/sheet/index.d.ts +3 -5
- package/dist/components/sheet/index.js +3 -5
- package/dist/components/sheet/styles.js +26 -5
- package/dist/components/sidebar/SidebarItem.svelte +10 -6
- package/dist/components/slider/Slider.svelte +86 -65
- package/dist/components/slider/Slider.svelte.d.ts +9 -8
- package/dist/components/split-button/SplitButton.svelte +20 -3
- package/dist/components/split-button/SplitButton.svelte.d.ts +1 -1
- package/dist/components/switch/Switch.svelte +77 -49
- package/dist/components/switch/Switch.svelte.d.ts +15 -8
- package/dist/components/tab-strip/TabStrip.svelte +110 -76
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +7 -2
- package/dist/components/tabs/Tabs.svelte +129 -99
- package/dist/components/tabs/Tabs.svelte.d.ts +6 -4
- package/dist/components/textarea/Textarea.svelte.d.ts +1 -1
- package/dist/components/toast/Toaster.svelte +132 -115
- package/dist/components/toast/Toaster.svelte.d.ts +5 -0
- package/dist/components/toast/toasts.svelte.d.ts +10 -23
- package/dist/components/toast/toasts.svelte.js +62 -40
- package/dist/components/toggle/Toggle.svelte +15 -9
- package/dist/components/toggle/Toggle.svelte.d.ts +8 -17
- package/dist/components/toggle-group/ToggleGroupItem.svelte +20 -9
- package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +10 -10
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +33 -18
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +4 -4
- package/dist/components/tool/ToolRoot.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipContent.svelte +38 -28
- package/dist/components/tooltip/TooltipContent.svelte.d.ts +6 -15
- package/dist/components/tooltip/TooltipProvider.svelte +34 -10
- package/dist/components/tooltip/TooltipProvider.svelte.d.ts +18 -4
- package/dist/components/tooltip/TooltipRoot.svelte +52 -23
- package/dist/components/tooltip/TooltipRoot.svelte.d.ts +10 -10
- package/dist/components/tooltip/TooltipTrigger.svelte +14 -17
- package/dist/components/tooltip/TooltipTrigger.svelte.d.ts +10 -4
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/work-fold/WorkFold.svelte +14 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/internal/TooltipScope.svelte +4 -4
- package/dist/internal/layer.d.ts +11 -9
- package/dist/internal/layer.js +21 -15
- package/dist/internal/loose.d.ts +30 -5
- package/dist/internal/loose.js +1 -1
- package/dist/internal/markers.stylex.d.ts +0 -4
- package/dist/internal/markers.stylex.js +0 -2
- package/dist/internal/toggle.d.ts +3 -0
- package/dist/internal/toggle.js +6 -2
- package/dist/internal/tooltip-trigger.d.ts +7 -6
- package/dist/internal/tooltip-trigger.js +9 -12
- package/dist/typography.d.ts +5 -0
- package/dist/typography.js +5 -0
- package/dist/vite.d.ts +7 -1
- package/dist/vite.js +20 -5
- package/package.json +3 -2
- package/skills/building-ui/SKILL.md +21 -21
- package/skills/building-ui/references/components.md +22 -7
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +4 -8
- package/skills/styling/SKILL.md +4 -2
- package/skills/theming/SKILL.md +3 -7
|
@@ -3,6 +3,11 @@ export type ToasterProps = {
|
|
|
3
3
|
offset?: string | undefined;
|
|
4
4
|
/** Accessible name of the region. */
|
|
5
5
|
label?: string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* The key that moves focus to the newest toast, and back again: `F6` by default, or
|
|
8
|
+
* `alt+t`. `null` leaves the key to the app, for one that cycles its own areas with F6.
|
|
9
|
+
*/
|
|
10
|
+
shortcut?: string | null | undefined;
|
|
6
11
|
};
|
|
7
12
|
declare const Toaster: import("svelte").Component<ToasterProps, {}, "">;
|
|
8
13
|
type Toaster = ReturnType<typeof Toaster>;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Toasts: short notes about something that happened away from where the person
|
|
3
|
-
* is looking. Call `toast()` from anywhere; one <Toaster /> shows them.
|
|
4
|
-
*/
|
|
5
1
|
export type ToastTone = 'default' | 'info' | 'success' | 'warning' | 'error' | 'loading';
|
|
6
2
|
/** A toast's id: the one `toast()` returns, or one of your own given as `id`. */
|
|
7
3
|
export type ToastId = string | number;
|
|
@@ -30,33 +26,24 @@ export type ToastOptions = {
|
|
|
30
26
|
/** Called when it goes by itself, as its time runs out. */
|
|
31
27
|
onAutoClose?: ((id: ToastId) => void) | undefined;
|
|
32
28
|
};
|
|
33
|
-
/**
|
|
34
|
-
export type
|
|
35
|
-
export type ToastEntry = {
|
|
29
|
+
/** What the Toaster reads from a toast's `data`: its own id, its tone and its action. */
|
|
30
|
+
export type ToastData = {
|
|
36
31
|
id: ToastId;
|
|
37
|
-
title: string;
|
|
38
32
|
tone: ToastTone;
|
|
39
|
-
description?: string | undefined;
|
|
40
33
|
action?: ToastAction | undefined;
|
|
41
|
-
duration: number | null;
|
|
42
|
-
onDismiss?: ((id: ToastId) => void) | undefined;
|
|
43
|
-
onAutoClose?: ((id: ToastId) => void) | undefined;
|
|
44
|
-
/** Changes each time the toast is replaced or updated, so its clock starts again. */
|
|
45
|
-
revision: number;
|
|
46
34
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Narvi's queue, on ui-sdk's toaster: its own, so an app's own ui-sdk toasts don't mix with
|
|
37
|
+
* these. The Toaster shows it. ui-sdk keeps each toast's place, and its timer, which starts
|
|
38
|
+
* again whenever the toast changes.
|
|
39
|
+
*/
|
|
40
|
+
export declare const toaster: import("@ui-sdk/core/toast").Toaster<string>;
|
|
51
41
|
declare function show(title: string, options?: ToastOptions): ToastId;
|
|
52
42
|
declare function update(id: ToastId, patch: ToastOptions & {
|
|
53
43
|
title?: string | undefined;
|
|
54
44
|
}): void;
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
* leaves; `revision` is the one it closed, so a toast replaced meanwhile stays.
|
|
58
|
-
*/
|
|
59
|
-
export declare function finish(id: ToastId, how: ToastEnd, revision?: number): void;
|
|
45
|
+
/** Closes a toast its action answered. The Toaster calls it. */
|
|
46
|
+
export declare function answer(id: ToastId): void;
|
|
60
47
|
/** Closes one toast, or every toast when given no id. Each one's `onDismiss` is called. */
|
|
61
48
|
declare function dismiss(id?: ToastId): void;
|
|
62
49
|
type Message<T> = string | ((value: T) => string);
|
|
@@ -2,65 +2,87 @@
|
|
|
2
2
|
* Toasts: short notes about something that happened away from where the person
|
|
3
3
|
* is looking. Call `toast()` from anywhere; one <Toaster /> shows them.
|
|
4
4
|
*/
|
|
5
|
+
import { createToaster } from '@ui-sdk/svelte/toast';
|
|
5
6
|
const DURATION = 5000;
|
|
6
7
|
let next = 1;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Narvi's queue, on ui-sdk's toaster: its own, so an app's own ui-sdk toasts don't mix with
|
|
10
|
+
* these. The Toaster shows it. ui-sdk keeps each toast's place, and its timer, which starts
|
|
11
|
+
* again whenever the toast changes.
|
|
12
|
+
*/
|
|
13
|
+
export const toaster = createToaster({ duration: DURATION });
|
|
14
|
+
// Each toast as it was last shown or updated, by ui-sdk's id for it
|
|
15
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity -- read as toasts end, never by the page
|
|
16
|
+
const entries = new Map();
|
|
17
|
+
// Toasts their own action closed: an answer of its own, which calls neither callback
|
|
18
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity -- read as toasts end, never by the page
|
|
19
|
+
const answered = new Set();
|
|
20
|
+
// ui-sdk's ids are strings; Narvi's may be numbers too, and 1 and '1' stay apart
|
|
21
|
+
const key = (id) => (typeof id === 'number' ? `n${id}` : `s${id}`);
|
|
12
22
|
// Errors and work in progress stay until they are dealt with
|
|
13
23
|
const lasting = (tone) => tone === 'error' || tone === 'loading';
|
|
14
|
-
|
|
24
|
+
const durationFor = (tone, duration) => duration !== undefined ? duration : lasting(tone) ? null : DURATION;
|
|
25
|
+
function ended(at, details) {
|
|
26
|
+
const entry = entries.get(at);
|
|
27
|
+
entries.delete(at);
|
|
28
|
+
if (answered.delete(at) || !entry)
|
|
29
|
+
return;
|
|
30
|
+
if (details.reason === 'timeout')
|
|
31
|
+
entry.onAutoClose?.(entry.id);
|
|
32
|
+
else if (details.reason !== 'action')
|
|
33
|
+
entry.onDismiss?.(entry.id);
|
|
34
|
+
}
|
|
35
|
+
// Every field is given each time, so a toast shown again under its id is replaced whole
|
|
36
|
+
function put(entry) {
|
|
37
|
+
const at = key(entry.id);
|
|
38
|
+
entries.set(at, entry);
|
|
39
|
+
toaster({
|
|
40
|
+
id: at,
|
|
41
|
+
title: entry.title,
|
|
42
|
+
description: entry.description,
|
|
43
|
+
type: entry.tone,
|
|
44
|
+
duration: entry.duration ?? Infinity,
|
|
45
|
+
data: { id: entry.id, tone: entry.tone, action: entry.action },
|
|
46
|
+
onDismiss: (details) => ended(at, details)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function show(title, options = {}) {
|
|
50
|
+
const id = options.id ?? next++;
|
|
15
51
|
const tone = options.tone ?? 'default';
|
|
16
|
-
|
|
52
|
+
put({
|
|
17
53
|
id,
|
|
18
54
|
title,
|
|
19
55
|
tone,
|
|
20
56
|
description: options.description,
|
|
21
57
|
action: options.action,
|
|
22
|
-
duration:
|
|
58
|
+
duration: durationFor(tone, options.duration),
|
|
23
59
|
onDismiss: options.onDismiss,
|
|
24
|
-
onAutoClose: options.onAutoClose
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function show(title, options = {}) {
|
|
29
|
-
const id = options.id ?? next++;
|
|
30
|
-
const entry = entryFrom(id, title, options);
|
|
31
|
-
const at = toasts.list.findIndex((existing) => existing.id === id);
|
|
32
|
-
toasts.list = at === -1 ? [...toasts.list, entry] : toasts.list.with(at, entry);
|
|
60
|
+
onAutoClose: options.onAutoClose
|
|
61
|
+
});
|
|
33
62
|
return id;
|
|
34
63
|
}
|
|
35
64
|
function update(id, patch) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return { ...entry, ...defined, id, tone, duration, revision: revisions++ };
|
|
43
|
-
});
|
|
65
|
+
const entry = entries.get(key(id));
|
|
66
|
+
if (!entry)
|
|
67
|
+
return;
|
|
68
|
+
const tone = patch.tone ?? entry.tone;
|
|
69
|
+
const defined = Object.fromEntries(Object.entries(patch).filter(([, value]) => value !== undefined));
|
|
70
|
+
put({ ...entry, ...defined, id: entry.id, tone, duration: durationFor(tone, patch.duration) });
|
|
44
71
|
}
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export function finish(id, how, revision) {
|
|
50
|
-
const entry = toasts.list.find((existing) => existing.id === id);
|
|
51
|
-
if (!entry || (revision !== undefined && entry.revision !== revision))
|
|
72
|
+
/** Closes a toast its action answered. The Toaster calls it. */
|
|
73
|
+
export function answer(id) {
|
|
74
|
+
const at = key(id);
|
|
75
|
+
if (!entries.has(at))
|
|
52
76
|
return;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
entry.onDismiss?.(id);
|
|
56
|
-
else if (how === 'auto')
|
|
57
|
-
entry.onAutoClose?.(id);
|
|
77
|
+
answered.add(at);
|
|
78
|
+
toaster.dismiss(at);
|
|
58
79
|
}
|
|
59
80
|
/** Closes one toast, or every toast when given no id. Each one's `onDismiss` is called. */
|
|
60
81
|
function dismiss(id) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
82
|
+
if (id === undefined)
|
|
83
|
+
toaster.dismiss();
|
|
84
|
+
else
|
|
85
|
+
toaster.dismiss(key(id));
|
|
64
86
|
}
|
|
65
87
|
/**
|
|
66
88
|
* Shows a toast and returns its id.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import { Toggle } from '
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { Toggle as UiToggle } from '@ui-sdk/svelte/toggle';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
6
|
import { toggle, type ToggleSize, type ToggleTone } from '../../internal/toggle.js';
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
Omit<
|
|
8
|
+
export interface ToggleProps extends Loose<
|
|
9
|
+
Omit<PartProps<typeof UiToggle>, 'children' | 'render' | 'value'> & {
|
|
10
10
|
size?: ToggleSize | undefined;
|
|
11
11
|
/**
|
|
12
12
|
* How it shows it is pressed: lit in the `accent`, or `neutral`, in the fill of what is
|
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
tone?: ToggleTone | undefined;
|
|
16
16
|
/** Square, for a single icon. Give it an `aria-label`. */
|
|
17
17
|
iconOnly?: boolean | undefined;
|
|
18
|
+
/** The button element. Bindable. */
|
|
19
|
+
ref?: HTMLButtonElement | null | undefined;
|
|
18
20
|
sx?: Sx | undefined;
|
|
19
21
|
/** An icon, a short label, or both. */
|
|
20
22
|
children?: Snippet | undefined;
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
> {}
|
|
23
25
|
</script>
|
|
24
26
|
|
|
25
27
|
<script lang="ts">
|
|
@@ -38,16 +40,20 @@
|
|
|
38
40
|
const square = { sm: toggle.iconSm, md: toggle.iconMd };
|
|
39
41
|
</script>
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
<!-- An icon put in it takes its size (`data-icons`), as in a Button -->
|
|
44
|
+
<UiToggle
|
|
42
45
|
bind:pressed
|
|
43
|
-
bind:ref
|
|
44
|
-
data-slot="toggle"
|
|
45
46
|
data-tone={tone}
|
|
47
|
+
data-icons
|
|
46
48
|
{...rest}
|
|
47
49
|
{...attrs(
|
|
48
50
|
[toggle.base, tone === 'neutral' && toggle.neutral, toggle[size], iconOnly && square[size], sx],
|
|
49
51
|
className
|
|
50
52
|
)}
|
|
53
|
+
{@attach (element: HTMLButtonElement) => {
|
|
54
|
+
ref = element;
|
|
55
|
+
return () => (ref = null);
|
|
56
|
+
}}
|
|
51
57
|
>
|
|
52
58
|
{@render children?.()}
|
|
53
|
-
</
|
|
59
|
+
</UiToggle>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import { Toggle } from '
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { Toggle as UiToggle } from '@ui-sdk/svelte/toggle';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
5
|
import { type ToggleSize, type ToggleTone } from '../../internal/toggle.js';
|
|
6
|
-
export
|
|
6
|
+
export interface ToggleProps extends Loose<Omit<PartProps<typeof UiToggle>, 'children' | 'render' | 'value'> & {
|
|
7
7
|
size?: ToggleSize | undefined;
|
|
8
8
|
/**
|
|
9
9
|
* How it shows it is pressed: lit in the `accent`, or `neutral`, in the fill of what is
|
|
@@ -12,22 +12,13 @@ export type ToggleProps = Loose<Omit<Toggle.RootProps, 'children' | 'child'> & {
|
|
|
12
12
|
tone?: ToggleTone | undefined;
|
|
13
13
|
/** Square, for a single icon. Give it an `aria-label`. */
|
|
14
14
|
iconOnly?: boolean | undefined;
|
|
15
|
+
/** The button element. Bindable. */
|
|
16
|
+
ref?: HTMLButtonElement | null | undefined;
|
|
15
17
|
sx?: Sx | undefined;
|
|
16
18
|
/** An icon, a short label, or both. */
|
|
17
19
|
children?: Snippet | undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* How it shows it is pressed: lit in the `accent`, or `neutral`, in the fill of what is
|
|
23
|
-
* chosen, for a toolbar's icons that show or hide something.
|
|
24
|
-
*/
|
|
25
|
-
tone?: ToggleTone | undefined;
|
|
26
|
-
/** Square, for a single icon. Give it an `aria-label`. */
|
|
27
|
-
iconOnly?: boolean | undefined;
|
|
28
|
-
sx?: Sx | undefined;
|
|
29
|
-
/** An icon, a short label, or both. */
|
|
30
|
-
children?: Snippet | undefined;
|
|
31
|
-
}>, {}, "ref" | "pressed">;
|
|
20
|
+
}> {
|
|
21
|
+
}
|
|
22
|
+
declare const Toggle: import("svelte").Component<ToggleProps, {}, "ref" | "pressed">;
|
|
32
23
|
type Toggle = ReturnType<typeof Toggle>;
|
|
33
24
|
export default Toggle;
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { Toggle } from '@ui-sdk/svelte/toggle';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
6
|
import { toggle } from '../../internal/toggle.js';
|
|
7
7
|
import { getToggleGroupContext } from './context.js';
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
Omit<
|
|
9
|
+
export interface ToggleGroupItemProps extends Loose<
|
|
10
|
+
Omit<
|
|
11
|
+
PartProps<typeof Toggle>,
|
|
12
|
+
'children' | 'render' | 'pressed' | 'defaultPressed' | 'onPressedChange' | 'value'
|
|
13
|
+
> & {
|
|
14
|
+
/** What the group's value holds while this item is pressed. */
|
|
15
|
+
value: string;
|
|
11
16
|
/** Square, for a single icon. Give it an `aria-label`. */
|
|
12
17
|
iconOnly?: boolean | undefined;
|
|
18
|
+
/** The button element. Bindable. */
|
|
19
|
+
ref?: HTMLButtonElement | null | undefined;
|
|
13
20
|
sx?: Sx | undefined;
|
|
14
21
|
children?: Snippet | undefined;
|
|
15
22
|
}
|
|
16
|
-
|
|
23
|
+
> {}
|
|
17
24
|
</script>
|
|
18
25
|
|
|
19
26
|
<script lang="ts">
|
|
@@ -30,10 +37,10 @@
|
|
|
30
37
|
const square = { sm: toggle.iconSm, md: toggle.iconMd };
|
|
31
38
|
</script>
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
data-slot="toggle-group-item"
|
|
40
|
+
<!-- A ui-sdk Toggle inside a ToggleGroup: the group decides whether it is pressed -->
|
|
41
|
+
<Toggle
|
|
36
42
|
{...rest}
|
|
43
|
+
data-icons
|
|
37
44
|
{...attrs(
|
|
38
45
|
[
|
|
39
46
|
toggle.base,
|
|
@@ -44,6 +51,10 @@
|
|
|
44
51
|
],
|
|
45
52
|
className
|
|
46
53
|
)}
|
|
54
|
+
{@attach (element: HTMLButtonElement) => {
|
|
55
|
+
ref = element;
|
|
56
|
+
return () => (ref = null);
|
|
57
|
+
}}
|
|
47
58
|
>
|
|
48
59
|
{@render children?.()}
|
|
49
|
-
</
|
|
60
|
+
</Toggle>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { Toggle } from '@ui-sdk/svelte/toggle';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
|
-
export
|
|
5
|
+
export interface ToggleGroupItemProps extends Loose<Omit<PartProps<typeof Toggle>, 'children' | 'render' | 'pressed' | 'defaultPressed' | 'onPressedChange' | 'value'> & {
|
|
6
|
+
/** What the group's value holds while this item is pressed. */
|
|
7
|
+
value: string;
|
|
6
8
|
/** Square, for a single icon. Give it an `aria-label`. */
|
|
7
9
|
iconOnly?: boolean | undefined;
|
|
10
|
+
/** The button element. Bindable. */
|
|
11
|
+
ref?: HTMLButtonElement | null | undefined;
|
|
8
12
|
sx?: Sx | undefined;
|
|
9
13
|
children?: Snippet | undefined;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
iconOnly?: boolean | undefined;
|
|
14
|
-
sx?: Sx | undefined;
|
|
15
|
-
children?: Snippet | undefined;
|
|
16
|
-
}>, {}, "ref">;
|
|
14
|
+
}> {
|
|
15
|
+
}
|
|
16
|
+
declare const ToggleGroupItem: import("svelte").Component<ToggleGroupItemProps, {}, "ref">;
|
|
17
17
|
type ToggleGroupItem = ReturnType<typeof ToggleGroupItem>;
|
|
18
18
|
export default ToggleGroupItem;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import { ToggleGroup } from '
|
|
2
|
+
import { ToggleGroup } from '@ui-sdk/svelte/toggle';
|
|
3
3
|
import * as stylex from '@stylexjs/stylex';
|
|
4
4
|
import { density } from '../../tokens.stylex.js';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
|
-
import type { Loose } from '../../internal/loose.js';
|
|
6
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
7
7
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
8
8
|
import type { ToggleSize, ToggleTone } from '../../internal/toggle.js';
|
|
9
9
|
import { setToggleGroupContext } from './context.js';
|
|
@@ -25,8 +25,15 @@
|
|
|
25
25
|
|
|
26
26
|
type Html = Loose<
|
|
27
27
|
Omit<
|
|
28
|
-
ToggleGroup
|
|
29
|
-
|
|
28
|
+
PartProps<typeof ToggleGroup>,
|
|
29
|
+
| 'value'
|
|
30
|
+
| 'defaultValue'
|
|
31
|
+
| 'onValueChange'
|
|
32
|
+
| 'multiple'
|
|
33
|
+
| 'deselectable'
|
|
34
|
+
| 'render'
|
|
35
|
+
| 'children'
|
|
36
|
+
| keyof Base
|
|
30
37
|
>
|
|
31
38
|
>;
|
|
32
39
|
|
|
@@ -53,12 +60,14 @@
|
|
|
53
60
|
const d = (rem: string) => `calc(${rem} * ${density.factor})`;
|
|
54
61
|
|
|
55
62
|
const styles = stylex.create({
|
|
63
|
+
// More items than the row has room for go on to the next line, rather than out of the box
|
|
56
64
|
root: {
|
|
57
65
|
display: 'inline-flex',
|
|
66
|
+
flexWrap: 'wrap',
|
|
58
67
|
alignItems: 'center',
|
|
59
68
|
gap: d('0.25rem')
|
|
60
69
|
},
|
|
61
|
-
vertical: { flexDirection: 'column', alignItems: 'stretch' }
|
|
70
|
+
vertical: { flexDirection: 'column', flexWrap: 'nowrap', alignItems: 'stretch' }
|
|
62
71
|
});
|
|
63
72
|
</script>
|
|
64
73
|
|
|
@@ -86,23 +95,29 @@
|
|
|
86
95
|
}
|
|
87
96
|
});
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
// ui-sdk's group holds a list either way; a single group's is of one value at most
|
|
99
|
+
const pressed = $derived(
|
|
100
|
+
type === 'multiple' ? ((value as string[] | undefined) ?? []) : value ? [value as string] : []
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
function change(next: string[]) {
|
|
104
|
+
const settled = type === 'multiple' ? next : (next[0] ?? '');
|
|
105
|
+
value = settled;
|
|
106
|
+
(onValueChange as ((value: string | string[]) => void) | undefined)?.(settled);
|
|
107
|
+
}
|
|
97
108
|
</script>
|
|
98
109
|
|
|
99
|
-
<ToggleGroup
|
|
100
|
-
|
|
110
|
+
<ToggleGroup
|
|
111
|
+
value={pressed}
|
|
112
|
+
onValueChange={change}
|
|
113
|
+
multiple={type === 'multiple'}
|
|
101
114
|
{orientation}
|
|
102
|
-
data-slot="toggle-group"
|
|
103
|
-
{...group}
|
|
104
115
|
{...rest}
|
|
105
116
|
{...attrs([styles.root, orientation === 'vertical' && styles.vertical, sx], className)}
|
|
117
|
+
{@attach (element: HTMLElement) => {
|
|
118
|
+
ref = element;
|
|
119
|
+
return () => (ref = null);
|
|
120
|
+
}}
|
|
106
121
|
>
|
|
107
122
|
{@render children?.()}
|
|
108
|
-
</ToggleGroup
|
|
123
|
+
</ToggleGroup>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ToggleGroup } from '
|
|
1
|
+
import { ToggleGroup } from '@ui-sdk/svelte/toggle';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
5
|
import type { ToggleSize, ToggleTone } from '../../internal/toggle.js';
|
|
6
6
|
type Base = {
|
|
@@ -17,7 +17,7 @@ type Base = {
|
|
|
17
17
|
/** ToggleGroup.Item buttons. */
|
|
18
18
|
children?: Snippet | undefined;
|
|
19
19
|
};
|
|
20
|
-
type Html = Loose<Omit<ToggleGroup
|
|
20
|
+
type Html = Loose<Omit<PartProps<typeof ToggleGroup>, 'value' | 'defaultValue' | 'onValueChange' | 'multiple' | 'deselectable' | 'render' | 'children' | keyof Base>>;
|
|
21
21
|
export type ToggleGroupRootProps = Html & Base & ({
|
|
22
22
|
/** One item at most is pressed; pressing it again lets it go. */
|
|
23
23
|
type: 'single';
|
|
@@ -31,6 +31,6 @@ export type ToggleGroupRootProps = Html & Base & ({
|
|
|
31
31
|
value?: string[] | undefined;
|
|
32
32
|
onValueChange?: ((value: string[]) => void) | undefined;
|
|
33
33
|
});
|
|
34
|
-
declare const ToggleGroupRoot: import("svelte").Component<ToggleGroupRootProps, {}, "
|
|
34
|
+
declare const ToggleGroupRoot: import("svelte").Component<ToggleGroupRootProps, {}, "value" | "ref">;
|
|
35
35
|
type ToggleGroupRoot = ReturnType<typeof ToggleGroupRoot>;
|
|
36
36
|
export default ToggleGroupRoot;
|
|
@@ -18,6 +18,6 @@ export type ToolRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
|
|
|
18
18
|
/** A Tool.Trigger and a Tool.Content. */
|
|
19
19
|
children?: Snippet | undefined;
|
|
20
20
|
};
|
|
21
|
-
declare const ToolRoot: import("svelte").Component<ToolRootProps, {}, "
|
|
21
|
+
declare const ToolRoot: import("svelte").Component<ToolRootProps, {}, "open" | "ref">;
|
|
22
22
|
type ToolRoot = ReturnType<typeof ToolRoot>;
|
|
23
23
|
export default ToolRoot;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { TooltipContent as UiTooltipContent } from '@ui-sdk/svelte/tooltip';
|
|
4
4
|
import * as stylex from '@stylexjs/stylex';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
6
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import { media } from '../../media.stylex.js';
|
|
9
9
|
import Kbd from '../kbd/Kbd.svelte';
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
Omit<
|
|
11
|
+
export interface TooltipContentProps extends Loose<
|
|
12
|
+
Omit<PartProps<typeof UiTooltipContent>, 'children' | 'render'> & {
|
|
13
13
|
/** The keys that do the same, shown after the label: `['⌘', 'K']`. */
|
|
14
14
|
shortcut?: string[] | undefined;
|
|
15
15
|
/**
|
|
@@ -20,17 +20,18 @@
|
|
|
20
20
|
sx?: Sx | undefined;
|
|
21
21
|
children?: Snippet | undefined;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
> {}
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
const
|
|
25
|
+
const STARTING = ':is([data-starting-style])';
|
|
26
|
+
const CLOSED = ':is([data-ending-style])';
|
|
27
|
+
const INSTANT = ':is([data-instant])';
|
|
27
28
|
|
|
28
29
|
/** A length at the window's density (`density` in the tokens). */
|
|
29
30
|
const d = (rem: string) => `calc(${rem} * ${density.factor})`;
|
|
30
31
|
|
|
31
32
|
const styles = stylex.create({
|
|
33
|
+
// In the top layer, over whatever opened before it: no z-index orders it
|
|
32
34
|
content: {
|
|
33
|
-
zIndex: 60,
|
|
34
35
|
display: 'flex',
|
|
35
36
|
alignItems: 'center',
|
|
36
37
|
gap: '0.5rem',
|
|
@@ -44,11 +45,13 @@
|
|
|
44
45
|
fontFamily: font.body,
|
|
45
46
|
fontSize: font.sizeCaption,
|
|
46
47
|
lineHeight: font.leadingSnug,
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
// A path or a hash with nowhere to break breaks anywhere, rather than running out
|
|
49
|
+
overflowWrap: 'anywhere',
|
|
50
|
+
transformOrigin: 'var(--transform-origin)',
|
|
51
|
+
opacity: { default: 1, '@starting-style': 0, [STARTING]: 0, [CLOSED]: 0 },
|
|
49
52
|
scale: {
|
|
50
53
|
default: null,
|
|
51
|
-
[media.motion]: { default: 1, '@starting-style': 0.97, [CLOSED]: 0.97 }
|
|
54
|
+
[media.motion]: { default: 1, '@starting-style': 0.97, [STARTING]: 0.97, [CLOSED]: 0.97 }
|
|
52
55
|
},
|
|
53
56
|
transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale' },
|
|
54
57
|
transitionTimingFunction: motion.easeOut,
|
|
@@ -62,7 +65,15 @@
|
|
|
62
65
|
gap: '0.125rem',
|
|
63
66
|
paddingBlock: d('0.4375rem')
|
|
64
67
|
},
|
|
65
|
-
keys
|
|
68
|
+
// The keys keep their line beside a long label. Written out, too many for that, they wrap
|
|
69
|
+
// in up to 60% of the tooltip, and leave the label the rest
|
|
70
|
+
keys: {
|
|
71
|
+
display: 'inline-flex',
|
|
72
|
+
flexWrap: 'wrap',
|
|
73
|
+
flexShrink: 0,
|
|
74
|
+
maxWidth: '60%',
|
|
75
|
+
gap: '0.125rem'
|
|
76
|
+
}
|
|
66
77
|
});
|
|
67
78
|
</script>
|
|
68
79
|
|
|
@@ -79,19 +90,18 @@
|
|
|
79
90
|
}: TooltipContentProps = $props();
|
|
80
91
|
</script>
|
|
81
92
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</Tooltip.Portal>
|
|
93
|
+
<!-- In place, in the top layer, and in the page while closed, hidden, so it names or describes
|
|
94
|
+
its trigger before focus reaches it -->
|
|
95
|
+
<UiTooltipContent
|
|
96
|
+
{sideOffset}
|
|
97
|
+
{collisionPadding}
|
|
98
|
+
{...rest}
|
|
99
|
+
{...attrs([styles.content, layout === 'column' && styles.column, sx], className)}
|
|
100
|
+
>
|
|
101
|
+
{@render children?.()}
|
|
102
|
+
{#if shortcut?.length}
|
|
103
|
+
<span {...stylex.attrs(styles.keys)}>
|
|
104
|
+
{#each shortcut as key, index (index)}<Kbd>{key}</Kbd>{/each}
|
|
105
|
+
</span>
|
|
106
|
+
{/if}
|
|
107
|
+
</UiTooltipContent>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { TooltipContent as UiTooltipContent } from '@ui-sdk/svelte/tooltip';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
|
-
export
|
|
5
|
+
export interface TooltipContentProps extends Loose<Omit<PartProps<typeof UiTooltipContent>, 'children' | 'render'> & {
|
|
6
6
|
/** The keys that do the same, shown after the label: `['⌘', 'K']`. */
|
|
7
7
|
shortcut?: string[] | undefined;
|
|
8
8
|
/**
|
|
@@ -12,17 +12,8 @@ export type TooltipContentProps = Loose<Omit<Tooltip.ContentProps, 'children' |
|
|
|
12
12
|
layout?: 'row' | 'column' | undefined;
|
|
13
13
|
sx?: Sx | undefined;
|
|
14
14
|
children?: Snippet | undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
shortcut?: string[] | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* `row` keeps the label and the shortcut on one line. `column` sets the content one
|
|
21
|
-
* part under another: a title, then a line or two that says more.
|
|
22
|
-
*/
|
|
23
|
-
layout?: "row" | "column" | undefined;
|
|
24
|
-
sx?: Sx | undefined;
|
|
25
|
-
children?: Snippet | undefined;
|
|
26
|
-
}>, {}, "">;
|
|
15
|
+
}> {
|
|
16
|
+
}
|
|
17
|
+
declare const TooltipContent: import("svelte").Component<TooltipContentProps, {}, "">;
|
|
27
18
|
type TooltipContent = ReturnType<typeof TooltipContent>;
|
|
28
19
|
export default TooltipContent;
|