horizon-design 1.0.0 → 2.0.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 +153 -105
- package/dist/components/accordion/AccordionItem.svelte +3 -2
- package/dist/components/accordion/AccordionItem.svelte.d.ts +4 -1
- package/dist/components/angle-slider/AngleSlider.svelte +8 -4
- package/dist/components/angle-slider/AngleSlider.svelte.d.ts +5 -1
- package/dist/components/asset-card/AssetCard.svelte +23 -10
- package/dist/components/asset-card/AssetCard.svelte.d.ts +11 -5
- package/dist/components/avatar/Avatar.svelte +8 -2
- package/dist/components/avatar/Avatar.svelte.d.ts +1 -1
- package/dist/components/button/Button.svelte +1 -1
- package/dist/components/button/Button.svelte.d.ts +1 -1
- package/dist/components/button/button-variants.d.ts +2 -0
- package/dist/components/button/button-variants.js +2 -0
- package/dist/components/calendar/Calendar.svelte +22 -167
- package/dist/components/calendar/Calendar.svelte.d.ts +9 -3
- package/dist/components/calendar/CalendarViews.svelte +204 -0
- package/dist/components/calendar/CalendarViews.svelte.d.ts +24 -0
- package/dist/components/calendar/trigger-ids.d.ts +14 -0
- package/dist/components/calendar/trigger-ids.js +7 -0
- package/dist/components/card/Card.svelte +8 -2
- package/dist/components/card/Card.svelte.d.ts +4 -1
- package/dist/components/carousel/Carousel.svelte +57 -19
- package/dist/components/carousel/Carousel.svelte.d.ts +5 -2
- package/dist/components/checkbox/Checkbox.svelte +7 -7
- package/dist/components/checkbox/Checkbox.svelte.d.ts +1 -1
- package/dist/components/circular-progress/CircularProgress.svelte +3 -9
- package/dist/components/circular-progress/CircularProgress.svelte.d.ts +1 -1
- package/dist/components/circular-slider/CircularSlider.svelte +5 -11
- package/dist/components/circular-slider/CircularSlider.svelte.d.ts +1 -1
- package/dist/components/clipboard/Clipboard.svelte +30 -13
- package/dist/components/clipboard/Clipboard.svelte.d.ts +6 -2
- package/dist/components/collapsible/Collapsible.svelte +10 -3
- package/dist/components/collapsible/Collapsible.svelte.d.ts +7 -2
- package/dist/components/color-picker/ColorPicker.svelte +105 -28
- package/dist/components/color-picker/ColorPicker.svelte.d.ts +20 -5
- package/dist/components/color-picker/formats.d.ts +23 -0
- package/dist/components/color-picker/formats.js +52 -0
- package/dist/components/color-picker/index.d.ts +3 -1
- package/dist/components/color-picker/index.js +2 -1
- package/dist/components/combobox/Combobox.svelte +28 -4
- package/dist/components/combobox/Combobox.svelte.d.ts +9 -1
- package/dist/components/date-picker/DatePicker.svelte +46 -139
- package/dist/components/date-picker/DatePicker.svelte.d.ts +12 -2
- package/dist/components/dialog/Dialog.svelte +28 -10
- package/dist/components/dialog/Dialog.svelte.d.ts +6 -3
- package/dist/components/dialog/DialogClose.svelte +48 -21
- package/dist/components/dialog/DialogClose.svelte.d.ts +16 -6
- package/dist/components/dialog/context.d.ts +9 -0
- package/dist/components/dialog/context.js +16 -0
- package/dist/components/drawer/Drawer.svelte +25 -10
- package/dist/components/drawer/Drawer.svelte.d.ts +5 -3
- package/dist/components/editable/Editable.svelte +3 -0
- package/dist/components/file-upload/FileUpload.svelte +8 -6
- package/dist/components/file-upload/FileUpload.svelte.d.ts +4 -3
- package/dist/components/floating-panel/FloatingPanel.svelte +16 -9
- package/dist/components/floating-panel/FloatingPanel.svelte.d.ts +3 -2
- package/dist/components/frame/Frame.svelte +10 -6
- package/dist/components/frame/Frame.svelte.d.ts +2 -1
- package/dist/components/game-hero/GameHero.svelte +1 -1
- package/dist/components/game-hero/GameHero.svelte.d.ts +1 -1
- package/dist/components/icon-button/IconButton.svelte +60 -0
- package/dist/components/icon-button/IconButton.svelte.d.ts +31 -0
- package/dist/components/icon-button/index.d.ts +5 -0
- package/dist/components/icon-button/index.js +5 -0
- package/dist/components/item/Item.svelte +34 -11
- package/dist/components/item/Item.svelte.d.ts +11 -2
- package/dist/components/kbd/Kbd.svelte +34 -4
- package/dist/components/kbd/Kbd.svelte.d.ts +16 -2
- package/dist/components/listbox/Listbox.svelte +6 -3
- package/dist/components/listbox/Listbox.svelte.d.ts +4 -1
- package/dist/components/menu/Menu.svelte +33 -5
- package/dist/components/menu/Menu.svelte.d.ts +12 -2
- package/dist/components/native-select/NativeSelect.svelte +3 -2
- package/dist/components/native-select/NativeSelect.svelte.d.ts +2 -1
- package/dist/components/notification-center/NotificationCenter.svelte +1 -1
- package/dist/components/number-input/NumberInput.svelte +39 -13
- package/dist/components/number-input/NumberInput.svelte.d.ts +5 -3
- package/dist/components/pagination/Pagination.svelte +4 -3
- package/dist/components/pagination/Pagination.svelte.d.ts +2 -1
- package/dist/components/pagination/PaginationNextTrigger.svelte +30 -11
- package/dist/components/pagination/PaginationNextTrigger.svelte.d.ts +9 -1
- package/dist/components/pagination/PaginationPrevTrigger.svelte +30 -11
- package/dist/components/pagination/PaginationPrevTrigger.svelte.d.ts +9 -1
- package/dist/components/pin-input/PinInput.svelte +3 -2
- package/dist/components/pin-input/PinInput.svelte.d.ts +2 -1
- package/dist/components/popover/Popover.svelte +34 -6
- package/dist/components/popover/Popover.svelte.d.ts +11 -3
- package/dist/components/popover/PopoverClose.svelte +24 -9
- package/dist/components/popover/PopoverClose.svelte.d.ts +6 -1
- package/dist/components/progress/Progress.svelte +3 -3
- package/dist/components/radio-group/RadioGroup.svelte +43 -34
- package/dist/components/radio-group/RadioGroup.svelte.d.ts +3 -1
- package/dist/components/rating-group/RatingGroup.svelte +7 -2
- package/dist/components/rating-group/RatingGroup.svelte.d.ts +1 -0
- package/dist/components/ring/Ring.svelte +42 -0
- package/dist/components/ring/Ring.svelte.d.ts +16 -0
- package/dist/components/scroll-area/ScrollArea.svelte +30 -10
- package/dist/components/scroll-area/ScrollArea.svelte.d.ts +9 -1
- package/dist/components/segment-group/SegmentGroup.svelte +38 -17
- package/dist/components/segment-group/SegmentGroup.svelte.d.ts +9 -4
- package/dist/components/select/Select.svelte +2 -2
- package/dist/components/select/Select.svelte.d.ts +1 -1
- package/dist/components/sheet/Sheet.svelte +54 -15
- package/dist/components/sheet/Sheet.svelte.d.ts +15 -6
- package/dist/components/sidebar/Sidebar.svelte +18 -3
- package/dist/components/sidebar/Sidebar.svelte.d.ts +9 -3
- package/dist/components/sidebar/SidebarItem.svelte +53 -26
- package/dist/components/sidebar/SidebarItem.svelte.d.ts +8 -4
- package/dist/components/sidebar/SidebarSection.svelte +1 -1
- package/dist/components/sidebar/context.d.ts +9 -0
- package/dist/components/sidebar/context.js +15 -0
- package/dist/components/signature-pad/SignaturePad.svelte +3 -2
- package/dist/components/signature-pad/SignaturePad.svelte.d.ts +2 -1
- package/dist/components/slider/Slider.svelte +21 -10
- package/dist/components/slider/Slider.svelte.d.ts +3 -1
- package/dist/components/splitter/Splitter.svelte +8 -2
- package/dist/components/splitter/Splitter.svelte.d.ts +2 -1
- package/dist/components/switch/Switch.svelte +26 -41
- package/dist/components/switch/Switch.svelte.d.ts +2 -2
- package/dist/components/table/Table.svelte +21 -26
- package/dist/components/table/Table.svelte.d.ts +41 -22
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/index.js +1 -1
- package/dist/components/tag-picker/TagPicker.svelte +3 -5
- package/dist/components/tag-picker/TagPicker.svelte.d.ts +1 -1
- package/dist/components/textarea/Textarea.svelte +8 -2
- package/dist/components/textarea/Textarea.svelte.d.ts +4 -1
- package/dist/components/theme-switch/ThemeSwitch.svelte +64 -18
- package/dist/components/theme-switch/ThemeSwitch.svelte.d.ts +6 -3
- package/dist/components/thumb-card/ThumbCard.svelte +19 -6
- package/dist/components/thumb-card/ThumbCard.svelte.d.ts +9 -2
- package/dist/components/timer/Timer.svelte +26 -15
- package/dist/components/timer/Timer.svelte.d.ts +3 -2
- package/dist/components/toast/Toast.svelte +15 -8
- package/dist/components/toast/Toast.svelte.d.ts +3 -2
- package/dist/components/toast/Toaster.svelte +1 -1
- package/dist/components/toast/Toaster.svelte.d.ts +1 -1
- package/dist/components/toggle/Toggle.svelte +4 -2
- package/dist/components/toggle/Toggle.svelte.d.ts +4 -2
- package/dist/components/toggle-group/ToggleGroup.svelte +61 -14
- package/dist/components/toggle-group/ToggleGroup.svelte.d.ts +13 -5
- package/dist/components/toggle-tooltip/ToggleTooltip.svelte +26 -29
- package/dist/components/toggle-tooltip/ToggleTooltip.svelte.d.ts +4 -3
- package/dist/components/tooltip/Tooltip.svelte +31 -5
- package/dist/components/tooltip/Tooltip.svelte.d.ts +10 -2
- package/dist/components/tour/Tour.svelte +21 -13
- package/dist/components/tour/Tour.svelte.d.ts +3 -3
- package/dist/components/virtual-tree/VirtualTree.svelte +7 -6
- package/dist/components/virtual-tree/VirtualTree.svelte.d.ts +3 -2
- package/dist/editor/horizon-layout/HorizonLayout.svelte +8 -7
- package/dist/editor/horizon-layout/HorizonLayout.svelte.d.ts +2 -2
- package/dist/editor/inspector-panel/InspectorPanel.svelte +60 -9
- package/dist/editor/inspector-panel/InspectorPanel.svelte.d.ts +19 -1
- package/dist/generated/theme.css +16 -11
- package/dist/generated/tokens.d.ts +1 -1
- package/dist/generated/tokens.js +13 -11
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/motion/sliding-indicator.d.ts +28 -0
- package/dist/motion/sliding-indicator.js +54 -0
- package/dist/platform.d.ts +21 -0
- package/dist/platform.js +19 -0
- package/dist/theme.svelte.d.ts +3 -3
- package/dist/theme.svelte.js +7 -7
- package/package.json +12 -12
- package/dist/components/tabs/Tabs.svelte +0 -119
- package/dist/components/tabs/Tabs.svelte.d.ts +0 -31
- package/dist/components/tabs/index.d.ts +0 -5
- package/dist/components/tabs/index.js +0 -5
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
1
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
2
2
|
import { Menu, type MenuOpenChangeDetails } from '@ark-ui/svelte';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
/** The content of the button that opens the menu; no trigger when unset. */
|
|
5
5
|
trigger?: Snippet;
|
|
6
|
+
/**
|
|
7
|
+
* The trigger's action, translated, such as "More actions", for a trigger that shows only an
|
|
8
|
+
* icon: its accessible name and its tooltip. Unset, the trigger's content names it.
|
|
9
|
+
*/
|
|
10
|
+
triggerLabel?: string;
|
|
6
11
|
/** Classes of the trigger button, such as `buttonVariants(…)`. */
|
|
7
12
|
triggerClass?: string;
|
|
8
13
|
/** The menu's items: `MenuItem`, `MenuGroup` and `MenuSeparator`. */
|
|
@@ -15,10 +20,15 @@ type $$ComponentProps = {
|
|
|
15
20
|
open?: boolean;
|
|
16
21
|
/** Called with the new state when the menu opens or closes. */
|
|
17
22
|
onOpenChange?: (details: MenuOpenChangeDetails) => void;
|
|
23
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
24
|
+
ids?: ComponentProps<typeof Menu.Root>['ids'];
|
|
18
25
|
/** Other props of Ark's `Menu.Root`, such as `onSelect` or `positioning`. */
|
|
19
26
|
[key: string]: unknown;
|
|
20
27
|
};
|
|
21
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* A dropdown menu opened by its trigger (Ark Menu); `frosted` for a translucent surface. A trigger
|
|
30
|
+
* that shows only an icon takes a `triggerLabel`: its accessible name and its tooltip.
|
|
31
|
+
*/
|
|
22
32
|
declare const Menu: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
23
33
|
type Menu = ReturnType<typeof Menu>;
|
|
24
34
|
export default Menu;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
The browser's own select, styled like the other fields; `value` binds the chosen option. Name it
|
|
4
|
-
with a `<label for>` or an `aria-label`, both passed to the `<select
|
|
4
|
+
with a `<label for>` or an `aria-label`, both passed to the `<select>`; `aria-invalid` turns the
|
|
5
|
+
border danger.
|
|
5
6
|
-->
|
|
6
7
|
<script lang="ts">
|
|
7
8
|
import type { Snippet } from 'svelte';
|
|
@@ -28,7 +29,7 @@ with a `<label for>` or an `aria-label`, both passed to the `<select>`.
|
|
|
28
29
|
<div class="relative w-full">
|
|
29
30
|
<select
|
|
30
31
|
class={cn(
|
|
31
|
-
'flex h-control-md w-full appearance-none rounded-lg border border-border bg-sunken px-2.5 pr-8 text-sm text-fg transition-colors outline-none focus-visible:border-primary focus-visible:ring-3 focus-visible:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50',
|
|
32
|
+
'flex h-control-md w-full appearance-none rounded-lg border border-border bg-sunken px-2.5 pr-8 text-sm text-fg transition-colors outline-none focus-visible:border-primary focus-visible:ring-3 focus-visible:ring-primary/20 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger aria-invalid:focus-visible:ring-danger/20',
|
|
32
33
|
className
|
|
33
34
|
)}
|
|
34
35
|
data-slot="native-select"
|
|
@@ -11,7 +11,8 @@ type $$ComponentProps = {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* The browser's own select, styled like the other fields; `value` binds the chosen option. Name it
|
|
14
|
-
* with a `<label for>` or an `aria-label`, both passed to the `<select
|
|
14
|
+
* with a `<label for>` or an `aria-label`, both passed to the `<select>`; `aria-invalid` turns the
|
|
15
|
+
* border danger.
|
|
15
16
|
*/
|
|
16
17
|
declare const NativeSelect: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
17
18
|
type NativeSelect = ReturnType<typeof NativeSelect>;
|
|
@@ -112,7 +112,7 @@ text translated and every time formatted.
|
|
|
112
112
|
{#if item.unread}<span class="sr-only">({unreadLabel})</span>{/if}
|
|
113
113
|
</p>
|
|
114
114
|
{#if item.body}<p class="mt-0.5 text-xs text-muted">{item.body}</p>{/if}
|
|
115
|
-
<p class="mt-0.5 text-xs text-
|
|
115
|
+
<p class="mt-0.5 text-xs text-muted">{item.time}</p>
|
|
116
116
|
{#if actions}
|
|
117
117
|
<div class="relative z-1 mt-2 flex flex-wrap gap-1.5">{@render actions(item)}</div>
|
|
118
118
|
{/if}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
@component
|
|
3
3
|
A number field with increment and decrement buttons (Ark NumberInput). `value` binds the text of
|
|
4
4
|
the field; without it, Ark's `defaultValue` sets the first value. `translations` names the two
|
|
5
|
-
buttons (`incrementLabel`, `decrementLabel`) and gives the
|
|
6
|
-
(`roleDescription`).
|
|
5
|
+
buttons (`incrementLabel`, `decrementLabel`), which show their names as tooltips too, and gives the
|
|
6
|
+
field's announced role (`roleDescription`). Ark's `invalid` turns the border danger.
|
|
7
7
|
-->
|
|
8
8
|
<script lang="ts">
|
|
9
|
-
import type { Snippet } from 'svelte';
|
|
9
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
10
10
|
import {
|
|
11
11
|
NumberInput,
|
|
12
12
|
type NumberInputRootProps,
|
|
@@ -15,6 +15,7 @@ buttons (`incrementLabel`, `decrementLabel`) and gives the field's announced rol
|
|
|
15
15
|
import MingcuteUpLine from '~icons/mingcute/up-line';
|
|
16
16
|
import MingcuteDownLine from '~icons/mingcute/down-line';
|
|
17
17
|
import { cn } from '../../utils.js';
|
|
18
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
18
19
|
|
|
19
20
|
let {
|
|
20
21
|
class: className = '',
|
|
@@ -23,6 +24,7 @@ buttons (`incrementLabel`, `decrementLabel`) and gives the field's announced rol
|
|
|
23
24
|
value = $bindable(),
|
|
24
25
|
onValueChange,
|
|
25
26
|
translations,
|
|
27
|
+
ids: appIds,
|
|
26
28
|
...rest
|
|
27
29
|
}: {
|
|
28
30
|
/** Classes added to the root, around the label and the field. */
|
|
@@ -44,14 +46,20 @@ buttons (`incrementLabel`, `decrementLabel`) and gives the field's announced rol
|
|
|
44
46
|
Pick<NonNullable<NumberInputRootProps['translations']>, 'incrementLabel' | 'decrementLabel'>
|
|
45
47
|
> &
|
|
46
48
|
NonNullable<NumberInputRootProps['translations']> & { roleDescription: string };
|
|
49
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
50
|
+
ids?: ComponentProps<typeof NumberInput.Root>['ids'];
|
|
47
51
|
/** Other props of Ark's `NumberInput.Root`. */
|
|
48
52
|
[key: string]: unknown;
|
|
49
53
|
} = $props();
|
|
50
54
|
|
|
51
55
|
const { roleDescription, ...arkTranslations } = $derived(translations);
|
|
56
|
+
// Each step button is also its tooltip's trigger, so both must know it by the same id.
|
|
57
|
+
const id = $props.id();
|
|
58
|
+
const ids = { incrementTrigger: `${id}-increment`, decrementTrigger: `${id}-decrement` };
|
|
52
59
|
</script>
|
|
53
60
|
|
|
54
61
|
<NumberInput.Root
|
|
62
|
+
ids={{ ...appIds, ...ids }}
|
|
55
63
|
translations={arkTranslations}
|
|
56
64
|
class={cn('flex min-w-12 flex-col gap-1.5', className)}
|
|
57
65
|
data-slot="number-input"
|
|
@@ -69,23 +77,41 @@ buttons (`incrementLabel`, `decrementLabel`) and gives the field's announced rol
|
|
|
69
77
|
{/if}
|
|
70
78
|
{@render children?.()}
|
|
71
79
|
<NumberInput.Control
|
|
72
|
-
class="flex h-9 w-full overflow-hidden rounded-lg border border-border bg-sunken transition-all has-[input:focus-visible]:border-primary has-[input:focus-visible]:ring-3 has-[input:focus-visible]:ring-primary/20"
|
|
80
|
+
class="flex h-9 w-full overflow-hidden rounded-lg border border-border bg-sunken transition-all has-[input:focus-visible]:border-primary has-[input:focus-visible]:ring-3 has-[input:focus-visible]:ring-primary/20 data-disabled:opacity-50 data-invalid:border-danger data-invalid:has-[input:focus-visible]:border-danger data-invalid:has-[input:focus-visible]:ring-danger/20"
|
|
73
81
|
>
|
|
74
82
|
<NumberInput.Input
|
|
75
83
|
aria-roledescription={roleDescription}
|
|
76
|
-
class="min-w-0 flex-1 bg-transparent pl-2 text-sm text-fg outline-none placeholder:text-muted disabled:cursor-not-allowed
|
|
84
|
+
class="min-w-0 flex-1 bg-transparent pl-2 text-sm text-fg outline-none placeholder:text-muted disabled:cursor-not-allowed"
|
|
77
85
|
/>
|
|
78
86
|
<div class="flex shrink-0 flex-col border-l border-border">
|
|
79
|
-
<
|
|
80
|
-
|
|
87
|
+
<Tooltip
|
|
88
|
+
content={translations.incrementLabel}
|
|
89
|
+
triggerId={ids.incrementTrigger}
|
|
90
|
+
positioning={{ placement: 'right' }}
|
|
81
91
|
>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
{#snippet trigger(props)}
|
|
93
|
+
<NumberInput.IncrementTrigger
|
|
94
|
+
{...props}
|
|
95
|
+
class="flex flex-1 items-center justify-center px-1.5 text-muted transition-colors outline-none hover:bg-hover hover:text-fg focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none"
|
|
96
|
+
>
|
|
97
|
+
<MingcuteUpLine class="size-3" aria-hidden="true" />
|
|
98
|
+
</NumberInput.IncrementTrigger>
|
|
99
|
+
{/snippet}
|
|
100
|
+
</Tooltip>
|
|
101
|
+
<Tooltip
|
|
102
|
+
content={translations.decrementLabel}
|
|
103
|
+
triggerId={ids.decrementTrigger}
|
|
104
|
+
positioning={{ placement: 'right' }}
|
|
86
105
|
>
|
|
87
|
-
|
|
88
|
-
|
|
106
|
+
{#snippet trigger(props)}
|
|
107
|
+
<NumberInput.DecrementTrigger
|
|
108
|
+
{...props}
|
|
109
|
+
class="flex flex-1 items-center justify-center border-t border-border px-1.5 text-muted transition-colors outline-none hover:bg-hover hover:text-fg focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none"
|
|
110
|
+
>
|
|
111
|
+
<MingcuteDownLine class="size-3" aria-hidden="true" />
|
|
112
|
+
</NumberInput.DecrementTrigger>
|
|
113
|
+
{/snippet}
|
|
114
|
+
</Tooltip>
|
|
89
115
|
</div>
|
|
90
116
|
</NumberInput.Control>
|
|
91
117
|
</NumberInput.Root>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
1
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
2
2
|
import { NumberInput, type NumberInputRootProps, type NumberInputValueChangeDetails } from '@ark-ui/svelte';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
/** Classes added to the root, around the label and the field. */
|
|
@@ -19,14 +19,16 @@ type $$ComponentProps = {
|
|
|
19
19
|
translations: Required<Pick<NonNullable<NumberInputRootProps['translations']>, 'incrementLabel' | 'decrementLabel'>> & NonNullable<NumberInputRootProps['translations']> & {
|
|
20
20
|
roleDescription: string;
|
|
21
21
|
};
|
|
22
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
23
|
+
ids?: ComponentProps<typeof NumberInput.Root>['ids'];
|
|
22
24
|
/** Other props of Ark's `NumberInput.Root`. */
|
|
23
25
|
[key: string]: unknown;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* A number field with increment and decrement buttons (Ark NumberInput). `value` binds the text of
|
|
27
29
|
* the field; without it, Ark's `defaultValue` sets the first value. `translations` names the two
|
|
28
|
-
* buttons (`incrementLabel`, `decrementLabel`) and gives the
|
|
29
|
-
* (`roleDescription`).
|
|
30
|
+
* buttons (`incrementLabel`, `decrementLabel`), which show their names as tooltips too, and gives the
|
|
31
|
+
* field's announced role (`roleDescription`). Ark's `invalid` turns the border danger.
|
|
30
32
|
*/
|
|
31
33
|
declare const NumberInput: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
32
34
|
type NumberInput = ReturnType<typeof NumberInput>;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
@component
|
|
3
3
|
Page links with previous and next (Ark Pagination). `page` binds the current page; without it,
|
|
4
4
|
Ark's `defaultPage` sets the first one. Ark's `translations` name its controls (`rootLabel`,
|
|
5
|
-
`prevTriggerLabel`, `nextTriggerLabel`, `itemLabel`)
|
|
5
|
+
`prevTriggerLabel`, `nextTriggerLabel`, `itemLabel`); the previous and next arrows show their
|
|
6
|
+
names as tooltips too.
|
|
6
7
|
|
|
7
8
|
`children` replaces the built-in controls with the app's own, composed from the parts:
|
|
8
9
|
`PaginationPrevTrigger`, `PaginationNextTrigger`, `PaginationItem` (one page link),
|
|
@@ -81,7 +82,7 @@ Ark's `defaultPage` sets the first one. Ark's `translations` name its controls (
|
|
|
81
82
|
{:else}
|
|
82
83
|
<Pagination.Context>
|
|
83
84
|
{#snippet render(api)}
|
|
84
|
-
<PaginationPrevTrigger class="text-muted">
|
|
85
|
+
<PaginationPrevTrigger class="text-muted" label={translations.prevTriggerLabel}>
|
|
85
86
|
<MingcuteLeftLine class="size-4" aria-hidden="true" />
|
|
86
87
|
</PaginationPrevTrigger>
|
|
87
88
|
|
|
@@ -93,7 +94,7 @@ Ark's `defaultPage` sets the first one. Ark's `translations` name its controls (
|
|
|
93
94
|
{/if}
|
|
94
95
|
{/each}
|
|
95
96
|
|
|
96
|
-
<PaginationNextTrigger class="text-muted">
|
|
97
|
+
<PaginationNextTrigger class="text-muted" label={translations.nextTriggerLabel}>
|
|
97
98
|
<MingcuteRightLine class="size-4" aria-hidden="true" />
|
|
98
99
|
</PaginationNextTrigger>
|
|
99
100
|
{/snippet}
|
|
@@ -23,7 +23,8 @@ type $$ComponentProps = {
|
|
|
23
23
|
/**
|
|
24
24
|
* Page links with previous and next (Ark Pagination). `page` binds the current page; without it,
|
|
25
25
|
* Ark's `defaultPage` sets the first one. Ark's `translations` name its controls (`rootLabel`,
|
|
26
|
-
* `prevTriggerLabel`, `nextTriggerLabel`, `itemLabel`)
|
|
26
|
+
* `prevTriggerLabel`, `nextTriggerLabel`, `itemLabel`); the previous and next arrows show their
|
|
27
|
+
* names as tooltips too.
|
|
27
28
|
*
|
|
28
29
|
* `children` replaces the built-in controls with the app's own, composed from the parts:
|
|
29
30
|
* `PaginationPrevTrigger`, `PaginationNextTrigger`, `PaginationItem` (one page link),
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
|
-
The next-page button of a `Pagination`.
|
|
3
|
+
The next-page button of a `Pagination`, named by the pagination's `nextTriggerLabel`. A button
|
|
4
|
+
that shows only an icon takes a `label`, the same text: its accessible name and its tooltip.
|
|
4
5
|
-->
|
|
5
6
|
<script lang="ts">
|
|
6
7
|
import type { Snippet } from 'svelte';
|
|
8
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
9
|
import { Pagination } from '@ark-ui/svelte';
|
|
10
|
+
import { mergeProps } from '@ark-ui/svelte/utils';
|
|
8
11
|
import { cn } from '../../utils.js';
|
|
12
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
9
13
|
|
|
10
14
|
let {
|
|
11
15
|
class: className = '',
|
|
16
|
+
label,
|
|
12
17
|
children,
|
|
13
18
|
...rest
|
|
14
19
|
}: {
|
|
15
20
|
/** Classes added to the button. */
|
|
16
21
|
class?: string;
|
|
22
|
+
/**
|
|
23
|
+
* For a button that shows only an icon: its accessible name and its tooltip, the
|
|
24
|
+
* pagination's `nextTriggerLabel`. Unset, the button has no tooltip.
|
|
25
|
+
*/
|
|
26
|
+
label?: string;
|
|
17
27
|
/** The button's content, such as an arrow icon (with `aria-hidden`). */
|
|
18
28
|
children?: Snippet;
|
|
19
29
|
/** Other props of Ark's `Pagination.NextTrigger`. */
|
|
@@ -21,13 +31,22 @@ The next-page button of a `Pagination`.
|
|
|
21
31
|
} = $props();
|
|
22
32
|
</script>
|
|
23
33
|
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
{#snippet button(tooltipProps: HTMLAttributes<HTMLElement>)}
|
|
35
|
+
<Pagination.NextTrigger
|
|
36
|
+
{...mergeProps(tooltipProps, rest)}
|
|
37
|
+
aria-label={label}
|
|
38
|
+
class={cn(
|
|
39
|
+
'inline-flex size-8 items-center justify-center rounded-lg border border-transparent text-sm font-medium transition-colors hover:bg-hover hover:text-fg disabled:pointer-events-none disabled:opacity-50',
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
data-slot="pagination-next-trigger"
|
|
43
|
+
>
|
|
44
|
+
{@render children?.()}
|
|
45
|
+
</Pagination.NextTrigger>
|
|
46
|
+
{/snippet}
|
|
47
|
+
|
|
48
|
+
{#if label}
|
|
49
|
+
<Tooltip content={label} trigger={button} />
|
|
50
|
+
{:else}
|
|
51
|
+
{@render button({})}
|
|
52
|
+
{/if}
|
|
@@ -2,12 +2,20 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
type $$ComponentProps = {
|
|
3
3
|
/** Classes added to the button. */
|
|
4
4
|
class?: string;
|
|
5
|
+
/**
|
|
6
|
+
* For a button that shows only an icon: its accessible name and its tooltip, the
|
|
7
|
+
* pagination's `nextTriggerLabel`. Unset, the button has no tooltip.
|
|
8
|
+
*/
|
|
9
|
+
label?: string;
|
|
5
10
|
/** The button's content, such as an arrow icon (with `aria-hidden`). */
|
|
6
11
|
children?: Snippet;
|
|
7
12
|
/** Other props of Ark's `Pagination.NextTrigger`. */
|
|
8
13
|
[key: string]: unknown;
|
|
9
14
|
};
|
|
10
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The next-page button of a `Pagination`, named by the pagination's `nextTriggerLabel`. A button
|
|
17
|
+
* that shows only an icon takes a `label`, the same text: its accessible name and its tooltip.
|
|
18
|
+
*/
|
|
11
19
|
declare const PaginationNextTrigger: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
12
20
|
type PaginationNextTrigger = ReturnType<typeof PaginationNextTrigger>;
|
|
13
21
|
export default PaginationNextTrigger;
|
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
|
-
The previous-page button of a `Pagination`.
|
|
3
|
+
The previous-page button of a `Pagination`, named by the pagination's `prevTriggerLabel`. A button
|
|
4
|
+
that shows only an icon takes a `label`, the same text: its accessible name and its tooltip.
|
|
4
5
|
-->
|
|
5
6
|
<script lang="ts">
|
|
6
7
|
import type { Snippet } from 'svelte';
|
|
8
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
9
|
import { Pagination } from '@ark-ui/svelte';
|
|
10
|
+
import { mergeProps } from '@ark-ui/svelte/utils';
|
|
8
11
|
import { cn } from '../../utils.js';
|
|
12
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
9
13
|
|
|
10
14
|
let {
|
|
11
15
|
class: className = '',
|
|
16
|
+
label,
|
|
12
17
|
children,
|
|
13
18
|
...rest
|
|
14
19
|
}: {
|
|
15
20
|
/** Classes added to the button. */
|
|
16
21
|
class?: string;
|
|
22
|
+
/**
|
|
23
|
+
* For a button that shows only an icon: its accessible name and its tooltip, the
|
|
24
|
+
* pagination's `prevTriggerLabel`. Unset, the button has no tooltip.
|
|
25
|
+
*/
|
|
26
|
+
label?: string;
|
|
17
27
|
/** The button's content, such as an arrow icon (with `aria-hidden`). */
|
|
18
28
|
children?: Snippet;
|
|
19
29
|
/** Other props of Ark's `Pagination.PrevTrigger`. */
|
|
@@ -21,13 +31,22 @@ The previous-page button of a `Pagination`.
|
|
|
21
31
|
} = $props();
|
|
22
32
|
</script>
|
|
23
33
|
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
{#snippet button(tooltipProps: HTMLAttributes<HTMLElement>)}
|
|
35
|
+
<Pagination.PrevTrigger
|
|
36
|
+
{...mergeProps(tooltipProps, rest)}
|
|
37
|
+
aria-label={label}
|
|
38
|
+
class={cn(
|
|
39
|
+
'inline-flex size-8 items-center justify-center rounded-lg border border-transparent text-sm font-medium transition-colors hover:bg-hover hover:text-fg disabled:pointer-events-none disabled:opacity-50',
|
|
40
|
+
className
|
|
41
|
+
)}
|
|
42
|
+
data-slot="pagination-prev-trigger"
|
|
43
|
+
>
|
|
44
|
+
{@render children?.()}
|
|
45
|
+
</Pagination.PrevTrigger>
|
|
46
|
+
{/snippet}
|
|
47
|
+
|
|
48
|
+
{#if label}
|
|
49
|
+
<Tooltip content={label} trigger={button} />
|
|
50
|
+
{:else}
|
|
51
|
+
{@render button({})}
|
|
52
|
+
{/if}
|
|
@@ -2,12 +2,20 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
type $$ComponentProps = {
|
|
3
3
|
/** Classes added to the button. */
|
|
4
4
|
class?: string;
|
|
5
|
+
/**
|
|
6
|
+
* For a button that shows only an icon: its accessible name and its tooltip, the
|
|
7
|
+
* pagination's `prevTriggerLabel`. Unset, the button has no tooltip.
|
|
8
|
+
*/
|
|
9
|
+
label?: string;
|
|
5
10
|
/** The button's content, such as an arrow icon (with `aria-hidden`). */
|
|
6
11
|
children?: Snippet;
|
|
7
12
|
/** Other props of Ark's `Pagination.PrevTrigger`. */
|
|
8
13
|
[key: string]: unknown;
|
|
9
14
|
};
|
|
10
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The previous-page button of a `Pagination`, named by the pagination's `prevTriggerLabel`. A button
|
|
17
|
+
* that shows only an icon takes a `label`, the same text: its accessible name and its tooltip.
|
|
18
|
+
*/
|
|
11
19
|
declare const PaginationPrevTrigger: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
12
20
|
type PaginationPrevTrigger = ReturnType<typeof PaginationPrevTrigger>;
|
|
13
21
|
export default PaginationPrevTrigger;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
@component
|
|
3
3
|
A row of one-character fields for a code, such as the sign-up code (Ark PinInput). `value` binds
|
|
4
4
|
the characters; without it, Ark's `defaultValue` sets the first ones. Ark's
|
|
5
|
-
`translations.inputLabel` names each field ("Digit 2 of 6")
|
|
5
|
+
`translations.inputLabel` names each field ("Digit 2 of 6"), and its `invalid` turns the fields'
|
|
6
|
+
borders danger.
|
|
6
7
|
-->
|
|
7
8
|
<script lang="ts">
|
|
8
9
|
import type { Snippet } from 'svelte';
|
|
@@ -67,7 +68,7 @@ the characters; without it, Ark's `defaultValue` sets the first ones. Ark's
|
|
|
67
68
|
{#each indexes as index (index)}
|
|
68
69
|
<PinInput.Input
|
|
69
70
|
{index}
|
|
70
|
-
class="flex size-10 items-center justify-center rounded-lg border border-border bg-sunken text-center text-sm font-medium text-fg transition-colors outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"
|
|
71
|
+
class="flex size-10 items-center justify-center rounded-lg border border-border bg-sunken text-center text-sm font-medium text-fg transition-colors outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50 data-invalid:border-danger data-invalid:focus-visible:ring-danger"
|
|
71
72
|
/>
|
|
72
73
|
{/each}
|
|
73
74
|
</PinInput.Control>
|
|
@@ -21,7 +21,8 @@ type $$ComponentProps = {
|
|
|
21
21
|
/**
|
|
22
22
|
* A row of one-character fields for a code, such as the sign-up code (Ark PinInput). `value` binds
|
|
23
23
|
* the characters; without it, Ark's `defaultValue` sets the first ones. Ark's
|
|
24
|
-
* `translations.inputLabel` names each field ("Digit 2 of 6")
|
|
24
|
+
* `translations.inputLabel` names each field ("Digit 2 of 6"), and its `invalid` turns the fields'
|
|
25
|
+
* borders danger.
|
|
25
26
|
*/
|
|
26
27
|
declare const PinInput: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
27
28
|
type PinInput = ReturnType<typeof PinInput>;
|
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
@component
|
|
3
3
|
A non-modal panel anchored to its trigger (Ark Popover), with a title, content and footer;
|
|
4
4
|
`frosted` for a translucent surface. The trigger is a button holding the `trigger` snippet, styled
|
|
5
|
-
by `triggerClass
|
|
6
|
-
|
|
5
|
+
by `triggerClass`, and a trigger that shows only an icon takes a `triggerLabel`: its accessible
|
|
6
|
+
name and its tooltip. The title and description name and describe the panel. `open` binds whether
|
|
7
|
+
it is open; without it, Ark's `defaultOpen` sets the first state.
|
|
7
8
|
-->
|
|
8
9
|
<script lang="ts">
|
|
9
|
-
import type { Snippet } from 'svelte';
|
|
10
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
10
11
|
import { Popover, type PopoverOpenChangeDetails } from '@ark-ui/svelte';
|
|
11
12
|
import { Portal } from '@ark-ui/svelte/portal';
|
|
12
13
|
import { cn } from '../../utils.js';
|
|
14
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
13
15
|
|
|
14
16
|
let {
|
|
15
|
-
trigger,
|
|
17
|
+
trigger: triggerContent,
|
|
18
|
+
triggerLabel,
|
|
16
19
|
triggerClass = '',
|
|
17
20
|
title,
|
|
18
21
|
description,
|
|
@@ -22,10 +25,16 @@ is open; without it, Ark's `defaultOpen` sets the first state.
|
|
|
22
25
|
frosted = false,
|
|
23
26
|
open = $bindable(),
|
|
24
27
|
onOpenChange,
|
|
28
|
+
ids: appIds,
|
|
25
29
|
...rest
|
|
26
30
|
}: {
|
|
27
31
|
/** The trigger button's content; without it, the popover opens only through `open`. */
|
|
28
32
|
trigger?: Snippet;
|
|
33
|
+
/**
|
|
34
|
+
* The trigger's action, translated, such as "Filters", for a trigger that shows only an icon:
|
|
35
|
+
* its accessible name and its tooltip. Unset, the trigger's content names it.
|
|
36
|
+
*/
|
|
37
|
+
triggerLabel?: string;
|
|
29
38
|
/** Classes of the trigger button, such as `buttonVariants(...)`. */
|
|
30
39
|
triggerClass?: string;
|
|
31
40
|
/** The panel's title, which names it. */
|
|
@@ -44,12 +53,18 @@ is open; without it, Ark's `defaultOpen` sets the first state.
|
|
|
44
53
|
open?: boolean;
|
|
45
54
|
/** Called when the panel opens or closes, after `open` is updated. */
|
|
46
55
|
onOpenChange?: (details: PopoverOpenChangeDetails) => void;
|
|
56
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
57
|
+
ids?: ComponentProps<typeof Popover.Root>['ids'];
|
|
47
58
|
/** Other props of Ark's `Popover.Root`. */
|
|
48
59
|
[key: string]: unknown;
|
|
49
60
|
} = $props();
|
|
61
|
+
|
|
62
|
+
// The tooltip and the popover share the trigger, so both must know it by the same id.
|
|
63
|
+
const triggerId = $props.id();
|
|
50
64
|
</script>
|
|
51
65
|
|
|
52
66
|
<Popover.Root
|
|
67
|
+
ids={{ ...appIds, trigger: triggerId }}
|
|
53
68
|
{open}
|
|
54
69
|
onOpenChange={(details) => {
|
|
55
70
|
open = details.open;
|
|
@@ -57,9 +72,22 @@ is open; without it, Ark's `defaultOpen` sets the first state.
|
|
|
57
72
|
}}
|
|
58
73
|
{...rest}
|
|
59
74
|
>
|
|
60
|
-
{#if
|
|
75
|
+
{#if triggerContent && triggerLabel}
|
|
76
|
+
<Tooltip content={triggerLabel} {triggerId}>
|
|
77
|
+
{#snippet trigger(props)}
|
|
78
|
+
<Popover.Trigger
|
|
79
|
+
{...props}
|
|
80
|
+
aria-label={triggerLabel}
|
|
81
|
+
class={triggerClass || undefined}
|
|
82
|
+
data-slot="popover-trigger"
|
|
83
|
+
>
|
|
84
|
+
{@render triggerContent()}
|
|
85
|
+
</Popover.Trigger>
|
|
86
|
+
{/snippet}
|
|
87
|
+
</Tooltip>
|
|
88
|
+
{:else if triggerContent}
|
|
61
89
|
<Popover.Trigger class={triggerClass || undefined} data-slot="popover-trigger">
|
|
62
|
-
{@render
|
|
90
|
+
{@render triggerContent()}
|
|
63
91
|
</Popover.Trigger>
|
|
64
92
|
{/if}
|
|
65
93
|
<Portal>
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
1
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
2
2
|
import { Popover, type PopoverOpenChangeDetails } from '@ark-ui/svelte';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
/** The trigger button's content; without it, the popover opens only through `open`. */
|
|
5
5
|
trigger?: Snippet;
|
|
6
|
+
/**
|
|
7
|
+
* The trigger's action, translated, such as "Filters", for a trigger that shows only an icon:
|
|
8
|
+
* its accessible name and its tooltip. Unset, the trigger's content names it.
|
|
9
|
+
*/
|
|
10
|
+
triggerLabel?: string;
|
|
6
11
|
/** Classes of the trigger button, such as `buttonVariants(...)`. */
|
|
7
12
|
triggerClass?: string;
|
|
8
13
|
/** The panel's title, which names it. */
|
|
@@ -21,14 +26,17 @@ type $$ComponentProps = {
|
|
|
21
26
|
open?: boolean;
|
|
22
27
|
/** Called when the panel opens or closes, after `open` is updated. */
|
|
23
28
|
onOpenChange?: (details: PopoverOpenChangeDetails) => void;
|
|
29
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
30
|
+
ids?: ComponentProps<typeof Popover.Root>['ids'];
|
|
24
31
|
/** Other props of Ark's `Popover.Root`. */
|
|
25
32
|
[key: string]: unknown;
|
|
26
33
|
};
|
|
27
34
|
/**
|
|
28
35
|
* A non-modal panel anchored to its trigger (Ark Popover), with a title, content and footer;
|
|
29
36
|
* `frosted` for a translucent surface. The trigger is a button holding the `trigger` snippet, styled
|
|
30
|
-
* by `triggerClass
|
|
31
|
-
*
|
|
37
|
+
* by `triggerClass`, and a trigger that shows only an icon takes a `triggerLabel`: its accessible
|
|
38
|
+
* name and its tooltip. The title and description name and describe the panel. `open` binds whether
|
|
39
|
+
* it is open; without it, Ark's `defaultOpen` sets the first state.
|
|
32
40
|
*/
|
|
33
41
|
declare const Popover: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
34
42
|
type Popover = ReturnType<typeof Popover>;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
|
-
A button that closes the `Popover` it is in
|
|
3
|
+
A button that closes the `Popover` it is in, named by its `label`. A button that shows only an
|
|
4
|
+
icon sets `iconOnly`, and shows its `label` as a tooltip too.
|
|
4
5
|
-->
|
|
5
6
|
<script lang="ts">
|
|
6
7
|
import type { Snippet } from 'svelte';
|
|
8
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
9
|
import { Popover } from '@ark-ui/svelte';
|
|
10
|
+
import { mergeProps } from '@ark-ui/svelte/utils';
|
|
11
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
8
12
|
|
|
9
13
|
let {
|
|
10
14
|
class: className = '',
|
|
11
15
|
label,
|
|
16
|
+
iconOnly = false,
|
|
12
17
|
children,
|
|
13
18
|
...rest
|
|
14
19
|
}: {
|
|
@@ -16,6 +21,8 @@ A button that closes the `Popover` it is in.
|
|
|
16
21
|
class?: string;
|
|
17
22
|
/** The button's accessible name, such as "Close"; the same as its text when it has one. */
|
|
18
23
|
label: string;
|
|
24
|
+
/** The button shows only an icon: `label` is its tooltip too. */
|
|
25
|
+
iconOnly?: boolean;
|
|
19
26
|
/** The button's content: its text or an icon. */
|
|
20
27
|
children?: Snippet;
|
|
21
28
|
/** Other props of Ark's `Popover.CloseTrigger`. */
|
|
@@ -23,11 +30,19 @@ A button that closes the `Popover` it is in.
|
|
|
23
30
|
} = $props();
|
|
24
31
|
</script>
|
|
25
32
|
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
{#snippet button(tooltipProps: HTMLAttributes<HTMLElement>)}
|
|
34
|
+
<Popover.CloseTrigger
|
|
35
|
+
{...mergeProps(tooltipProps, rest)}
|
|
36
|
+
class={className || undefined}
|
|
37
|
+
aria-label={label}
|
|
38
|
+
data-slot="popover-close"
|
|
39
|
+
>
|
|
40
|
+
{@render children?.()}
|
|
41
|
+
</Popover.CloseTrigger>
|
|
42
|
+
{/snippet}
|
|
43
|
+
|
|
44
|
+
{#if iconOnly}
|
|
45
|
+
<Tooltip content={label} trigger={button} />
|
|
46
|
+
{:else}
|
|
47
|
+
{@render button({})}
|
|
48
|
+
{/if}
|
|
@@ -4,12 +4,17 @@ type $$ComponentProps = {
|
|
|
4
4
|
class?: string;
|
|
5
5
|
/** The button's accessible name, such as "Close"; the same as its text when it has one. */
|
|
6
6
|
label: string;
|
|
7
|
+
/** The button shows only an icon: `label` is its tooltip too. */
|
|
8
|
+
iconOnly?: boolean;
|
|
7
9
|
/** The button's content: its text or an icon. */
|
|
8
10
|
children?: Snippet;
|
|
9
11
|
/** Other props of Ark's `Popover.CloseTrigger`. */
|
|
10
12
|
[key: string]: unknown;
|
|
11
13
|
};
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* A button that closes the `Popover` it is in, named by its `label`. A button that shows only an
|
|
16
|
+
* icon sets `iconOnly`, and shows its `label` as a tooltip too.
|
|
17
|
+
*/
|
|
13
18
|
declare const PopoverClose: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
19
|
type PopoverClose = ReturnType<typeof PopoverClose>;
|
|
15
20
|
export default PopoverClose;
|