@widgetic/design-system 0.5.39 → 0.5.41
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 +73 -0
- package/dist/components/ContentRefreshOverlay.svelte +103 -0
- package/dist/components/ContentRefreshOverlay.svelte.d.ts +18 -0
- package/dist/components/chat/Composer.svelte +381 -20
- package/dist/components/chat/Composer.svelte.d.ts +88 -1
- package/dist/components/chat/PlanCard.svelte +218 -88
- package/dist/components/chat/PlanCard.svelte.d.ts +11 -0
- package/dist/components/chat/QuestionCard.svelte +180 -70
- package/dist/components/chat/QuestionCard.svelte.d.ts +28 -2
- package/dist/components/chat/QuestionCardSummary.svelte +96 -0
- package/dist/components/chat/QuestionCardSummary.svelte.d.ts +20 -0
- package/dist/components/chat/QueueCard.svelte +185 -0
- package/dist/components/chat/QueueCard.svelte.d.ts +40 -0
- package/dist/components/chat/composerLogic.d.ts +31 -0
- package/dist/components/chat/composerLogic.js +37 -0
- package/dist/components/chat/composerReferences.d.ts +28 -0
- package/dist/components/chat/composerReferences.js +23 -0
- package/dist/components/chat/index.d.ts +8 -3
- package/dist/components/chat/index.js +10 -2
- package/dist/components/chat/questionCardLogic.d.ts +40 -3
- package/dist/components/chat/questionCardLogic.js +54 -3
- package/dist/components/chat/queueCardLogic.d.ts +7 -0
- package/dist/components/chat/queueCardLogic.js +5 -0
- package/dist/components/creator/index.d.ts +1 -2
- package/dist/components/creator/index.js +2 -0
- package/dist/components/filters/FilterByButton.svelte +2 -1
- package/dist/components/index.d.ts +8 -7
- package/dist/components/index.js +8 -6
- package/dist/components/modals/BaseModal.svelte +14 -4
- package/dist/components/navigation/Breadcrumbs.svelte +1 -1
- package/dist/components/navigation/breadcrumbSlideIn.d.ts +6 -2
- package/dist/components/navigation/breadcrumbSlideIn.js +6 -6
- package/dist/components/search-input/SearchInput.svelte +282 -14
- package/dist/components/search-input/SearchInput.svelte.d.ts +3 -0
- package/dist/components/search-input/index.d.ts +1 -0
- package/dist/components/search-input/index.js +1 -0
- package/dist/components/search-input/index2.d.ts +4 -0
- package/dist/components/search-input/recentSearches.d.ts +12 -0
- package/dist/components/search-input/recentSearches.js +124 -0
- package/dist/components/toast/ToasterModal.svelte +8 -2
- package/dist/components/toast/ToasterModal.svelte.d.ts +2 -0
- package/dist/components/ui/chip/chip.svelte +39 -1
- package/dist/components/ui/chip/chip.svelte.d.ts +8 -0
- package/dist/components/ui/chip/chipProgress.d.ts +14 -0
- package/dist/components/ui/chip/chipProgress.js +21 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +1 -1
- package/dist/components/ui/icon-button/icon-button.svelte +2 -0
- package/dist/components/ui/icon-button/icon-button.svelte.d.ts +5 -0
- package/dist/components/ui/number-controls/index.d.ts +2 -0
- package/dist/components/ui/number-controls/index.js +2 -0
- package/dist/components/ui/number-controls/number-controls.svelte +530 -0
- package/dist/components/ui/number-controls/number-controls.svelte.d.ts +46 -0
- package/dist/components/ui/number-controls/numberControlsSteps.d.ts +17 -0
- package/dist/components/ui/number-controls/numberControlsSteps.js +23 -0
- package/dist/components/ui/number-controls/numberControlsValueArea.d.ts +29 -0
- package/dist/components/ui/number-controls/numberControlsValueArea.js +51 -0
- package/dist/components/ui/text-flip/index.d.ts +1 -0
- package/dist/components/ui/text-flip/index.js +1 -0
- package/dist/components/ui/text-flip/text-flip.svelte +103 -0
- package/dist/components/ui/text-flip/text-flip.svelte.d.ts +15 -0
- package/dist/components/ui/text-flip/textFlipLogic.d.ts +49 -0
- package/dist/components/ui/text-flip/textFlipLogic.js +151 -0
- package/dist/inline-completion/completionAnswer.d.ts +11 -0
- package/dist/inline-completion/completionAnswer.js +49 -0
- package/dist/inline-completion/completionCache.d.ts +24 -0
- package/dist/inline-completion/completionCache.js +47 -0
- package/dist/inline-completion/completionController.d.ts +61 -0
- package/dist/inline-completion/completionController.js +280 -0
- package/dist/inline-completion/completionKeys.d.ts +21 -0
- package/dist/inline-completion/completionKeys.js +19 -0
- package/dist/inline-completion/completionText.d.ts +53 -0
- package/dist/inline-completion/completionText.js +79 -0
- package/dist/inline-completion/completionTypes.d.ts +71 -0
- package/dist/inline-completion/completionTypes.js +5 -0
- package/dist/inline-completion/gatewayCompletion.d.ts +37 -0
- package/dist/inline-completion/gatewayCompletion.js +77 -0
- package/dist/inline-completion/ghostTap.d.ts +19 -0
- package/dist/inline-completion/ghostTap.js +20 -0
- package/dist/inline-completion/hintMemory.d.ts +43 -0
- package/dist/inline-completion/hintMemory.js +90 -0
- package/dist/inline-completion/httpSource.d.ts +40 -0
- package/dist/inline-completion/httpSource.js +149 -0
- package/dist/inline-completion/index.d.ts +30 -0
- package/dist/inline-completion/index.js +20 -0
- package/dist/inline-completion/inlineCompletionAction.d.ts +54 -0
- package/dist/inline-completion/inlineCompletionAction.js +310 -0
- package/dist/inline-completion/outcomeReporter.d.ts +49 -0
- package/dist/inline-completion/outcomeReporter.js +139 -0
- package/dist/inline-completion/promiseLike.d.ts +9 -0
- package/dist/inline-completion/promiseLike.js +9 -0
- package/dist/prompt-references/ReferenceMenu.svelte +344 -0
- package/dist/prompt-references/ReferenceMenu.svelte.d.ts +26 -0
- package/dist/prompt-references/index.d.ts +27 -0
- package/dist/prompt-references/index.js +20 -0
- package/dist/prompt-references/neutralizingSource.d.ts +21 -0
- package/dist/prompt-references/neutralizingSource.js +29 -0
- package/dist/prompt-references/promptReferences.d.ts +28 -0
- package/dist/prompt-references/promptReferences.js +766 -0
- package/dist/prompt-references/referenceBadge.d.ts +61 -0
- package/dist/prompt-references/referenceBadge.js +82 -0
- package/dist/prompt-references/referenceBadgePainter.d.ts +31 -0
- package/dist/prompt-references/referenceBadgePainter.js +106 -0
- package/dist/prompt-references/referenceEditing.d.ts +60 -0
- package/dist/prompt-references/referenceEditing.js +135 -0
- package/dist/prompt-references/referenceLabels.d.ts +56 -0
- package/dist/prompt-references/referenceLabels.js +215 -0
- package/dist/prompt-references/referenceMeasure.d.ts +12 -0
- package/dist/prompt-references/referenceMeasure.js +63 -0
- package/dist/prompt-references/referenceMenuHost.svelte.d.ts +29 -0
- package/dist/prompt-references/referenceMenuHost.svelte.js +43 -0
- package/dist/prompt-references/referenceMenuKeys.d.ts +26 -0
- package/dist/prompt-references/referenceMenuKeys.js +49 -0
- package/dist/prompt-references/referenceMenuPlacement.d.ts +63 -0
- package/dist/prompt-references/referenceMenuPlacement.js +66 -0
- package/dist/prompt-references/referenceTokens.d.ts +175 -0
- package/dist/prompt-references/referenceTokens.js +332 -0
- package/dist/prompt-references/referenceTrigger.d.ts +52 -0
- package/dist/prompt-references/referenceTrigger.js +100 -0
- package/dist/prompt-references/referenceTypes.d.ts +38 -0
- package/dist/prompt-references/referenceTypes.js +4 -0
- package/dist/prompt-references/sentReferences.d.ts +50 -0
- package/dist/prompt-references/sentReferences.js +122 -0
- package/dist/styles/tokens.css +58 -0
- package/dist/textarea-overlay/index.d.ts +9 -0
- package/dist/textarea-overlay/index.js +7 -0
- package/dist/textarea-overlay/mirrorSegments.d.ts +31 -0
- package/dist/textarea-overlay/mirrorSegments.js +47 -0
- package/dist/textarea-overlay/mirrorSizing.d.ts +39 -0
- package/dist/textarea-overlay/mirrorSizing.js +40 -0
- package/dist/textarea-overlay/textareaOverlay.d.ts +25 -0
- package/dist/textarea-overlay/textareaOverlay.js +277 -0
- package/dist/utils/overlayMotion.d.ts +1 -0
- package/dist/utils/overlayMotion.js +3 -3
- package/dist/utils/reducedMotion.d.ts +9 -0
- package/dist/utils/reducedMotion.js +13 -0
- package/package.json +16 -1
- package/dist/components/ui/number-stepper/index.d.ts +0 -3
- package/dist/components/ui/number-stepper/index.js +0 -3
- package/dist/components/ui/number-stepper/number-stepper.svelte +0 -212
- package/dist/components/ui/number-stepper/number-stepper.svelte.d.ts +0 -24
- package/dist/components/ui/number-stepper/numberStepperSteps.d.ts +0 -26
- package/dist/components/ui/number-stepper/numberStepperSteps.js +0 -45
package/README.md
CHANGED
|
@@ -343,6 +343,79 @@ What it cannot see (found by looking at a screen in Arabic, not by the audit, so
|
|
|
343
343
|
- A change of `locale` or `messages` reaches the toolbar, the menus and the images that are already in the text, without making the editor again.
|
|
344
344
|
- Two words are not the editor's to change: the button of the file chooser in the image pop-up is the browser's own, and the colour picker names its window `color picker` in English.
|
|
345
345
|
|
|
346
|
+
### Ghost text in a text box (`@widgetic/design-system/inline-completion`)
|
|
347
|
+
|
|
348
|
+
A text box can show a likely continuation of what is typed, in grey after the caret: type "build a v" and "ideo player" appears, type on "with th" and "umbnails" does. The suggestion is set in the **box's own font, size and line**, only in the muted colour, and wraps as the text does, so it reads as the rest of what is being typed (it is painted on a layer that copies the box's typography, and has no look of its own). **Tab** takes it (a tap on it does, on a touch screen), **Esc** sends it away, typing on along it follows it with no new request, and typing something else, or moving the caret away from the end of the text (a click in the text, an arrow key, a selection), lets it go. Tab and Esc are the suggestion's only while one shows: a box with no suggestion keeps its tab stop and its Esc. The engine knows only text, the caret and keys; **where suggestions come from is the page's** (a call to its own service, a fixed list), and a box given no source draws nothing and asks for nothing.
|
|
349
|
+
|
|
350
|
+
- **The chat's `Composer`** takes a `completion` prop (`ComposerCompletion`): `{ source, debounceMs?, dismissalLimit?, onEvent?, log? }`. While a suggestion shows, the toolbar says what to do with it ("Tab to accept", or "Tap the suggestion to accept" when the main pointer is a finger: the `completionHint` and `completionHintTouch` messages), **until the person has taken one suggestion**: after the first Tab (or tap) the hint stays away for good in that browser (see `completionHintMemory` below). A screen reader always hears the last words typed with the suggestion in them, and how to take it. Enter still sends and the suggestion goes with the message; it **stays while the assistant builds** (`busy`) and goes only with a disabled box.
|
|
351
|
+
- **Any textarea or text input**: `use:inlineCompletion={{ source, value }}`. `value` is the text the page holds, so a change the page makes by itself (a sent message clears the box, a draft is restored) is noticed; `disabled`, `ghostClass`, `announce`, `onChange` (the suggestion that shows, or `null`; for a hint beside the box), `onEvent`, `hintMemory` and `log` are optional. The grey text is drawn on a layer placed against the box's nearest positioned parent, so give the box's wrapper `relative` (the composer does).
|
|
352
|
+
- **A hint for the first suggestion only**: the action notes the first suggestion taken (Tab or a tap) in `completionHintMemory`, one small word in the browser's `localStorage` (`widgetic:completion-hint-learned:v1`; a browser that gives no storage, such as a private window, keeps it for the life of the page instead). A host that shows its own hint beside a box ("Tab to accept") reads `completionHintMemory.learned` when `onChange` hands it a suggestion and shows the hint only while it is `false` (the chat's `Composer` and the widget creator's note card do). `completionHintMemory.forget()` brings the hint back (a demo, a test); a host that wants no note passes `hintMemory: null`, or its own, made with `createCompletionHintMemory({ storage, key, log })`. What a screen reader is told is not held back.
|
|
353
|
+
- **A source** is anything with `suggest({ text, signal })` that answers with the continuations, best first (`signal` fires when the person has typed on: an answer nobody waits for is dropped). `createHttpCompletionSource({ url, body, headers, fetchImpl, credentials, timeoutMs, now, log })` is the one for the Widgetic gateway's suggest routes: one POST per request with the text added to the fields `body()` gives. `headers()` may be asynchronous (a host that refreshes its token on demand): the request waits for it, a person who types on in the meantime cancels the request before it is made, and a function that throws is "nothing to show". It never rejects: a request that fails, times out or answers with something unexpected is "nothing to show", kept for ten seconds so the box does not ask at every keystroke, and each kind of failure is logged once. A route that answers `source: 'disabled'` (the surface is switched off, or the language has no catalog) is believed for five minutes (`DISABLED_MEMO_MS`): until then the box gets "nothing to show" without a request, so a surface that is off costs one request, not one per pause in typing.
|
|
354
|
+
- **What the engine does for you**: a pause of 150 ms in typing before a request (`debounceMs`), a cache of answers (so typing along an answer, or going back a letter, asks nothing), the request in flight cancelled when the text moves on, nothing while an input method is composing, nothing unless the box has focus and the caret is at the very end of the text, and after **three dismissals in a row** (`dismissalLimit`) no more suggestions for the session.
|
|
355
|
+
- **Measuring**: `createOutcomeReporter({ surface, url })` counts what happened to each suggestion (shown, accepted, accepted from further down the list, dismissed, typed past) from the `onEvent` of the box, and reports the counts in batches. Counts only, never the text. A report that fails is dropped. Its `headers()` may be asynchronous too; one that answers at once keeps a report made as the page is left inside that very turn, which is what lets `keepalive` finish it.
|
|
356
|
+
- **A box of an assistant, in one call**: `createGatewayCompletion({ surface, suggestUrl, outcomeUrl?, headers?, credentials?, locale, context? })` joins the two above for a box that one of the gateway's suggest routes serves (the embed assistant's, the workflows assistant's) and gives `{ source, onEvent, destroy }`. The body of a request is `{ locale, text }` and `{ context }` when the box has something to say about itself (`context()` is read at every request, as `locale()`; a tag the gateway would refuse is asked as English; a context that cannot be read is asked without, and said once). A host without an `outcomeUrl` still suggests and reports nothing. `destroy()` reports what is counted as the box goes away.
|
|
357
|
+
|
|
358
|
+
```svelte
|
|
359
|
+
<script lang="ts">
|
|
360
|
+
import { Composer } from '@widgetic/design-system/components/chat/index';
|
|
361
|
+
import { createHttpCompletionSource, createOutcomeReporter } from '@widgetic/design-system/inline-completion';
|
|
362
|
+
|
|
363
|
+
let value = $state('');
|
|
364
|
+
const outcomes = createOutcomeReporter({ surface: 'creator_chat', url: `${gatewayUrl}/agent/composer/outcome` });
|
|
365
|
+
const completion = {
|
|
366
|
+
source: createHttpCompletionSource({
|
|
367
|
+
url: `${gatewayUrl}/agent/composer/suggest`,
|
|
368
|
+
body: () => ({ surface: 'creator_chat', language: 'en' })
|
|
369
|
+
}),
|
|
370
|
+
onEvent: (event) => outcomes.record(event)
|
|
371
|
+
};
|
|
372
|
+
</script>
|
|
373
|
+
|
|
374
|
+
<Composer bind:value {completion} onSend={send} />
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
The pieces are exported for a page that draws its own box: `createCompletionController` (the state machine, with no DOM), `createCompletionCache`, `interpretGhostKey` (which key is the ghost's) and the types. `@widgetic/design-system/textarea-overlay` is the layer the grey text is painted on: `acquireTextareaOverlay(field, owner)` gives one transparent copy of the box's text, laid exactly over it (the box's typography, padding and direction, its scroll followed, no pointer events, hidden from assistive technology), shared by every feature that paints on the box, each under its own owner name. To see it work run `npm run dev` and open `/showcase/inline-completion` (a textarea, an input, a pretend source with a wait you can set) or the two "With suggestions" composers on `/showcase/chat`.
|
|
378
|
+
|
|
379
|
+
### References to attached files in a text box (`@widgetic/design-system/prompt-references`)
|
|
380
|
+
|
|
381
|
+
A person who attaches three pictures can say what happens with each: type `#` after a space and the attached files are listed with their thumbnails (as `@` lists the compositions of the workflows assistant); pick one and it stands in the sentence as a badge (thumbnail, name, an X): "Put **▣ #hero_banner** behind **▣ #logo**". The box stays the native textarea. Underneath, a badge is plain text, `#hero_banner`, between two runs of figure spaces that reserve room for the thumbnail and the X; a layer laid over the box (`textarea-overlay`) paints the badge there. So selection, undo, paste, input methods and the caret keep working natively, and what is sent is only text.
|
|
382
|
+
|
|
383
|
+
- **The chat's `Composer`** takes a `references` prop (`ComposerReferences`): `{ items, messages: { hint, menuLabel, remove }, onHover?, triggerCharacter?, maxReferences?, log? }`. `onSend` then gets a second argument, `{ references }`: the attached files the text names, once each and in order (`{ id, label }`, `id` being the one the host gave the item). Without `references` the box is as it was: no menu, no badges, no listeners, and `onSend` gets the text alone. The text is what a person reads ("Put #hero_banner behind #logo"): the room of a badge is not sent, and is not counted by `maxLength`. While a file is attached the box says how to refer to it under the text (`messages.hint`, "Type # to reference an attached file"). The design system holds no English: the host passes all three words.
|
|
384
|
+
- **The files** are `items: ReferenceItem[]`, in tray order: `{ id, label, number, fileName, previewUrl?, sizeLabel? }`. `number` is the file's number in the tray (`#2` offers the second file), `previewUrl` any address a picture can be drawn from (without one the badge shows a file glyph). The host gives a file its `label` **once, when the file joins**, and keeps it: `assignReferenceLabel(fileName, { takenLabels, genericNumberFloor })`. A name that says something gives its label (`hero-banner-final.png` is `hero_banner_final`; a name taken gets `_2`), a name that says nothing (`IMG_4021.jpg`, `Screenshot 2026-11-17 at 7.55.01 AM.png`) is `Image_N`, with N above every generic number the draft has handed out so far (`genericLabelNumber` reads it back), so `#Image_2` typed for a file that has gone can never quietly mean the next one. A label is one to 24 letters, digits and underscores, in any script.
|
|
385
|
+
- **When a file leaves** the tray, `removeTokensOfLabel(text, label)` takes its badges out of the text (each with one adjacent space; a `#label` the person typed by hand stays: it is their own word). A text restored from a draft goes through `unbadgeTokensWithoutFiles(text, labels)`: a badge whose file is not there any more is plain `#label` again. Both are exported from `components/chat` as well, where the chat imports them.
|
|
386
|
+
- **`#` opens the menu** after the start of the text, a blank, an opening bracket or a quote, or a badge. It does not open in `a#b`, after a hyphen, in a hex colour (`#fff`) or a link. The menu is a list of the files whose label, file name or tray number matches what follows the `#` (`#2`, `#her`), with a picture of the highlighted one beside it; Up and Down move, **Enter** or **Tab** choose, **Esc** closes, a click chooses, and a key with a modifier is left to the box. It is drawn in the top layer, so no panel of the page clips it, and it opens upwards when there is no room below. While it is open the ghost text of the same box is off, and Enter does not send.
|
|
387
|
+
- **Editing around a badge**: the caret never rests inside one (arrows jump over it, a click next to it snaps), Backspace or Delete next to one takes the whole badge, the X takes it out, pasted text loses any figure space it carries, and Undo brings back the `#he` that was typed (the edit goes through the browser's own edit command). A badge that would not fit where the text puts its characters (the box wraps differently from the layer, for instance at a fractional width) is **not drawn**: the plain `#label` shows until the text or the width changes, and it is logged once.
|
|
388
|
+
- **A badge is a file**: a pointer on a badge, or the keys on a menu row, tell the host (`onHover({ label, source })`) so its tray rings the same file. A change to the tray (a file removed, a name changed) repaints the badges on the spot.
|
|
389
|
+
- **What a suggestion service sees**: with `references`, the ghost text of the box asks its source with every reference (a badge, and a hand-typed `#label` that names an attached file) as the neutral word `#file`: `neutralizeReferences(text, { knownLabels })`. A person's file names never reach a service through a suggestion. A text that cannot be made neutral asks nothing.
|
|
390
|
+
- **A box of your own with ghost text**: `neutralizingSource(source, () => ({ labels, triggerCharacter? }))` wraps a suggestion source so it is asked with every reference as `#file` (the Composer does exactly this: it is the same function). Put it in front of the source whenever a box has both `use:inlineCompletion` and `use:promptReferences`; the labels are read at each request, so files can come and go without the box's suggestions starting over. Without it a label, which is made from a file's name, would reach the service.
|
|
391
|
+
- **Any textarea**: `use:promptReferences={{ items, messages, value, enabled?, triggerCharacter?, onHover?, onMenuChange?, logger? }}`. `value` is the text the page holds, so a change the page makes by itself repaints the badges. The pure model is exported too: `buildToken`, `parseTokens`, `normalizeForSend`, `collectReferences(text, attachments, { max })` (the references a message makes, once per file, in order), `findReferenceTrigger`, `snapSelection`, the label rules and the badge's own classes (`REFERENCE_BADGE_CLASSES` and its siblings), for a page that draws the same badge elsewhere (a sent message).
|
|
392
|
+
- **A sent message** shows the same badge without the X. `segmentSentText(text, attachments, { maxBadges?, triggerCharacter? })` cuts the text of a message into plain runs (`{ kind: 'text', text }`) and badges (`{ kind: 'badge', word, label, attachmentIndex }`, `word` being what was written, `#Hero` and not `#hero`), so that the pieces put the message back together as it was; `attachments` is `{ fileName?, label?, badge? }[]`, in the files' order. A saved message keeps the text and the files and not the labels the box gave them, so each label is worked out again from the file's name (`labelsOfSentAttachments`, the rule that gave it), and a page that did keep them passes them as `label` and gets exactly the badges that were made. It is cautious, because a wrong thumbnail is worse than none: a name that says nothing (`image.png`) has no label, files that share a name (and any `_2` label next to them) have none, and a word that names no file, or is part of a longer one, stays text. `SENT_BADGE_CLASSES` and `SENT_BADGE_LABEL_CLASSES` are the pill (an inline box one line high, whatever the line height of the text is, and top-aligned, so a line with a badge is as tall as a line without one and the name is on the baseline of the words beside it; light with a hairline ring, because the bubble that holds a sent message is itself muted) and its label (give the label `dir="auto"`, so `#hero` stays `#hero` in a right-to-left message), `SENT_BADGE_THUMBNAIL_CLASSES` is its picture (an image in the line, pulled into the pill's leading room by a negative margin, and not an absolutely positioned one, which a reader of the text would take for a block and break the line before every label), and `sentBadgeWidth(labelWidth)` is its width in whole pixels: write it on the box (`style="width: …px"`) so that a text measurer and the browser agree to the pixel, as the chat's tight bubbles do.
|
|
393
|
+
|
|
394
|
+
```svelte
|
|
395
|
+
<script lang="ts">
|
|
396
|
+
import { Composer } from '@widgetic/design-system/components/chat/index';
|
|
397
|
+
import { assignReferenceLabel } from '@widgetic/design-system/prompt-references';
|
|
398
|
+
|
|
399
|
+
const files = [{ id: 'up-1', fileName: 'hero-banner-final.png', url: heroUrl, size: '1.2 MB' }];
|
|
400
|
+
const items = files.map((file, index) => ({
|
|
401
|
+
id: file.id,
|
|
402
|
+
label: assignReferenceLabel(file.fileName, { takenLabels: [] }),
|
|
403
|
+
number: index + 1,
|
|
404
|
+
fileName: file.fileName,
|
|
405
|
+
previewUrl: file.url,
|
|
406
|
+
sizeLabel: file.size
|
|
407
|
+
}));
|
|
408
|
+
</script>
|
|
409
|
+
|
|
410
|
+
<Composer
|
|
411
|
+
bind:value
|
|
412
|
+
references={{ items, messages: { hint: 'Type # to reference an attached file', menuLabel: 'Attached files', remove: 'Remove {name}' } }}
|
|
413
|
+
onSend={(text, options) => send(text, options?.references ?? [])}
|
|
414
|
+
/>
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
To see it work run `npm run dev` and open `/showcase/prompt-references` (a tray of made-up files and five boxes: a wide one, a narrow one, one with ghost text, a right-to-left one) or the "With file references" composer on `/showcase/chat`. In a right-to-left box the badge reads as the bidirectional algorithm reads it: `label#`.
|
|
418
|
+
|
|
346
419
|
## Troubleshooting
|
|
347
420
|
|
|
348
421
|
### File Case Sensitivity Issues (macOS/Windows Teams)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Content refresh overlay — dims and blocks in-place content while it reloads (e.g. a tab whose file changed elsewhere).
|
|
3
|
+
Figma: Editor overlays / content refresh (scrim + centred status pill).
|
|
4
|
+
-->
|
|
5
|
+
<script lang="ts" module>
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
|
|
8
|
+
export type ContentRefreshOverlayProps = {
|
|
9
|
+
/** When true, the scrim fades in and blocks interaction until it becomes false again. */
|
|
10
|
+
active: boolean;
|
|
11
|
+
/** Primary line in the centred pill; omit for spinner-only. */
|
|
12
|
+
message?: string;
|
|
13
|
+
/** Optional second line inside the pill. */
|
|
14
|
+
description?: string;
|
|
15
|
+
/** Screen-reader announcement while active; defaults to `message`. */
|
|
16
|
+
statusLabel?: string;
|
|
17
|
+
/** `container` covers this root; `viewport` uses a fixed full-screen scrim. */
|
|
18
|
+
scope?: 'container' | 'viewport';
|
|
19
|
+
class?: string;
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import { fade } from 'svelte/transition';
|
|
26
|
+
import IconLoader2 from '@tabler/icons-svelte/icons/loader-2';
|
|
27
|
+
import { cn } from '../utils.js';
|
|
28
|
+
import {
|
|
29
|
+
overlayDialogOverlayClasses,
|
|
30
|
+
overlayScrimFadeTransition
|
|
31
|
+
} from '../utils/overlayMotion.js';
|
|
32
|
+
|
|
33
|
+
let {
|
|
34
|
+
active,
|
|
35
|
+
message,
|
|
36
|
+
description,
|
|
37
|
+
statusLabel,
|
|
38
|
+
scope = 'container',
|
|
39
|
+
class: className,
|
|
40
|
+
children
|
|
41
|
+
}: ContentRefreshOverlayProps = $props();
|
|
42
|
+
|
|
43
|
+
const scrimFade = $derived(overlayScrimFadeTransition());
|
|
44
|
+
|
|
45
|
+
const announcedStatus = $derived(active ? (statusLabel ?? message ?? '') : '');
|
|
46
|
+
|
|
47
|
+
// Both scopes sit at z-40: covered content may hold floating panels of its own (z-20, z-30, as the editors' settings panel and
|
|
48
|
+
// cards do), and the scrim has to be above all of them for the dark layer to cover them too.
|
|
49
|
+
const scrimPositionClasses = $derived(
|
|
50
|
+
scope === 'viewport' ? 'fixed inset-0 z-40' : 'absolute inset-0 z-40'
|
|
51
|
+
);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div
|
|
55
|
+
data-slot="content-refresh-overlay"
|
|
56
|
+
class={cn('relative', className)}
|
|
57
|
+
aria-busy={active || undefined}
|
|
58
|
+
>
|
|
59
|
+
<span data-slot="content-refresh-status" class="sr-only" role="status" aria-live="polite"
|
|
60
|
+
>{announcedStatus}</span
|
|
61
|
+
>
|
|
62
|
+
|
|
63
|
+
<!--
|
|
64
|
+
`contents`: the wrapper takes no box, so the covered content keeps the layout its own classes (and `class` on the root)
|
|
65
|
+
give it (flex columns, h-full, grid areas). `inert` still applies to everything inside it.
|
|
66
|
+
-->
|
|
67
|
+
<div data-slot="content-refresh-content" class="contents" inert={active}>
|
|
68
|
+
{@render children?.()}
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
{#if active}
|
|
72
|
+
<div
|
|
73
|
+
data-slot="content-refresh-scrim"
|
|
74
|
+
class={cn(
|
|
75
|
+
'pointer-events-auto flex items-center justify-center',
|
|
76
|
+
scrimPositionClasses,
|
|
77
|
+
overlayDialogOverlayClasses
|
|
78
|
+
)}
|
|
79
|
+
in:fade={scrimFade}
|
|
80
|
+
out:fade={scrimFade}
|
|
81
|
+
>
|
|
82
|
+
<div
|
|
83
|
+
data-slot="content-refresh-pill"
|
|
84
|
+
class="border-border bg-background text-foreground shadow-floating flex max-w-[min(100%-2rem,24rem)] items-center gap-2 rounded-full border px-4 py-2"
|
|
85
|
+
aria-hidden="true"
|
|
86
|
+
>
|
|
87
|
+
<IconLoader2
|
|
88
|
+
class="text-muted-foreground size-4 shrink-0 animate-spin stroke-2 motion-reduce:animate-none"
|
|
89
|
+
/>
|
|
90
|
+
{#if message || description}
|
|
91
|
+
<div class="flex min-w-0 flex-col gap-0.5 text-start">
|
|
92
|
+
{#if message}
|
|
93
|
+
<span class="text-body-medium truncate">{message}</span>
|
|
94
|
+
{/if}
|
|
95
|
+
{#if description}
|
|
96
|
+
<span class="text-caption text-muted-foreground">{description}</span>
|
|
97
|
+
{/if}
|
|
98
|
+
</div>
|
|
99
|
+
{/if}
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
{/if}
|
|
103
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export type ContentRefreshOverlayProps = {
|
|
3
|
+
/** When true, the scrim fades in and blocks interaction until it becomes false again. */
|
|
4
|
+
active: boolean;
|
|
5
|
+
/** Primary line in the centred pill; omit for spinner-only. */
|
|
6
|
+
message?: string;
|
|
7
|
+
/** Optional second line inside the pill. */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Screen-reader announcement while active; defaults to `message`. */
|
|
10
|
+
statusLabel?: string;
|
|
11
|
+
/** `container` covers this root; `viewport` uses a fixed full-screen scrim. */
|
|
12
|
+
scope?: 'container' | 'viewport';
|
|
13
|
+
class?: string;
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
};
|
|
16
|
+
declare const ContentRefreshOverlay: import("svelte").Component<ContentRefreshOverlayProps, {}, "">;
|
|
17
|
+
type ContentRefreshOverlay = ReturnType<typeof ContentRefreshOverlay>;
|
|
18
|
+
export default ContentRefreshOverlay;
|