@immich/ui 0.50.1 → 0.52.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/dist/components/Alert/Alert.svelte +1 -1
- package/dist/components/Badge/Badge.svelte +1 -1
- package/dist/components/Card/Card.svelte +2 -2
- package/dist/components/CommandPalette/CommandPaletteDefaultProvider.svelte +14 -0
- package/dist/components/CommandPalette/CommandPaletteDefaultProvider.svelte.d.ts +8 -0
- package/dist/components/CommandPalette/CommandPaletteItem.svelte +4 -23
- package/dist/components/CommandPalette/CommandPaletteItem.svelte.d.ts +0 -1
- package/dist/components/CommandPalette/CommandPaletteProvider.svelte +18 -0
- package/dist/components/CommandPalette/CommandPaletteProvider.svelte.d.ts +7 -0
- package/dist/components/Heading/Heading.svelte +6 -13
- package/dist/components/IconButton/IconButton.svelte +2 -2
- package/dist/components/Markdown/Heading.svelte +9 -12
- package/dist/components/Modal/Modal.svelte +31 -31
- package/dist/components/Textarea/Textarea.svelte +8 -2
- package/dist/components/Toast/ToastPanel.svelte +19 -16
- package/dist/components/Tooltip/Tooltip.svelte +38 -0
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +11 -0
- package/dist/components/Tooltip/TooltipProvider.svelte +15 -0
- package/dist/components/Tooltip/TooltipProvider.svelte.d.ts +8 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/internal/Button.svelte +44 -27
- package/dist/internal/CommandPaletteModal.svelte +26 -23
- package/dist/internal/CommandPaletteModal.svelte.d.ts +3 -1
- package/dist/internal/Select.svelte +1 -1
- package/dist/services/command-palette-manager.svelte.d.ts +19 -77
- package/dist/services/command-palette-manager.svelte.js +44 -152
- package/dist/site/SiteFooter.svelte +3 -0
- package/dist/site/constants.d.ts +1 -0
- package/dist/site/constants.js +2 -1
- package/dist/types.d.ts +1 -0
- package/dist/utilities/common.d.ts +1 -0
- package/dist/utilities/common.js +15 -1
- package/dist/utilities/internal.d.ts +3 -1
- package/dist/utilities/internal.js +3 -0
- package/package.json +2 -2
- package/dist/components/CommandPalette/CommandPaletteContext.svelte +0 -18
- package/dist/components/CommandPalette/CommandPaletteContext.svelte.d.ts +0 -7
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
{#if open}
|
|
84
84
|
<Card {color} class={cleanClass(className)}>
|
|
85
85
|
<CardBody>
|
|
86
|
-
<div class=
|
|
86
|
+
<div class={cleanClass((closable || onClose) && 'flex items-center justify-between')}>
|
|
87
87
|
<div class={cleanClass('flex gap-2')}>
|
|
88
88
|
{#if icon}
|
|
89
89
|
<div>
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
primary: 'bg-primary-50 dark:bg-primary-100',
|
|
53
53
|
secondary: 'text-dark bg-light-50 dark:bg-light-100 dark:text-white',
|
|
54
54
|
success: 'bg-success-50 dark:bg-success-100',
|
|
55
|
-
danger: 'bg-danger-
|
|
56
|
-
warning: 'bg-warning-
|
|
55
|
+
danger: 'bg-danger-100',
|
|
56
|
+
warning: 'bg-warning-100',
|
|
57
57
|
info: 'bg-info-50 dark:bg-info-100',
|
|
58
58
|
},
|
|
59
59
|
},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import CommandPaletteProvider from './CommandPaletteProvider.svelte';
|
|
3
|
+
import { defaultProvider } from '../../services/command-palette-manager.svelte.js';
|
|
4
|
+
import type { ActionItem } from '../../types.js';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
name: string;
|
|
8
|
+
actions?: ActionItem[];
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const { name, actions = [] }: Props = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<CommandPaletteProvider providers={[defaultProvider({ name, actions })]} />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActionItem } from '../../types.js';
|
|
2
|
+
type Props = {
|
|
3
|
+
name: string;
|
|
4
|
+
actions?: ActionItem[];
|
|
5
|
+
};
|
|
6
|
+
declare const CommandPaletteDefaultProvider: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type CommandPaletteDefaultProvider = ReturnType<typeof CommandPaletteDefaultProvider>;
|
|
8
|
+
export default CommandPaletteDefaultProvider;
|
|
@@ -3,26 +3,18 @@
|
|
|
3
3
|
import Badge from '../Badge/Badge.svelte';
|
|
4
4
|
import Button from '../Button/Button.svelte';
|
|
5
5
|
import Icon from '../Icon/Icon.svelte';
|
|
6
|
-
import IconButton from '../IconButton/IconButton.svelte';
|
|
7
6
|
import Kbd from '../Kbd/Kbd.svelte';
|
|
8
7
|
import Text from '../Text/Text.svelte';
|
|
9
8
|
import type { ActionItem } from '../../types.js';
|
|
10
9
|
import { cleanClass } from '../../utilities/internal.js';
|
|
11
|
-
import { mdiClose } from '@mdi/js';
|
|
12
10
|
|
|
13
11
|
type Props = {
|
|
14
12
|
item: ActionItem;
|
|
15
13
|
selected: boolean;
|
|
16
14
|
onSelect: () => void;
|
|
17
|
-
onRemove?: () => void;
|
|
18
15
|
};
|
|
19
16
|
|
|
20
|
-
const { item, selected,
|
|
21
|
-
|
|
22
|
-
const handleRemove = (event: MouseEvent) => {
|
|
23
|
-
event.stopPropagation();
|
|
24
|
-
onRemove?.();
|
|
25
|
-
};
|
|
17
|
+
const { item, selected, onSelect }: Props = $props();
|
|
26
18
|
|
|
27
19
|
const shortcuts =
|
|
28
20
|
item.shortcuts === undefined ? [] : Array.isArray(item.shortcuts) ? item.shortcuts : [item.shortcuts];
|
|
@@ -60,24 +52,13 @@
|
|
|
60
52
|
>
|
|
61
53
|
{/if}
|
|
62
54
|
<div class="mt-2">
|
|
63
|
-
<Badge color="primary" size="small">{item.type}</Badge>
|
|
55
|
+
<Badge color="primary" size="small" shape="round">{item.type}</Badge>
|
|
64
56
|
{#if item.isGlobal}
|
|
65
|
-
<Badge color="warning" size="small">Global</Badge>
|
|
57
|
+
<Badge color="warning" size="small" shape="round">Global</Badge>
|
|
66
58
|
{/if}
|
|
67
59
|
</div>
|
|
68
60
|
</div>
|
|
69
|
-
{#if
|
|
70
|
-
<IconButton
|
|
71
|
-
size="small"
|
|
72
|
-
onclick={handleRemove}
|
|
73
|
-
class="shrink-0"
|
|
74
|
-
icon={mdiClose}
|
|
75
|
-
shape="round"
|
|
76
|
-
variant="ghost"
|
|
77
|
-
color="secondary"
|
|
78
|
-
aria-label="Remove"
|
|
79
|
-
/>
|
|
80
|
-
{:else if renderedShortcuts.length > 0}
|
|
61
|
+
{#if renderedShortcuts.length > 0}
|
|
81
62
|
<div class="flex shrink-0 flex-col justify-end gap-1">
|
|
82
63
|
{#each renderedShortcuts as shortcut (shortcut.join('-'))}
|
|
83
64
|
<div class="flex justify-end">
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { commandPaletteManager, type ActionProvider } from '../../services/command-palette-manager.svelte.js';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
providers: ActionProvider[];
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const { providers }: Props = $props();
|
|
9
|
+
|
|
10
|
+
$effect(() => {
|
|
11
|
+
const callbacks: Array<() => void> = [];
|
|
12
|
+
for (const provider of providers) {
|
|
13
|
+
callbacks.push(commandPaletteManager.addProvider(provider));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return () => callbacks.forEach((callback) => callback());
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ActionProvider } from '../../services/command-palette-manager.svelte.js';
|
|
2
|
+
type Props = {
|
|
3
|
+
providers: ActionProvider[];
|
|
4
|
+
};
|
|
5
|
+
declare const CommandPaletteProvider: import("svelte").Component<Props, {}, "">;
|
|
6
|
+
type CommandPaletteProvider = ReturnType<typeof CommandPaletteProvider>;
|
|
7
|
+
export default CommandPaletteProvider;
|
|
@@ -20,25 +20,18 @@
|
|
|
20
20
|
children: Snippet;
|
|
21
21
|
} & HTMLAttributes<HTMLElement>;
|
|
22
22
|
|
|
23
|
-
const {
|
|
24
|
-
tag = 'p',
|
|
25
|
-
size = 'medium',
|
|
26
|
-
fontWeight = 'semi-bold',
|
|
27
|
-
class: className,
|
|
28
|
-
children,
|
|
29
|
-
...restProps
|
|
30
|
-
}: Props = $props();
|
|
23
|
+
const { tag = 'p', size = 'medium', fontWeight = 'bold', class: className, children, ...restProps }: Props = $props();
|
|
31
24
|
|
|
32
25
|
const styles = tv({
|
|
33
26
|
base: 'leading-none tracking-tight',
|
|
34
27
|
variants: {
|
|
35
28
|
size: {
|
|
36
|
-
tiny: 'text-
|
|
37
|
-
small: 'text-
|
|
38
|
-
medium: 'text-
|
|
29
|
+
tiny: 'text-base',
|
|
30
|
+
small: 'text-lg',
|
|
31
|
+
medium: 'text-xl',
|
|
39
32
|
large: 'text-3xl',
|
|
40
|
-
giant: 'text-
|
|
41
|
-
title: 'text-
|
|
33
|
+
giant: 'text-5xl',
|
|
34
|
+
title: 'text-7xl',
|
|
42
35
|
},
|
|
43
36
|
},
|
|
44
37
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import Button from '../../internal/Button.svelte';
|
|
3
2
|
import Icon from '../Icon/Icon.svelte';
|
|
3
|
+
import Button from '../../internal/Button.svelte';
|
|
4
4
|
import type { IconButtonProps } from '../../types.js';
|
|
5
5
|
|
|
6
6
|
const { icon, flipped, flopped, title, 'aria-label': ariaLabel, ...buttonProps }: IconButtonProps = $props();
|
|
7
7
|
|
|
8
|
-
const buttonTitle = $derived(title
|
|
8
|
+
const buttonTitle = $derived(title ?? ariaLabel);
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<Button icon {...buttonProps} title={buttonTitle} aria-label={ariaLabel}>
|
|
@@ -11,33 +11,30 @@
|
|
|
11
11
|
|
|
12
12
|
const { children, id, level }: Props = $props();
|
|
13
13
|
|
|
14
|
-
const getSizeAndTag = (level?: number): { size: Size; tag: HeadingTag } => {
|
|
14
|
+
const getSizeAndTag = (level?: number): { size: Size; tag: HeadingTag; padding: string } => {
|
|
15
15
|
switch (level) {
|
|
16
16
|
case 1: {
|
|
17
|
-
return { size: 'giant', tag: 'h1' };
|
|
17
|
+
return { size: 'giant', tag: 'h1', padding: 'mb-6' };
|
|
18
18
|
}
|
|
19
19
|
case 2: {
|
|
20
|
-
return { size: 'large', tag: 'h2' };
|
|
20
|
+
return { size: 'large', tag: 'h2', padding: 'my-4' };
|
|
21
21
|
}
|
|
22
22
|
case 3: {
|
|
23
|
-
return { size: 'medium', tag: 'h3' };
|
|
23
|
+
return { size: 'medium', tag: 'h3', padding: 'my-3' };
|
|
24
24
|
}
|
|
25
25
|
case 4: {
|
|
26
|
-
return { size: 'small', tag: 'h4' };
|
|
26
|
+
return { size: 'small', tag: 'h4', padding: 'my-1' };
|
|
27
27
|
}
|
|
28
28
|
case 5: {
|
|
29
|
-
return { size: 'tiny', tag: 'h5' };
|
|
30
|
-
}
|
|
31
|
-
case 6: {
|
|
32
|
-
return { size: 'tiny', tag: 'h6' };
|
|
29
|
+
return { size: 'tiny', tag: 'h5', padding: 'my-0.5' };
|
|
33
30
|
}
|
|
34
31
|
default: {
|
|
35
|
-
return { size: 'tiny', tag: 'p' };
|
|
32
|
+
return { size: 'tiny', tag: 'p', padding: '' };
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
};
|
|
39
36
|
|
|
40
|
-
let { size, tag } = $derived(getSizeAndTag(level));
|
|
37
|
+
let { size, tag, padding } = $derived(getSizeAndTag(level));
|
|
41
38
|
</script>
|
|
42
39
|
|
|
43
|
-
<Heading {size} {tag} class=
|
|
40
|
+
<Heading {size} {tag} class={padding} {id} {children} />
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
import CloseButton from '../CloseButton/CloseButton.svelte';
|
|
9
9
|
import Icon from '../Icon/Icon.svelte';
|
|
10
10
|
import Logo from '../Logo/Logo.svelte';
|
|
11
|
+
import TooltipProvider from '../Tooltip/TooltipProvider.svelte';
|
|
11
12
|
import { ChildKey, zIndex } from '../../constants.js';
|
|
12
|
-
import { commandPaletteManager } from '../../services/command-palette-manager.svelte.js';
|
|
13
13
|
import type { ModalSize } from '../../types.js';
|
|
14
14
|
import { cleanClass } from '../../utilities/internal.js';
|
|
15
15
|
import { Dialog } from 'bits-ui';
|
|
16
|
-
import {
|
|
16
|
+
import { tick, type Snippet } from 'svelte';
|
|
17
17
|
import { tv } from 'tailwind-variants';
|
|
18
18
|
|
|
19
19
|
type Props = {
|
|
@@ -86,8 +86,6 @@
|
|
|
86
86
|
|
|
87
87
|
const interactOutsideBehavior = $derived(closeOnBackdropClick ? 'close' : 'ignore');
|
|
88
88
|
const escapeKeydownBehavior = $derived(closeOnEsc ? 'close' : 'ignore');
|
|
89
|
-
|
|
90
|
-
onMount(() => commandPaletteManager.pushContextLayer());
|
|
91
89
|
</script>
|
|
92
90
|
|
|
93
91
|
<Dialog.Root open={true} onOpenChange={(isOpen: boolean) => !isOpen && handleClose()}>
|
|
@@ -99,35 +97,37 @@
|
|
|
99
97
|
{interactOutsideBehavior}
|
|
100
98
|
class={cleanClass(modalContentStyles({ size }))}
|
|
101
99
|
>
|
|
102
|
-
<
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
100
|
+
<TooltipProvider>
|
|
101
|
+
<div class={cleanClass('flex w-full grow flex-col justify-center')}>
|
|
102
|
+
<Card bind:ref={cardRef} class={cleanClass(modalStyles({ size }), className)}>
|
|
103
|
+
<CardHeader class="border-b border-gray-200 px-5 py-3 dark:border-white/10">
|
|
104
|
+
{#if headerChildren}
|
|
105
|
+
{@render headerChildren.snippet()}
|
|
106
|
+
{:else if title}
|
|
107
|
+
<div class="flex items-center justify-between gap-2">
|
|
108
|
+
{#if typeof icon === 'string'}
|
|
109
|
+
<Icon {icon} size="1.5rem" aria-hidden />
|
|
110
|
+
{:else if icon}
|
|
111
|
+
<Logo variant="icon" size="tiny" />
|
|
112
|
+
{/if}
|
|
113
|
+
<CardTitle tag="p" class="text-dark/90 grow text-lg font-semibold">{title}</CardTitle>
|
|
114
|
+
<CloseButton class="-me-2" onclick={() => handleClose()} />
|
|
115
|
+
</div>
|
|
116
|
+
{/if}
|
|
117
|
+
</CardHeader>
|
|
119
118
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
<CardBody class="grow px-5">
|
|
120
|
+
{@render bodyChildren?.snippet()}
|
|
121
|
+
</CardBody>
|
|
123
122
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
123
|
+
{#if footerChildren}
|
|
124
|
+
<CardFooter class="border-t border-gray-200 dark:border-white/10">
|
|
125
|
+
{@render footerChildren.snippet()}
|
|
126
|
+
</CardFooter>
|
|
127
|
+
{/if}
|
|
128
|
+
</Card>
|
|
129
|
+
</div>
|
|
130
|
+
</TooltipProvider>
|
|
131
131
|
</Dialog.Content>
|
|
132
132
|
</Dialog.Portal>
|
|
133
133
|
</Dialog.Root>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { styleVariants } from '../../styles.js';
|
|
6
6
|
import type { TextareaProps } from '../../types.js';
|
|
7
7
|
import { cleanClass, generateId } from '../../utilities/internal.js';
|
|
8
|
+
import { onMount } from 'svelte';
|
|
8
9
|
import type { FormEventHandler } from 'svelte/elements';
|
|
9
10
|
import { tv } from 'tailwind-variants';
|
|
10
11
|
|
|
@@ -53,15 +54,20 @@
|
|
|
53
54
|
const labelId = `label-${id}`;
|
|
54
55
|
const descriptionId = $derived(description ? `description-${id}` : undefined);
|
|
55
56
|
|
|
56
|
-
const
|
|
57
|
-
const element = event.target as HTMLTextAreaElement;
|
|
57
|
+
const autogrow = (element: HTMLTextAreaElement | null) => {
|
|
58
58
|
if (element && grow) {
|
|
59
|
+
element.style.minHeight = '0';
|
|
59
60
|
element.style.height = 'auto';
|
|
60
61
|
element.style.height = `${element.scrollHeight}px`;
|
|
61
62
|
}
|
|
63
|
+
};
|
|
62
64
|
|
|
65
|
+
const onInput: FormEventHandler<HTMLTextAreaElement> = (event) => {
|
|
66
|
+
autogrow(event.target as HTMLTextAreaElement);
|
|
63
67
|
restProps?.oninput?.(event);
|
|
64
68
|
};
|
|
69
|
+
|
|
70
|
+
onMount(() => autogrow(ref));
|
|
65
71
|
</script>
|
|
66
72
|
|
|
67
73
|
<div class="flex w-full flex-col gap-1" bind:this={containerRef}>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import Toast from './Toast.svelte';
|
|
3
|
+
import TooltipProvider from '../Tooltip/TooltipProvider.svelte';
|
|
3
4
|
import { zIndex } from '../../constants.js';
|
|
4
5
|
import { isCustomToast } from '../../services/toast-manager.svelte.js';
|
|
5
6
|
import type { ToastPanelProps } from '../../types.js';
|
|
@@ -10,19 +11,21 @@
|
|
|
10
11
|
const isEmpty = $derived(items.length === 0);
|
|
11
12
|
</script>
|
|
12
13
|
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{#
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
<TooltipProvider>
|
|
15
|
+
<div
|
|
16
|
+
class={cleanClass(
|
|
17
|
+
isEmpty ? 'hidden' : 'absolute top-0 right-0 flex flex-col items-end justify-end gap-2 p-4',
|
|
18
|
+
zIndex.ToastPanel,
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
{#each items as item (item.id)}
|
|
24
|
+
{#if isCustomToast(item)}
|
|
25
|
+
<item.component {...item.props} />
|
|
26
|
+
{:else}
|
|
27
|
+
<Toast {...item} />
|
|
28
|
+
{/if}
|
|
29
|
+
{/each}
|
|
30
|
+
</div>
|
|
31
|
+
</TooltipProvider>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { zIndex } from '../../constants.js';
|
|
3
|
+
import { Tooltip } from 'bits-ui';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import { fly } from 'svelte/transition';
|
|
6
|
+
|
|
7
|
+
type Props = Tooltip.RootProps & {
|
|
8
|
+
text?: string | null;
|
|
9
|
+
child: Snippet<[{ props: Record<string, unknown> }]>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
let { open = $bindable(false), child, text, ...restProps }: Props = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if text}
|
|
16
|
+
<Tooltip.Root bind:open {...restProps}>
|
|
17
|
+
<Tooltip.Trigger {child} />
|
|
18
|
+
<Tooltip.Portal>
|
|
19
|
+
<Tooltip.Content
|
|
20
|
+
sideOffset={8}
|
|
21
|
+
forceMount
|
|
22
|
+
class="bg-light-800 text-light {zIndex.Tooltip} rounded-lg px-3.5 py-2 text-xs shadow-lg"
|
|
23
|
+
>
|
|
24
|
+
{#snippet child({ wrapperProps, props, open })}
|
|
25
|
+
{#if open}
|
|
26
|
+
<div {...wrapperProps}>
|
|
27
|
+
<div {...props} transition:fly={{ y: 4, duration: 150 }}>
|
|
28
|
+
{text}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
{/if}
|
|
32
|
+
{/snippet}
|
|
33
|
+
</Tooltip.Content>
|
|
34
|
+
</Tooltip.Portal>
|
|
35
|
+
</Tooltip.Root>
|
|
36
|
+
{:else}
|
|
37
|
+
{@render child({ props: {} })}
|
|
38
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tooltip } from 'bits-ui';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type Props = Tooltip.RootProps & {
|
|
4
|
+
text?: string | null;
|
|
5
|
+
child: Snippet<[{
|
|
6
|
+
props: Record<string, unknown>;
|
|
7
|
+
}]>;
|
|
8
|
+
};
|
|
9
|
+
declare const Tooltip: import("svelte").Component<Props, {}, "open">;
|
|
10
|
+
type Tooltip = ReturnType<typeof Tooltip>;
|
|
11
|
+
export default Tooltip;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Tooltip } from 'bits-ui';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
delayDuration?: number;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const { children, delayDuration }: Props = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Tooltip.Provider disableCloseOnTriggerClick ignoreNonKeyboardFocus {delayDuration}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</Tooltip.Provider>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type Props = {
|
|
3
|
+
delayDuration?: number;
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const TooltipProvider: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type TooltipProvider = ReturnType<typeof TooltipProvider>;
|
|
8
|
+
export default TooltipProvider;
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,8 @@ export { default as Checkbox } from './components/Checkbox/Checkbox.svelte';
|
|
|
29
29
|
export { default as CloseButton } from './components/CloseButton/CloseButton.svelte';
|
|
30
30
|
export { default as Code } from './components/Code/Code.svelte';
|
|
31
31
|
export { default as CodeBlock } from './components/CodeBlock/CodeBlock.svelte';
|
|
32
|
-
export { default as
|
|
32
|
+
export { default as CommandPaletteDefaultProvider } from './components/CommandPalette/CommandPaletteDefaultProvider.svelte';
|
|
33
|
+
export { default as CommandPaletteProvider } from './components/CommandPalette/CommandPaletteProvider.svelte';
|
|
33
34
|
export { default as ConfirmModal } from './components/ConfirmModal/ConfirmModal.svelte';
|
|
34
35
|
export { default as Container } from './components/Container/Container.svelte';
|
|
35
36
|
export { default as ContextMenuButton } from './components/ContextMenu/ContextMenuButton.svelte';
|
|
@@ -73,6 +74,8 @@ export { default as Toast } from './components/Toast/Toast.svelte';
|
|
|
73
74
|
export { default as ToastContainer } from './components/Toast/ToastContainer.svelte';
|
|
74
75
|
export { default as ToastContent } from './components/Toast/ToastContent.svelte';
|
|
75
76
|
export { default as ToastPanel } from './components/Toast/ToastPanel.svelte';
|
|
77
|
+
export { default as Tooltip } from './components/Tooltip/Tooltip.svelte';
|
|
78
|
+
export { default as TooltipProvider } from './components/Tooltip/TooltipProvider.svelte';
|
|
76
79
|
export * from './services/command-palette-manager.svelte.js';
|
|
77
80
|
export * from './services/menu-manager.svelte.js';
|
|
78
81
|
export * from './services/modal-manager.svelte.js';
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,8 @@ export { default as Checkbox } from './components/Checkbox/Checkbox.svelte';
|
|
|
31
31
|
export { default as CloseButton } from './components/CloseButton/CloseButton.svelte';
|
|
32
32
|
export { default as Code } from './components/Code/Code.svelte';
|
|
33
33
|
export { default as CodeBlock } from './components/CodeBlock/CodeBlock.svelte';
|
|
34
|
-
export { default as
|
|
34
|
+
export { default as CommandPaletteDefaultProvider } from './components/CommandPalette/CommandPaletteDefaultProvider.svelte';
|
|
35
|
+
export { default as CommandPaletteProvider } from './components/CommandPalette/CommandPaletteProvider.svelte';
|
|
35
36
|
export { default as ConfirmModal } from './components/ConfirmModal/ConfirmModal.svelte';
|
|
36
37
|
export { default as Container } from './components/Container/Container.svelte';
|
|
37
38
|
export { default as ContextMenuButton } from './components/ContextMenu/ContextMenuButton.svelte';
|
|
@@ -75,6 +76,8 @@ export { default as Toast } from './components/Toast/Toast.svelte';
|
|
|
75
76
|
export { default as ToastContainer } from './components/Toast/ToastContainer.svelte';
|
|
76
77
|
export { default as ToastContent } from './components/Toast/ToastContent.svelte';
|
|
77
78
|
export { default as ToastPanel } from './components/Toast/ToastPanel.svelte';
|
|
79
|
+
export { default as Tooltip } from './components/Tooltip/Tooltip.svelte';
|
|
80
|
+
export { default as TooltipProvider } from './components/Tooltip/TooltipProvider.svelte';
|
|
78
81
|
// helpers
|
|
79
82
|
export * from './services/command-palette-manager.svelte.js';
|
|
80
83
|
export * from './services/menu-manager.svelte.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import Icon from '../components/Icon/Icon.svelte';
|
|
3
3
|
import LoadingSpinner from '../components/LoadingSpinner/LoadingSpinner.svelte';
|
|
4
|
+
import Tooltip from '../components/Tooltip/Tooltip.svelte';
|
|
4
5
|
import { styleVariants } from '../styles.js';
|
|
5
6
|
import type { ButtonProps, Size } from '../types.js';
|
|
6
7
|
import { isExternalLink, resolveUrl } from '../utilities/common.js';
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
leadingIcon,
|
|
28
29
|
trailingIcon,
|
|
29
30
|
icon = false,
|
|
31
|
+
title,
|
|
30
32
|
class: className = '',
|
|
31
33
|
children,
|
|
32
34
|
...restProps
|
|
@@ -35,7 +37,7 @@
|
|
|
35
37
|
const disabled = $derived((restProps as HTMLButtonAttributes).disabled || loading);
|
|
36
38
|
|
|
37
39
|
const buttonVariants = tv({
|
|
38
|
-
base: '
|
|
40
|
+
base: 'flex items-center justify-center gap-1 rounded-md text-sm font-medium outline-offset-2 transition-colors focus-visible:outline-2',
|
|
39
41
|
variants: {
|
|
40
42
|
disabled: {
|
|
41
43
|
true: 'disabled:pointer-events-none disabled:opacity-50 aria-disabled:opacity-50',
|
|
@@ -67,6 +69,14 @@
|
|
|
67
69
|
large: 'rounded-xl',
|
|
68
70
|
giant: 'rounded-2xl',
|
|
69
71
|
},
|
|
72
|
+
focusOutlineColor: {
|
|
73
|
+
primary: 'outline-primary',
|
|
74
|
+
secondary: 'outline-dark',
|
|
75
|
+
success: 'outline-success',
|
|
76
|
+
danger: 'outline-danger',
|
|
77
|
+
warning: 'outline-warning',
|
|
78
|
+
info: 'outline-info',
|
|
79
|
+
},
|
|
70
80
|
filledColor: styleVariants.filledColor,
|
|
71
81
|
filledColorHover: styleVariants.filledColorHover,
|
|
72
82
|
outlineColor: {
|
|
@@ -110,6 +120,7 @@
|
|
|
110
120
|
filledColorHover: variant === 'filled' ? color : undefined,
|
|
111
121
|
outlineColor: variant === 'outline' ? color : undefined,
|
|
112
122
|
ghostColor: variant === 'ghost' ? color : undefined,
|
|
123
|
+
focusOutlineColor: color,
|
|
113
124
|
}),
|
|
114
125
|
className,
|
|
115
126
|
),
|
|
@@ -149,29 +160,35 @@
|
|
|
149
160
|
{/if}
|
|
150
161
|
{/snippet}
|
|
151
162
|
|
|
152
|
-
{
|
|
153
|
-
{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
{
|
|
163
|
+
<Tooltip text={title}>
|
|
164
|
+
{#snippet child({ props })}
|
|
165
|
+
{#if href}
|
|
166
|
+
{@const resolved = resolveUrl(href)}
|
|
167
|
+
{@const external = isExternalLink(resolved)}
|
|
168
|
+
<a
|
|
169
|
+
bind:this={ref}
|
|
170
|
+
{...props}
|
|
171
|
+
href={resolved}
|
|
172
|
+
class={classList}
|
|
173
|
+
aria-disabled={disabled}
|
|
174
|
+
target={external ? '_blank' : undefined}
|
|
175
|
+
rel={external ? 'noopener noreferrer' : undefined}
|
|
176
|
+
{...restProps as HTMLAnchorAttributes}
|
|
177
|
+
>
|
|
178
|
+
{@render wrapper()}
|
|
179
|
+
</a>
|
|
180
|
+
{:else}
|
|
181
|
+
<ButtonPrimitive.Root
|
|
182
|
+
bind:ref
|
|
183
|
+
{...props}
|
|
184
|
+
class={classList}
|
|
185
|
+
type={type as HTMLButtonAttributes['type']}
|
|
186
|
+
{...restProps as HTMLButtonAttributes}
|
|
187
|
+
{disabled}
|
|
188
|
+
aria-disabled={disabled}
|
|
189
|
+
>
|
|
190
|
+
{@render wrapper()}
|
|
191
|
+
</ButtonPrimitive.Root>
|
|
192
|
+
{/if}
|
|
193
|
+
{/snippet}
|
|
194
|
+
</Tooltip>
|