@insymetri/styleguide 0.1.73 → 0.1.75
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/IIButton/IIButton.svelte +5 -2
- package/dist/IIButton/IIButton.svelte.d.ts +2 -0
- package/dist/IIDropdownInput/IIDropdownInput.svelte +1 -1
- package/dist/IIDropdownMenu/IIDropdownMenu.svelte +1 -1
- package/dist/IIModal/IIModal.svelte +11 -2
- package/dist/IIModal/IIModal.svelte.d.ts +5 -1
- package/dist/IIPillTabs/IIPillTabs.svelte +33 -17
- package/dist/IIPillTabs/IIPillTabs.svelte.d.ts +2 -0
- package/dist/IITabBar/IITabBar.svelte +8 -2
- package/dist/IITabBar/IITabBar.svelte.d.ts +2 -0
- package/dist/IITable/IITable.svelte +111 -4
- package/dist/IITable/IITable.svelte.d.ts +53 -5
- package/dist/IITooltip/IITooltip.svelte +48 -0
- package/dist/IITooltip/IITooltip.svelte.d.ts +16 -0
- package/dist/IITooltip/index.d.ts +1 -0
- package/dist/IITooltip/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
iconName?: IconName
|
|
13
13
|
loading?: boolean
|
|
14
14
|
disabled?: boolean
|
|
15
|
+
/** Stretch to fill the available width. */
|
|
16
|
+
fullWidth?: boolean
|
|
15
17
|
children?: Snippet
|
|
16
18
|
class?: string
|
|
17
19
|
ref?: HTMLButtonElement | HTMLAnchorElement
|
|
@@ -28,6 +30,7 @@
|
|
|
28
30
|
iconName,
|
|
29
31
|
loading = false,
|
|
30
32
|
disabled = false,
|
|
33
|
+
fullWidth = false,
|
|
31
34
|
children,
|
|
32
35
|
class: className,
|
|
33
36
|
href,
|
|
@@ -125,7 +128,7 @@
|
|
|
125
128
|
<a
|
|
126
129
|
bind:this={ref}
|
|
127
130
|
{href}
|
|
128
|
-
class={cn(baseClasses, variantClasses[variant], resolvedSizeClasses, className)}
|
|
131
|
+
class={cn(baseClasses, variantClasses[variant], resolvedSizeClasses, fullWidth && 'w-full', className)}
|
|
129
132
|
{onclick}
|
|
130
133
|
{...restProps as HTMLAnchorAttributes}
|
|
131
134
|
>
|
|
@@ -135,7 +138,7 @@
|
|
|
135
138
|
<button
|
|
136
139
|
bind:this={ref}
|
|
137
140
|
disabled={isDisabled}
|
|
138
|
-
class={cn(baseClasses, variantClasses[variant], resolvedSizeClasses, className)}
|
|
141
|
+
class={cn(baseClasses, variantClasses[variant], resolvedSizeClasses, fullWidth && 'w-full', className)}
|
|
139
142
|
onclick={handleClick}
|
|
140
143
|
{...restProps as HTMLButtonAttributes}
|
|
141
144
|
>
|
|
@@ -261,7 +261,7 @@
|
|
|
261
261
|
{#if renderSelected && selectedItem}
|
|
262
262
|
{@render renderSelected(selectedItem)}
|
|
263
263
|
{:else}
|
|
264
|
-
<span>{selectedLabel}</span>
|
|
264
|
+
<span class="flex-1 min-w-0 truncate text-left">{selectedLabel}</span>
|
|
265
265
|
{/if}
|
|
266
266
|
<IIIcon iconName="caret-down" />
|
|
267
267
|
</button>
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
aria-haspopup="menu"
|
|
332
332
|
aria-expanded={open}
|
|
333
333
|
data-state={open ? 'open' : 'closed'}
|
|
334
|
-
class={cn(children
|
|
334
|
+
class={cn(children ? cn('[all:unset] cursor-default', triggerClass) : defaultTriggerClass)}
|
|
335
335
|
onclick={toggle}
|
|
336
336
|
>
|
|
337
337
|
{#if children}
|
|
@@ -13,8 +13,12 @@
|
|
|
13
13
|
titleAccessory?: Snippet
|
|
14
14
|
footer?: Snippet
|
|
15
15
|
showCloseButton?: boolean
|
|
16
|
-
size?: 'sm' | 'md' | 'lg'
|
|
16
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full'
|
|
17
17
|
overlay?: 'dark' | 'light' | 'none'
|
|
18
|
+
/** Cap the modal height (any CSS value, e.g. "60vh"). Defaults to 90vh. */
|
|
19
|
+
maxHeight?: string
|
|
20
|
+
/** Replace the body wrapper's padding/scroll defaults — e.g. for a full-height flex body. */
|
|
21
|
+
bodyClass?: string
|
|
18
22
|
class?: string
|
|
19
23
|
}
|
|
20
24
|
|
|
@@ -29,6 +33,8 @@
|
|
|
29
33
|
showCloseButton = true,
|
|
30
34
|
size = 'md',
|
|
31
35
|
overlay = 'dark',
|
|
36
|
+
maxHeight,
|
|
37
|
+
bodyClass,
|
|
32
38
|
class: className,
|
|
33
39
|
}: Props = $props()
|
|
34
40
|
|
|
@@ -80,8 +86,11 @@
|
|
|
80
86
|
size === 'sm' && 'max-w-400',
|
|
81
87
|
size === 'md' && 'max-w-500',
|
|
82
88
|
size === 'lg' && 'max-w-700',
|
|
89
|
+
size === 'xl' && 'max-w-[1100px]',
|
|
90
|
+
size === 'full' && 'max-w-[95vw] h-[90vh]',
|
|
83
91
|
className
|
|
84
92
|
)}
|
|
93
|
+
style={maxHeight ? `max-height: ${maxHeight}` : undefined}
|
|
85
94
|
>
|
|
86
95
|
<div class="flex items-start justify-between gap-12 px-24 pt-24 shrink-0">
|
|
87
96
|
<div class="flex flex-col min-w-0 flex-1">
|
|
@@ -105,7 +114,7 @@
|
|
|
105
114
|
</Dialog.Close>
|
|
106
115
|
{/if}
|
|
107
116
|
</div>
|
|
108
|
-
<div class=
|
|
117
|
+
<div class={cn('flex-auto min-h-0', bodyClass ?? 'px-24 py-20 overflow-y-auto')}>
|
|
109
118
|
{@render children()}
|
|
110
119
|
</div>
|
|
111
120
|
{#if footer}
|
|
@@ -8,8 +8,12 @@ type Props = {
|
|
|
8
8
|
titleAccessory?: Snippet;
|
|
9
9
|
footer?: Snippet;
|
|
10
10
|
showCloseButton?: boolean;
|
|
11
|
-
size?: 'sm' | 'md' | 'lg';
|
|
11
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
12
12
|
overlay?: 'dark' | 'light' | 'none';
|
|
13
|
+
/** Cap the modal height (any CSS value, e.g. "60vh"). Defaults to 90vh. */
|
|
14
|
+
maxHeight?: string;
|
|
15
|
+
/** Replace the body wrapper's padding/scroll defaults — e.g. for a full-height flex body. */
|
|
16
|
+
bodyClass?: string;
|
|
13
17
|
class?: string;
|
|
14
18
|
};
|
|
15
19
|
declare const IIModal: import("svelte").Component<Props, {}, "open">;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {cn} from '../utils/cn'
|
|
3
3
|
import IIDropdownInput from '../IIDropdownInput/IIDropdownInput.svelte'
|
|
4
|
+
import IITooltip from '../IITooltip/IITooltip.svelte'
|
|
4
5
|
import {useDensity} from '../density'
|
|
5
6
|
|
|
6
7
|
type Tab = {
|
|
7
8
|
value: string
|
|
8
9
|
label: string
|
|
9
10
|
count?: number
|
|
11
|
+
disabled?: boolean
|
|
12
|
+
tooltip?: string
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
type Props = {
|
|
@@ -55,6 +58,29 @@
|
|
|
55
58
|
</script>
|
|
56
59
|
|
|
57
60
|
<div bind:this={containerEl} class={cn('min-w-0 relative', className)}>
|
|
61
|
+
{#snippet pill(tab: Tab)}
|
|
62
|
+
<button
|
|
63
|
+
class={cn(
|
|
64
|
+
'flex items-center rounded-control border-none outline-none cursor-default whitespace-nowrap',
|
|
65
|
+
densityClasses[density.value],
|
|
66
|
+
tab.disabled
|
|
67
|
+
? 'bg-surface text-tertiary opacity-50 cursor-not-allowed'
|
|
68
|
+
: value === tab.value
|
|
69
|
+
? 'bg-gray-100 text-gray-700'
|
|
70
|
+
: 'bg-surface text-secondary shadow-pill hover:bg-gray-100 hover:text-gray-700'
|
|
71
|
+
)}
|
|
72
|
+
style="transition: all var(--transition-fast)"
|
|
73
|
+
disabled={tab.disabled}
|
|
74
|
+
onclick={() => !tab.disabled && select(tab.value)}
|
|
75
|
+
tabindex={overflow ? -1 : 0}
|
|
76
|
+
>
|
|
77
|
+
{tab.label}
|
|
78
|
+
{#if tab.count != null}
|
|
79
|
+
<span class="ml-2 text-tiny opacity-70">({tab.count})</span>
|
|
80
|
+
{/if}
|
|
81
|
+
</button>
|
|
82
|
+
{/snippet}
|
|
83
|
+
|
|
58
84
|
<!-- Hidden measure element — always rendered to detect when pills fit again -->
|
|
59
85
|
<div
|
|
60
86
|
bind:this={measureEl}
|
|
@@ -63,23 +89,13 @@
|
|
|
63
89
|
style={overflow ? 'position: absolute; visibility: hidden; height: 0; overflow: hidden; pointer-events: none;' : ''}
|
|
64
90
|
>
|
|
65
91
|
{#each tabs as tab (tab.value)}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)}
|
|
74
|
-
style="transition: all var(--transition-fast)"
|
|
75
|
-
onclick={() => select(tab.value)}
|
|
76
|
-
tabindex={overflow ? -1 : 0}
|
|
77
|
-
>
|
|
78
|
-
{tab.label}
|
|
79
|
-
{#if tab.count != null}
|
|
80
|
-
<span class="ml-2 text-tiny opacity-70">({tab.count})</span>
|
|
81
|
-
{/if}
|
|
82
|
-
</button>
|
|
92
|
+
{#if tab.tooltip}
|
|
93
|
+
<IITooltip text={tab.tooltip} side="top" disabled={overflow}>
|
|
94
|
+
{@render pill(tab)}
|
|
95
|
+
</IITooltip>
|
|
96
|
+
{:else}
|
|
97
|
+
{@render pill(tab)}
|
|
98
|
+
{/if}
|
|
83
99
|
{/each}
|
|
84
100
|
</div>
|
|
85
101
|
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
tabs: Tab[]
|
|
17
17
|
value: string
|
|
18
18
|
onChange: (value: string) => void
|
|
19
|
+
/** Stretch to fill the available width. Defaults to sizing to content. */
|
|
20
|
+
fullWidth?: boolean
|
|
19
21
|
class?: string
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
let {tabs, value, onChange, class: className}: Props = $props()
|
|
24
|
+
let {tabs, value, onChange, fullWidth = false, class: className}: Props = $props()
|
|
23
25
|
|
|
24
26
|
let listEl = $state<HTMLElement | null>(null)
|
|
25
27
|
let overflowing = $state(false)
|
|
@@ -45,7 +47,11 @@
|
|
|
45
47
|
}
|
|
46
48
|
</script>
|
|
47
49
|
|
|
48
|
-
<Tabs.Root
|
|
50
|
+
<Tabs.Root
|
|
51
|
+
{value}
|
|
52
|
+
onValueChange={onChange}
|
|
53
|
+
class={cn('relative h-full', fullWidth ? 'w-full' : 'w-auto min-w-0 shrink', className)}
|
|
54
|
+
>
|
|
49
55
|
<Tabs.List
|
|
50
56
|
bind:ref={listEl}
|
|
51
57
|
class={cn(
|
|
@@ -9,6 +9,8 @@ type Props = {
|
|
|
9
9
|
tabs: Tab[];
|
|
10
10
|
value: string;
|
|
11
11
|
onChange: (value: string) => void;
|
|
12
|
+
/** Stretch to fill the available width. Defaults to sizing to content. */
|
|
13
|
+
fullWidth?: boolean;
|
|
12
14
|
class?: string;
|
|
13
15
|
};
|
|
14
16
|
declare const IITabBar: import("svelte").Component<Props, {}, "">;
|
|
@@ -1,17 +1,124 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" generics="T">
|
|
2
2
|
import type {Snippet} from 'svelte'
|
|
3
3
|
import {cn} from '../utils/cn'
|
|
4
|
+
import IITableSkeleton from '../IITableSkeleton/IITableSkeleton.svelte'
|
|
5
|
+
|
|
6
|
+
type Column = {
|
|
7
|
+
/** Stable id (used as the header key today; the sort key when sorting lands). */
|
|
8
|
+
key: string
|
|
9
|
+
header: string
|
|
10
|
+
/** Renders the cell content for a row — badges, buttons, editable text, etc. */
|
|
11
|
+
cell: Snippet<[T]>
|
|
12
|
+
align?: 'left' | 'right' | 'center'
|
|
13
|
+
/** Width utility, e.g. `w-120` / `min-w-180`, and responsive hides like `max-md:hidden`. */
|
|
14
|
+
width?: string
|
|
15
|
+
/** Extra classes on the `<td>`, static or per-row (e.g. `text-secondary`, `font-mono`). */
|
|
16
|
+
class?: string | ((row: T) => string)
|
|
17
|
+
/** Extra classes on the `<th>`. */
|
|
18
|
+
headerClass?: string
|
|
19
|
+
}
|
|
4
20
|
|
|
5
21
|
type Props = {
|
|
6
|
-
|
|
22
|
+
columns: Column[]
|
|
23
|
+
rows: T[]
|
|
24
|
+
rowKey: (row: T) => string
|
|
25
|
+
loading?: boolean
|
|
26
|
+
loadingRows?: number
|
|
27
|
+
/** Rendered (spanning all columns) when there are no rows and not loading. */
|
|
28
|
+
empty?: Snippet
|
|
29
|
+
onRowClick?: (row: T, event: MouseEvent) => void
|
|
30
|
+
/** Per-row class for states like dimmed/disabled (e.g. `opacity-60`). */
|
|
31
|
+
rowClass?: (row: T) => string | false | undefined | null
|
|
32
|
+
/** Optional expandable content rendered as a spanning row beneath an expanded row. */
|
|
33
|
+
expandedRow?: Snippet<[T]>
|
|
34
|
+
isExpanded?: (row: T) => boolean
|
|
35
|
+
stickyHeader?: boolean
|
|
36
|
+
/** `sm` → text-small (default), `md` → text-default. */
|
|
37
|
+
size?: 'sm' | 'md'
|
|
7
38
|
class?: string
|
|
8
39
|
}
|
|
9
40
|
|
|
10
|
-
let {
|
|
41
|
+
let {
|
|
42
|
+
columns,
|
|
43
|
+
rows,
|
|
44
|
+
rowKey,
|
|
45
|
+
loading = false,
|
|
46
|
+
loadingRows = 5,
|
|
47
|
+
empty,
|
|
48
|
+
onRowClick,
|
|
49
|
+
rowClass,
|
|
50
|
+
expandedRow,
|
|
51
|
+
isExpanded,
|
|
52
|
+
stickyHeader = false,
|
|
53
|
+
size = 'sm',
|
|
54
|
+
class: className,
|
|
55
|
+
}: Props = $props()
|
|
56
|
+
|
|
57
|
+
const alignClass = {left: 'text-left', right: 'text-right', center: 'text-center'} as const
|
|
58
|
+
const cellText = $derived(size === 'sm' ? 'text-small' : 'text-default')
|
|
59
|
+
const interactive = $derived(!!onRowClick)
|
|
60
|
+
|
|
61
|
+
function cellClass(col: Column, row: T): string {
|
|
62
|
+
return typeof col.class === 'function' ? col.class(row) : (col.class ?? '')
|
|
63
|
+
}
|
|
11
64
|
</script>
|
|
12
65
|
|
|
13
66
|
<div class={cn('bg-surface border border-primary rounded-10 overflow-x-auto overflow-y-hidden', className)}>
|
|
14
67
|
<table class="w-full border-collapse">
|
|
15
|
-
{
|
|
68
|
+
<thead class={cn('bg-background border-b border-primary', stickyHeader && 'sticky top-0 z-1')}>
|
|
69
|
+
<tr>
|
|
70
|
+
{#each columns as col (col.key)}
|
|
71
|
+
<th
|
|
72
|
+
class={cn(
|
|
73
|
+
'px-16 py-8 text-tiny-strong text-secondary uppercase',
|
|
74
|
+
alignClass[col.align ?? 'left'],
|
|
75
|
+
col.width,
|
|
76
|
+
col.headerClass
|
|
77
|
+
)}
|
|
78
|
+
>
|
|
79
|
+
{col.header}
|
|
80
|
+
</th>
|
|
81
|
+
{/each}
|
|
82
|
+
</tr>
|
|
83
|
+
</thead>
|
|
84
|
+
<tbody>
|
|
85
|
+
{#if loading}
|
|
86
|
+
<IITableSkeleton rows={loadingRows} columns={columns.map(() => 'text')} />
|
|
87
|
+
{:else if rows.length === 0}
|
|
88
|
+
{#if empty}
|
|
89
|
+
<tr>
|
|
90
|
+
<td colspan={columns.length} class="px-16 py-32 text-center">
|
|
91
|
+
{@render empty()}
|
|
92
|
+
</td>
|
|
93
|
+
</tr>
|
|
94
|
+
{/if}
|
|
95
|
+
{:else}
|
|
96
|
+
{#each rows as row (rowKey(row))}
|
|
97
|
+
<tr
|
|
98
|
+
class={cn(
|
|
99
|
+
'border-b border-primary last:border-b-0',
|
|
100
|
+
interactive && 'cursor-pointer hover:bg-background',
|
|
101
|
+
rowClass?.(row)
|
|
102
|
+
)}
|
|
103
|
+
style="transition: background-color var(--transition-fast)"
|
|
104
|
+
onclick={onRowClick ? e => onRowClick(row, e) : undefined}
|
|
105
|
+
onauxclick={onRowClick ? e => onRowClick(row, e) : undefined}
|
|
106
|
+
>
|
|
107
|
+
{#each columns as col (col.key)}
|
|
108
|
+
<td class={cn('px-16 py-8 text-body', cellText, alignClass[col.align ?? 'left'], col.width, cellClass(col, row))}>
|
|
109
|
+
{@render col.cell(row)}
|
|
110
|
+
</td>
|
|
111
|
+
{/each}
|
|
112
|
+
</tr>
|
|
113
|
+
{#if expandedRow && isExpanded?.(row)}
|
|
114
|
+
<tr class="border-b border-primary last:border-b-0 bg-background">
|
|
115
|
+
<td colspan={columns.length} class="px-16 py-12">
|
|
116
|
+
{@render expandedRow(row)}
|
|
117
|
+
</td>
|
|
118
|
+
</tr>
|
|
119
|
+
{/if}
|
|
120
|
+
{/each}
|
|
121
|
+
{/if}
|
|
122
|
+
</tbody>
|
|
16
123
|
</table>
|
|
17
124
|
</div>
|
|
@@ -1,8 +1,56 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
declare function $$render<T>(): {
|
|
3
|
+
props: {
|
|
4
|
+
columns: {
|
|
5
|
+
/** Stable id (used as the header key today; the sort key when sorting lands). */
|
|
6
|
+
key: string;
|
|
7
|
+
header: string;
|
|
8
|
+
/** Renders the cell content for a row — badges, buttons, editable text, etc. */
|
|
9
|
+
cell: Snippet<[T]>;
|
|
10
|
+
align?: "left" | "right" | "center";
|
|
11
|
+
/** Width utility, e.g. `w-120` / `min-w-180`, and responsive hides like `max-md:hidden`. */
|
|
12
|
+
width?: string;
|
|
13
|
+
/** Extra classes on the `<td>`, static or per-row (e.g. `text-secondary`, `font-mono`). */
|
|
14
|
+
class?: string | ((row: T) => string);
|
|
15
|
+
/** Extra classes on the `<th>`. */
|
|
16
|
+
headerClass?: string;
|
|
17
|
+
}[];
|
|
18
|
+
rows: T[];
|
|
19
|
+
rowKey: (row: T) => string;
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
loadingRows?: number;
|
|
22
|
+
/** Rendered (spanning all columns) when there are no rows and not loading. */
|
|
23
|
+
empty?: Snippet;
|
|
24
|
+
onRowClick?: (row: T, event: MouseEvent) => void;
|
|
25
|
+
/** Per-row class for states like dimmed/disabled (e.g. `opacity-60`). */
|
|
26
|
+
rowClass?: (row: T) => string | false | undefined | null;
|
|
27
|
+
/** Optional expandable content rendered as a spanning row beneath an expanded row. */
|
|
28
|
+
expandedRow?: Snippet<[T]>;
|
|
29
|
+
isExpanded?: (row: T) => boolean;
|
|
30
|
+
stickyHeader?: boolean;
|
|
31
|
+
/** `sm` → text-small (default), `md` → text-default. */
|
|
32
|
+
size?: "sm" | "md";
|
|
33
|
+
class?: string;
|
|
34
|
+
};
|
|
35
|
+
exports: {};
|
|
36
|
+
bindings: "";
|
|
37
|
+
slots: {};
|
|
38
|
+
events: {};
|
|
5
39
|
};
|
|
6
|
-
declare
|
|
7
|
-
|
|
40
|
+
declare class __sveltets_Render<T> {
|
|
41
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
42
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
43
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
44
|
+
bindings(): "";
|
|
45
|
+
exports(): {};
|
|
46
|
+
}
|
|
47
|
+
interface $$IsomorphicComponent {
|
|
48
|
+
new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
49
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
50
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
51
|
+
<T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
52
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
53
|
+
}
|
|
54
|
+
declare const IITable: $$IsomorphicComponent;
|
|
55
|
+
type IITable<T> = InstanceType<typeof IITable<T>>;
|
|
8
56
|
export default IITable;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {Tooltip as B} from 'bits-ui'
|
|
3
|
+
import {cn} from '../utils/cn'
|
|
4
|
+
import type {Snippet} from 'svelte'
|
|
5
|
+
|
|
6
|
+
type Side = 'top' | 'right' | 'bottom' | 'left'
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
text: string
|
|
10
|
+
side?: Side
|
|
11
|
+
/** Extra classes for the trigger wrapper (e.g. to size it as a flex child). */
|
|
12
|
+
class?: string
|
|
13
|
+
/** Render children in a plain wrapper with no tooltip (keeps layout identical). */
|
|
14
|
+
disabled?: boolean
|
|
15
|
+
/** Hover delay before the tooltip opens, in ms. */
|
|
16
|
+
delay?: number
|
|
17
|
+
children: Snippet
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {text, side = 'right', class: className, disabled = false, delay = 150, children}: Props = $props()
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
{#if disabled}
|
|
24
|
+
<span class={cn('inline-block', className)}>
|
|
25
|
+
{@render children()}
|
|
26
|
+
</span>
|
|
27
|
+
{:else}
|
|
28
|
+
<B.Provider delayDuration={delay}>
|
|
29
|
+
<B.Root>
|
|
30
|
+
<B.Trigger>
|
|
31
|
+
{#snippet child({props})}
|
|
32
|
+
<span {...props} class={cn('inline-block', className)}>
|
|
33
|
+
{@render children()}
|
|
34
|
+
</span>
|
|
35
|
+
{/snippet}
|
|
36
|
+
</B.Trigger>
|
|
37
|
+
<B.Portal>
|
|
38
|
+
<B.Content
|
|
39
|
+
{side}
|
|
40
|
+
sideOffset={6}
|
|
41
|
+
class="z-19 rounded-4 bg-gray-900 text-white text-tiny leading-tight font-medium px-8 py-4 shadow-dropdown data-[state=delayed-open]:animate-fade-in data-[state=instant-open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none"
|
|
42
|
+
>
|
|
43
|
+
{text}
|
|
44
|
+
</B.Content>
|
|
45
|
+
</B.Portal>
|
|
46
|
+
</B.Root>
|
|
47
|
+
</B.Provider>
|
|
48
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type Side = 'top' | 'right' | 'bottom' | 'left';
|
|
3
|
+
type Props = {
|
|
4
|
+
text: string;
|
|
5
|
+
side?: Side;
|
|
6
|
+
/** Extra classes for the trigger wrapper (e.g. to size it as a flex child). */
|
|
7
|
+
class?: string;
|
|
8
|
+
/** Render children in a plain wrapper with no tooltip (keeps layout identical). */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Hover delay before the tooltip opens, in ms. */
|
|
11
|
+
delay?: number;
|
|
12
|
+
children: Snippet;
|
|
13
|
+
};
|
|
14
|
+
declare const IITooltip: import("svelte").Component<Props, {}, "">;
|
|
15
|
+
type IITooltip = ReturnType<typeof IITooltip>;
|
|
16
|
+
export default IITooltip;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as IITooltip } from './IITooltip.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as IITooltip } from './IITooltip.svelte';
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export { IITaskCardSkeleton } from './IITaskCardSkeleton';
|
|
|
42
42
|
export { IITextarea } from './IITextarea';
|
|
43
43
|
export { IIToggle } from './IIToggle';
|
|
44
44
|
export { IIToaster } from './IIToaster';
|
|
45
|
+
export { IITooltip } from './IITooltip';
|
|
45
46
|
export { IIViewFilterChip } from './IIViewFilterChip';
|
|
46
47
|
export type { AuditEvent, AuditFilter, Severity } from './IIAuditTrail';
|
|
47
48
|
export type { BadgeVariant } from './IIBadge';
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ export { IITaskCardSkeleton } from './IITaskCardSkeleton';
|
|
|
46
46
|
export { IITextarea } from './IITextarea';
|
|
47
47
|
export { IIToggle } from './IIToggle';
|
|
48
48
|
export { IIToaster } from './IIToaster';
|
|
49
|
+
export { IITooltip } from './IITooltip';
|
|
49
50
|
export { IIViewFilterChip } from './IIViewFilterChip';
|
|
50
51
|
// Utilities
|
|
51
52
|
export { toast } from './toast';
|