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,11 +1,13 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
Copies a value to the clipboard, showing it, selectable, with a copy button that confirms the
|
|
4
|
-
copy (Ark Clipboard); Ark `translations` name the button (`triggerLabel`)
|
|
4
|
+
copy (Ark Clipboard); Ark `translations` name the button (`triggerLabel`), and the button, which
|
|
5
|
+
has no text, shows the same name in a tooltip, before and after the copy.
|
|
5
6
|
-->
|
|
6
7
|
<script lang="ts">
|
|
7
8
|
import { Clipboard, type ClipboardRootProps } from '@ark-ui/svelte';
|
|
8
9
|
import { cn } from '../../utils.js';
|
|
10
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
9
11
|
import MingcuteCopy2Line from '~icons/mingcute/copy-2-line';
|
|
10
12
|
import MingcuteCheckLine from '~icons/mingcute/check-line';
|
|
11
13
|
|
|
@@ -20,7 +22,10 @@ copy (Ark Clipboard); Ark `translations` name the button (`triggerLabel`).
|
|
|
20
22
|
value: string;
|
|
21
23
|
/** The visible label above the value, such as "Invite link". */
|
|
22
24
|
label?: string;
|
|
23
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* `triggerLabel(copied)` names the copy button, before and after the copy: its accessible
|
|
27
|
+
* name and its tooltip.
|
|
28
|
+
*/
|
|
24
29
|
translations: Required<NonNullable<ClipboardRootProps['translations']>>;
|
|
25
30
|
/** Classes merged onto the root. */
|
|
26
31
|
class?: string;
|
|
@@ -48,16 +53,28 @@ copy (Ark Clipboard); Ark `translations` name the button (`triggerLabel`).
|
|
|
48
53
|
>
|
|
49
54
|
<Clipboard.ValueText class="flex-1 truncate select-text" />
|
|
50
55
|
</div>
|
|
51
|
-
<Clipboard.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
<Clipboard.Context>
|
|
57
|
+
{#snippet render(clipboard)}
|
|
58
|
+
{@const name = translations.triggerLabel(clipboard().copied)}
|
|
59
|
+
<!-- Kept open on click, so the tooltip turns to the copied label under the pointer. -->
|
|
60
|
+
<Tooltip content={name} closeOnClick={false}>
|
|
61
|
+
{#snippet trigger(props)}
|
|
62
|
+
<Clipboard.Trigger
|
|
63
|
+
{...props}
|
|
64
|
+
aria-label={name}
|
|
65
|
+
class="relative inline-flex h-8 w-8 items-center justify-center gap-2 rounded-lg border border-border text-muted transition-all hover:bg-hover hover:text-fg"
|
|
66
|
+
data-slot="clipboard-trigger"
|
|
67
|
+
>
|
|
68
|
+
<Clipboard.Indicator>
|
|
69
|
+
<MingcuteCopy2Line class="size-4" aria-hidden="true" />
|
|
70
|
+
{#snippet copied()}
|
|
71
|
+
<MingcuteCheckLine class="size-4 text-success" aria-hidden="true" />
|
|
72
|
+
{/snippet}
|
|
73
|
+
</Clipboard.Indicator>
|
|
74
|
+
</Clipboard.Trigger>
|
|
75
|
+
{/snippet}
|
|
76
|
+
</Tooltip>
|
|
77
|
+
{/snippet}
|
|
78
|
+
</Clipboard.Context>
|
|
62
79
|
</div>
|
|
63
80
|
</Clipboard.Root>
|
|
@@ -4,7 +4,10 @@ type $$ComponentProps = {
|
|
|
4
4
|
value: string;
|
|
5
5
|
/** The visible label above the value, such as "Invite link". */
|
|
6
6
|
label?: string;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* `triggerLabel(copied)` names the copy button, before and after the copy: its accessible
|
|
9
|
+
* name and its tooltip.
|
|
10
|
+
*/
|
|
8
11
|
translations: Required<NonNullable<ClipboardRootProps['translations']>>;
|
|
9
12
|
/** Classes merged onto the root. */
|
|
10
13
|
class?: string;
|
|
@@ -13,7 +16,8 @@ type $$ComponentProps = {
|
|
|
13
16
|
};
|
|
14
17
|
/**
|
|
15
18
|
* Copies a value to the clipboard, showing it, selectable, with a copy button that confirms the
|
|
16
|
-
* copy (Ark Clipboard); Ark `translations` name the button (`triggerLabel`)
|
|
19
|
+
* copy (Ark Clipboard); Ark `translations` name the button (`triggerLabel`), and the button, which
|
|
20
|
+
* has no text, shows the same name in a tooltip, before and after the copy.
|
|
17
21
|
*/
|
|
18
22
|
declare const Clipboard: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
19
23
|
type Clipboard = ReturnType<typeof Clipboard>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
|
-
Content that a trigger shows and hides (Ark Collapsible)
|
|
3
|
+
Content that a trigger shows and hides (Ark Collapsible); disabled, the trigger is turned off and
|
|
4
|
+
faded.
|
|
4
5
|
-->
|
|
5
6
|
<script lang="ts">
|
|
6
7
|
import type { Snippet } from 'svelte';
|
|
@@ -13,6 +14,7 @@ Content that a trigger shows and hides (Ark Collapsible).
|
|
|
13
14
|
children,
|
|
14
15
|
open = $bindable(),
|
|
15
16
|
onOpenChange,
|
|
17
|
+
disabled = false,
|
|
16
18
|
...rest
|
|
17
19
|
}: {
|
|
18
20
|
/** Classes merged onto the root. */
|
|
@@ -25,7 +27,9 @@ Content that a trigger shows and hides (Ark Collapsible).
|
|
|
25
27
|
open?: boolean;
|
|
26
28
|
/** Called with the new state when the content is shown or hidden. */
|
|
27
29
|
onOpenChange?: (details: CollapsibleOpenChangeDetails) => void;
|
|
28
|
-
/**
|
|
30
|
+
/** Turns the trigger off (faded), so the content stays shown or hidden as it is. */
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/** Other props of Ark's `Collapsible.Root`, such as `defaultOpen` and `lazyMount`. */
|
|
29
33
|
[key: string]: unknown;
|
|
30
34
|
} = $props();
|
|
31
35
|
</script>
|
|
@@ -34,6 +38,7 @@ Content that a trigger shows and hides (Ark Collapsible).
|
|
|
34
38
|
class={cn('flex flex-col', className)}
|
|
35
39
|
data-slot="collapsible"
|
|
36
40
|
{open}
|
|
41
|
+
{disabled}
|
|
37
42
|
onOpenChange={(details) => {
|
|
38
43
|
open = details.open;
|
|
39
44
|
onOpenChange?.(details);
|
|
@@ -41,8 +46,10 @@ Content that a trigger shows and hides (Ark Collapsible).
|
|
|
41
46
|
{...rest}
|
|
42
47
|
>
|
|
43
48
|
{#if trigger}
|
|
49
|
+
<!-- Zag only marks the trigger data-disabled: the attribute takes it out of the tab order too. -->
|
|
44
50
|
<Collapsible.Trigger
|
|
45
|
-
|
|
51
|
+
{disabled}
|
|
52
|
+
class="flex items-center gap-2 text-sm font-medium outline-none focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50"
|
|
46
53
|
data-slot="collapsible-trigger"
|
|
47
54
|
>
|
|
48
55
|
{@render trigger()}
|
|
@@ -11,10 +11,15 @@ type $$ComponentProps = {
|
|
|
11
11
|
open?: boolean;
|
|
12
12
|
/** Called with the new state when the content is shown or hidden. */
|
|
13
13
|
onOpenChange?: (details: CollapsibleOpenChangeDetails) => void;
|
|
14
|
-
/**
|
|
14
|
+
/** Turns the trigger off (faded), so the content stays shown or hidden as it is. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Other props of Ark's `Collapsible.Root`, such as `defaultOpen` and `lazyMount`. */
|
|
15
17
|
[key: string]: unknown;
|
|
16
18
|
};
|
|
17
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Content that a trigger shows and hides (Ark Collapsible); disabled, the trigger is turned off and
|
|
21
|
+
* faded.
|
|
22
|
+
*/
|
|
18
23
|
declare const Collapsible: import("svelte").Component<$$ComponentProps, {}, "open">;
|
|
19
24
|
type Collapsible = ReturnType<typeof Collapsible>;
|
|
20
25
|
export default Collapsible;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
Picks a colour: a hex field and a swatch trigger opening an area, hue and alpha sliders and
|
|
4
|
-
fields (Ark ColorPicker)
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
fields (Ark ColorPicker). The hex fields show 8 digits, the alpha always written (`FF` when
|
|
5
|
+
opaque), and take 3, 4, 6 or 8 digits (opaque without alpha digits). Under the controls, the colour
|
|
6
|
+
is written in each of `formats` at once (hex, `rgba()` and `hsla()` by default), and under them the
|
|
7
|
+
`swatches`, preset colours on a single line; no swatches, no row. `labels` names every control
|
|
8
|
+
for assistive technology and gives the values the sliders announce; the trigger takes the visible
|
|
9
|
+
`label` when there is one, and shows `labels.trigger` in its tooltip.
|
|
7
10
|
-->
|
|
8
11
|
<script lang="ts">
|
|
12
|
+
import type { ComponentProps } from 'svelte';
|
|
9
13
|
import {
|
|
10
14
|
ColorPicker,
|
|
11
15
|
type ColorPickerColor as Color,
|
|
@@ -13,6 +17,8 @@ there is one.
|
|
|
13
17
|
} from '@ark-ui/svelte';
|
|
14
18
|
import { Portal } from '@ark-ui/svelte/portal';
|
|
15
19
|
import { cn } from '../../utils.js';
|
|
20
|
+
import { formatColor, parseHex, type ColorFormat } from './formats';
|
|
21
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
16
22
|
|
|
17
23
|
let {
|
|
18
24
|
class: className = '',
|
|
@@ -21,6 +27,10 @@ there is one.
|
|
|
21
27
|
value = $bindable(),
|
|
22
28
|
onValueChange,
|
|
23
29
|
swatches = [],
|
|
30
|
+
formats = ['hexa', 'rgba', 'hsla'],
|
|
31
|
+
disabled = false,
|
|
32
|
+
readOnly = false,
|
|
33
|
+
ids: appIds,
|
|
24
34
|
...rest
|
|
25
35
|
}: {
|
|
26
36
|
/** Classes merged onto the root. */
|
|
@@ -52,14 +62,24 @@ there is one.
|
|
|
52
62
|
hex: string;
|
|
53
63
|
/** A preset swatch, from its colour string, such as `Use ${color}`. */
|
|
54
64
|
swatch: (color: string) => string;
|
|
65
|
+
/** The list of the colour's values in `formats`, such as "Colour values". */
|
|
66
|
+
formats: string;
|
|
55
67
|
};
|
|
56
68
|
/** The colour (bindable), from `parseColor`; when unset, `defaultValue` gives the first one. */
|
|
57
69
|
value?: Color;
|
|
58
70
|
/** Called with the new colour while it changes. */
|
|
59
71
|
onValueChange?: (details: ColorPickerValueChangeDetails) => void;
|
|
60
|
-
/** Preset colours offered under the picker, as CSS colour strings; none when empty. */
|
|
72
|
+
/** Preset colours offered on one line under the picker, as CSS colour strings; none when empty. */
|
|
61
73
|
swatches?: readonly string[];
|
|
62
|
-
/**
|
|
74
|
+
/** The formats the colour is written in under the controls, in order; none when empty. */
|
|
75
|
+
formats?: readonly ColorFormat[];
|
|
76
|
+
/** Turns every control off. */
|
|
77
|
+
disabled?: boolean;
|
|
78
|
+
/** Shows the colour without letting it change. */
|
|
79
|
+
readOnly?: boolean;
|
|
80
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
81
|
+
ids?: ComponentProps<typeof ColorPicker.Root>['ids'];
|
|
82
|
+
/** Other props of Ark's `ColorPicker.Root`, such as `defaultValue` and `name`. */
|
|
63
83
|
[key: string]: unknown;
|
|
64
84
|
} = $props();
|
|
65
85
|
|
|
@@ -67,12 +87,52 @@ there is one.
|
|
|
67
87
|
function toAreaColor(color: Color, format: string): Color {
|
|
68
88
|
return color.toFormat(format.startsWith('hsl') ? 'hsla' : 'hsba');
|
|
69
89
|
}
|
|
90
|
+
|
|
91
|
+
// The trigger's id, shared by Ark's color picker and its tooltip, which both find it by id.
|
|
92
|
+
const uid = $props.id();
|
|
93
|
+
const triggerId = `${uid}-trigger`;
|
|
94
|
+
|
|
95
|
+
/** Takes the typed hex when it reads as a colour; otherwise puts the current one back. */
|
|
96
|
+
function commitHex(input: HTMLInputElement, current: Color, setValue: (color: Color) => void) {
|
|
97
|
+
const typed = parseHex(input.value);
|
|
98
|
+
if (typed) setValue(typed);
|
|
99
|
+
input.value = formatColor(typed ?? current, 'hexa');
|
|
100
|
+
}
|
|
70
101
|
</script>
|
|
71
102
|
|
|
103
|
+
{#snippet hexField(className: string)}
|
|
104
|
+
<ColorPicker.Context>
|
|
105
|
+
{#snippet render(api)}
|
|
106
|
+
<input
|
|
107
|
+
type="text"
|
|
108
|
+
aria-label={labels.hex}
|
|
109
|
+
spellcheck="false"
|
|
110
|
+
autocomplete="off"
|
|
111
|
+
maxlength={9}
|
|
112
|
+
class={cn(
|
|
113
|
+
'flex w-full rounded-lg border border-border bg-sunken font-mono text-fg outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary disabled:opacity-50',
|
|
114
|
+
className
|
|
115
|
+
)}
|
|
116
|
+
data-slot="color-picker-hex"
|
|
117
|
+
value={formatColor(api().value, 'hexa')}
|
|
118
|
+
{disabled}
|
|
119
|
+
readonly={readOnly}
|
|
120
|
+
onchange={(event) => commitHex(event.currentTarget, api().value, api().setValue)}
|
|
121
|
+
onkeydown={(event) => {
|
|
122
|
+
if (event.key === 'Enter') commitHex(event.currentTarget, api().value, api().setValue);
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
{/snippet}
|
|
126
|
+
</ColorPicker.Context>
|
|
127
|
+
{/snippet}
|
|
128
|
+
|
|
72
129
|
<ColorPicker.Root
|
|
73
130
|
class={cn('flex flex-col gap-1.5', className)}
|
|
74
131
|
data-slot="color-picker"
|
|
75
132
|
{value}
|
|
133
|
+
{disabled}
|
|
134
|
+
{readOnly}
|
|
135
|
+
ids={{ ...appIds, trigger: triggerId }}
|
|
76
136
|
onValueChange={(details) => {
|
|
77
137
|
value = details.value;
|
|
78
138
|
onValueChange?.(details);
|
|
@@ -83,22 +143,23 @@ there is one.
|
|
|
83
143
|
<ColorPicker.Label class="text-sm font-medium text-fg">{label}</ColorPicker.Label>
|
|
84
144
|
{/if}
|
|
85
145
|
<ColorPicker.Control class="flex items-center gap-2">
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
146
|
+
{@render hexField('h-8 px-3 py-1 text-sm shadow-sm')}
|
|
147
|
+
<Tooltip content={labels.trigger} {triggerId}>
|
|
148
|
+
{#snippet trigger(props)}
|
|
149
|
+
<ColorPicker.Trigger
|
|
150
|
+
{...props}
|
|
151
|
+
aria-label={labels.trigger}
|
|
152
|
+
class="inline-flex size-8 shrink-0 items-center justify-center rounded-lg border border-border shadow-sm transition-colors hover:opacity-90"
|
|
153
|
+
>
|
|
154
|
+
<ColorPicker.TransparencyGrid class="rounded-md" />
|
|
155
|
+
<ColorPicker.Context>
|
|
156
|
+
{#snippet render(api)}
|
|
157
|
+
<ColorPicker.Swatch value={api().value} class="size-full rounded-md" />
|
|
158
|
+
{/snippet}
|
|
159
|
+
</ColorPicker.Context>
|
|
160
|
+
</ColorPicker.Trigger>
|
|
161
|
+
{/snippet}
|
|
162
|
+
</Tooltip>
|
|
102
163
|
</ColorPicker.Control>
|
|
103
164
|
<Portal>
|
|
104
165
|
<ColorPicker.Positioner>
|
|
@@ -146,11 +207,7 @@ there is one.
|
|
|
146
207
|
</ColorPicker.Context>
|
|
147
208
|
|
|
148
209
|
<div class="flex gap-2">
|
|
149
|
-
|
|
150
|
-
channel="hex"
|
|
151
|
-
aria-label={labels.hex}
|
|
152
|
-
class="flex h-7 w-full rounded-md border border-border bg-sunken px-2 font-mono text-xs text-fg outline-none focus-visible:ring-1 focus-visible:ring-primary"
|
|
153
|
-
/>
|
|
210
|
+
{@render hexField('h-7 rounded-md px-2 text-xs')}
|
|
154
211
|
<ColorPicker.ChannelInput
|
|
155
212
|
channel="alpha"
|
|
156
213
|
aria-label={labels.alpha}
|
|
@@ -158,13 +215,33 @@ there is one.
|
|
|
158
215
|
/>
|
|
159
216
|
</div>
|
|
160
217
|
|
|
218
|
+
{#if formats.length > 0}
|
|
219
|
+
<ColorPicker.Context>
|
|
220
|
+
{#snippet render(api)}
|
|
221
|
+
<ul
|
|
222
|
+
aria-label={labels.formats}
|
|
223
|
+
class="grid gap-1 border-t border-border pt-3 font-mono text-xs text-fg-2"
|
|
224
|
+
data-slot="color-picker-formats"
|
|
225
|
+
>
|
|
226
|
+
{#each formats as format (format)}
|
|
227
|
+
<li class="truncate select-text">{formatColor(api().value, format)}</li>
|
|
228
|
+
{/each}
|
|
229
|
+
</ul>
|
|
230
|
+
{/snippet}
|
|
231
|
+
</ColorPicker.Context>
|
|
232
|
+
{/if}
|
|
233
|
+
|
|
161
234
|
{#if swatches.length > 0}
|
|
162
|
-
|
|
235
|
+
<!-- One line whatever their number: the swatches share its width. -->
|
|
236
|
+
<ColorPicker.SwatchGroup
|
|
237
|
+
class="grid auto-cols-fr grid-flow-col gap-1.5"
|
|
238
|
+
data-slot="color-picker-swatches"
|
|
239
|
+
>
|
|
163
240
|
{#each swatches as color (color)}
|
|
164
241
|
<ColorPicker.SwatchTrigger
|
|
165
242
|
value={color}
|
|
166
243
|
aria-label={labels.swatch(color)}
|
|
167
|
-
class="
|
|
244
|
+
class="aspect-square max-h-7 w-full rounded-md border border-border shadow-sm transition-transform hover:scale-110"
|
|
168
245
|
>
|
|
169
246
|
<ColorPicker.Swatch value={color} class="size-full rounded-md" />
|
|
170
247
|
</ColorPicker.SwatchTrigger>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
1
2
|
import { ColorPicker, type ColorPickerColor as Color, type ColorPickerValueChangeDetails } from '@ark-ui/svelte';
|
|
3
|
+
import { type ColorFormat } from './formats';
|
|
2
4
|
type $$ComponentProps = {
|
|
3
5
|
/** Classes merged onto the root. */
|
|
4
6
|
class?: string;
|
|
@@ -29,21 +31,34 @@ type $$ComponentProps = {
|
|
|
29
31
|
hex: string;
|
|
30
32
|
/** A preset swatch, from its colour string, such as `Use ${color}`. */
|
|
31
33
|
swatch: (color: string) => string;
|
|
34
|
+
/** The list of the colour's values in `formats`, such as "Colour values". */
|
|
35
|
+
formats: string;
|
|
32
36
|
};
|
|
33
37
|
/** The colour (bindable), from `parseColor`; when unset, `defaultValue` gives the first one. */
|
|
34
38
|
value?: Color;
|
|
35
39
|
/** Called with the new colour while it changes. */
|
|
36
40
|
onValueChange?: (details: ColorPickerValueChangeDetails) => void;
|
|
37
|
-
/** Preset colours offered under the picker, as CSS colour strings; none when empty. */
|
|
41
|
+
/** Preset colours offered on one line under the picker, as CSS colour strings; none when empty. */
|
|
38
42
|
swatches?: readonly string[];
|
|
39
|
-
/**
|
|
43
|
+
/** The formats the colour is written in under the controls, in order; none when empty. */
|
|
44
|
+
formats?: readonly ColorFormat[];
|
|
45
|
+
/** Turns every control off. */
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/** Shows the colour without letting it change. */
|
|
48
|
+
readOnly?: boolean;
|
|
49
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
50
|
+
ids?: ComponentProps<typeof ColorPicker.Root>['ids'];
|
|
51
|
+
/** Other props of Ark's `ColorPicker.Root`, such as `defaultValue` and `name`. */
|
|
40
52
|
[key: string]: unknown;
|
|
41
53
|
};
|
|
42
54
|
/**
|
|
43
55
|
* Picks a colour: a hex field and a swatch trigger opening an area, hue and alpha sliders and
|
|
44
|
-
* fields (Ark ColorPicker)
|
|
45
|
-
*
|
|
46
|
-
*
|
|
56
|
+
* fields (Ark ColorPicker). The hex fields show 8 digits, the alpha always written (`FF` when
|
|
57
|
+
* opaque), and take 3, 4, 6 or 8 digits (opaque without alpha digits). Under the controls, the colour
|
|
58
|
+
* is written in each of `formats` at once (hex, `rgba()` and `hsla()` by default), and under them the
|
|
59
|
+
* `swatches`, preset colours on a single line; no swatches, no row. `labels` names every control
|
|
60
|
+
* for assistive technology and gives the values the sliders announce; the trigger takes the visible
|
|
61
|
+
* `label` when there is one, and shows `labels.trigger` in its tooltip.
|
|
47
62
|
*/
|
|
48
63
|
declare const ColorPicker: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
49
64
|
type ColorPicker = ReturnType<typeof ColorPicker>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colour formats `ColorPicker` writes a colour in: 8-digit hex (the alpha always written, `FF`
|
|
3
|
+
* when opaque), `rgba()`, `hsla()` and `hsba()`, rounded for reading; and the hex text a person
|
|
4
|
+
* types, read back into a colour.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type ColorPickerColor } from '@ark-ui/svelte';
|
|
8
|
+
/** A format the picker can show a colour in. */
|
|
9
|
+
export type ColorFormat = 'hexa' | 'rgba' | 'hsla' | 'hsba';
|
|
10
|
+
/**
|
|
11
|
+
* `color` written in `format`: `#RRGGBBAA` in capitals, or a CSS function with whole channels and
|
|
12
|
+
* the alpha to two decimals.
|
|
13
|
+
*
|
|
14
|
+
* @example formatColor(parseColor('#3b82f6'), 'rgba') // 'rgba(59, 130, 246, 1)'
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatColor(color: ColorPickerColor, format: ColorFormat): string;
|
|
17
|
+
/**
|
|
18
|
+
* The colour a person typed as hex: 3, 4, 6 or 8 digits, with or without `#`, any case. Without
|
|
19
|
+
* alpha digits, the colour is opaque. `undefined` for anything else.
|
|
20
|
+
*
|
|
21
|
+
* @example parseHex('3b82f6')?.toString('hexa') // '#3B82F6FF'
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseHex(text: string): ColorPickerColor | undefined;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colour formats `ColorPicker` writes a colour in: 8-digit hex (the alpha always written, `FF`
|
|
3
|
+
* when opaque), `rgba()`, `hsla()` and `hsba()`, rounded for reading; and the hex text a person
|
|
4
|
+
* types, read back into a colour.
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { parseColor } from '@ark-ui/svelte';
|
|
8
|
+
/** Rounds to at most `digits` decimals, without trailing zeros. */
|
|
9
|
+
function round(value, digits = 0) {
|
|
10
|
+
const scale = 10 ** digits;
|
|
11
|
+
return Math.round(value * scale) / scale;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `color` written in `format`: `#RRGGBBAA` in capitals, or a CSS function with whole channels and
|
|
15
|
+
* the alpha to two decimals.
|
|
16
|
+
*
|
|
17
|
+
* @example formatColor(parseColor('#3b82f6'), 'rgba') // 'rgba(59, 130, 246, 1)'
|
|
18
|
+
*/
|
|
19
|
+
export function formatColor(color, format) {
|
|
20
|
+
const alpha = round(color.getChannelValue('alpha'), 2);
|
|
21
|
+
switch (format) {
|
|
22
|
+
case 'hexa':
|
|
23
|
+
return color.toString('hexa');
|
|
24
|
+
case 'rgba': {
|
|
25
|
+
const rgb = color.toFormat('rgba');
|
|
26
|
+
const [red, green, blue] = ['red', 'green', 'blue'].map((channel) => round(rgb.getChannelValue(channel)));
|
|
27
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
28
|
+
}
|
|
29
|
+
case 'hsla': {
|
|
30
|
+
const hsl = color.toFormat('hsla');
|
|
31
|
+
const [hue, saturation, lightness] = ['hue', 'saturation', 'lightness'].map((channel) => round(hsl.getChannelValue(channel)));
|
|
32
|
+
return `hsla(${hue}, ${saturation}%, ${lightness}%, ${alpha})`;
|
|
33
|
+
}
|
|
34
|
+
case 'hsba': {
|
|
35
|
+
const hsb = color.toFormat('hsba');
|
|
36
|
+
const [hue, saturation, brightness] = ['hue', 'saturation', 'brightness'].map((channel) => round(hsb.getChannelValue(channel)));
|
|
37
|
+
return `hsba(${hue}, ${saturation}%, ${brightness}%, ${alpha})`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The colour a person typed as hex: 3, 4, 6 or 8 digits, with or without `#`, any case. Without
|
|
43
|
+
* alpha digits, the colour is opaque. `undefined` for anything else.
|
|
44
|
+
*
|
|
45
|
+
* @example parseHex('3b82f6')?.toString('hexa') // '#3B82F6FF'
|
|
46
|
+
*/
|
|
47
|
+
export function parseHex(text) {
|
|
48
|
+
const digits = text.trim().replace(/^#/, '');
|
|
49
|
+
if (!/^([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(digits))
|
|
50
|
+
return undefined;
|
|
51
|
+
return parseColor(`#${digits}`);
|
|
52
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The color picker entry point: `ColorPicker`,
|
|
2
|
+
* The color picker entry point: `ColorPicker`, the `ColorFormat`s it writes a colour in, and
|
|
3
|
+
* `ColorPickerColor as Color`, `parseColor`.
|
|
3
4
|
* @module
|
|
4
5
|
*/
|
|
5
6
|
export { default as ColorPicker } from './ColorPicker.svelte';
|
|
7
|
+
export type { ColorFormat } from './formats';
|
|
6
8
|
export type { ColorPickerColor as Color } from '@ark-ui/svelte';
|
|
7
9
|
export { parseColor } from '@ark-ui/svelte';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The color picker entry point: `ColorPicker`,
|
|
2
|
+
* The color picker entry point: `ColorPicker`, the `ColorFormat`s it writes a colour in, and
|
|
3
|
+
* `ColorPickerColor as Color`, `parseColor`.
|
|
3
4
|
* @module
|
|
4
5
|
*/
|
|
5
6
|
export { default as ColorPicker } from './ColorPicker.svelte';
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
A text field that filters a list of options to choose from (Ark Combobox): typing keeps the
|
|
4
4
|
options whose label contains the text, ignoring case and accents, and `emptyText` shows when none
|
|
5
5
|
does. `label`, required, names the field, and Ark `translations` name the open button
|
|
6
|
-
(`triggerLabel
|
|
6
|
+
(`triggerLabel`, also its tooltip). `openOnClick` opens the options as soon as the field is pressed. Ark announces the number of matching options to screen readers only when
|
|
7
7
|
`translations` gives the messages (`resultsCount`, `noResults`, `loading`): it has no English of its
|
|
8
8
|
own to fall back on here.
|
|
9
9
|
-->
|
|
10
10
|
<script lang="ts">
|
|
11
|
+
import type { ComponentProps } from 'svelte';
|
|
11
12
|
import {
|
|
12
13
|
Combobox,
|
|
13
14
|
createListCollection,
|
|
@@ -19,6 +20,7 @@ own to fall back on here.
|
|
|
19
20
|
import { cn } from '../../utils.js';
|
|
20
21
|
import MingcuteSelectorVerticalLine from '~icons/mingcute/selector-vertical-line';
|
|
21
22
|
import MingcuteCheckLine from '~icons/mingcute/check-line';
|
|
23
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
22
24
|
|
|
23
25
|
type ArkTranslations = NonNullable<
|
|
24
26
|
ComboboxRootProps<{ label: string; value: string }>['translations']
|
|
@@ -29,9 +31,11 @@ own to fall back on here.
|
|
|
29
31
|
label,
|
|
30
32
|
placeholder = '',
|
|
31
33
|
emptyText,
|
|
34
|
+
openOnClick = false,
|
|
32
35
|
onInputValueChange,
|
|
33
36
|
translations,
|
|
34
37
|
class: className = '',
|
|
38
|
+
ids: appIds,
|
|
35
39
|
...rest
|
|
36
40
|
}: {
|
|
37
41
|
/** The options: the text shown and the value chosen, unique. */
|
|
@@ -42,6 +46,11 @@ own to fall back on here.
|
|
|
42
46
|
placeholder?: string;
|
|
43
47
|
/** Shown when no option matches, such as "No results found." */
|
|
44
48
|
emptyText: string;
|
|
49
|
+
/**
|
|
50
|
+
* Opens the options as soon as the field is pressed, not only once the user types or from
|
|
51
|
+
* the open button; the field keeps the focus, so typing to search starts at once.
|
|
52
|
+
*/
|
|
53
|
+
openOnClick?: boolean;
|
|
45
54
|
/** Called with the field's text when it changes. */
|
|
46
55
|
onInputValueChange?: (details: ComboboxInputValueChangeDetails) => void;
|
|
47
56
|
/**
|
|
@@ -52,6 +61,8 @@ own to fall back on here.
|
|
|
52
61
|
Pick<ArkTranslations, 'resultsCount' | 'noResults' | 'loading'>;
|
|
53
62
|
/** Classes merged onto the root. */
|
|
54
63
|
class?: string;
|
|
64
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
65
|
+
ids?: ComponentProps<typeof Combobox.Root>['ids'];
|
|
55
66
|
/** Other props of Ark's `Combobox.Root`, such as `value`, `onValueChange` and `multiple`. */
|
|
56
67
|
[key: string]: unknown;
|
|
57
68
|
} = $props();
|
|
@@ -65,6 +76,10 @@ own to fall back on here.
|
|
|
65
76
|
loading: translations.loading ?? ''
|
|
66
77
|
});
|
|
67
78
|
|
|
79
|
+
// The open button's id, shared by Ark's combobox and its tooltip, which both find it by id.
|
|
80
|
+
const uid = $props.id();
|
|
81
|
+
const triggerId = `${uid}-trigger`;
|
|
82
|
+
|
|
68
83
|
const filters = useFilter({ sensitivity: 'base' });
|
|
69
84
|
let query = $state('');
|
|
70
85
|
const matches = $derived(items.filter((item) => filters().contains(item.label, query)));
|
|
@@ -80,6 +95,8 @@ own to fall back on here.
|
|
|
80
95
|
|
|
81
96
|
<Combobox.Root
|
|
82
97
|
{collection}
|
|
98
|
+
{openOnClick}
|
|
99
|
+
ids={{ ...appIds, trigger: triggerId }}
|
|
83
100
|
onInputValueChange={changeInput}
|
|
84
101
|
translations={arkTranslations}
|
|
85
102
|
class={cn('flex flex-col gap-1.5', className)}
|
|
@@ -95,9 +112,16 @@ own to fall back on here.
|
|
|
95
112
|
class="flex h-8 w-full rounded-lg border border-border bg-sunken px-3 py-1 text-sm text-fg shadow-sm outline-none placeholder:text-muted focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary"
|
|
96
113
|
data-slot="combobox-input"
|
|
97
114
|
/>
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
115
|
+
<Tooltip content={translations.triggerLabel} {triggerId}>
|
|
116
|
+
{#snippet trigger(props)}
|
|
117
|
+
<Combobox.Trigger
|
|
118
|
+
{...props}
|
|
119
|
+
class="absolute top-1/2 right-2 -translate-y-1/2 text-muted transition-colors hover:text-fg"
|
|
120
|
+
>
|
|
121
|
+
<MingcuteSelectorVerticalLine class="size-4" aria-hidden="true" />
|
|
122
|
+
</Combobox.Trigger>
|
|
123
|
+
{/snippet}
|
|
124
|
+
</Tooltip>
|
|
101
125
|
</Combobox.Control>
|
|
102
126
|
<Portal>
|
|
103
127
|
<Combobox.Positioner>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
1
2
|
import { Combobox, type ComboboxInputValueChangeDetails, type ComboboxRootProps } from '@ark-ui/svelte';
|
|
2
3
|
type ArkTranslations = NonNullable<ComboboxRootProps<{
|
|
3
4
|
label: string;
|
|
@@ -15,6 +16,11 @@ type $$ComponentProps = {
|
|
|
15
16
|
placeholder?: string;
|
|
16
17
|
/** Shown when no option matches, such as "No results found." */
|
|
17
18
|
emptyText: string;
|
|
19
|
+
/**
|
|
20
|
+
* Opens the options as soon as the field is pressed, not only once the user types or from
|
|
21
|
+
* the open button; the field keeps the focus, so typing to search starts at once.
|
|
22
|
+
*/
|
|
23
|
+
openOnClick?: boolean;
|
|
18
24
|
/** Called with the field's text when it changes. */
|
|
19
25
|
onInputValueChange?: (details: ComboboxInputValueChangeDetails) => void;
|
|
20
26
|
/**
|
|
@@ -24,6 +30,8 @@ type $$ComponentProps = {
|
|
|
24
30
|
translations: Required<Pick<ArkTranslations, 'triggerLabel'>> & Pick<ArkTranslations, 'resultsCount' | 'noResults' | 'loading'>;
|
|
25
31
|
/** Classes merged onto the root. */
|
|
26
32
|
class?: string;
|
|
33
|
+
/** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
|
|
34
|
+
ids?: ComponentProps<typeof Combobox.Root>['ids'];
|
|
27
35
|
/** Other props of Ark's `Combobox.Root`, such as `value`, `onValueChange` and `multiple`. */
|
|
28
36
|
[key: string]: unknown;
|
|
29
37
|
};
|
|
@@ -31,7 +39,7 @@ type $$ComponentProps = {
|
|
|
31
39
|
* A text field that filters a list of options to choose from (Ark Combobox): typing keeps the
|
|
32
40
|
* options whose label contains the text, ignoring case and accents, and `emptyText` shows when none
|
|
33
41
|
* does. `label`, required, names the field, and Ark `translations` name the open button
|
|
34
|
-
* (`triggerLabel
|
|
42
|
+
* (`triggerLabel`, also its tooltip). `openOnClick` opens the options as soon as the field is pressed. Ark announces the number of matching options to screen readers only when
|
|
35
43
|
* `translations` gives the messages (`resultsCount`, `noResults`, `loading`): it has no English of its
|
|
36
44
|
* own to fall back on here.
|
|
37
45
|
*/
|