@diegopluna/narvi 0.4.1 → 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 +350 -346
- 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/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 +2 -3
- 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 +87 -68
- 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/vite.d.ts +7 -1
- package/dist/vite.js +20 -5
- package/package.json +3 -2
- package/skills/building-ui/SKILL.md +20 -20
- package/skills/building-ui/references/components.md +11 -4
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +4 -8
- package/skills/styling/SKILL.md +1 -1
- package/skills/theming/SKILL.md +3 -7
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { ChangeDetails } from '@ui-sdk/core';
|
|
2
|
+
import type { RadioGroupValueChangeReason } from '@ui-sdk/core/radio';
|
|
3
|
+
import { RadioGroup } from '@ui-sdk/svelte/radio';
|
|
1
4
|
import type { IconComponent } from '../../internal/icon.js';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
5
|
import '../../internal/icons.css';
|
|
6
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
4
7
|
import { type Sx } from '../../internal/sx.js';
|
|
5
8
|
export type ChoiceCardOption = {
|
|
6
9
|
value: string;
|
|
@@ -11,19 +14,20 @@ export type ChoiceCardOption = {
|
|
|
11
14
|
icon?: IconComponent | undefined;
|
|
12
15
|
disabled?: boolean | undefined;
|
|
13
16
|
};
|
|
14
|
-
export
|
|
17
|
+
export interface ChoiceCardsProps extends Loose<Omit<PartProps<typeof RadioGroup>, 'children' | 'render' | 'value' | 'defaultValue' | 'onValueChange'> & {
|
|
15
18
|
options: ChoiceCardOption[];
|
|
16
19
|
/** The chosen option's value. Bindable. */
|
|
17
20
|
value?: string | undefined;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Called with the new value when the person chooses, and the change's details after:
|
|
23
|
+
* `details.reason`, and `details.cancel()` to keep the choice as it was.
|
|
24
|
+
*/
|
|
25
|
+
onValueChange?: ((value: string, details: ChangeDetails<RadioGroupValueChangeReason>) => void) | undefined;
|
|
22
26
|
/** How many cards to a row. Without it, as many as fit at 12rem or more each. */
|
|
23
27
|
columns?: 1 | 2 | 3 | 4 | undefined;
|
|
24
|
-
disabled?: boolean | undefined;
|
|
25
28
|
sx?: Sx | undefined;
|
|
26
|
-
}
|
|
29
|
+
}> {
|
|
30
|
+
}
|
|
27
31
|
declare const ChoiceCards: import("svelte").Component<ChoiceCardsProps, {}, "value">;
|
|
28
32
|
type ChoiceCards = ReturnType<typeof ChoiceCards>;
|
|
29
33
|
export default ChoiceCards;
|
|
@@ -1,38 +1,92 @@
|
|
|
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 { CollapsiblePanel } from '@ui-sdk/svelte/collapsible';
|
|
4
|
+
import * as stylex from '@stylexjs/stylex';
|
|
4
5
|
import type { Snippet } from 'svelte';
|
|
5
|
-
import
|
|
6
|
-
import type
|
|
6
|
+
import { getFoldShown, setFoldShown } from '../../internal/fold-shown.js';
|
|
7
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
8
|
+
import { motion } from '../../tokens.stylex.js';
|
|
9
|
+
import { media } from '../../media.stylex.js';
|
|
10
|
+
import { getCollapsibleContext } from './context.js';
|
|
7
11
|
|
|
8
|
-
export
|
|
9
|
-
Omit<
|
|
12
|
+
export interface CollapsibleContentProps extends Loose<
|
|
13
|
+
Omit<PartProps<typeof CollapsiblePanel>, 'children' | 'render' | 'keepMounted'> & {
|
|
14
|
+
/**
|
|
15
|
+
* Keeps the shut content in the page as `hidden="until-found"`, so the browser's find
|
|
16
|
+
* in page can match its text and open it. The content is then built while shut too.
|
|
17
|
+
*/
|
|
18
|
+
hiddenUntilFound?: boolean | undefined;
|
|
19
|
+
/** The fold's element. Bindable. */
|
|
20
|
+
ref?: HTMLElement | null | undefined;
|
|
10
21
|
/** Styles for the content, inside the fold: padding and gaps go here. */
|
|
11
22
|
sx?: Sx | undefined;
|
|
12
23
|
children?: Snippet | undefined;
|
|
13
24
|
}
|
|
14
|
-
|
|
25
|
+
> {}
|
|
26
|
+
|
|
27
|
+
// ui-sdk marks a shut panel `data-closed`, the frame it starts opening from
|
|
28
|
+
// `data-starting-style`, and the closing it waits on `data-ending-style`
|
|
29
|
+
const SHUT = ':is([data-closed], [data-starting-style], [data-ending-style])';
|
|
30
|
+
|
|
31
|
+
const styles = stylex.create({
|
|
32
|
+
// Its height eases between nothing and its content's by moving a grid row between 0fr and
|
|
33
|
+
// 1fr, which needs no measuring. Shut and done, ui-sdk hides it.
|
|
34
|
+
region: {
|
|
35
|
+
display: 'grid',
|
|
36
|
+
gridTemplateRows: { default: '1fr', [SHUT]: '0fr' },
|
|
37
|
+
opacity: { default: 1, [SHUT]: 0 },
|
|
38
|
+
transitionProperty: { default: 'opacity', [media.motion]: 'grid-template-rows, opacity' },
|
|
39
|
+
transitionDuration: motion.slow,
|
|
40
|
+
transitionTimingFunction: motion.easeOut
|
|
41
|
+
},
|
|
42
|
+
// It clips, for the fold, so a word too long for the line wraps rather than being cut off
|
|
43
|
+
inner: { minHeight: 0, overflow: 'hidden', overflowWrap: 'break-word' }
|
|
44
|
+
});
|
|
15
45
|
</script>
|
|
16
46
|
|
|
17
47
|
<script lang="ts">
|
|
18
48
|
let {
|
|
49
|
+
hiddenUntilFound = false,
|
|
19
50
|
ref = $bindable(null),
|
|
20
51
|
sx,
|
|
21
52
|
class: className,
|
|
22
53
|
children,
|
|
23
54
|
...rest
|
|
24
55
|
}: CollapsibleContentProps = $props();
|
|
56
|
+
|
|
57
|
+
const collapsible = getCollapsibleContext('Content');
|
|
58
|
+
|
|
59
|
+
// What is inside is shown while this is open and every fold around it is
|
|
60
|
+
const outerShown = getFoldShown();
|
|
61
|
+
setFoldShown(() => collapsible.open && outerShown());
|
|
62
|
+
|
|
63
|
+
// Built the first time it opens, and kept after; find in page needs it built while shut.
|
|
64
|
+
// A plain variable: it only ever turns true, and only with `open`.
|
|
65
|
+
let opened = false;
|
|
66
|
+
const built = $derived.by(() => {
|
|
67
|
+
if (collapsible.open) opened = true;
|
|
68
|
+
return opened || hiddenUntilFound;
|
|
69
|
+
});
|
|
25
70
|
</script>
|
|
26
71
|
|
|
27
72
|
<!--
|
|
28
|
-
Kept in the page while shut, so its height can ease between nothing and its
|
|
29
|
-
|
|
30
|
-
accessibility tree.
|
|
73
|
+
Kept in the page while shut, so its height can ease between nothing and its content's, and
|
|
74
|
+
so what is in it keeps its state. Shut, ui-sdk hides it: out of the tab order, the
|
|
75
|
+
accessibility tree and find in page, unless `hiddenUntilFound` lets find in.
|
|
31
76
|
-->
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
|
|
77
|
+
<CollapsiblePanel
|
|
78
|
+
keepMounted
|
|
79
|
+
{hiddenUntilFound}
|
|
80
|
+
{...rest}
|
|
81
|
+
{...stylex.attrs(styles.region)}
|
|
82
|
+
{@attach (element: HTMLElement) => {
|
|
83
|
+
ref = element;
|
|
84
|
+
return () => (ref = null);
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<div {...stylex.attrs(styles.inner)}>
|
|
88
|
+
<div {...attrs([sx], className)}>
|
|
89
|
+
{#if built}{@render children?.()}{/if}
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</CollapsiblePanel>
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { CollapsiblePanel } from '@ui-sdk/svelte/collapsible';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
-
import type
|
|
5
|
-
export
|
|
4
|
+
import { type Sx } from '../../internal/sx.js';
|
|
5
|
+
export interface CollapsibleContentProps extends Loose<Omit<PartProps<typeof CollapsiblePanel>, 'children' | 'render' | 'keepMounted'> & {
|
|
6
|
+
/**
|
|
7
|
+
* Keeps the shut content in the page as `hidden="until-found"`, so the browser's find
|
|
8
|
+
* in page can match its text and open it. The content is then built while shut too.
|
|
9
|
+
*/
|
|
10
|
+
hiddenUntilFound?: boolean | undefined;
|
|
11
|
+
/** The fold's element. Bindable. */
|
|
12
|
+
ref?: HTMLElement | null | undefined;
|
|
6
13
|
/** Styles for the content, inside the fold: padding and gaps go here. */
|
|
7
14
|
sx?: Sx | undefined;
|
|
8
15
|
children?: Snippet | undefined;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
sx?: Sx | undefined;
|
|
13
|
-
children?: Snippet | undefined;
|
|
14
|
-
}>, {}, "ref">;
|
|
16
|
+
}> {
|
|
17
|
+
}
|
|
18
|
+
declare const CollapsibleContent: import("svelte").Component<CollapsibleContentProps, {}, "ref">;
|
|
15
19
|
type CollapsibleContent = ReturnType<typeof CollapsibleContent>;
|
|
16
20
|
export default CollapsibleContent;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import { Collapsible } from '
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { Collapsible } from '@ui-sdk/svelte/collapsible';
|
|
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';
|
|
7
7
|
import { setCollapsibleContext } from './context.js';
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
Omit<Collapsible
|
|
9
|
+
export interface CollapsibleRootProps extends Loose<
|
|
10
|
+
Omit<PartProps<typeof Collapsible>, 'children' | 'render'> & {
|
|
11
|
+
/** The root element. Bindable. */
|
|
12
|
+
ref?: HTMLElement | null | undefined;
|
|
11
13
|
sx?: Sx | undefined;
|
|
12
14
|
/** A Collapsible.Trigger and a Collapsible.Content, with anything else around them. */
|
|
13
15
|
children?: Snippet | undefined;
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
> {}
|
|
16
18
|
|
|
17
19
|
const styles = stylex.create({
|
|
18
20
|
root: { display: 'flex', flexDirection: 'column', minWidth: 0 }
|
|
@@ -36,12 +38,14 @@
|
|
|
36
38
|
});
|
|
37
39
|
</script>
|
|
38
40
|
|
|
39
|
-
<Collapsible
|
|
41
|
+
<Collapsible
|
|
40
42
|
bind:open
|
|
41
|
-
bind:ref
|
|
42
|
-
data-slot="collapsible"
|
|
43
43
|
{...rest}
|
|
44
44
|
{...attrs([styles.root, sx], className)}
|
|
45
|
+
{@attach (element: HTMLElement) => {
|
|
46
|
+
ref = element;
|
|
47
|
+
return () => (ref = null);
|
|
48
|
+
}}
|
|
45
49
|
>
|
|
46
50
|
{@render children?.()}
|
|
47
|
-
</Collapsible
|
|
51
|
+
</Collapsible>
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import { Collapsible } from '
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { Collapsible } from '@ui-sdk/svelte/collapsible';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
|
-
export
|
|
5
|
+
export interface CollapsibleRootProps extends Loose<Omit<PartProps<typeof Collapsible>, 'children' | 'render'> & {
|
|
6
|
+
/** The root element. Bindable. */
|
|
7
|
+
ref?: HTMLElement | null | undefined;
|
|
6
8
|
sx?: Sx | undefined;
|
|
7
9
|
/** A Collapsible.Trigger and a Collapsible.Content, with anything else around them. */
|
|
8
10
|
children?: Snippet | undefined;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/** A Collapsible.Trigger and a Collapsible.Content, with anything else around them. */
|
|
13
|
-
children?: Snippet | undefined;
|
|
14
|
-
}>, {}, "ref" | "open">;
|
|
11
|
+
}> {
|
|
12
|
+
}
|
|
13
|
+
declare const CollapsibleRoot: import("svelte").Component<CollapsibleRootProps, {}, "open" | "ref">;
|
|
15
14
|
type CollapsibleRoot = ReturnType<typeof CollapsibleRoot>;
|
|
16
15
|
export default CollapsibleRoot;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { ChildSnippet, Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { CollapsibleTrigger as UiCollapsibleTrigger } from '@ui-sdk/svelte/collapsible';
|
|
4
4
|
import * as stylex from '@stylexjs/stylex';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
6
|
import Chevron from '../../internal/Chevron.svelte';
|
|
@@ -9,18 +9,25 @@
|
|
|
9
9
|
import { media } from '../../media.stylex.js';
|
|
10
10
|
import { getCollapsibleContext } from './context.js';
|
|
11
11
|
|
|
12
|
-
export
|
|
13
|
-
Omit<
|
|
12
|
+
export interface CollapsibleTriggerProps extends Loose<
|
|
13
|
+
Omit<PartProps<typeof UiCollapsibleTrigger>, 'children' | 'render'> & {
|
|
14
14
|
/**
|
|
15
15
|
* Where the chevron goes, pointing down while open: `end` after the label (as `true`
|
|
16
16
|
* does), `start` before it, as in a tree. `false` leaves it out.
|
|
17
17
|
*/
|
|
18
18
|
chevron?: boolean | 'start' | 'end' | undefined;
|
|
19
|
+
/** The button element. Bindable. */
|
|
20
|
+
ref?: HTMLElement | null | undefined;
|
|
19
21
|
sx?: Sx | undefined;
|
|
22
|
+
/** Renders the trigger as an element of your own, such as a Button: spread `props` on it. */
|
|
23
|
+
child?: ChildSnippet | undefined;
|
|
20
24
|
/** The label. Pass `child` instead to make your own control the trigger. */
|
|
21
25
|
children?: Snippet | undefined;
|
|
22
26
|
}
|
|
23
|
-
|
|
27
|
+
> {}
|
|
28
|
+
|
|
29
|
+
// A disabled collapsible's trigger stays focusable, with `aria-disabled` and `data-disabled`
|
|
30
|
+
const DISABLED = ':is(:disabled, [data-disabled])';
|
|
24
31
|
|
|
25
32
|
/** A length at the window's density (`density` in the tokens). */
|
|
26
33
|
const d = (rem: string) => `calc(${rem} * ${density.factor})`;
|
|
@@ -45,8 +52,10 @@
|
|
|
45
52
|
fontWeight: font.weightMedium,
|
|
46
53
|
lineHeight: font.leadingSnug,
|
|
47
54
|
textAlign: 'start',
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
// A label with no break in it, such as a path, wraps rather than running out of the box
|
|
56
|
+
overflowWrap: 'anywhere',
|
|
57
|
+
cursor: { default: 'pointer', [DISABLED]: 'not-allowed' },
|
|
58
|
+
opacity: { default: 1, [DISABLED]: 0.5 },
|
|
50
59
|
WebkitTapHighlightColor: 'transparent',
|
|
51
60
|
WebkitAppRegion: 'no-drag',
|
|
52
61
|
outlineStyle: 'solid',
|
|
@@ -73,17 +82,17 @@
|
|
|
73
82
|
}: CollapsibleTriggerProps = $props();
|
|
74
83
|
|
|
75
84
|
const collapsible = getCollapsibleContext('Trigger');
|
|
85
|
+
|
|
86
|
+
function bindRef(element: HTMLElement) {
|
|
87
|
+
ref = element;
|
|
88
|
+
return () => (ref = null);
|
|
89
|
+
}
|
|
76
90
|
</script>
|
|
77
91
|
|
|
78
92
|
{#if child}
|
|
79
|
-
<
|
|
93
|
+
<UiCollapsibleTrigger render={child} {...rest} {@attach bindRef} />
|
|
80
94
|
{:else}
|
|
81
|
-
<
|
|
82
|
-
bind:ref
|
|
83
|
-
data-slot="collapsible-trigger"
|
|
84
|
-
{...rest}
|
|
85
|
-
{...attrs([styles.trigger, sx], className)}
|
|
86
|
-
>
|
|
95
|
+
<UiCollapsibleTrigger {...rest} {...attrs([styles.trigger, sx], className)} {@attach bindRef}>
|
|
87
96
|
{#if chevron === 'start'}
|
|
88
97
|
<span {...stylex.attrs(styles.chevron)}><Chevron open={collapsible.open} size={12} /></span>
|
|
89
98
|
{/if}
|
|
@@ -91,5 +100,5 @@
|
|
|
91
100
|
{#if chevron === true || chevron === 'end'}
|
|
92
101
|
<span {...stylex.attrs(styles.chevron)}><Chevron open={collapsible.open} size={12} /></span>
|
|
93
102
|
{/if}
|
|
94
|
-
</
|
|
103
|
+
</UiCollapsibleTrigger>
|
|
95
104
|
{/if}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { ChildSnippet, Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { CollapsibleTrigger as UiCollapsibleTrigger } from '@ui-sdk/svelte/collapsible';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
|
-
export
|
|
5
|
+
export interface CollapsibleTriggerProps extends Loose<Omit<PartProps<typeof UiCollapsibleTrigger>, 'children' | 'render'> & {
|
|
6
6
|
/**
|
|
7
7
|
* Where the chevron goes, pointing down while open: `end` after the label (as `true`
|
|
8
8
|
* does), `start` before it, as in a tree. `false` leaves it out.
|
|
9
9
|
*/
|
|
10
10
|
chevron?: boolean | 'start' | 'end' | undefined;
|
|
11
|
+
/** The button element. Bindable. */
|
|
12
|
+
ref?: HTMLElement | null | undefined;
|
|
11
13
|
sx?: Sx | undefined;
|
|
14
|
+
/** Renders the trigger as an element of your own, such as a Button: spread `props` on it. */
|
|
15
|
+
child?: ChildSnippet | undefined;
|
|
12
16
|
/** The label. Pass `child` instead to make your own control the trigger. */
|
|
13
17
|
children?: Snippet | undefined;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* Where the chevron goes, pointing down while open: `end` after the label (as `true`
|
|
18
|
-
* does), `start` before it, as in a tree. `false` leaves it out.
|
|
19
|
-
*/
|
|
20
|
-
chevron?: boolean | "start" | "end" | undefined;
|
|
21
|
-
sx?: Sx | undefined;
|
|
22
|
-
/** The label. Pass `child` instead to make your own control the trigger. */
|
|
23
|
-
children?: Snippet | undefined;
|
|
24
|
-
}>, {}, "ref">;
|
|
18
|
+
}> {
|
|
19
|
+
}
|
|
20
|
+
declare const CollapsibleTrigger: import("svelte").Component<CollapsibleTriggerProps, {}, "ref">;
|
|
25
21
|
type CollapsibleTrigger = ReturnType<typeof CollapsibleTrigger>;
|
|
26
22
|
export default CollapsibleTrigger;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
-->
|
|
7
7
|
<script lang="ts" module>
|
|
8
8
|
import * as stylex from '@stylexjs/stylex';
|
|
9
|
-
import { Popover } from '
|
|
9
|
+
import { Popover, PopoverTrigger } from '@ui-sdk/svelte/popover';
|
|
10
10
|
import { untrack } from 'svelte';
|
|
11
11
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
12
12
|
import type { ControlSize } from '../../internal/control.js';
|
|
@@ -91,7 +91,12 @@
|
|
|
91
91
|
sm: { width: d('1.75rem'), height: d('1.75rem'), borderRadius: radius.item },
|
|
92
92
|
md: { width: d('2.125rem'), height: d('2.125rem') },
|
|
93
93
|
lg: { width: d('2.5rem'), height: d('2.5rem'), borderRadius: radius.panel },
|
|
94
|
+
// Squeezed, it gives up its spare room but never a digit: a hex cut to `#3b82` reads as
|
|
95
|
+
// another colour
|
|
94
96
|
hex: { width: '7.5rem', fontVariantNumeric: 'tabular-nums' },
|
|
97
|
+
hexSm: { minWidth: `calc(7ch + 2 * ${d('0.5rem')} + 2px)` },
|
|
98
|
+
hexMd: { minWidth: `calc(7ch + 2 * ${d('0.625rem')} + 2px)` },
|
|
99
|
+
hexLg: { minWidth: `calc(7ch + 2 * ${d('0.75rem')} + 2px)` },
|
|
95
100
|
// The area: saturation across, brightness up
|
|
96
101
|
area: {
|
|
97
102
|
position: 'relative',
|
|
@@ -136,6 +141,8 @@
|
|
|
136
141
|
// Lit by the pointer only: a thumb that grows while held
|
|
137
142
|
held: { scale: { default: null, [media.motion]: 1.15 } }
|
|
138
143
|
});
|
|
144
|
+
|
|
145
|
+
const hexSizes = { sm: styles.hexSm, md: styles.hexMd, lg: styles.hexLg };
|
|
139
146
|
</script>
|
|
140
147
|
|
|
141
148
|
<script lang="ts">
|
|
@@ -305,15 +312,14 @@
|
|
|
305
312
|
</script>
|
|
306
313
|
|
|
307
314
|
<div data-slot="color-field" {...rest} {...attrs([styles.field, sx], className)}>
|
|
308
|
-
<Popover
|
|
309
|
-
<
|
|
315
|
+
<Popover bind:open>
|
|
316
|
+
<PopoverTrigger
|
|
310
317
|
disabled={off}
|
|
311
318
|
aria-label={words.pick}
|
|
312
|
-
data-slot="color-field-swatch"
|
|
313
319
|
{...attrs([styles.swatch, styles[size], shared.focusable])}
|
|
314
320
|
style="background-color: {hex}"
|
|
315
321
|
/>
|
|
316
|
-
<PopoverContent width="15rem" layout="column"
|
|
322
|
+
<PopoverContent width="15rem" layout="column">
|
|
317
323
|
<div
|
|
318
324
|
role="slider"
|
|
319
325
|
tabindex="0"
|
|
@@ -378,7 +384,7 @@
|
|
|
378
384
|
{/if}
|
|
379
385
|
</div>
|
|
380
386
|
</PopoverContent>
|
|
381
|
-
</Popover
|
|
387
|
+
</Popover>
|
|
382
388
|
<Input
|
|
383
389
|
{size}
|
|
384
390
|
value={typed ?? hex}
|
|
@@ -387,7 +393,7 @@
|
|
|
387
393
|
autocomplete="off"
|
|
388
394
|
aria-label={field?.id ? undefined : label}
|
|
389
395
|
data-slot="color-field-hex"
|
|
390
|
-
sx={styles.hex}
|
|
396
|
+
sx={[styles.hex, hexSizes[size]]}
|
|
391
397
|
oninput={(event) => type(event.currentTarget.value)}
|
|
392
398
|
onblur={() => (typed = null)}
|
|
393
399
|
onkeydown={(event) => {
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
dialog of its own. Wire the shortcut that opens it, usually ⌘K, in your app.
|
|
4
4
|
-->
|
|
5
5
|
<script lang="ts" module>
|
|
6
|
-
import { Dialog } from '
|
|
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
9
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
10
10
|
import { visuallyHidden } from '../../visually-hidden.js';
|
|
11
|
+
import { provideDialogLabel } from './context.js';
|
|
11
12
|
import { command } from './styles.js';
|
|
12
13
|
|
|
13
14
|
export type CommandDialogProps = {
|
|
@@ -16,8 +17,9 @@
|
|
|
16
17
|
/** Called as it opens or closes. */
|
|
17
18
|
onopenchange?: ((open: boolean) => void) | undefined;
|
|
18
19
|
/**
|
|
19
|
-
* Called as Escape is pressed
|
|
20
|
-
*
|
|
20
|
+
* Called as Escape is pressed, with nothing left in the search to clear. Call
|
|
21
|
+
* `event.preventDefault()` to keep it open: to go back a step of a palette that has
|
|
22
|
+
* several, or to wait while something is on its way.
|
|
21
23
|
*/
|
|
22
24
|
onescape?: ((event: KeyboardEvent) => void) | undefined;
|
|
23
25
|
/**
|
|
@@ -25,7 +27,7 @@
|
|
|
25
27
|
* put the focus somewhere of its own, such as a thread it opened.
|
|
26
28
|
*/
|
|
27
29
|
restoreFocus?: boolean | undefined;
|
|
28
|
-
/** What the palette is, for assistive technology. */
|
|
30
|
+
/** What the palette is, for assistive technology. It names its search field too. */
|
|
29
31
|
label?: string | undefined;
|
|
30
32
|
/** On the palette's box: its place, its width, how tall it may grow. */
|
|
31
33
|
sx?: Sx | undefined;
|
|
@@ -46,21 +48,29 @@
|
|
|
46
48
|
class: className,
|
|
47
49
|
children
|
|
48
50
|
}: CommandDialogProps = $props();
|
|
51
|
+
|
|
52
|
+
provideDialogLabel(() => label);
|
|
53
|
+
|
|
54
|
+
// Heard on its way up to the document, where ui-sdk closes the dialog: an Escape the search
|
|
55
|
+
// used to clear itself comes prevented, and one the caller prevents here keeps it open. A
|
|
56
|
+
// menu open inside the palette, in a popover of its own, takes its own Escape.
|
|
57
|
+
const escape = (event: KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement }) => {
|
|
58
|
+
if (event.key !== 'Escape' || event.defaultPrevented || event.isComposing) return;
|
|
59
|
+
const layer = event.target instanceof Element ? event.target.closest('[popover]') : null;
|
|
60
|
+
if (layer && layer !== event.currentTarget) return;
|
|
61
|
+
onescape?.(event);
|
|
62
|
+
};
|
|
49
63
|
</script>
|
|
50
64
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{@render children?.()}
|
|
64
|
-
</Dialog.Content>
|
|
65
|
-
</Dialog.Portal>
|
|
66
|
-
</Dialog.Root>
|
|
65
|
+
<!-- In place, in the top layer: ui-sdk needs no portal -->
|
|
66
|
+
<Dialog bind:open onOpenChange={(next) => onopenchange?.(next)}>
|
|
67
|
+
<DialogBackdrop {...stylex.attrs(command.overlay)} />
|
|
68
|
+
<DialogContent
|
|
69
|
+
finalFocus={restoreFocus ? undefined : 'none'}
|
|
70
|
+
onkeydown={escape}
|
|
71
|
+
{...attrs([command.dialog, sx], className)}
|
|
72
|
+
>
|
|
73
|
+
<DialogTitle {...stylex.attrs(visuallyHidden)}>{label}</DialogTitle>
|
|
74
|
+
{@render children?.()}
|
|
75
|
+
</DialogContent>
|
|
76
|
+
</Dialog>
|
|
@@ -6,8 +6,9 @@ export type CommandDialogProps = {
|
|
|
6
6
|
/** Called as it opens or closes. */
|
|
7
7
|
onopenchange?: ((open: boolean) => void) | undefined;
|
|
8
8
|
/**
|
|
9
|
-
* Called as Escape is pressed
|
|
10
|
-
*
|
|
9
|
+
* Called as Escape is pressed, with nothing left in the search to clear. Call
|
|
10
|
+
* `event.preventDefault()` to keep it open: to go back a step of a palette that has
|
|
11
|
+
* several, or to wait while something is on its way.
|
|
11
12
|
*/
|
|
12
13
|
onescape?: ((event: KeyboardEvent) => void) | undefined;
|
|
13
14
|
/**
|
|
@@ -15,7 +16,7 @@ export type CommandDialogProps = {
|
|
|
15
16
|
* put the focus somewhere of its own, such as a thread it opened.
|
|
16
17
|
*/
|
|
17
18
|
restoreFocus?: boolean | undefined;
|
|
18
|
-
/** What the palette is, for assistive technology. */
|
|
19
|
+
/** What the palette is, for assistive technology. It names its search field too. */
|
|
19
20
|
label?: string | undefined;
|
|
20
21
|
/** On the palette's box: its place, its width, how tall it may grow. */
|
|
21
22
|
sx?: Sx | undefined;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
What the list says in place of items: that nothing matches, that results are on
|
|
3
3
|
their way, or that they could not be had. It shows only while the list has no
|
|
4
|
-
items, so results still listed stay as they are while new ones load.
|
|
4
|
+
items, so results still listed stay as they are while new ones load. It is a
|
|
5
|
+
live region, so what it says is announced as it shows: put it after the
|
|
6
|
+
Command.List, outside it.
|
|
5
7
|
-->
|
|
6
8
|
<script lang="ts" module>
|
|
7
|
-
import type { Loose } from '../../internal/loose.js';
|
|
8
|
-
import {
|
|
9
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
10
|
+
import { CommandEmpty as UiCommandEmpty } from '@ui-sdk/svelte/command';
|
|
9
11
|
import type { Snippet } from 'svelte';
|
|
10
12
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
11
13
|
import Spinner from '../spinner/Spinner.svelte';
|
|
12
14
|
import { command } from './styles.js';
|
|
13
15
|
|
|
14
|
-
export
|
|
15
|
-
Omit<
|
|
16
|
+
export interface CommandEmptyProps extends Loose<
|
|
17
|
+
Omit<PartProps<typeof UiCommandEmpty>, 'children' | 'render'> & {
|
|
16
18
|
/**
|
|
17
19
|
* Why there are no items: `loading`, with a spinner, while they are on their way, or
|
|
18
20
|
* `error`, in the danger colour, when they could not be had. Without it, nothing matches.
|
|
@@ -25,7 +27,7 @@
|
|
|
25
27
|
*/
|
|
26
28
|
children?: Snippet | undefined;
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
> {}
|
|
29
31
|
|
|
30
32
|
const fallback = {
|
|
31
33
|
empty: 'Nothing matches.',
|
|
@@ -38,8 +40,8 @@
|
|
|
38
40
|
let { status, sx, class: className, children, ...rest }: CommandEmptyProps = $props();
|
|
39
41
|
</script>
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
<!-- ui-sdk keeps the region in the page, and fills it only while nothing is listed -->
|
|
44
|
+
<UiCommandEmpty
|
|
43
45
|
data-status={status}
|
|
44
46
|
{...rest}
|
|
45
47
|
{...attrs(
|
|
@@ -54,4 +56,4 @@
|
|
|
54
56
|
>
|
|
55
57
|
{#if status === 'loading'}<Spinner size={16} label={null} />{/if}
|
|
56
58
|
{#if children}{@render children()}{:else}{fallback[status ?? 'empty']}{/if}
|
|
57
|
-
</
|
|
59
|
+
</UiCommandEmpty>
|
|
@@ -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 { CommandEmpty as UiCommandEmpty } from '@ui-sdk/svelte/command';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
|
-
export
|
|
5
|
+
export interface CommandEmptyProps extends Loose<Omit<PartProps<typeof UiCommandEmpty>, 'children' | 'render'> & {
|
|
6
6
|
/**
|
|
7
7
|
* Why there are no items: `loading`, with a spinner, while they are on their way, or
|
|
8
8
|
* `error`, in the danger colour, when they could not be had. Without it, nothing matches.
|
|
@@ -14,19 +14,8 @@ export type CommandEmptyProps = Loose<Omit<Command.EmptyProps, 'children' | 'chi
|
|
|
14
14
|
* what went wrong and what to do.
|
|
15
15
|
*/
|
|
16
16
|
children?: Snippet | undefined;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* Why there are no items: `loading`, with a spinner, while they are on their way, or
|
|
21
|
-
* `error`, in the danger colour, when they could not be had. Without it, nothing matches.
|
|
22
|
-
*/
|
|
23
|
-
status?: "loading" | "error" | undefined;
|
|
24
|
-
sx?: Sx | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* What to say. For no match, say what was searched for and what to try; for an error,
|
|
27
|
-
* what went wrong and what to do.
|
|
28
|
-
*/
|
|
29
|
-
children?: Snippet | undefined;
|
|
30
|
-
}>, {}, "">;
|
|
17
|
+
}> {
|
|
18
|
+
}
|
|
19
|
+
declare const CommandEmpty: import("svelte").Component<CommandEmptyProps, {}, "">;
|
|
31
20
|
type CommandEmpty = ReturnType<typeof CommandEmpty>;
|
|
32
21
|
export default CommandEmpty;
|