@widgetic/design-system 0.5.41 → 0.5.43
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 +3 -3
- package/dist/components/EmptyState.svelte +6 -2
- package/dist/components/chat/Composer.svelte +18 -10
- package/dist/components/chat/Composer.svelte.d.ts +7 -2
- package/dist/components/chat/Message.svelte +50 -41
- package/dist/components/chat/MessageRatingActions.svelte +12 -2
- package/dist/components/chat/PlanCard.svelte +39 -8
- package/dist/components/chat/planCardLogic.d.ts +24 -0
- package/dist/components/chat/planCardLogic.js +20 -0
- package/dist/components/creator/CreatorBar.svelte +54 -1
- package/dist/components/creator/CreatorBar.svelte.d.ts +5 -0
- package/dist/components/modals/BaseModal.svelte +9 -0
- package/dist/components/modals/BaseModal.svelte.d.ts +5 -0
- package/dist/components/search-input/SearchInput.svelte +38 -3
- package/dist/components/search-input/recentSearches.d.ts +5 -1
- package/dist/components/search-input/recentSearches.js +18 -1
- package/dist/components/shell/NavRow.svelte +53 -10
- package/dist/components/shell/NavRow.svelte.d.ts +23 -2
- package/dist/components/shell/NotificationRow.svelte +3 -2
- package/dist/components/shell/ProfileRow.svelte +6 -4
- package/dist/components/shell/ProfileRow.svelte.d.ts +2 -2
- package/dist/components/shell/SettingsDialog.svelte +23 -1
- package/dist/components/shell/WidgetRow.svelte +4 -3
- package/dist/components/shell/WidgetRow.svelte.d.ts +2 -2
- package/dist/components/ui/accordion/accordion-trigger.svelte +19 -0
- package/dist/components/ui/button/button.svelte +4 -2
- package/dist/components/ui/dialog/dialog-content.svelte +24 -2
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +2 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +12 -1
- package/dist/components/ui/hover-card/hover-card-content.svelte +2 -1
- package/dist/components/ui/popover/popover-content.svelte +2 -1
- package/dist/components/ui/select/select-content.svelte +2 -1
- package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
- package/dist/inline-completion/hintMemory.js +1 -0
- package/dist/inline-completion/inlineCompletionAction.js +1 -0
- package/dist/prompt-references/ReferenceMenu.svelte +72 -72
- package/dist/prompt-references/ReferenceMenu.svelte.d.ts +2 -2
- package/dist/prompt-references/promptReferences.js +15 -2
- package/dist/prompt-references/referenceMenuPlacement.d.ts +2 -16
- package/dist/prompt-references/referenceMenuPlacement.js +2 -25
- package/dist/prompt-references/referenceTypes.d.ts +5 -0
- package/dist/styles/tokens.css +94 -2
- package/dist/textarea-overlay/textareaOverlay.js +4 -1
- package/dist/utils/modalEnterKey.d.ts +139 -0
- package/dist/utils/modalEnterKey.js +276 -0
- package/dist/utils/modalFocusTrap.d.ts +7 -0
- package/dist/utils/modalFocusTrap.js +22 -0
- package/dist/utils/overlayMotion.d.ts +9 -0
- package/dist/utils/overlayMotion.js +9 -0
- package/dist/utils/revealOpeningSection.d.ts +51 -0
- package/dist/utils/revealOpeningSection.js +109 -0
- package/package.json +1 -1
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
Optional `recentSearchesKey` (a host-built localStorage key) shows up to three recent searches under the field when it is
|
|
7
7
|
focused and empty. With `recentSearchesKey` left at `''` the field matches the original Search Field (no recents panel).
|
|
8
|
+
|
|
9
|
+
Once a person has searched and then cleared the field (the clear button, or deleting every character), the list is not shown
|
|
10
|
+
again for the rest of that session (the life of the page, per key): they just did that search, so the list would only repeat
|
|
11
|
+
it. A reload starts a new session.
|
|
8
12
|
-->
|
|
9
13
|
<script lang="ts">
|
|
10
14
|
import { tick } from 'svelte';
|
|
@@ -14,7 +18,9 @@
|
|
|
14
18
|
|
|
15
19
|
import {
|
|
16
20
|
MIN_RECENT_SEARCH_LENGTH,
|
|
21
|
+
areRecentSearchesHiddenForSession,
|
|
17
22
|
clearRecentSearches,
|
|
23
|
+
hideRecentSearchesForSession,
|
|
18
24
|
readRecentSearches,
|
|
19
25
|
rememberRecentSearch
|
|
20
26
|
} from './recentSearches.js';
|
|
@@ -59,7 +65,8 @@
|
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
function openRecentPanelIfApplicable(): void {
|
|
62
|
-
|
|
68
|
+
// A person who searched and then cleared the field does not get the list back in this session: they just did the search
|
|
69
|
+
if (!recentSearchesKey || value.trim() || areRecentSearchesHiddenForSession(recentSearchesKey)) {
|
|
63
70
|
recentPanelOpen = false;
|
|
64
71
|
activeRecentIndex = -1;
|
|
65
72
|
return;
|
|
@@ -137,9 +144,28 @@
|
|
|
137
144
|
onBlur(event);
|
|
138
145
|
}
|
|
139
146
|
|
|
147
|
+
/** What the field held when it was last looked at: going from words to nothing is a search that is over. */
|
|
148
|
+
let lastObservedValue = value;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Looks at the words of the field. When there were words and now there are none (the clear button, the keyboard, or a host that
|
|
152
|
+
* empties the field), the search is over, so the recent searches are hidden for the rest of the session and the open card closes.
|
|
153
|
+
* It runs from the input event and from the reactive statement below; the second look of the same change finds nothing new.
|
|
154
|
+
*/
|
|
155
|
+
function observeValue(nextValue: string): void {
|
|
156
|
+
const hadWords = lastObservedValue.trim().length > 0;
|
|
157
|
+
lastObservedValue = nextValue;
|
|
158
|
+
if (!recentSearchesKey) return;
|
|
159
|
+
if (hadWords && !nextValue.trim()) {
|
|
160
|
+
hideRecentSearchesForSession(recentSearchesKey);
|
|
161
|
+
closeRecentPanel();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
140
165
|
function handleInputInternal(event: Event): void {
|
|
141
166
|
void onInput(event);
|
|
142
167
|
if (!recentSearchesKey) return;
|
|
168
|
+
observeValue(value);
|
|
143
169
|
if (value.trim()) {
|
|
144
170
|
closeRecentPanel();
|
|
145
171
|
} else if (typeof document !== 'undefined' && document.activeElement === inputElement) {
|
|
@@ -219,14 +245,20 @@
|
|
|
219
245
|
}
|
|
220
246
|
|
|
221
247
|
async function handleClearClick(): Promise<void> {
|
|
248
|
+
// The button only exists while there are words: this is a search that is over, so the list of recent searches stays hidden for
|
|
249
|
+
// the rest of the session. It is hidden before the host empties the field, so that nothing can open it in between.
|
|
250
|
+
if (recentSearchesKey) {
|
|
251
|
+
hideRecentSearchesForSession(recentSearchesKey);
|
|
252
|
+
closeRecentPanel();
|
|
253
|
+
}
|
|
222
254
|
onClear();
|
|
223
255
|
try {
|
|
224
256
|
if (!recentSearchesKey) return;
|
|
225
257
|
// The clear button leaves with the words and would take the focus with it: the field takes the focus back, so the keyboard
|
|
226
|
-
// keeps working and
|
|
258
|
+
// keeps working and a new search can start at once. The list stays closed (see above). A field without recent searches is
|
|
259
|
+
// left as it was.
|
|
227
260
|
await tick();
|
|
228
261
|
inputElement?.focus();
|
|
229
|
-
openRecentPanelIfApplicable();
|
|
230
262
|
} catch (error) {
|
|
231
263
|
console.warn('[SearchInput] Could not give the field the focus back after clearing it', error);
|
|
232
264
|
} finally {
|
|
@@ -252,6 +284,9 @@
|
|
|
252
284
|
$: if (recentSearchesKey && value.trim() && recentPanelOpen) {
|
|
253
285
|
closeRecentPanel();
|
|
254
286
|
}
|
|
287
|
+
|
|
288
|
+
// A host can change the words too (restoring a search from the address, emptying the field): every change is looked at
|
|
289
|
+
$: observeValue(value);
|
|
255
290
|
</script>
|
|
256
291
|
|
|
257
292
|
<div class="w-full {recentSearchesKey ? 'relative' : ''} {containerClass}">
|
|
@@ -8,5 +8,9 @@ export declare function readRecentSearches(key: string): string[];
|
|
|
8
8
|
export declare function rememberRecentSearch(key: string, term: string): string[];
|
|
9
9
|
/** Clears the stored list for `key`. Never throws. */
|
|
10
10
|
export declare function clearRecentSearches(key: string): void;
|
|
11
|
-
/**
|
|
11
|
+
/** Hides the recent searches of `key` for the rest of this session (they stay stored). Never throws. */
|
|
12
|
+
export declare function hideRecentSearchesForSession(key: string): void;
|
|
13
|
+
/** True while the recent searches of `key` are hidden for this session. */
|
|
14
|
+
export declare function areRecentSearchesHiddenForSession(key: string): boolean;
|
|
15
|
+
/** Test-only: reset in-memory fallback, the keys hidden for the session, and log latch. */
|
|
12
16
|
export declare function __resetRecentSearchesTestState(): void;
|
|
@@ -117,8 +117,25 @@ export function clearRecentSearches(key) {
|
|
|
117
117
|
removeFromLocalStorage(key);
|
|
118
118
|
memoryFallback.delete(key);
|
|
119
119
|
}
|
|
120
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* The keys whose recent searches stay hidden for the rest of this session. A session is the life of the page: the set lives in
|
|
122
|
+
* memory only, so a reload (or a new tab) starts a new one. It is filled when a person searched and then cleared the field:
|
|
123
|
+
* a list of what they searched would only repeat what they just did.
|
|
124
|
+
*/
|
|
125
|
+
const keysHiddenForSession = new Set();
|
|
126
|
+
/** Hides the recent searches of `key` for the rest of this session (they stay stored). Never throws. */
|
|
127
|
+
export function hideRecentSearchesForSession(key) {
|
|
128
|
+
if (!key)
|
|
129
|
+
return;
|
|
130
|
+
keysHiddenForSession.add(key);
|
|
131
|
+
}
|
|
132
|
+
/** True while the recent searches of `key` are hidden for this session. */
|
|
133
|
+
export function areRecentSearchesHiddenForSession(key) {
|
|
134
|
+
return Boolean(key) && keysHiddenForSession.has(key);
|
|
135
|
+
}
|
|
136
|
+
/** Test-only: reset in-memory fallback, the keys hidden for the session, and log latch. */
|
|
121
137
|
export function __resetRecentSearchesTestState() {
|
|
122
138
|
memoryFallback.clear();
|
|
139
|
+
keysHiddenForSession.clear();
|
|
123
140
|
loggedStorageFailure = false;
|
|
124
141
|
}
|
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
import type { WithElementRef } from 'bits-ui';
|
|
4
4
|
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
5
5
|
|
|
6
|
+
// Keyboard focus is drawn as the hover fill, with no ring (owner, 18 Nov 2026: "remove the focus ring around the sidebar
|
|
7
|
+
// elements"). The ring showed up on a row the moment a page was reloaded with the settings dialog open, because the dialog
|
|
8
|
+
// put the focus on its first row. A row that has the focus still looks different from its neighbours, so a person who
|
|
9
|
+
// moves with the keyboard can see where they are, but nothing is drawn around it.
|
|
6
10
|
export const navRowVariants = tv({
|
|
7
|
-
base: 'group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
11
|
+
base: 'group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2',
|
|
8
12
|
variants: {
|
|
9
13
|
active: {
|
|
10
14
|
true: 'bg-sidebar-accent text-sidebar-accent-foreground text-body-medium active:bg-accent-hover',
|
|
11
15
|
// The inactive row carries its own type style (14/20 regular, Figma Nav Row): without it the label took the size
|
|
12
16
|
// of whatever it sat in (16px in a dialog), bigger than the active row's 14/20 medium.
|
|
13
17
|
false:
|
|
14
|
-
'text-body text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-accent-hover active:text-sidebar-accent-foreground'
|
|
18
|
+
'text-body text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent focus-visible:text-sidebar-accent-foreground active:bg-accent-hover active:text-sidebar-accent-foreground'
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
defaultVariants: {
|
|
@@ -19,8 +23,23 @@
|
|
|
19
23
|
}
|
|
20
24
|
});
|
|
21
25
|
|
|
26
|
+
/**
|
|
27
|
+
* The filled pill of `trailingVariant="badge"`: the badge a phone draws on an app icon. A solid destructive (red) fill with the
|
|
28
|
+
* number in white, a circle for one digit (`min-w-5` is as wide as the 20px height) and a pill for more (`px-1.5`). It is
|
|
29
|
+
* the design system's Badge (`destructive`) at the size of a counter, so a count that wants attention stands out from the
|
|
30
|
+
* muted text of a count that only informs.
|
|
31
|
+
*/
|
|
32
|
+
export const navRowBadgeClass =
|
|
33
|
+
'inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-destructive px-1.5 text-label-small text-destructive-foreground tabular-nums';
|
|
34
|
+
|
|
35
|
+
/** The muted count to the right of a row (the default): it informs, it does not ask for attention. */
|
|
36
|
+
export const navRowTrailingTextClass = 'text-caption text-muted-foreground shrink-0 tabular-nums';
|
|
37
|
+
|
|
22
38
|
export type NavRowVisualState = 'default' | 'hover' | 'pressed' | 'active' | 'focus' | 'disabled';
|
|
23
39
|
|
|
40
|
+
/** How the text on the right of the row is drawn: muted text (a count that informs) or a filled badge (a count that asks for attention). */
|
|
41
|
+
export type NavRowTrailingVariant = 'text' | 'badge';
|
|
42
|
+
|
|
24
43
|
export type NavRowProps = WithElementRef<HTMLButtonAttributes> &
|
|
25
44
|
WithElementRef<HTMLAnchorAttributes> & {
|
|
26
45
|
ref?: HTMLAnchorElement | HTMLButtonElement | null;
|
|
@@ -32,6 +51,16 @@
|
|
|
32
51
|
showIcon?: boolean;
|
|
33
52
|
showTrailing?: boolean;
|
|
34
53
|
trailing?: string;
|
|
54
|
+
/**
|
|
55
|
+
* `text` (default): muted caption. `badge`: a filled pill like the unread count on a phone's app icon, for a number that
|
|
56
|
+
* wants to be noticed (the unread count of the Inbox).
|
|
57
|
+
*/
|
|
58
|
+
trailingVariant?: NavRowTrailingVariant;
|
|
59
|
+
/**
|
|
60
|
+
* What a screen reader says for the trailing text when the text alone says too little: a badge that shows "3" is "3 unread".
|
|
61
|
+
* When it is set the visible text is hidden from assistive technology and this is read instead.
|
|
62
|
+
*/
|
|
63
|
+
trailingAccessibleLabel?: string;
|
|
35
64
|
/** Showcase-only forced visual state (CSS `:hover` / `:focus-visible` otherwise). */
|
|
36
65
|
visualState?: NavRowVisualState;
|
|
37
66
|
};
|
|
@@ -52,6 +81,8 @@
|
|
|
52
81
|
showIcon = true,
|
|
53
82
|
showTrailing = false,
|
|
54
83
|
trailing = '',
|
|
84
|
+
trailingVariant = 'text',
|
|
85
|
+
trailingAccessibleLabel = undefined,
|
|
55
86
|
visualState = undefined,
|
|
56
87
|
icon,
|
|
57
88
|
iconComponent = undefined,
|
|
@@ -73,12 +104,28 @@
|
|
|
73
104
|
if (!visualState || visualState === 'default' || visualState === 'active') return '';
|
|
74
105
|
if (visualState === 'hover') return 'bg-sidebar-accent text-sidebar-accent-foreground';
|
|
75
106
|
if (visualState === 'pressed') return 'bg-accent-hover text-sidebar-accent-foreground';
|
|
76
|
-
|
|
77
|
-
|
|
107
|
+
// Keyboard focus is the hover fill: no ring is drawn around a sidebar row (see the note above `navRowVariants`)
|
|
108
|
+
if (visualState === 'focus') return 'bg-sidebar-accent text-sidebar-accent-foreground';
|
|
78
109
|
return '';
|
|
79
110
|
});
|
|
80
111
|
</script>
|
|
81
112
|
|
|
113
|
+
<!-- The text on the right of the row, in both the link and the button form of the row -->
|
|
114
|
+
{#snippet trailingContent()}
|
|
115
|
+
{#if showTrailing && trailing}
|
|
116
|
+
{#if trailingVariant === 'badge'}
|
|
117
|
+
<span class={navRowBadgeClass} data-nav-row-badge="">
|
|
118
|
+
<span aria-hidden={trailingAccessibleLabel ? 'true' : undefined}>{trailing}</span>
|
|
119
|
+
{#if trailingAccessibleLabel}
|
|
120
|
+
<span class="sr-only">{trailingAccessibleLabel}</span>
|
|
121
|
+
{/if}
|
|
122
|
+
</span>
|
|
123
|
+
{:else}
|
|
124
|
+
<span class={navRowTrailingTextClass}>{trailing}</span>
|
|
125
|
+
{/if}
|
|
126
|
+
{/if}
|
|
127
|
+
{/snippet}
|
|
128
|
+
|
|
82
129
|
{#if href && !isDisabled}
|
|
83
130
|
<a
|
|
84
131
|
bind:this={ref}
|
|
@@ -99,9 +146,7 @@
|
|
|
99
146
|
</span>
|
|
100
147
|
{/if}
|
|
101
148
|
<span class="min-w-0 flex-1 truncate">{label}</span>
|
|
102
|
-
{
|
|
103
|
-
<span class="text-caption text-muted-foreground shrink-0 tabular-nums">{trailing}</span>
|
|
104
|
-
{/if}
|
|
149
|
+
{@render trailingContent()}
|
|
105
150
|
{@render children?.()}
|
|
106
151
|
</a>
|
|
107
152
|
{:else}
|
|
@@ -124,9 +169,7 @@
|
|
|
124
169
|
</span>
|
|
125
170
|
{/if}
|
|
126
171
|
<span class="min-w-0 flex-1 truncate">{label}</span>
|
|
127
|
-
{
|
|
128
|
-
<span class="text-caption text-muted-foreground shrink-0 tabular-nums">{trailing}</span>
|
|
129
|
-
{/if}
|
|
172
|
+
{@render trailingContent()}
|
|
130
173
|
{@render children?.()}
|
|
131
174
|
</button>
|
|
132
175
|
{/if}
|
|
@@ -5,7 +5,7 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
|
|
|
5
5
|
true: string;
|
|
6
6
|
false: string;
|
|
7
7
|
};
|
|
8
|
-
}, undefined, "group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
8
|
+
}, undefined, "group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
9
9
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
10
10
|
active?: boolean | (string | number | symbol)[] | undefined;
|
|
11
11
|
} | undefined;
|
|
@@ -27,7 +27,7 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
|
|
|
27
27
|
true: string;
|
|
28
28
|
false: string;
|
|
29
29
|
};
|
|
30
|
-
}, undefined, "group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
30
|
+
}, undefined, "group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
31
31
|
active: {
|
|
32
32
|
true: string;
|
|
33
33
|
false: string;
|
|
@@ -38,7 +38,18 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
|
|
|
38
38
|
false: string;
|
|
39
39
|
};
|
|
40
40
|
}>, unknown, unknown, undefined>>;
|
|
41
|
+
/**
|
|
42
|
+
* The filled pill of `trailingVariant="badge"`: the badge a phone draws on an app icon. A solid destructive (red) fill with the
|
|
43
|
+
* number in white, a circle for one digit (`min-w-5` is as wide as the 20px height) and a pill for more (`px-1.5`). It is
|
|
44
|
+
* the design system's Badge (`destructive`) at the size of a counter, so a count that wants attention stands out from the
|
|
45
|
+
* muted text of a count that only informs.
|
|
46
|
+
*/
|
|
47
|
+
export declare const navRowBadgeClass = "inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-destructive px-1.5 text-label-small text-destructive-foreground tabular-nums";
|
|
48
|
+
/** The muted count to the right of a row (the default): it informs, it does not ask for attention. */
|
|
49
|
+
export declare const navRowTrailingTextClass = "text-caption text-muted-foreground shrink-0 tabular-nums";
|
|
41
50
|
export type NavRowVisualState = 'default' | 'hover' | 'pressed' | 'active' | 'focus' | 'disabled';
|
|
51
|
+
/** How the text on the right of the row is drawn: muted text (a count that informs) or a filled badge (a count that asks for attention). */
|
|
52
|
+
export type NavRowTrailingVariant = 'text' | 'badge';
|
|
42
53
|
export type NavRowProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<HTMLAnchorAttributes> & {
|
|
43
54
|
ref?: HTMLAnchorElement | HTMLButtonElement | null;
|
|
44
55
|
class?: string;
|
|
@@ -49,6 +60,16 @@ export type NavRowProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<
|
|
|
49
60
|
showIcon?: boolean;
|
|
50
61
|
showTrailing?: boolean;
|
|
51
62
|
trailing?: string;
|
|
63
|
+
/**
|
|
64
|
+
* `text` (default): muted caption. `badge`: a filled pill like the unread count on a phone's app icon, for a number that
|
|
65
|
+
* wants to be noticed (the unread count of the Inbox).
|
|
66
|
+
*/
|
|
67
|
+
trailingVariant?: NavRowTrailingVariant;
|
|
68
|
+
/**
|
|
69
|
+
* What a screen reader says for the trailing text when the text alone says too little: a badge that shows "3" is "3 unread".
|
|
70
|
+
* When it is set the visible text is hidden from assistive technology and this is read instead.
|
|
71
|
+
*/
|
|
72
|
+
trailingAccessibleLabel?: string;
|
|
52
73
|
/** Showcase-only forced visual state (CSS `:hover` / `:focus-visible` otherwise). */
|
|
53
74
|
visualState?: NavRowVisualState;
|
|
54
75
|
};
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
|
|
40
40
|
const rowClass = $derived(
|
|
41
41
|
cn(
|
|
42
|
-
|
|
42
|
+
// No colour transition on a list row (owner, 18 Nov 2026): the hover tint is a 4% tint, a 120ms fade made the hover show late
|
|
43
|
+
'group flex w-full items-center gap-4 rounded-xl px-4 py-3 text-start hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
43
44
|
className
|
|
44
45
|
)
|
|
45
46
|
);
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
|
|
52
53
|
{#snippet rowInner()}
|
|
53
54
|
<span
|
|
54
|
-
class="bg-muted text-foreground
|
|
55
|
+
class="bg-muted text-foreground group-hover:bg-background flex size-10 shrink-0 items-center justify-center rounded-lg"
|
|
55
56
|
>
|
|
56
57
|
{@render icon()}
|
|
57
58
|
</span>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<!-- Figma: Profile Row (component set 53:3, node 53:3). -->
|
|
2
2
|
<script lang="ts" module>
|
|
3
|
+
// No focus ring (owner, 18 Nov 2026: "remove the focus ring around the sidebar elements"): keyboard focus is drawn as the
|
|
4
|
+
// hover fill, like a Nav Row's.
|
|
3
5
|
export const profileRowVariants = tv({
|
|
4
|
-
base: 'flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
6
|
+
base: 'flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden',
|
|
5
7
|
variants: {
|
|
6
8
|
interactive: {
|
|
7
|
-
true: 'cursor-pointer hover:bg-sidebar-accent',
|
|
9
|
+
true: 'cursor-pointer hover:bg-sidebar-accent focus-visible:bg-sidebar-accent',
|
|
8
10
|
false: ''
|
|
9
11
|
}
|
|
10
12
|
},
|
|
@@ -49,8 +51,8 @@
|
|
|
49
51
|
const showcaseClass = $derived.by(() => {
|
|
50
52
|
if (!visualState || visualState === 'default') return '';
|
|
51
53
|
if (visualState === 'hover') return 'bg-sidebar-accent';
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
// Keyboard focus is the hover fill: no ring is drawn around a sidebar row
|
|
55
|
+
if (visualState === 'focus') return 'bg-sidebar-accent';
|
|
54
56
|
return '';
|
|
55
57
|
});
|
|
56
58
|
|
|
@@ -3,7 +3,7 @@ export declare const profileRowVariants: import("tailwind-variants").TVReturnTyp
|
|
|
3
3
|
true: string;
|
|
4
4
|
false: string;
|
|
5
5
|
};
|
|
6
|
-
}, undefined, "flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
6
|
+
}, undefined, "flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden", {
|
|
7
7
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
8
8
|
interactive?: boolean | (string | number | symbol)[] | undefined;
|
|
9
9
|
} | undefined;
|
|
@@ -25,7 +25,7 @@ export declare const profileRowVariants: import("tailwind-variants").TVReturnTyp
|
|
|
25
25
|
true: string;
|
|
26
26
|
false: string;
|
|
27
27
|
};
|
|
28
|
-
}, undefined, "flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
28
|
+
}, undefined, "flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
29
29
|
interactive: {
|
|
30
30
|
true: string;
|
|
31
31
|
false: string;
|
|
@@ -110,6 +110,25 @@
|
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// "Settings Panel": settingsPanelElement, the dialog's own box, which bits-ui makes focusable (`tabindex="-1"`) through the focus scope
|
|
114
|
+
let settingsPanelElement = $state<HTMLElement | null>(null);
|
|
115
|
+
|
|
116
|
+
// By default bits-ui puts the focus on the first tabbable element when the dialog opens, and in this dialog that is the first
|
|
117
|
+
// row of the navigation. A page reloaded with Settings open therefore opened with "Workspace settings" focused, which a
|
|
118
|
+
// keyboard-focus style is drawn on even when the page that is open is another (owner, 18 Nov 2026). The dialog takes the
|
|
119
|
+
// focus itself instead: the screen reader reads its title, Tab moves to the first row, and nothing is highlighted before
|
|
120
|
+
// the person has done anything. The focus stays inside the dialog, so the focus trap is not weakened.
|
|
121
|
+
function handleOpenAutoFocus(event: Event): void {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
requestAnimationFrame(() => {
|
|
124
|
+
try {
|
|
125
|
+
settingsPanelElement?.focus({ preventScroll: true });
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.warn('[SettingsDialog] Could not move the focus to the dialog panel', error);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
113
132
|
// Parent keeps pe-8 (32px): the cards of a page end on that line. When the page scrolls we pull the scroll area into that
|
|
114
133
|
// padding, so the bar is drawn in the margin right of the cards, close to the dialog edge, and never over a card.
|
|
115
134
|
const PANE_RIGHT_PADDING_PX = 32;
|
|
@@ -150,10 +169,12 @@
|
|
|
150
169
|
<!-- The scrim is the shared one of every overlay (muted foreground at 80%, 3px blur), set by the dialog overlay itself -->
|
|
151
170
|
<Dialog.Overlay />
|
|
152
171
|
<DialogPrimitive.Content
|
|
172
|
+
bind:ref={settingsPanelElement}
|
|
153
173
|
forceMount
|
|
154
174
|
aria-describedby={description || descriptionSlot ? 'settings-dialog-description' : undefined}
|
|
155
175
|
trapFocus={!nestedModalOpen}
|
|
156
176
|
onEscapeKeydown={handleEscapeKeydown}
|
|
177
|
+
onOpenAutoFocus={handleOpenAutoFocus}
|
|
157
178
|
class={className}
|
|
158
179
|
>
|
|
159
180
|
{#snippet child({ props, open })}
|
|
@@ -164,7 +185,8 @@
|
|
|
164
185
|
data-widgetic-overlay="dialog-panel"
|
|
165
186
|
style:z-index|important={overlayLayerContext.ensureLayer().scrimZ + 1}
|
|
166
187
|
class={cn(
|
|
167
|
-
|
|
188
|
+
// outline-hidden: the panel holds the focus when the dialog opens (see handleOpenAutoFocus) and must not draw a ring
|
|
189
|
+
'border-border bg-background fixed flex overflow-hidden border outline-hidden',
|
|
168
190
|
overlayReducedMotionClasses,
|
|
169
191
|
'inset-0 h-full max-h-none w-full rounded-none',
|
|
170
192
|
// Centred with auto margins, not with a translate: a CSS transform would make this box the containing block
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import type { VariantProps } from 'tailwind-variants';
|
|
4
4
|
|
|
5
5
|
export const widgetRowVariants = tv({
|
|
6
|
-
|
|
6
|
+
// No colour transition on a list row (owner, 18 Nov 2026: hover "used to be instant, now there's a lag"): the hover tint is a 4% tint, so a 120ms fade shows nothing for ~110ms and the row looks late; it must switch on the frame the pointer arrives.
|
|
7
|
+
base: 'group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4 focus-within:outline-hidden',
|
|
7
8
|
variants: {
|
|
8
9
|
selected: {
|
|
9
10
|
true: 'bg-brand-subtle ring-2 ring-brand',
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
>
|
|
102
103
|
<div
|
|
103
104
|
class={cn(
|
|
104
|
-
'bg-muted
|
|
105
|
+
'bg-muted group-hover/widget-row:bg-background flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg',
|
|
105
106
|
forceHover && 'bg-background'
|
|
106
107
|
)}
|
|
107
108
|
>
|
|
@@ -145,7 +146,7 @@
|
|
|
145
146
|
{#if actions}
|
|
146
147
|
<div
|
|
147
148
|
class={cn(
|
|
148
|
-
'
|
|
149
|
+
'shrink-0 opacity-0 group-focus-within/widget-row:opacity-100 group-hover/widget-row:opacity-100',
|
|
149
150
|
(actionsAlwaysVisible || forceHover || forceFocus) && 'opacity-100'
|
|
150
151
|
)}
|
|
151
152
|
>
|
|
@@ -7,7 +7,7 @@ export declare const widgetRowVariants: import("tailwind-variants").TVReturnType
|
|
|
7
7
|
true: string;
|
|
8
8
|
false: string;
|
|
9
9
|
};
|
|
10
|
-
}, undefined, "group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4
|
|
10
|
+
}, undefined, "group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4 focus-within:outline-hidden", {
|
|
11
11
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
12
12
|
selected?: boolean | (string | number | symbol)[] | undefined;
|
|
13
13
|
loading?: boolean | (string | number | symbol)[] | undefined;
|
|
@@ -38,7 +38,7 @@ export declare const widgetRowVariants: import("tailwind-variants").TVReturnType
|
|
|
38
38
|
true: string;
|
|
39
39
|
false: string;
|
|
40
40
|
};
|
|
41
|
-
}, undefined, "group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4
|
|
41
|
+
}, undefined, "group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4 focus-within:outline-hidden", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
42
42
|
selected: {
|
|
43
43
|
true: string;
|
|
44
44
|
false: string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Accordion as AccordionPrimitive, type WithoutChild } from "bits-ui";
|
|
3
3
|
import IconChevronDown from "@tabler/icons-svelte/icons/chevron-down";
|
|
4
4
|
import { cn } from "../../../utils.js";
|
|
5
|
+
import { followOpeningSection } from "../../../utils/revealOpeningSection.js";
|
|
5
6
|
|
|
6
7
|
let {
|
|
7
8
|
ref = $bindable(null),
|
|
@@ -37,14 +38,32 @@
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* A section that opens near the bottom of a scrolling box (the settings dialog, a page) grows below the edge of it. While it
|
|
43
|
+
* opens, its box is scrolled so the content comes into view, and the person does not have to scroll to read what they opened.
|
|
44
|
+
* At the time of the toggle the trigger still has the state it is leaving, so `closed` means this click opens the item.
|
|
45
|
+
*/
|
|
46
|
+
function keepOpeningItemInView(event: Event) {
|
|
47
|
+
try {
|
|
48
|
+
const trigger = event.currentTarget as HTMLElement | null;
|
|
49
|
+
if (trigger?.getAttribute("data-state") !== "closed") return;
|
|
50
|
+
const ownItem = trigger.closest<HTMLElement>("[data-accordion-item]");
|
|
51
|
+
if (ownItem) followOpeningSection(ownItem);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.warn("[accordion] could not keep the opening item in view:", error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
40
57
|
function handleTriggerClick(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) {
|
|
41
58
|
markAccordionItemsAnimate(event);
|
|
59
|
+
keepOpeningItemInView(event);
|
|
42
60
|
onclick?.(event);
|
|
43
61
|
}
|
|
44
62
|
|
|
45
63
|
function handleTriggerKeydown(event: KeyboardEvent & { currentTarget: EventTarget & HTMLButtonElement }) {
|
|
46
64
|
if (event.key === "Enter" || event.key === " ") {
|
|
47
65
|
markAccordionItemsAnimate(event);
|
|
66
|
+
keepOpeningItemInView(event);
|
|
48
67
|
}
|
|
49
68
|
onkeydown?.(event);
|
|
50
69
|
}
|
|
@@ -118,12 +118,14 @@
|
|
|
118
118
|
);
|
|
119
119
|
</script>
|
|
120
120
|
|
|
121
|
+
<!-- `data-variant` says how the button is drawn. A modal reads it to find its main button: Enter presses the last filled one
|
|
122
|
+
(default, accent or destructive, see utils/modalEnterKey.ts). A caller can still set its own through `restProps`. -->
|
|
121
123
|
{#if href}
|
|
122
|
-
<a bind:this={ref} class={classes} {href} {...restProps}>
|
|
124
|
+
<a bind:this={ref} class={classes} {href} data-variant={variant} {...restProps}>
|
|
123
125
|
{@render children?.()}
|
|
124
126
|
</a>
|
|
125
127
|
{:else}
|
|
126
|
-
<button bind:this={ref} class={classes} {type} {...restProps}>
|
|
128
|
+
<button bind:this={ref} class={classes} {type} data-variant={variant} {...restProps}>
|
|
127
129
|
{@render children?.()}
|
|
128
130
|
</button>
|
|
129
131
|
{/if}
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
import { claimOverlayLayerPair, overlayLayerZIndexStyle } from "../../../utils/overlayLayerStack.js";
|
|
15
15
|
import { OVERLAY_LAYER_CONTEXT_KEY, type OverlayLayerContext } from "./overlay-layer-context.js";
|
|
16
16
|
import DialogLayerSync from "./DialogLayerSync.svelte";
|
|
17
|
+
// Enter inside the card presses the dialog's main button (see utils/modalEnterKey.ts).
|
|
18
|
+
import { modalEnterKey } from "../../../utils/modalEnterKey.js";
|
|
19
|
+
import { dialogInitialFocusTarget } from "../../../utils/modalFocusTrap.js";
|
|
17
20
|
|
|
18
21
|
let {
|
|
19
22
|
ref = $bindable(null),
|
|
@@ -49,11 +52,28 @@
|
|
|
49
52
|
onDestroy(() => overlayLayerContext.releaseLayer());
|
|
50
53
|
|
|
51
54
|
const panelFly = $derived(overlayPanelFlyTransition());
|
|
55
|
+
|
|
56
|
+
// By default bits-ui puts the focus on the first tabbable element when the dialog opens, and in a confirm dialog that is
|
|
57
|
+
// "Cancel": Enter would then cancel the dialog, where the person expects it to press the main button (owner, 18 Nov 2026).
|
|
58
|
+
// The focus goes to the first field to type in, else to the card, and never to a button; a caller that wants something else
|
|
59
|
+
// passes its own `onOpenAutoFocus` (it comes after this one in the props). The focus stays inside the dialog, so the focus
|
|
60
|
+
// trap is not weakened.
|
|
61
|
+
function handleOpenAutoFocus(event: Event): void {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
requestAnimationFrame(() => {
|
|
64
|
+
try {
|
|
65
|
+
if (!ref) return;
|
|
66
|
+
dialogInitialFocusTarget(ref).focus({ preventScroll: true });
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.warn("[dialog] Could not move the focus into the dialog", error);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
52
72
|
</script>
|
|
53
73
|
|
|
54
74
|
<Dialog.Portal {...portalProps}>
|
|
55
75
|
<Dialog.Overlay />
|
|
56
|
-
<DialogPrimitive.Content bind:ref forceMount {...restProps}>
|
|
76
|
+
<DialogPrimitive.Content bind:ref forceMount onOpenAutoFocus={handleOpenAutoFocus} {...restProps}>
|
|
57
77
|
{#snippet child({ props, open })}
|
|
58
78
|
<DialogLayerSync {open} {overlayLayerContext} />
|
|
59
79
|
{#if open}
|
|
@@ -68,8 +88,10 @@
|
|
|
68
88
|
>
|
|
69
89
|
<div
|
|
70
90
|
{...props}
|
|
91
|
+
use:modalEnterKey
|
|
71
92
|
class={cn(
|
|
72
|
-
|
|
93
|
+
// outline-hidden: the card holds the focus when the dialog opens with no field in it (see handleOpenAutoFocus)
|
|
94
|
+
"bg-background border-border pointer-events-auto grid w-dialog max-w-[calc(100vw-3rem)] gap-4 rounded-panel border p-6 outline-hidden",
|
|
73
95
|
overlayDialogPanelCardClasses,
|
|
74
96
|
className
|
|
75
97
|
)}
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
{sideOffset}
|
|
26
26
|
dir={$textDirection}
|
|
27
27
|
class={cn(
|
|
28
|
-
|
|
28
|
+
// floating-motion: fade + 8px slide from the trigger side in 150ms (tokens.css); the account and workspace menus of the sidebar use it too
|
|
29
|
+
'bg-popover text-popover-foreground border-border floating-motion w-max min-w-[8rem] max-w-[min(24rem,calc(100vw-1rem))] overflow-hidden rounded-xl border p-1 outline-hidden',
|
|
29
30
|
overlayFloatingContentZClass,
|
|
30
31
|
className
|
|
31
32
|
)}
|
|
@@ -12,18 +12,29 @@
|
|
|
12
12
|
// alignment inside a menu of a right to left screen.
|
|
13
13
|
const textDirection = useTextDirection();
|
|
14
14
|
|
|
15
|
+
// The sub-menu hangs from its row: the top of its first entry is level with the row that opened it. The library centres a
|
|
16
|
+
// floating element on its anchor unless told otherwise, so a sub-menu of three entries sat a third of its height above the
|
|
17
|
+
// row and did not look as if it came out of it. The offset is the 1px border plus the 4px padding (`border p-1` below) that
|
|
18
|
+
// stand between the top edge of the box and its first entry.
|
|
19
|
+
const SUB_MENU_ALIGN_OFFSET_PX = -5;
|
|
20
|
+
|
|
15
21
|
let {
|
|
16
22
|
ref = $bindable(null),
|
|
17
23
|
class: className,
|
|
24
|
+
align = "start",
|
|
25
|
+
alignOffset = SUB_MENU_ALIGN_OFFSET_PX,
|
|
18
26
|
...restProps
|
|
19
27
|
}: DropdownMenuSubContentProps = $props();
|
|
20
28
|
</script>
|
|
21
29
|
|
|
22
30
|
<DropdownMenuPrimitive.SubContent
|
|
23
31
|
bind:ref
|
|
32
|
+
{align}
|
|
33
|
+
{alignOffset}
|
|
24
34
|
dir={$textDirection}
|
|
25
35
|
class={cn(
|
|
26
|
-
|
|
36
|
+
// floating-motion: the sub-menu slides in like the menu it opens from (it had no motion before)
|
|
37
|
+
'bg-popover text-popover-foreground border-border floating-motion w-max min-w-[8rem] max-w-[min(24rem,calc(100vw-1rem))] rounded-xl border p-1 focus:outline-hidden',
|
|
27
38
|
overlayFloatingContentZClass,
|
|
28
39
|
className
|
|
29
40
|
)}
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
{sideOffset}
|
|
28
28
|
dir={$textDirection}
|
|
29
29
|
class={cn(
|
|
30
|
-
|
|
30
|
+
// floating-motion: fade + 8px slide from the trigger side in 150ms (tokens.css)
|
|
31
|
+
'bg-popover text-popover-foreground border-border floating-motion mt-3 w-64 rounded-xl border p-4 outline-hidden',
|
|
31
32
|
overlayFloatingContentZClass,
|
|
32
33
|
className
|
|
33
34
|
)}
|