@widgetic/design-system 0.5.29 → 0.5.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/chat/SuggestionCard.svelte +13 -1
- package/dist/components/chat/SuggestionCard.svelte.d.ts +5 -0
- package/dist/components/color-picker/ColorPicker.svelte +324 -0
- package/dist/components/color-picker/ColorPicker.svelte.d.ts +34 -0
- package/dist/components/color-picker/colorPickerLogic.d.ts +77 -0
- package/dist/components/color-picker/colorPickerLogic.js +184 -0
- package/dist/components/color-picker/index.d.ts +2 -0
- package/dist/components/color-picker/index.js +3 -0
- package/dist/components/font-picker/FontPicker.svelte +169 -0
- package/dist/components/font-picker/FontPicker.svelte.d.ts +41 -0
- package/dist/components/font-picker/fontPickerLogic.d.ts +21 -0
- package/dist/components/font-picker/fontPickerLogic.js +29 -0
- package/dist/components/font-picker/index.d.ts +2 -0
- package/dist/components/font-picker/index.js +3 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/shell/NotificationDetail.svelte +96 -0
- package/dist/components/shell/NotificationDetail.svelte.d.ts +28 -0
- package/dist/components/shell/NotificationRow.svelte +6 -4
- package/dist/components/shell/SettingsDialog.svelte +43 -7
- package/dist/components/shell/SettingsDialog.svelte.d.ts +5 -0
- package/dist/components/shell/SettingsNav.svelte +72 -23
- package/dist/components/shell/SettingsNav.svelte.d.ts +7 -0
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +1 -0
- package/dist/components/toast/ToasterModal.svelte +4 -2
- package/dist/components/ui/button/button.svelte +11 -9
- package/dist/components/ui/button/button.svelte.d.ts +2 -2
- package/dist/components/ui/icon-button/icon-button.svelte +7 -6
- package/dist/components/ui/icon-button/icon-button.svelte.d.ts +2 -2
- package/dist/components/ui/select/select-item.svelte +18 -7
- package/dist/components/ui/select/select-item.svelte.d.ts +8 -2
- package/dist/components/ui/slider/slider.svelte +16 -1
- package/package.json +1 -1
|
@@ -10,37 +10,86 @@
|
|
|
10
10
|
groups: SettingsNavGroup[];
|
|
11
11
|
activeId: string;
|
|
12
12
|
onSelect?: (id: string) => void;
|
|
13
|
+
/**
|
|
14
|
+
* The menu is not known yet (the workspace the person is in is still loading, and with it what they may open): it is
|
|
15
|
+
* drawn as skeleton rows of the same size as the real ones, so that it does not grow row by row when it is known.
|
|
16
|
+
*/
|
|
17
|
+
pending?: boolean;
|
|
18
|
+
/** What a screen reader says for the menu while it is pending. */
|
|
19
|
+
pendingLabel?: string;
|
|
13
20
|
};
|
|
14
21
|
</script>
|
|
15
22
|
|
|
16
23
|
<script lang="ts">
|
|
17
24
|
import { cn } from '../../utils.js';
|
|
25
|
+
import Skeleton from '../ui/skeleton/skeleton.svelte';
|
|
18
26
|
import NavRow from './NavRow.svelte';
|
|
19
27
|
import NavSectionLabel from './NavSectionLabel.svelte';
|
|
20
28
|
import { settingsNavItemIsActive } from './settings-nav-types.js';
|
|
21
29
|
|
|
22
|
-
let {
|
|
30
|
+
let {
|
|
31
|
+
class: className,
|
|
32
|
+
groups,
|
|
33
|
+
activeId,
|
|
34
|
+
onSelect,
|
|
35
|
+
pending = false,
|
|
36
|
+
pendingLabel = 'Loading settings',
|
|
37
|
+
...restProps
|
|
38
|
+
}: SettingsNavProps = $props();
|
|
39
|
+
|
|
40
|
+
// The shape of the menu while it loads: a Workspace group of five rows and an Account group of two (what an owner sees
|
|
41
|
+
// at the least). Each row is a 16px icon and a label of its own width, on the 32px row of the real menu (Nav Row).
|
|
42
|
+
const pendingGroups: { id: string; labelWidth: string; labelWidths: string[] }[] = [
|
|
43
|
+
{ id: 'workspace', labelWidth: 'w-16', labelWidths: ['w-24', 'w-28', 'w-20', 'w-24', 'w-16'] },
|
|
44
|
+
{ id: 'account', labelWidth: 'w-14', labelWidths: ['w-20', 'w-28'] }
|
|
45
|
+
];
|
|
23
46
|
</script>
|
|
24
47
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</
|
|
48
|
+
{#if pending}
|
|
49
|
+
<!-- Figma: Settings Nav, Loading (Skeleton rows on the Nav Row grid) -->
|
|
50
|
+
<nav
|
|
51
|
+
class={cn('flex w-full flex-col gap-0.5', className)}
|
|
52
|
+
aria-label="Settings"
|
|
53
|
+
aria-busy="true"
|
|
54
|
+
data-settings-nav-pending
|
|
55
|
+
{...restProps}
|
|
56
|
+
>
|
|
57
|
+
<span class="sr-only" role="status">{pendingLabel}</span>
|
|
58
|
+
{#each pendingGroups as group (group.id)}
|
|
59
|
+
<div class="flex flex-col gap-0.5" aria-hidden="true">
|
|
60
|
+
<div class="flex h-8 w-full min-w-0 items-center py-1 ps-3 pe-2 pb-1">
|
|
61
|
+
<Skeleton class={cn('h-3', group.labelWidth)} pulse="low" />
|
|
62
|
+
</div>
|
|
63
|
+
{#each group.labelWidths as labelWidth, rowIndex (rowIndex)}
|
|
64
|
+
<div class="flex h-8 w-full min-w-0 items-center gap-2 py-1.5 ps-2 pe-2">
|
|
65
|
+
<Skeleton class="size-4 shrink-0" />
|
|
66
|
+
<Skeleton class={cn('h-3', labelWidth)} />
|
|
67
|
+
</div>
|
|
68
|
+
{/each}
|
|
69
|
+
</div>
|
|
70
|
+
{/each}
|
|
71
|
+
</nav>
|
|
72
|
+
{:else}
|
|
73
|
+
<nav class={cn('flex w-full flex-col gap-0.5', className)} aria-label="Settings" {...restProps}>
|
|
74
|
+
{#each groups as group (group.id)}
|
|
75
|
+
<div class="flex flex-col gap-0.5">
|
|
76
|
+
<NavSectionLabel label={group.label} />
|
|
77
|
+
{#each group.items as item (item.id)}
|
|
78
|
+
{@const active = settingsNavItemIsActive(activeId, item.id)}
|
|
79
|
+
<NavRow
|
|
80
|
+
label={item.label}
|
|
81
|
+
{active}
|
|
82
|
+
showIcon={Boolean(item.icon)}
|
|
83
|
+
onclick={() => onSelect?.(item.id)}
|
|
84
|
+
>
|
|
85
|
+
{#snippet icon()}
|
|
86
|
+
{#if item.icon}
|
|
87
|
+
{@render item.icon()}
|
|
88
|
+
{/if}
|
|
89
|
+
{/snippet}
|
|
90
|
+
</NavRow>
|
|
91
|
+
{/each}
|
|
92
|
+
</div>
|
|
93
|
+
{/each}
|
|
94
|
+
</nav>
|
|
95
|
+
{/if}
|
|
@@ -5,6 +5,13 @@ export type SettingsNavProps = HTMLAttributes<HTMLElement> & {
|
|
|
5
5
|
groups: SettingsNavGroup[];
|
|
6
6
|
activeId: string;
|
|
7
7
|
onSelect?: (id: string) => void;
|
|
8
|
+
/**
|
|
9
|
+
* The menu is not known yet (the workspace the person is in is still loading, and with it what they may open): it is
|
|
10
|
+
* drawn as skeleton rows of the same size as the real ones, so that it does not grow row by row when it is known.
|
|
11
|
+
*/
|
|
12
|
+
pending?: boolean;
|
|
13
|
+
/** What a screen reader says for the menu while it is pending. */
|
|
14
|
+
pendingLabel?: string;
|
|
8
15
|
};
|
|
9
16
|
declare const SettingsNav: import("svelte").Component<SettingsNavProps, {}, "">;
|
|
10
17
|
type SettingsNav = ReturnType<typeof SettingsNav>;
|
|
@@ -11,6 +11,7 @@ export { default as AppShell } from './AppShell.svelte';
|
|
|
11
11
|
export { default as ErrorState } from './ErrorState.svelte';
|
|
12
12
|
export { defaultErrorStateMessages, type ErrorStateMessages } from './error-state-messages.js';
|
|
13
13
|
export { default as NotificationRow, type NotificationRowProps } from './NotificationRow.svelte';
|
|
14
|
+
export { default as NotificationDetail, type NotificationDetailProps } from './NotificationDetail.svelte';
|
|
14
15
|
export { default as SettingsNav, type SettingsNavProps } from './SettingsNav.svelte';
|
|
15
16
|
export { default as SettingsDialog, type SettingsDialogProps } from './SettingsDialog.svelte';
|
|
16
17
|
export { default as Stat, type StatProps, statVariants } from './Stat.svelte';
|
|
@@ -14,6 +14,7 @@ export { default as ErrorState } from './ErrorState.svelte';
|
|
|
14
14
|
export { defaultErrorStateMessages } from './error-state-messages.js';
|
|
15
15
|
// [S2 exports]
|
|
16
16
|
export { default as NotificationRow } from './NotificationRow.svelte';
|
|
17
|
+
export { default as NotificationDetail } from './NotificationDetail.svelte';
|
|
17
18
|
export { default as SettingsNav } from './SettingsNav.svelte';
|
|
18
19
|
export { default as SettingsDialog } from './SettingsDialog.svelte';
|
|
19
20
|
export { default as Stat, statVariants } from './Stat.svelte';
|
|
@@ -90,15 +90,17 @@
|
|
|
90
90
|
classes: {
|
|
91
91
|
toast:
|
|
92
92
|
toastMainClass +
|
|
93
|
-
' !fixed !bottom-5 !end-5 !flex !min-w-[20rem] !max-w-[22.25rem] !items-start !gap-3 !rounded-xl !border !border-border !bg-popover !p-4 !text-popover-foreground !shadow-none [&>[data-icon]]:!mt-0.5 [&>[data-icon]]:!size-4 [&>[data-icon]_svg]:!size-4 [&>[data-icon]_svg]:!stroke-2',
|
|
93
|
+
' !fixed !bottom-5 !end-5 !flex !min-w-[20rem] !max-w-[22.25rem] !items-start !gap-3 !rounded-xl !border !border-border !bg-popover !p-4 !pe-10 !text-popover-foreground !shadow-none [&>[data-icon]]:!mt-0.5 [&>[data-icon]]:!size-4 [&>[data-icon]_svg]:!size-4 [&>[data-icon]_svg]:!stroke-2',
|
|
94
94
|
title: toastMainClass + '-title text-body-medium text-foreground',
|
|
95
95
|
description: toastMainClass + '-description text-body text-muted-foreground',
|
|
96
96
|
actionButton:
|
|
97
97
|
'!h-8 !rounded-lg !border !border-input !bg-background !px-2 !text-label !text-foreground hover:!bg-accent',
|
|
98
98
|
cancelButton: '',
|
|
99
|
+
// The same X as the one of the settings dialog: a plain X, no background, inside the toast at its end and top
|
|
100
|
+
// (16px, 2 stroke; its 32px target tints on hover and on the keyboard focus, as the dialog's does).
|
|
99
101
|
closeButton:
|
|
100
102
|
toastMainClass +
|
|
101
|
-
'-close-button !absolute
|
|
103
|
+
'-close-button !absolute !end-2 !top-2 !flex !size-8 !items-center !justify-center !rounded-lg !border-0 !bg-transparent !p-0 !text-foreground !transition-colors hover:!bg-accent focus-visible:!bg-accent focus-visible:!outline-hidden [&_svg]:!size-4 [&_svg]:!stroke-2',
|
|
102
104
|
// The icon takes the colour of its tone, the Icon modes of Figma: Muted for info (Default), Brand, Warning and Destructive.
|
|
103
105
|
info: '[&>[data-icon]]:!text-muted-foreground',
|
|
104
106
|
success: '[&>[data-icon]]:!text-brand',
|
|
@@ -13,21 +13,23 @@
|
|
|
13
13
|
import type { VariantProps } from "tailwind-variants";
|
|
14
14
|
|
|
15
15
|
export const buttonVariants = tv({
|
|
16
|
-
base: "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden
|
|
16
|
+
base: "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
|
|
17
17
|
variants: {
|
|
18
18
|
variant: {
|
|
19
|
-
|
|
19
|
+
// A button draws no ring when it holds the focus (a ring is drawn outside the button, and the edge of a scroll box
|
|
20
|
+
// or a card cut it off): the keyboard focus takes the look of the hover, inside the button.
|
|
21
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:bg-primary/90",
|
|
20
22
|
destructive:
|
|
21
|
-
"bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
23
|
+
"bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:bg-destructive/90",
|
|
22
24
|
outline:
|
|
23
|
-
"border border-input bg-background text-foreground hover:bg-accent hover:text-foreground",
|
|
25
|
+
"border border-input bg-background text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
24
26
|
secondary:
|
|
25
|
-
"bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground",
|
|
26
|
-
ghost: "text-foreground hover:bg-accent hover:text-foreground",
|
|
27
|
-
accent: "bg-brand text-brand-foreground hover:bg-brand/90",
|
|
27
|
+
"bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
28
|
+
ghost: "text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
29
|
+
accent: "bg-brand text-brand-foreground hover:bg-brand/90 focus-visible:bg-brand/90",
|
|
28
30
|
stroke:
|
|
29
|
-
"border border-border-strong/30 bg-transparent text-foreground hover:bg-accent hover:text-foreground",
|
|
30
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
31
|
+
"border border-border-strong/30 bg-transparent text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
32
|
+
link: "text-primary underline-offset-4 hover:underline focus-visible:underline",
|
|
31
33
|
},
|
|
32
34
|
size: {
|
|
33
35
|
// The 12 of the side (small: 8) and the 4 of the label box (see the note at the top), as Figma
|
|
@@ -23,7 +23,7 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
|
23
23
|
true: string;
|
|
24
24
|
false: string;
|
|
25
25
|
};
|
|
26
|
-
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden
|
|
26
|
+
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
27
27
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
28
28
|
size?: boolean | (string | number | symbol)[] | undefined;
|
|
29
29
|
iconPadding?: boolean | (string | number | symbol)[] | undefined;
|
|
@@ -81,7 +81,7 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
|
81
81
|
true: string;
|
|
82
82
|
false: string;
|
|
83
83
|
};
|
|
84
|
-
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden
|
|
84
|
+
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
85
85
|
variant: {
|
|
86
86
|
default: string;
|
|
87
87
|
destructive: string;
|
|
@@ -8,19 +8,20 @@
|
|
|
8
8
|
import type { VariantProps } from "tailwind-variants";
|
|
9
9
|
|
|
10
10
|
export const iconButtonVariants = tv({
|
|
11
|
-
base: "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden
|
|
11
|
+
base: "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
14
|
+
// No ring when it holds the focus (see Button): the keyboard focus takes the look of the hover.
|
|
14
15
|
ghost:
|
|
15
|
-
"rounded-lg text-foreground hover:bg-accent hover:text-foreground",
|
|
16
|
+
"rounded-lg text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
16
17
|
secondary:
|
|
17
|
-
"rounded-lg bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground",
|
|
18
|
+
"rounded-lg bg-secondary text-secondary-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
18
19
|
outline:
|
|
19
|
-
"rounded-lg border border-input bg-background text-foreground hover:bg-accent hover:text-foreground",
|
|
20
|
+
"rounded-lg border border-input bg-background text-foreground hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
20
21
|
primary:
|
|
21
|
-
"rounded-full bg-primary text-primary-foreground hover:bg-primary/90",
|
|
22
|
+
"rounded-full bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:bg-primary/90",
|
|
22
23
|
accent:
|
|
23
|
-
"rounded-full bg-brand text-brand-foreground hover:bg-brand/90",
|
|
24
|
+
"rounded-full bg-brand text-brand-foreground hover:bg-brand/90 focus-visible:bg-brand/90",
|
|
24
25
|
},
|
|
25
26
|
size: {
|
|
26
27
|
default: "size-8",
|
|
@@ -13,7 +13,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
13
13
|
default: string;
|
|
14
14
|
sm: string;
|
|
15
15
|
};
|
|
16
|
-
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden
|
|
16
|
+
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
17
17
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
18
18
|
size?: boolean | (string | number | symbol)[] | undefined;
|
|
19
19
|
variant?: boolean | (string | number | symbol)[] | undefined;
|
|
@@ -50,7 +50,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
50
50
|
default: string;
|
|
51
51
|
sm: string;
|
|
52
52
|
};
|
|
53
|
-
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden
|
|
53
|
+
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
54
54
|
variant: {
|
|
55
55
|
ghost: string;
|
|
56
56
|
secondary: string;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
<!-- Figma: Select Option (component set 170:135, node 170:135). -->
|
|
2
2
|
<script lang="ts" module>
|
|
3
3
|
import { Select as SelectPrimitive, type WithoutChild } from "bits-ui";
|
|
4
|
-
export type SelectItemProps = WithoutChild<SelectPrimitive.ItemProps
|
|
4
|
+
export type SelectItemProps = WithoutChild<SelectPrimitive.ItemProps> & {
|
|
5
|
+
/**
|
|
6
|
+
* The check at the start of the chosen row (default: shown). Turn it off when the row draws its own leading mark and says
|
|
7
|
+
* "Selected" in words (Figma: Billing, "Paid with": a card icon on every row, "Selected" at the end of the chosen one).
|
|
8
|
+
*/
|
|
9
|
+
showIndicator?: boolean;
|
|
10
|
+
};
|
|
5
11
|
</script>
|
|
6
12
|
|
|
7
13
|
<script lang="ts">
|
|
@@ -13,6 +19,7 @@
|
|
|
13
19
|
class: className,
|
|
14
20
|
value,
|
|
15
21
|
label,
|
|
22
|
+
showIndicator = true,
|
|
16
23
|
children: childrenProp,
|
|
17
24
|
...restProps
|
|
18
25
|
}: SelectItemProps = $props();
|
|
@@ -29,17 +36,21 @@
|
|
|
29
36
|
bind:ref
|
|
30
37
|
{value}
|
|
31
38
|
class={cn(
|
|
32
|
-
"relative flex h-8 w-full cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5
|
|
39
|
+
"relative flex h-8 w-full cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 text-body outline-hidden data-[selected]:bg-brand-subtle hover:not-data-[selected]:bg-accent [[data-input-modality=keyboard]_&]:not-data-[selected]:data-[highlighted]:bg-accent [[data-input-modality=keyboard]_&]:not-data-[selected]:not-data-[highlighted]:hover:bg-transparent data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50",
|
|
40
|
+
// The start padding leaves room for the check; a row without one keeps the plain padding for its own leading mark.
|
|
41
|
+
showIndicator && "ps-8",
|
|
33
42
|
className
|
|
34
43
|
)}
|
|
35
44
|
{...restProps}
|
|
36
45
|
>
|
|
37
46
|
{#snippet children({ selected, highlighted })}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
{#if showIndicator}
|
|
48
|
+
<span class="absolute start-2 flex size-3.5 items-center justify-center">
|
|
49
|
+
{#if selected}
|
|
50
|
+
<IconCheck class="size-4 stroke-2" aria-hidden="true" />
|
|
51
|
+
{/if}
|
|
52
|
+
</span>
|
|
53
|
+
{/if}
|
|
43
54
|
{#if childrenProp}
|
|
44
55
|
{@render childrenProp({ selected, highlighted })}
|
|
45
56
|
{:else}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Select as SelectPrimitive, type WithoutChild } from "bits-ui";
|
|
2
|
-
export type SelectItemProps = WithoutChild<SelectPrimitive.ItemProps
|
|
3
|
-
|
|
2
|
+
export type SelectItemProps = WithoutChild<SelectPrimitive.ItemProps> & {
|
|
3
|
+
/**
|
|
4
|
+
* The check at the start of the chosen row (default: shown). Turn it off when the row draws its own leading mark and says
|
|
5
|
+
* "Selected" in words (Figma: Billing, "Paid with": a card icon on every row, "Selected" at the end of the chosen one).
|
|
6
|
+
*/
|
|
7
|
+
showIndicator?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const SelectItem: import("svelte").Component<SelectItemProps, {}, "ref">;
|
|
4
10
|
type SelectItem = ReturnType<typeof SelectItem>;
|
|
5
11
|
export default SelectItem;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<!--
|
|
1
|
+
<!--
|
|
2
|
+
Figma: IC Slider (Editor); track input, range primary, 4px track / 16px thumb.
|
|
3
|
+
|
|
4
|
+
`aria-label` and `aria-labelledby` name the thumb, which is the element a screen reader lands on (the root is a plain span with
|
|
5
|
+
no role, so a name on it is never spoken). With two thumbs (a range) each one gets the name and its place: "Price 1", "Price 2".
|
|
6
|
+
-->
|
|
2
7
|
<script lang="ts" module>
|
|
3
8
|
import { Slider as SliderPrimitive, type WithoutChildrenOrChild } from "bits-ui";
|
|
4
9
|
export type SliderProps = WithoutChildrenOrChild<SliderPrimitive.RootProps>;
|
|
@@ -14,8 +19,16 @@
|
|
|
14
19
|
ref = $bindable(null),
|
|
15
20
|
value = $bindable(),
|
|
16
21
|
class: className,
|
|
22
|
+
"aria-label": ariaLabel,
|
|
23
|
+
"aria-labelledby": ariaLabelledby,
|
|
17
24
|
...restProps
|
|
18
25
|
}: SliderProps = $props();
|
|
26
|
+
|
|
27
|
+
/** The name of one thumb: the label as given for a single thumb, numbered for a range. */
|
|
28
|
+
function thumbLabel(thumb: number, thumbCount: number): string | undefined {
|
|
29
|
+
if (!ariaLabel) return undefined;
|
|
30
|
+
return thumbCount > 1 ? `${ariaLabel} ${thumb + 1}` : ariaLabel;
|
|
31
|
+
}
|
|
19
32
|
</script>
|
|
20
33
|
|
|
21
34
|
<SliderPrimitive.Root
|
|
@@ -32,6 +45,8 @@
|
|
|
32
45
|
{#each thumbs as thumb}
|
|
33
46
|
<SliderPrimitive.Thumb
|
|
34
47
|
index={thumb}
|
|
48
|
+
aria-label={thumbLabel(thumb, thumbs.length)}
|
|
49
|
+
aria-labelledby={ariaLabelledby}
|
|
35
50
|
class="relative z-20 block size-4 rounded-full border-2 border-primary bg-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50"
|
|
36
51
|
/>
|
|
37
52
|
{/each}
|