@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
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
{align}
|
|
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 w-72 rounded-xl border p-4 outline-hidden',
|
|
31
32
|
overlayFloatingContentZClass,
|
|
32
33
|
className
|
|
33
34
|
)}
|
|
@@ -128,7 +128,8 @@
|
|
|
128
128
|
{sideOffset}
|
|
129
129
|
dir={$textDirection}
|
|
130
130
|
class={cn(
|
|
131
|
-
|
|
131
|
+
// floating-motion: fade + 8px slide from the trigger side in 150ms (tokens.css); the translate-* classes are the 4px gap
|
|
132
|
+
'relative max-h-96 min-w-[8rem] overflow-hidden rounded-xl border border-border bg-popover text-popover-foreground floating-motion data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
|
132
133
|
overlayFloatingContentZClass,
|
|
133
134
|
className
|
|
134
135
|
)}
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
const variantClasses = {
|
|
27
27
|
default:
|
|
28
|
-
'bg-popover text-popover-foreground border border-border shadow-
|
|
28
|
+
'bg-popover text-popover-foreground border border-border shadow-floating',
|
|
29
29
|
inverse: 'bg-inverse text-inverse-foreground border-transparent'
|
|
30
30
|
};
|
|
31
31
|
</script>
|
|
@@ -3,6 +3,7 @@ export const COMPLETION_HINT_STORAGE_KEY = 'widgetic:completion-hint-learned:v1'
|
|
|
3
3
|
/** What is stored once a suggestion was taken. */
|
|
4
4
|
const LEARNED_VALUE = '1';
|
|
5
5
|
const defaultLog = (message, detail) => {
|
|
6
|
+
// Kept on: this is the documented default of the `log` option (a test pins it), and it writes at debug level only.
|
|
6
7
|
console.debug('[inline-completion]', message, detail ?? '');
|
|
7
8
|
};
|
|
8
9
|
/** The page's own storage, or null when there is none (a server render) or the browser refuses to hand it out (it throws). */
|
|
@@ -8,6 +8,7 @@ export const GHOST_OVERLAY_OWNER = 'ghost';
|
|
|
8
8
|
/** The ghost's colour: the muted text colour of the design system. A host may pass its own classes. */
|
|
9
9
|
export const DEFAULT_GHOST_CLASS = 'text-muted-foreground';
|
|
10
10
|
const defaultLog = (message, detail) => {
|
|
11
|
+
// Kept on: this is the documented default of the `log` option (the same line as the hint memory's), and it writes at debug level only.
|
|
11
12
|
console.debug('[inline-completion]', message, detail ?? '');
|
|
12
13
|
};
|
|
13
14
|
/** Text for assistive technology only: out of sight, still read. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
/**
|
|
3
|
-
* The `#` menu: the files a person may refer to, each with its thumbnail
|
|
4
|
-
*
|
|
3
|
+
* The `#` menu: the files a person may refer to, each row with its small thumbnail and the file's name, and nothing else (the
|
|
4
|
+
* thumbnail IS the preview: no larger card opens beside the list). It can also show a larger preview alone, over a badge the pointer
|
|
5
|
+
* is on.
|
|
5
6
|
*
|
|
6
7
|
* It does not own any state: the action (`promptReferences`) tells it what to show and where, and hears back which row was chosen or
|
|
7
8
|
* hovered. The focus never leaves the text box (this is a combobox popup: the action sets `aria-activedescendant` on the box), so the
|
|
@@ -12,12 +13,7 @@
|
|
|
12
13
|
* Where the top layer is not available they are `fixed` with a high z-index instead.
|
|
13
14
|
*/
|
|
14
15
|
import { FILE_GLYPH_PATHS } from './referenceBadge.js';
|
|
15
|
-
import {
|
|
16
|
-
placeMenu,
|
|
17
|
-
placePreview,
|
|
18
|
-
type Box,
|
|
19
|
-
type MenuDirection
|
|
20
|
-
} from './referenceMenuPlacement.js';
|
|
16
|
+
import { placeMenu, type Box, type MenuDirection } from './referenceMenuPlacement.js';
|
|
21
17
|
import type { ReferenceItem } from './referenceTypes.js';
|
|
22
18
|
|
|
23
19
|
type Props = {
|
|
@@ -27,9 +23,9 @@
|
|
|
27
23
|
activeIndex: number;
|
|
28
24
|
/** The `#` the list hangs from, in viewport pixels. */
|
|
29
25
|
anchor: Box | null;
|
|
30
|
-
/** The file the preview shows
|
|
26
|
+
/** The file the preview shows: the badge the pointer is on. Never a row of the list, which carries its own small picture. */
|
|
31
27
|
previewItem: ReferenceItem | null;
|
|
32
|
-
/** What the preview hangs from
|
|
28
|
+
/** What the preview hangs from: the badge, in viewport pixels. Without it there is no preview. */
|
|
33
29
|
previewAnchor: Box | null;
|
|
34
30
|
/** The id of the list, for the box's `aria-controls`. The rows are `{menuId}-option-{index}`. */
|
|
35
31
|
menuId: string;
|
|
@@ -71,15 +67,15 @@
|
|
|
71
67
|
let previewPosition = $state<{ left: number; top: number } | null>(null);
|
|
72
68
|
/**
|
|
73
69
|
* The distance of the list and of the picture from the left edge of the page. Both are put by pixel at a place measured from the
|
|
74
|
-
* rectangles of the text box and of the page (the placement code picks the side
|
|
75
|
-
* and a right-to-left page put them alike.
|
|
70
|
+
* rectangles of the text box (or of the badge) and of the page (the placement code picks the side there is room on), so a
|
|
71
|
+
* left-to-right and a right-to-left page put them alike.
|
|
76
72
|
*/
|
|
77
73
|
const listOffsetStyle = $derived(
|
|
78
74
|
// rtl-ok: measured from the left edge of the page, at a place the placement code chose
|
|
79
75
|
`left: ${listBox?.left ?? 0}px;`
|
|
80
76
|
);
|
|
81
77
|
const previewOffsetStyle = $derived(
|
|
82
|
-
// rtl-ok: measured from the left edge of the page, at a place the placement code chose
|
|
78
|
+
// rtl-ok: measured from the left edge of the page, at a place the placement code chose over the badge
|
|
83
79
|
`left: ${previewPosition?.left ?? 0}px;`
|
|
84
80
|
);
|
|
85
81
|
/** The window's size, kept by Svelte: a resize or a zoom places both again. */
|
|
@@ -94,10 +90,10 @@
|
|
|
94
90
|
function reportProblemOnce(error: unknown): void {
|
|
95
91
|
if (reportedProblem) return;
|
|
96
92
|
reportedProblem = true;
|
|
97
|
-
console.debug(
|
|
98
|
-
'[prompt-references] could not place the menu',
|
|
99
|
-
error instanceof Error ? error.message : error
|
|
100
|
-
);
|
|
93
|
+
// console.debug(
|
|
94
|
+
// '[prompt-references] could not place the menu',
|
|
95
|
+
// error instanceof Error ? error.message : error
|
|
96
|
+
// );
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
/** The space the page can show, in the same pixels as the anchors: the visual viewport when there is one (a keyboard shrinks it). */
|
|
@@ -161,37 +157,21 @@
|
|
|
161
157
|
}
|
|
162
158
|
});
|
|
163
159
|
|
|
164
|
-
// The preview:
|
|
160
|
+
// The preview: above (or below) the badge it belongs to. The list has no card of its own beside it (its rows carry a small picture).
|
|
165
161
|
$effect(() => {
|
|
166
162
|
void windowWidth;
|
|
167
163
|
void windowHeight;
|
|
168
164
|
const element = previewElement;
|
|
169
165
|
const shown = previewItem;
|
|
170
|
-
|
|
166
|
+
const hangFrom = previewAnchor;
|
|
167
|
+
if (!element || !shown || !hangFrom) {
|
|
171
168
|
previewPosition = null;
|
|
172
169
|
return;
|
|
173
170
|
}
|
|
174
171
|
try {
|
|
175
172
|
const size = { width: element.offsetWidth, height: element.offsetHeight };
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
previewPosition = placePreview({
|
|
179
|
-
beside: {
|
|
180
|
-
left: listBox.left,
|
|
181
|
-
top: listBox.top,
|
|
182
|
-
right: listBox.left + listBox.width,
|
|
183
|
-
bottom: listBox.top + listBox.height
|
|
184
|
-
},
|
|
185
|
-
preview: size,
|
|
186
|
-
viewport,
|
|
187
|
-
direction
|
|
188
|
-
});
|
|
189
|
-
} else if (previewAnchor) {
|
|
190
|
-
const placed = placeMenu({ anchor: previewAnchor, menu: size, viewport, direction });
|
|
191
|
-
previewPosition = { left: placed.left, top: placed.top };
|
|
192
|
-
} else {
|
|
193
|
-
previewPosition = null;
|
|
194
|
-
}
|
|
173
|
+
const placed = placeMenu({ anchor: hangFrom, menu: size, viewport: viewportSize(), direction });
|
|
174
|
+
previewPosition = { left: placed.left, top: placed.top };
|
|
195
175
|
} catch (error) {
|
|
196
176
|
reportProblemOnce(error);
|
|
197
177
|
}
|
|
@@ -215,6 +195,11 @@
|
|
|
215
195
|
failedPictures[url] = true;
|
|
216
196
|
}
|
|
217
197
|
|
|
198
|
+
/** What the pointer shows when it rests on a row: the whole name (a long one is cut short), and the size when the host knows it. */
|
|
199
|
+
function rowTitle(item: ReferenceItem): string {
|
|
200
|
+
return item.sizeLabel ? `${item.fileName} · ${item.sizeLabel}` : item.fileName;
|
|
201
|
+
}
|
|
202
|
+
|
|
218
203
|
/** A move over a row highlights it, unless the pointer has not really moved (the rows scrolled under it). */
|
|
219
204
|
function handleRowPointerMove(event: MouseEvent, index: number): void {
|
|
220
205
|
if (event.clientX === lastPointerPosition.x && event.clientY === lastPointerPosition.y) return;
|
|
@@ -282,6 +267,7 @@
|
|
|
282
267
|
id="{menuId}-option-{index}"
|
|
283
268
|
role="option"
|
|
284
269
|
aria-selected={index === activeIndex}
|
|
270
|
+
aria-label={item.fileName}
|
|
285
271
|
data-prompt-reference-option={index}
|
|
286
272
|
data-label={item.label}
|
|
287
273
|
class="aria-selected:bg-accent aria-selected:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-sm"
|
|
@@ -289,56 +275,70 @@
|
|
|
289
275
|
onclick={() => onChoose(item)}
|
|
290
276
|
>
|
|
291
277
|
{@render picture(item, 'size-8 rounded-lg', 'size-4')}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
278
|
+
<!-- The name and nothing else. It may take a second line before it is cut with an ellipsis: files from a camera or an
|
|
279
|
+
export often share a long beginning and differ at the end, so one line cut at the end would show two rows alike. -->
|
|
280
|
+
<span
|
|
281
|
+
class="line-clamp-2 min-w-0 flex-1 [overflow-wrap:anywhere]"
|
|
282
|
+
data-prompt-reference-name
|
|
283
|
+
title={rowTitle(item)}>{item.fileName}</span
|
|
284
|
+
>
|
|
298
285
|
<span class="text-muted-foreground text-xs tabular-nums">{item.number}</span>
|
|
299
286
|
</div>
|
|
300
287
|
{/each}
|
|
301
288
|
</div>
|
|
302
289
|
{/if}
|
|
303
290
|
|
|
304
|
-
{#if previewItem}
|
|
291
|
+
{#if previewItem && previewAnchor}
|
|
292
|
+
<!-- Over a badge the pointer is on. A row of the list never gets one: its small picture is the preview. -->
|
|
305
293
|
<div
|
|
306
294
|
bind:this={previewElement}
|
|
307
295
|
use:showInTopLayer
|
|
308
296
|
popover="manual"
|
|
309
297
|
aria-hidden="true"
|
|
310
298
|
data-prompt-reference-preview
|
|
311
|
-
class="border-border bg-popover text-popover-foreground pointer-events-none fixed inset-auto z-[1100] m-0 box-content flex
|
|
299
|
+
class="border-border bg-popover text-popover-foreground pointer-events-none fixed inset-auto z-[1100] m-0 box-content flex flex-col gap-1 overflow-hidden rounded-xl border p-1 {previewItem.excerpt
|
|
300
|
+
? 'w-64'
|
|
301
|
+
: 'w-40'}"
|
|
312
302
|
style={previewOffsetStyle}
|
|
313
303
|
style:top="{previewPosition?.top ?? 0}px"
|
|
314
304
|
style:visibility={previewPosition ? 'visible' : 'hidden'}
|
|
315
305
|
>
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
306
|
+
{#if previewItem.excerpt}
|
|
307
|
+
<!-- A text: what it says, from its beginning, cut short with an ellipsis (a long text is far more than the card can hold).
|
|
308
|
+
The padding sits on the wrapper: a clamped box with padding of its own lets a tenth line show through the padding. -->
|
|
309
|
+
<div class="bg-background w-full overflow-hidden rounded-lg p-2">
|
|
310
|
+
<p
|
|
311
|
+
class="text-muted-foreground line-clamp-9 w-full text-xs leading-4 break-words whitespace-pre-wrap"
|
|
312
|
+
data-prompt-reference-excerpt>{previewItem.excerpt}</p>
|
|
313
|
+
</div>
|
|
314
|
+
{:else}
|
|
315
|
+
<div class="bg-background flex size-40 items-center justify-center overflow-hidden rounded-lg">
|
|
316
|
+
{#if previewItem.previewUrl && !failedPictures[previewItem.previewUrl]}
|
|
317
|
+
<img
|
|
318
|
+
src={previewItem.previewUrl}
|
|
319
|
+
alt=""
|
|
320
|
+
draggable="false"
|
|
321
|
+
class="size-full object-contain"
|
|
322
|
+
onerror={() => markPictureFailed(previewItem?.previewUrl ?? '')}
|
|
323
|
+
/>
|
|
324
|
+
{:else}
|
|
325
|
+
<svg
|
|
326
|
+
viewBox="0 0 24 24"
|
|
327
|
+
fill="none"
|
|
328
|
+
stroke="currentColor"
|
|
329
|
+
stroke-width="1.5"
|
|
330
|
+
stroke-linecap="round"
|
|
331
|
+
stroke-linejoin="round"
|
|
332
|
+
aria-hidden="true"
|
|
333
|
+
class="text-muted-foreground size-10"
|
|
334
|
+
>
|
|
335
|
+
{#each FILE_GLYPH_PATHS as pathData (pathData)}
|
|
336
|
+
<path d={pathData} />
|
|
337
|
+
{/each}
|
|
338
|
+
</svg>
|
|
339
|
+
{/if}
|
|
340
|
+
</div>
|
|
341
|
+
{/if}
|
|
342
342
|
<span class="truncate px-1 text-xs">{previewItem.fileName}</span>
|
|
343
343
|
</div>
|
|
344
344
|
{/if}
|
|
@@ -7,9 +7,9 @@ type Props = {
|
|
|
7
7
|
activeIndex: number;
|
|
8
8
|
/** The `#` the list hangs from, in viewport pixels. */
|
|
9
9
|
anchor: Box | null;
|
|
10
|
-
/** The file the preview shows
|
|
10
|
+
/** The file the preview shows: the badge the pointer is on. Never a row of the list, which carries its own small picture. */
|
|
11
11
|
previewItem: ReferenceItem | null;
|
|
12
|
-
/** What the preview hangs from
|
|
12
|
+
/** What the preview hangs from: the badge, in viewport pixels. Without it there is no preview. */
|
|
13
13
|
previewAnchor: Box | null;
|
|
14
14
|
/** The id of the list, for the box's `aria-controls`. The rows are `{menuId}-option-{index}`. */
|
|
15
15
|
menuId: string;
|
|
@@ -82,6 +82,7 @@ export function promptReferences(field, initialParams) {
|
|
|
82
82
|
const reportedKinds = new Set();
|
|
83
83
|
function log(message, detail) {
|
|
84
84
|
try {
|
|
85
|
+
// Kept on: the console at debug level is the documented default of the `logger` option.
|
|
85
86
|
if (params.logger)
|
|
86
87
|
params.logger(message, detail);
|
|
87
88
|
else
|
|
@@ -196,8 +197,15 @@ export function promptReferences(field, initialParams) {
|
|
|
196
197
|
const selection = currentSelection();
|
|
197
198
|
const decorations = [];
|
|
198
199
|
let badgeCount = 0;
|
|
200
|
+
const tokens = badgesFellBack ? [] : readTokens();
|
|
201
|
+
// The badge under the pointer can be gone with no pointer move (the message was sent, or the text cleared, while the pointer rested
|
|
202
|
+
// on it): its preview goes with it, instead of hanging over the box until the pointer moves.
|
|
203
|
+
const hoveredBadgeIsGone = badgeHover !== null &&
|
|
204
|
+
!tokens.some((token) => itemOfToken(token)?.label.toLowerCase() === hoveredLabel());
|
|
205
|
+
if (hoveredBadgeIsGone)
|
|
206
|
+
badgeHover = null;
|
|
199
207
|
if (!badgesFellBack) {
|
|
200
|
-
for (const token of
|
|
208
|
+
for (const token of tokens) {
|
|
201
209
|
const item = itemOfToken(token);
|
|
202
210
|
if (!item)
|
|
203
211
|
continue;
|
|
@@ -230,6 +238,10 @@ export function promptReferences(field, initialParams) {
|
|
|
230
238
|
});
|
|
231
239
|
}
|
|
232
240
|
overlay.setDecorations(decorations);
|
|
241
|
+
if (hoveredBadgeIsGone) {
|
|
242
|
+
syncMenuView();
|
|
243
|
+
tellHover(null, 'badge');
|
|
244
|
+
}
|
|
233
245
|
if (badgeCount > 0 && !layoutCheckQueued) {
|
|
234
246
|
layoutCheckQueued = true;
|
|
235
247
|
// After the layer's own paint, which is queued first.
|
|
@@ -383,12 +395,13 @@ export function promptReferences(field, initialParams) {
|
|
|
383
395
|
const host = ensureMenuHost();
|
|
384
396
|
const base = { menuLabel: params.messages.menuLabel, direction: fieldDirection() };
|
|
385
397
|
if (openMenu) {
|
|
398
|
+
// The list alone: each row has its own small picture, so no larger card opens beside it for the highlighted row.
|
|
386
399
|
host.update({
|
|
387
400
|
...base,
|
|
388
401
|
items: openMenu.matches,
|
|
389
402
|
activeIndex: openMenu.activeIndex,
|
|
390
403
|
anchor: measureAnchor(),
|
|
391
|
-
previewItem:
|
|
404
|
+
previewItem: null,
|
|
392
405
|
previewAnchor: null
|
|
393
406
|
});
|
|
394
407
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Where the `#` menu and the preview of a file
|
|
2
|
+
* Where the `#` menu goes, and the preview of a file over a badge (it hangs from its anchor the way the menu does). Pure functions, no
|
|
3
|
+
* DOM: rectangles in, rectangles out, all in viewport pixels.
|
|
3
4
|
*
|
|
4
5
|
* The composer sits at the bottom edge of a page, so the menu opens ABOVE the `#` when there is no room below, and it never leaves the
|
|
5
6
|
* viewport. The side it hangs from follows the field's direction: a right-to-left field has its menu start at the `#`'s right edge.
|
|
@@ -46,18 +47,3 @@ export interface PlaceMenuInput {
|
|
|
46
47
|
* right-to-left field), moved in if it would leave the viewport.
|
|
47
48
|
*/
|
|
48
49
|
export declare function placeMenu(input: PlaceMenuInput): MenuPlacement;
|
|
49
|
-
export interface PlacePreviewInput {
|
|
50
|
-
/** The menu (or the badge) the preview goes beside. */
|
|
51
|
-
beside: Box;
|
|
52
|
-
preview: Size;
|
|
53
|
-
viewport: Size;
|
|
54
|
-
direction?: MenuDirection;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* The preview card's place: beside the menu on its end side (right in a left-to-right page) when it fits, otherwise on the other side,
|
|
58
|
-
* otherwise over the menu's top edge. Aligned with the menu's top, and kept inside the viewport.
|
|
59
|
-
*/
|
|
60
|
-
export declare function placePreview(input: PlacePreviewInput): {
|
|
61
|
-
left: number;
|
|
62
|
-
top: number;
|
|
63
|
-
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Where the `#` menu and the preview of a file
|
|
2
|
+
* Where the `#` menu goes, and the preview of a file over a badge (it hangs from its anchor the way the menu does). Pure functions, no
|
|
3
|
+
* DOM: rectangles in, rectangles out, all in viewport pixels.
|
|
3
4
|
*
|
|
4
5
|
* The composer sits at the bottom edge of a page, so the menu opens ABOVE the `#` when there is no room below, and it never leaves the
|
|
5
6
|
* viewport. The side it hangs from follows the field's direction: a right-to-left field has its menu start at the `#`'s right edge.
|
|
@@ -40,27 +41,3 @@ export function placeMenu(input) {
|
|
|
40
41
|
const left = clamp(preferredLeft, margin, viewport.width - menu.width - margin);
|
|
41
42
|
return { left, top: Math.max(margin, top), placement, maxHeight };
|
|
42
43
|
}
|
|
43
|
-
/**
|
|
44
|
-
* The preview card's place: beside the menu on its end side (right in a left-to-right page) when it fits, otherwise on the other side,
|
|
45
|
-
* otherwise over the menu's top edge. Aligned with the menu's top, and kept inside the viewport.
|
|
46
|
-
*/
|
|
47
|
-
export function placePreview(input) {
|
|
48
|
-
const { beside, preview, viewport } = input;
|
|
49
|
-
const margin = MENU_VIEWPORT_MARGIN;
|
|
50
|
-
const gap = MENU_ANCHOR_GAP;
|
|
51
|
-
const endSideLeft = input.direction === 'rtl' ? beside.left - gap - preview.width : beside.right + gap;
|
|
52
|
-
const startSideLeft = input.direction === 'rtl' ? beside.right + gap : beside.left - gap - preview.width;
|
|
53
|
-
const fits = (left) => left >= margin && left + preview.width <= viewport.width - margin;
|
|
54
|
-
let left;
|
|
55
|
-
let top = beside.top;
|
|
56
|
-
if (fits(endSideLeft))
|
|
57
|
-
left = endSideLeft;
|
|
58
|
-
else if (fits(startSideLeft))
|
|
59
|
-
left = startSideLeft;
|
|
60
|
-
else {
|
|
61
|
-
// No room at either side: the card sits above the box instead of over it.
|
|
62
|
-
left = clamp(beside.left, margin, viewport.width - preview.width - margin);
|
|
63
|
-
top = beside.top - gap - preview.height;
|
|
64
|
-
}
|
|
65
|
-
return { left, top: clamp(top, margin, viewport.height - preview.height - margin) };
|
|
66
|
-
}
|
|
@@ -15,6 +15,11 @@ export interface ReferenceItem {
|
|
|
15
15
|
previewUrl?: string | null;
|
|
16
16
|
/** The size, already written for people ("1.2 MB"). */
|
|
17
17
|
sizeLabel?: string;
|
|
18
|
+
/**
|
|
19
|
+
* For a file that is a text (a long text that was pasted): the beginning of the text. The card that opens over its badge shows
|
|
20
|
+
* it, cut short with an ellipsis, in place of a picture: what the badge stands for is what it holds, not the name of a file.
|
|
21
|
+
*/
|
|
22
|
+
excerpt?: string;
|
|
18
23
|
}
|
|
19
24
|
/** The words the action shows or speaks. The host passes them from its own messages, so the design system holds no English. */
|
|
20
25
|
export interface ReferenceMessages {
|
package/dist/styles/tokens.css
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
--color-light-green: #e3f0db;
|
|
19
19
|
/*
|
|
20
20
|
* Success toast pill (round 5): the green of the reference toast, one step darker so that white 14px/500 text keeps 4.5:1 (4.54:1).
|
|
21
|
-
* Used by the toast only
|
|
21
|
+
* Used by the toast only. It is the Figma primitive status/toast-green (added to the Primitives collection on 18 Nov 2026, so
|
|
22
|
+
* that the Foundations list and the library hold every colour of this file); a second use asks for a semantic token first.
|
|
22
23
|
*/
|
|
23
24
|
--color-toast-green: #008932;
|
|
24
25
|
|
|
@@ -71,6 +72,8 @@
|
|
|
71
72
|
--brand-subtle: var(--color-light-green);
|
|
72
73
|
--border: var(--color-neutral-200);
|
|
73
74
|
--border-strong: var(--color-alpha-dark-30);
|
|
75
|
+
/* The quiet line (Figma border/subtle, 18 Nov 2026): neutral/100, for the divider between the header of a panel and its body, where `--border` is too loud. */
|
|
76
|
+
--border-subtle: var(--color-neutral-100);
|
|
74
77
|
--input: var(--color-neutral-200);
|
|
75
78
|
--ring: var(--color-deep-forest-green);
|
|
76
79
|
--sidebar: var(--color-neutral-100);
|
|
@@ -123,6 +126,9 @@
|
|
|
123
126
|
--duration-base: 160ms;
|
|
124
127
|
--duration-slow: 250ms;
|
|
125
128
|
--duration-enter: 500ms;
|
|
129
|
+
/* A floating surface (dropdown, sub-menu, popover, select list, hover card) opening from its trigger: see `floating-motion` */
|
|
130
|
+
--duration-floating: 150ms;
|
|
131
|
+
--floating-slide: 8px;
|
|
126
132
|
--stagger-item: 50ms;
|
|
127
133
|
--ease-standard: ease;
|
|
128
134
|
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
|
@@ -170,6 +176,7 @@
|
|
|
170
176
|
--brand-subtle: var(--color-alpha-sage-15);
|
|
171
177
|
--border: var(--color-alpha-sage-25);
|
|
172
178
|
--border-strong: var(--color-alpha-light-30);
|
|
179
|
+
--border-subtle: var(--color-alpha-light-10);
|
|
173
180
|
--input: var(--color-alpha-sage-25);
|
|
174
181
|
--ring: var(--color-sage-green);
|
|
175
182
|
--sidebar: var(--color-dark);
|
|
@@ -213,6 +220,7 @@
|
|
|
213
220
|
--color-brand-subtle: var(--brand-subtle);
|
|
214
221
|
--color-border: var(--border);
|
|
215
222
|
--color-border-strong: var(--border-strong);
|
|
223
|
+
--color-border-subtle: var(--border-subtle);
|
|
216
224
|
--color-input: var(--input);
|
|
217
225
|
--color-ring: var(--ring);
|
|
218
226
|
--color-sidebar: var(--sidebar);
|
|
@@ -314,6 +322,9 @@
|
|
|
314
322
|
* stylesheet won, and when that was `transition-colors` the press had no transition at all: the control snapped in and
|
|
315
323
|
* snapped back. `:not([data-no-press])` raises the specificity above `transition-colors` and `duration-*`, so they compose
|
|
316
324
|
* in any order, and `data-no-press` is the way to opt one control out.
|
|
325
|
+
*
|
|
326
|
+
* The opacity of the control is in the list too, but with no time of its own (`--press-feedback-opacity-duration`, 0s): a
|
|
327
|
+
* change of opacity (the half-opacity of `disabled:`) still snaps, as it always did. `press-feedback-fade` gives it a time.
|
|
317
328
|
*/
|
|
318
329
|
@utility press-feedback {
|
|
319
330
|
&:not([data-no-press]) {
|
|
@@ -325,7 +336,8 @@
|
|
|
325
336
|
text-decoration-color var(--duration-fast) cubic-bezier(0.4, 0, 0.2, 1),
|
|
326
337
|
fill var(--duration-fast) cubic-bezier(0.4, 0, 0.2, 1),
|
|
327
338
|
stroke var(--duration-fast) cubic-bezier(0.4, 0, 0.2, 1),
|
|
328
|
-
transform var(--duration-base) var(--ease-out)
|
|
339
|
+
transform var(--duration-base) var(--ease-out),
|
|
340
|
+
opacity var(--press-feedback-opacity-duration, 0s) cubic-bezier(0.4, 0, 0.2, 1);
|
|
329
341
|
}
|
|
330
342
|
|
|
331
343
|
&:active:not(:disabled):not([aria-disabled='true']),
|
|
@@ -341,6 +353,86 @@
|
|
|
341
353
|
}
|
|
342
354
|
}
|
|
343
355
|
|
|
356
|
+
/*
|
|
357
|
+
* A pressable control that fades between two looks that differ in opacity (the send button of the composer: half opacity while
|
|
358
|
+
* there is nothing to send): put `press-feedback-fade` beside `press-feedback`, and the change takes `--duration-fast` instead of
|
|
359
|
+
* snapping. A transition can be turned around by itself: when the look changes back while the fade is under way (the box goes
|
|
360
|
+
* empty and is typed in again within the fade), the browser fades on from the opacity it has reached, towards the look it is
|
|
361
|
+
* asked for now, so nothing is started over and nothing jumps to either end. It is a fade, not a movement, so it stays for
|
|
362
|
+
* people who ask for less motion.
|
|
363
|
+
*/
|
|
364
|
+
@utility press-feedback-fade {
|
|
365
|
+
--press-feedback-opacity-duration: var(--duration-fast);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/*
|
|
369
|
+
* The motion of a floating surface that opens from a trigger (the dropdown and its sub-menus, the popover, the select list, the
|
|
370
|
+
* hover card; the account and workspace menus of the sidebar are dropdowns): it fades in while it slides `--floating-slide` (8px)
|
|
371
|
+
* from the side it opens towards, in `--duration-floating` (150ms) on `--ease-out`, so it arrives quickly and almost at once, the
|
|
372
|
+
* way a dialog slides in (owner, 18 Nov 2026). On the way out it only fades, in `--duration-fast`. People who ask for less motion get
|
|
373
|
+
* no animation at all. It reads the `data-state` and `data-side` that bits-ui writes on the floating element, so put it on the
|
|
374
|
+
* element that carries them (the `Content`), and do not combine it with the `animate-in` / `slide-in-from-*` utilities.
|
|
375
|
+
*
|
|
376
|
+
* Why not those utilities: `tailwindcss-animate` writes the slide as `--tw-enter-translate-y` in a `data-[side=bottom]:` rule and
|
|
377
|
+
* `data-[state=open]:animate-in` resets that variable to `initial`. Tailwind 4 puts the `data-[side=...]` rules before the
|
|
378
|
+
* `data-[state=...]` ones, so the reset won and the menus only faded: no slide at all (measured with `getAnimations()`).
|
|
379
|
+
* An open surface is anything that is not `closed`, because a tooltip says `delayed-open` and `instant-open`.
|
|
380
|
+
*/
|
|
381
|
+
@keyframes floating-enter {
|
|
382
|
+
from {
|
|
383
|
+
opacity: 0;
|
|
384
|
+
transform: translate3d(var(--floating-slide-x, 0px), var(--floating-slide-y, 0px), 0);
|
|
385
|
+
}
|
|
386
|
+
to {
|
|
387
|
+
opacity: 1;
|
|
388
|
+
transform: none;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
@keyframes floating-exit {
|
|
392
|
+
from {
|
|
393
|
+
opacity: 1;
|
|
394
|
+
}
|
|
395
|
+
to {
|
|
396
|
+
opacity: 0;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
@utility floating-motion {
|
|
400
|
+
/*
|
|
401
|
+
* Both axes are written on the surface itself, 0 unless its side says otherwise. A custom property is inherited and a sub-menu is
|
|
402
|
+
* a DOM child of the menu it opens from, so a sub-menu that opens to the right used to pick up the -8px of its parent's `bottom`
|
|
403
|
+
* side as well and slid in from the top left corner, diagonally, instead of out of its row (owner, 20 Nov 2026: "the submenu
|
|
404
|
+
* doesn't slide in from that button").
|
|
405
|
+
*/
|
|
406
|
+
--floating-slide-x: 0px;
|
|
407
|
+
--floating-slide-y: 0px;
|
|
408
|
+
|
|
409
|
+
&[data-side='bottom'] {
|
|
410
|
+
--floating-slide-y: calc(var(--floating-slide) * -1);
|
|
411
|
+
}
|
|
412
|
+
&[data-side='top'] {
|
|
413
|
+
--floating-slide-y: var(--floating-slide);
|
|
414
|
+
}
|
|
415
|
+
&[data-side='right'] {
|
|
416
|
+
--floating-slide-x: calc(var(--floating-slide) * -1);
|
|
417
|
+
}
|
|
418
|
+
&[data-side='left'] {
|
|
419
|
+
--floating-slide-x: var(--floating-slide);
|
|
420
|
+
}
|
|
421
|
+
&:not([data-state='closed']) {
|
|
422
|
+
animation: floating-enter var(--duration-floating) var(--ease-out) backwards;
|
|
423
|
+
}
|
|
424
|
+
&[data-state='closed'] {
|
|
425
|
+
animation: floating-exit var(--duration-fast) ease-out forwards;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
@media (prefers-reduced-motion: reduce) {
|
|
429
|
+
&:not([data-state='closed']),
|
|
430
|
+
&[data-state='closed'] {
|
|
431
|
+
animation: none;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
344
436
|
/*
|
|
345
437
|
* Text that is being worked on: a soft band of a lighter colour keeps passing over it, the way "Planning" waits for the plan, the
|
|
346
438
|
* task that is being built is shown, or "thinking" is said. Put `shimmer` on an element that holds only text and is as wide as that text
|
|
@@ -58,7 +58,10 @@ function reportProblemOnce(kind, error) {
|
|
|
58
58
|
if (reportedProblems.has(kind))
|
|
59
59
|
return;
|
|
60
60
|
reportedProblems.add(kind);
|
|
61
|
-
console.debug(
|
|
61
|
+
// console.debug(
|
|
62
|
+
// `[textarea-overlay] ${kind}`,
|
|
63
|
+
// error instanceof Error ? error.message : (error ?? '')
|
|
64
|
+
// );
|
|
62
65
|
}
|
|
63
66
|
function createOverlayCore(field) {
|
|
64
67
|
const doc = field.ownerDocument;
|