@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
package/README.md
CHANGED
|
@@ -380,10 +380,10 @@ The pieces are exported for a page that draws its own box: `createCompletionCont
|
|
|
380
380
|
|
|
381
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
382
|
|
|
383
|
-
- **The chat's `Composer`** takes a `references` prop (`ComposerReferences`): `{ items, messages: {
|
|
383
|
+
- **The chat's `Composer`** takes a `references` prop (`ComposerReferences`): `{ items, messages: { menuLabel, remove, hint? }, 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`. The box draws no line of help for `#` under the text: a person who sees the box is not shown one. A host that wants a screen reader told how to refer to a file may pass the optional `messages.hint` (it is said while a file is attached, it is `sr-only`, and the box points to it); without it the box says nothing and points at nothing, as in the chat. The design system holds no English: the host passes the words (`menuLabel` and `remove`, and `hint` when it wants one).
|
|
384
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
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`),
|
|
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`): each row is the file's small picture, its name (two lines at most; the whole name and the size show in the row's `title`) and its tray number, and no larger card opens beside the list (the picture is the preview; a larger one shows only over a badge the pointer is on); 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
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
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
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.
|
|
@@ -409,7 +409,7 @@ A person who attaches three pictures can say what happens with each: type `#` af
|
|
|
409
409
|
|
|
410
410
|
<Composer
|
|
411
411
|
bind:value
|
|
412
|
-
references={{ items, messages: {
|
|
412
|
+
references={{ items, messages: { menuLabel: 'Attached files', remove: 'Remove {name}' } }}
|
|
413
413
|
onSend={(text, options) => send(text, options?.references ?? [])}
|
|
414
414
|
/>
|
|
415
415
|
```
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* EmptyState — Figma: Empty State (component set 54:71, node 54:71).
|
|
3
3
|
* Centered empty view with icon tile, title, optional description, and actions.
|
|
4
4
|
*
|
|
5
|
+
* The look of Figma's "Components" empty state (node 1634:8567), the one the owner picked for every empty placeholder
|
|
6
|
+
* (18 Nov 2026): a grey tile (`muted/default`) behind the icon, a title in Body/Medium and a description in Body/Default,
|
|
7
|
+
* both in `muted/foreground`. The tile used to be `brand/subtle` (light green) and the title `foreground`.
|
|
8
|
+
*
|
|
5
9
|
* In a pane below a header, pass `class="min-h-0 flex-1"`, `height="auto"` or `height="100%"`, and put the empty state in a
|
|
6
10
|
* flex column parent so it grows into the remaining space and keeps its content centered.
|
|
7
11
|
-->
|
|
@@ -90,7 +94,7 @@
|
|
|
90
94
|
>
|
|
91
95
|
{#if shouldShowIcon}
|
|
92
96
|
<div
|
|
93
|
-
class="bg-
|
|
97
|
+
class="bg-muted flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-xl"
|
|
94
98
|
>
|
|
95
99
|
<!-- Figma draws the icon of every Empty State in the foreground colour (Icon collection, Default mode); `iconColor` still overrides it, on the icon itself -->
|
|
96
100
|
<IconComponent class="text-foreground size-4" style={iconStyle} aria-hidden="true" />
|
|
@@ -98,7 +102,7 @@
|
|
|
98
102
|
{/if}
|
|
99
103
|
|
|
100
104
|
<div class="flex w-full min-w-0 flex-col gap-1">
|
|
101
|
-
<p class="text-body text-foreground font-medium" style={titleStyle}>{message}</p>
|
|
105
|
+
<p class="text-body text-muted-foreground font-medium" style={titleStyle}>{message}</p>
|
|
102
106
|
{#if description}
|
|
103
107
|
<p class="text-body text-muted-foreground">{description}</p>
|
|
104
108
|
{/if}
|
|
@@ -46,8 +46,13 @@
|
|
|
46
46
|
|
|
47
47
|
/** The words the box says about files a message may refer to. The design system holds no English: the host passes them. */
|
|
48
48
|
export type ComposerReferenceMessages = {
|
|
49
|
-
/**
|
|
50
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Optional. What a screen reader is told about the box while a file is attached: how to refer to it. Nothing is drawn for it:
|
|
51
|
+
* a person who sees the box is not shown a line of help under the text. Left out (or empty), nothing is said and nothing is
|
|
52
|
+
* drawn for it at all, and the box does not point at a hint: the chat leaves it out, since a person who has attached a file
|
|
53
|
+
* needs no line of help for it.
|
|
54
|
+
*/
|
|
55
|
+
hint?: string;
|
|
51
56
|
/** What a screen reader calls the list of files the `#` menu opens ("Attached files"). */
|
|
52
57
|
menuLabel: string;
|
|
53
58
|
/** What the X of a badge is called, with `{name}` for the file's name ("Remove {name}"). */
|
|
@@ -249,8 +254,9 @@
|
|
|
249
254
|
const referencesOn = $derived(references !== undefined);
|
|
250
255
|
const sendableValue = $derived(messageText(value, referencesOn));
|
|
251
256
|
const referenceHintId = nextReferenceHintId();
|
|
257
|
+
// A hint is said only when the host gave one (the message is optional): without it the box points at nothing.
|
|
252
258
|
const referenceHintShown = $derived(
|
|
253
|
-
references !== undefined && references.items.length > 0 && references.messages.hint !== ''
|
|
259
|
+
references !== undefined && references.items.length > 0 && (references.messages.hint ?? '') !== ''
|
|
254
260
|
);
|
|
255
261
|
// Whether the `#` menu is open: the grey suggestion of the same box goes while it is.
|
|
256
262
|
let referenceMenuOpen = $state(false);
|
|
@@ -520,12 +526,8 @@
|
|
|
520
526
|
<p class="text-caption text-destructive mt-1" role="status">{messages.characterLimit}</p>
|
|
521
527
|
{/if}
|
|
522
528
|
{#if referenceHintShown && references}
|
|
523
|
-
<!-- How to refer to an attached file
|
|
524
|
-
<p
|
|
525
|
-
id={referenceHintId}
|
|
526
|
-
class="text-caption text-muted-foreground mt-1"
|
|
527
|
-
data-testid="composer-reference-hint"
|
|
528
|
-
>
|
|
529
|
+
<!-- How to refer to an attached file, said to a screen reader only (the box points at it): a person who sees the box is not shown a line of help for it. -->
|
|
530
|
+
<p id={referenceHintId} class="sr-only" data-testid="composer-reference-hint">
|
|
529
531
|
{references.messages.hint}
|
|
530
532
|
</p>
|
|
531
533
|
{/if}
|
|
@@ -596,7 +598,13 @@
|
|
|
596
598
|
variant={primaryAction === 'stop' ? 'inverse' : 'primary'}
|
|
597
599
|
data-testid="composer-send"
|
|
598
600
|
data-action={primaryAction}
|
|
599
|
-
class={
|
|
601
|
+
class={cn(
|
|
602
|
+
// Enabled and disabled are two looks the control fades between, very quickly. A fade that is under way turns
|
|
603
|
+
// around by itself when the look changes back (see `press-feedback-fade`), so a text that is typed, erased and
|
|
604
|
+
// typed again never leaves the control half way or makes it jump.
|
|
605
|
+
'press-feedback-fade',
|
|
606
|
+
sendAttention?.bounce && 'wc-composer-send-bounce'
|
|
607
|
+
)}
|
|
600
608
|
label={primaryLabel}
|
|
601
609
|
disabled={!sendEnabled}
|
|
602
610
|
onclick={() => handleSend('control')}
|
|
@@ -30,8 +30,13 @@ export type ComposerCompletion = {
|
|
|
30
30
|
};
|
|
31
31
|
/** The words the box says about files a message may refer to. The design system holds no English: the host passes them. */
|
|
32
32
|
export type ComposerReferenceMessages = {
|
|
33
|
-
/**
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Optional. What a screen reader is told about the box while a file is attached: how to refer to it. Nothing is drawn for it:
|
|
35
|
+
* a person who sees the box is not shown a line of help under the text. Left out (or empty), nothing is said and nothing is
|
|
36
|
+
* drawn for it at all, and the box does not point at a hint: the chat leaves it out, since a person who has attached a file
|
|
37
|
+
* needs no line of help for it.
|
|
38
|
+
*/
|
|
39
|
+
hint?: string;
|
|
35
40
|
/** What a screen reader calls the list of files the `#` menu opens ("Attached files"). */
|
|
36
41
|
menuLabel: string;
|
|
37
42
|
/** What the X of a badge is called, with `{name}` for the file's name ("Remove {name}"). */
|
|
@@ -67,6 +67,11 @@
|
|
|
67
67
|
|
|
68
68
|
const messages = $derived({ ...defaultMessages, ...messagesProp });
|
|
69
69
|
const isUser = $derived(role === 'user');
|
|
70
|
+
// The row of actions under a message is drawn only when there is an action to put in it. A row with nothing in it still took its
|
|
71
|
+
// 32 px (and the 4 px gap above it): the space between a message and the next one grew by 36 px for no reason, and the chat had to
|
|
72
|
+
// hide the empty row with a rule of its own. Where there are actions the row keeps its place while hidden, so showing it never moves anything.
|
|
73
|
+
const hasUserActions = $derived(Boolean(onRestoreCheckpoint || onCopy || actions));
|
|
74
|
+
const hasAssistantActions = $derived(Boolean(onCopy || onRegenerate || actions));
|
|
70
75
|
</script>
|
|
71
76
|
|
|
72
77
|
<div
|
|
@@ -89,27 +94,29 @@
|
|
|
89
94
|
{@render children()}
|
|
90
95
|
{/if}
|
|
91
96
|
</div>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
{#if hasUserActions}
|
|
98
|
+
<div
|
|
99
|
+
class={cn(
|
|
100
|
+
'duration-fast flex min-h-8 items-center gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none',
|
|
101
|
+
showActions && 'opacity-100'
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
{#if onRestoreCheckpoint}
|
|
105
|
+
<Button variant="ghost" size="sm" onclick={onRestoreCheckpoint}>
|
|
106
|
+
<IconRestore class="size-4 stroke-2" aria-hidden="true" />
|
|
107
|
+
{messages.restoreCheckpoint}
|
|
108
|
+
</Button>
|
|
109
|
+
{/if}
|
|
110
|
+
{#if onCopy}
|
|
111
|
+
<IconButton variant="ghost" label={messages.copy} onclick={onCopy}>
|
|
112
|
+
<IconCopy class="size-4 stroke-2" aria-hidden="true" />
|
|
113
|
+
</IconButton>
|
|
114
|
+
{/if}
|
|
115
|
+
{#if actions}
|
|
116
|
+
{@render actions()}
|
|
117
|
+
{/if}
|
|
118
|
+
</div>
|
|
119
|
+
{/if}
|
|
113
120
|
{:else}
|
|
114
121
|
<div
|
|
115
122
|
class={cn('text-body text-foreground w-full', error && 'text-destructive')}
|
|
@@ -134,25 +141,27 @@
|
|
|
134
141
|
</span>
|
|
135
142
|
{/if}
|
|
136
143
|
</div>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
{
|
|
155
|
-
|
|
156
|
-
|
|
144
|
+
{#if hasAssistantActions}
|
|
145
|
+
<div
|
|
146
|
+
class={cn(
|
|
147
|
+
'duration-fast flex min-h-8 items-center gap-1 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 motion-reduce:transition-none',
|
|
148
|
+
showActions && 'opacity-100'
|
|
149
|
+
)}
|
|
150
|
+
>
|
|
151
|
+
{#if onCopy}
|
|
152
|
+
<IconButton variant="ghost" label={messages.copy} onclick={onCopy}>
|
|
153
|
+
<IconCopy class="size-4 stroke-2" aria-hidden="true" />
|
|
154
|
+
</IconButton>
|
|
155
|
+
{/if}
|
|
156
|
+
{#if onRegenerate}
|
|
157
|
+
<IconButton variant="ghost" label={messages.regenerate} onclick={onRegenerate}>
|
|
158
|
+
<IconRefresh class="size-4 stroke-2" aria-hidden="true" />
|
|
159
|
+
</IconButton>
|
|
160
|
+
{/if}
|
|
161
|
+
{#if actions}
|
|
162
|
+
{@render actions()}
|
|
163
|
+
{/if}
|
|
164
|
+
</div>
|
|
165
|
+
{/if}
|
|
157
166
|
{/if}
|
|
158
167
|
</div>
|
|
@@ -68,6 +68,14 @@
|
|
|
68
68
|
...restProps
|
|
69
69
|
}: MessageRatingActionsProps = $props();
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* The row is not what the eyes should go to, so its buttons rest in the placeholder grey (`text-muted-foreground`, the colour of the
|
|
73
|
+
* placeholder in the composer) and take the full text colour under the pointer and under the keyboard focus (the ghost button's own
|
|
74
|
+
* hover). A thumb that was pressed keeps the full colour, so a vote that was given stays easy to see.
|
|
75
|
+
*/
|
|
76
|
+
const quietButtonClass = 'text-muted-foreground';
|
|
77
|
+
const quietThumbClass = 'text-muted-foreground aria-pressed:text-foreground';
|
|
78
|
+
|
|
71
79
|
const messages = $derived({ ...defaultMessages, ...messagesProp });
|
|
72
80
|
const visible = $derived(
|
|
73
81
|
shouldRenderMessageRatingBar({ copyText, canRegenerate, ratedMessageId })
|
|
@@ -108,7 +116,7 @@
|
|
|
108
116
|
{...restProps}
|
|
109
117
|
>
|
|
110
118
|
{#if shouldShowCopyAction(copyText) && onCopy}
|
|
111
|
-
<IconButton variant="ghost" label={copied ? messages.copied : messages.copy} onclick={handleCopy}>
|
|
119
|
+
<IconButton variant="ghost" class={quietButtonClass} label={copied ? messages.copied : messages.copy} onclick={handleCopy}>
|
|
112
120
|
{#if copied}
|
|
113
121
|
<IconCheck class="size-4 stroke-2" aria-hidden="true" />
|
|
114
122
|
{:else}
|
|
@@ -118,7 +126,7 @@
|
|
|
118
126
|
{/if}
|
|
119
127
|
|
|
120
128
|
{#if shouldShowRegenerateAction(canRegenerate) && onRegenerate}
|
|
121
|
-
<IconButton variant="ghost" label={messages.regenerate} onclick={onRegenerate}>
|
|
129
|
+
<IconButton variant="ghost" class={quietButtonClass} label={messages.regenerate} onclick={onRegenerate}>
|
|
122
130
|
<IconRefresh class="size-4 stroke-2" aria-hidden="true" />
|
|
123
131
|
</IconButton>
|
|
124
132
|
{/if}
|
|
@@ -127,6 +135,7 @@
|
|
|
127
135
|
<span class="inline-flex items-center gap-0.5" role="group" aria-label={messages.rateGroup}>
|
|
128
136
|
<IconButton
|
|
129
137
|
variant="ghost"
|
|
138
|
+
class={quietThumbClass}
|
|
130
139
|
label={messages.rateUp}
|
|
131
140
|
aria-pressed={thumbIsPressed(rating, 'up')}
|
|
132
141
|
onclick={() => onRate(ratedMessageId, 'up')}
|
|
@@ -139,6 +148,7 @@
|
|
|
139
148
|
</IconButton>
|
|
140
149
|
<IconButton
|
|
141
150
|
variant="ghost"
|
|
151
|
+
class={quietThumbClass}
|
|
142
152
|
label={messages.rateDown}
|
|
143
153
|
aria-pressed={thumbIsPressed(rating, 'down')}
|
|
144
154
|
onclick={() => onRate(ratedMessageId, 'down')}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import { TextFlip } from '../ui/text-flip';
|
|
21
21
|
import { cn } from '../../utils.js';
|
|
22
22
|
import { prefersReducedMotion } from '../../utils/reducedMotion.js';
|
|
23
|
+
import { shouldOpenCollapsedPlanCard } from './planCardLogic.js';
|
|
23
24
|
|
|
24
25
|
export type PlanTask = {
|
|
25
26
|
id: string;
|
|
@@ -112,6 +113,7 @@
|
|
|
112
113
|
headerIcon,
|
|
113
114
|
primaryAction,
|
|
114
115
|
secondaryAction,
|
|
116
|
+
onclick: onclickProp = undefined,
|
|
115
117
|
...restProps
|
|
116
118
|
}: Props = $props();
|
|
117
119
|
|
|
@@ -145,6 +147,28 @@
|
|
|
145
147
|
: messages.showMoreTasks.replace('{count}', String(hiddenCount))
|
|
146
148
|
);
|
|
147
149
|
|
|
150
|
+
// A collapsed card (tasks still folded away) is a surface that opens: the whole of it answers the pointer like a chip does (grey on hover),
|
|
151
|
+
// and a press on it, outside its buttons and links, shows the rest of the tasks, as the toggle at the end of the list does.
|
|
152
|
+
const opensOnPress = $derived(!planning && hiddenCount > 0 && !expanded);
|
|
153
|
+
|
|
154
|
+
function handleCardClick(event: Parameters<NonNullable<Props['onclick']>>[0]): void {
|
|
155
|
+
try {
|
|
156
|
+
// The page's own handler goes first, and may answer the press itself (`preventDefault`)
|
|
157
|
+
onclickProp?.(event);
|
|
158
|
+
const shouldOpen = shouldOpenCollapsedPlanCard({
|
|
159
|
+
collapsed: opensOnPress,
|
|
160
|
+
defaultPrevented: event.defaultPrevented,
|
|
161
|
+
pressedElement: event.target instanceof Element ? event.target : null,
|
|
162
|
+
selectedText: window.getSelection()?.toString() ?? ''
|
|
163
|
+
});
|
|
164
|
+
if (!shouldOpen) return;
|
|
165
|
+
// console.debug('[PlanCard] the collapsed card was pressed: its folded tasks are shown');
|
|
166
|
+
expanded = true;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error('[PlanCard] could not open the collapsed card:', error);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
148
172
|
// The three screens of the responsive view, in the order of the plan: small to large. A screen without text is left out.
|
|
149
173
|
const responsiveRows = $derived(
|
|
150
174
|
responsive
|
|
@@ -243,14 +267,18 @@
|
|
|
243
267
|
</div>
|
|
244
268
|
{/snippet}
|
|
245
269
|
|
|
270
|
+
<!-- The press on the card is a pointer shortcut: a keyboard and a screen reader have the toggle at the end of the list, a button -->
|
|
246
271
|
<div
|
|
247
272
|
bind:this={ref}
|
|
248
273
|
class={cn(
|
|
249
|
-
'rounded-card border-border bg-background flex w-full max-w-full flex-col border p-4',
|
|
274
|
+
'rounded-card border-border bg-background duration-fast flex w-full max-w-full flex-col border p-4 transition-colors',
|
|
275
|
+
opensOnPress && 'hover:bg-accent cursor-pointer',
|
|
250
276
|
className
|
|
251
277
|
)}
|
|
252
278
|
data-plan-state={planning ? 'planning' : 'ready'}
|
|
279
|
+
data-plan-collapsed={opensOnPress ? true : undefined}
|
|
253
280
|
aria-busy={planning ? true : undefined}
|
|
281
|
+
onclick={handleCardClick}
|
|
254
282
|
{...restProps}
|
|
255
283
|
>
|
|
256
284
|
<header class="flex min-w-0 items-center gap-2">
|
|
@@ -311,6 +339,16 @@
|
|
|
311
339
|
|
|
312
340
|
{#if hiddenCount > 0}
|
|
313
341
|
<Collapsible.Root bind:open={expanded}>
|
|
342
|
+
<!-- The tasks that were hidden come first, so that opening them lists them right after the ones that were already
|
|
343
|
+
visible; the toggle stays the last thing of the list, whether it says "Show more" or "Show fewer". -->
|
|
344
|
+
<Collapsible.Content
|
|
345
|
+
class="flex flex-col overflow-hidden motion-reduce:transition-none"
|
|
346
|
+
data-testid="plan-card-hidden-tasks"
|
|
347
|
+
>
|
|
348
|
+
{#each hiddenTasks as task (task.id)}
|
|
349
|
+
{@render taskRow(task)}
|
|
350
|
+
{/each}
|
|
351
|
+
</Collapsible.Content>
|
|
314
352
|
<Collapsible.Trigger
|
|
315
353
|
class="text-label text-foreground duration-fast hover:bg-accent focus-visible:ring-ring focus-visible:ring-offset-background mt-1 inline-flex h-8 items-center gap-1 rounded-lg px-2 transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden"
|
|
316
354
|
>
|
|
@@ -323,13 +361,6 @@
|
|
|
323
361
|
aria-hidden="true"
|
|
324
362
|
/>
|
|
325
363
|
</Collapsible.Trigger>
|
|
326
|
-
<Collapsible.Content
|
|
327
|
-
class="flex flex-col overflow-hidden motion-reduce:transition-none"
|
|
328
|
-
>
|
|
329
|
-
{#each hiddenTasks as task (task.id)}
|
|
330
|
-
{@render taskRow(task)}
|
|
331
|
-
{/each}
|
|
332
|
-
</Collapsible.Content>
|
|
333
364
|
</Collapsible.Root>
|
|
334
365
|
{/if}
|
|
335
366
|
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a press on a plan card is the press that opens it.
|
|
3
|
+
*
|
|
4
|
+
* A collapsed card (it has tasks folded away behind its toggle) is a surface that opens: a press anywhere on it shows the rest of the
|
|
5
|
+
* tasks, as the toggle at the end of the list does. Three presses are not that one:
|
|
6
|
+
* - one a handler of the page already answered (it called `preventDefault`);
|
|
7
|
+
* - one on a button or a link of the card (it does its own work, and the toggle, which is a button, must not be counted twice);
|
|
8
|
+
* - the end of a drag over the text of the card (the person was selecting words, not pressing the card).
|
|
9
|
+
*/
|
|
10
|
+
/** What counts as a control of its own inside the card: a press on one of these (or on something inside one) is theirs. */
|
|
11
|
+
export declare const PLAN_CARD_CONTROLS_SELECTOR = "button, a, [role=\"button\"]";
|
|
12
|
+
export type PlanCardPress = {
|
|
13
|
+
/** The card is collapsed: it has tasks folded away, it is not being planned and it is not open. */
|
|
14
|
+
collapsed: boolean;
|
|
15
|
+
/** A handler of the page already answered the press. */
|
|
16
|
+
defaultPrevented: boolean;
|
|
17
|
+
/** What was pressed, or `null` when it is no element. */
|
|
18
|
+
pressedElement: {
|
|
19
|
+
closest(selectors: string): unknown;
|
|
20
|
+
} | null;
|
|
21
|
+
/** The text the person has selected on the page ('' for none). */
|
|
22
|
+
selectedText: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function shouldOpenCollapsedPlanCard(press: PlanCardPress): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a press on a plan card is the press that opens it.
|
|
3
|
+
*
|
|
4
|
+
* A collapsed card (it has tasks folded away behind its toggle) is a surface that opens: a press anywhere on it shows the rest of the
|
|
5
|
+
* tasks, as the toggle at the end of the list does. Three presses are not that one:
|
|
6
|
+
* - one a handler of the page already answered (it called `preventDefault`);
|
|
7
|
+
* - one on a button or a link of the card (it does its own work, and the toggle, which is a button, must not be counted twice);
|
|
8
|
+
* - the end of a drag over the text of the card (the person was selecting words, not pressing the card).
|
|
9
|
+
*/
|
|
10
|
+
/** What counts as a control of its own inside the card: a press on one of these (or on something inside one) is theirs. */
|
|
11
|
+
export const PLAN_CARD_CONTROLS_SELECTOR = 'button, a, [role="button"]';
|
|
12
|
+
export function shouldOpenCollapsedPlanCard(press) {
|
|
13
|
+
if (!press.collapsed || press.defaultPrevented)
|
|
14
|
+
return false;
|
|
15
|
+
if (press.pressedElement?.closest(PLAN_CARD_CONTROLS_SELECTOR))
|
|
16
|
+
return false;
|
|
17
|
+
if (press.selectedText !== '')
|
|
18
|
+
return false;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
titleAsCaption?: boolean;
|
|
43
43
|
/** Figma title button min width varies by state (Failed 143px vs Ready 201px). */
|
|
44
44
|
titleButtonClass?: string;
|
|
45
|
+
/** Inline title rename state for the sketch bar. */
|
|
46
|
+
isRenaming?: boolean;
|
|
47
|
+
renameValue?: string;
|
|
48
|
+
onRenameCommit?: (nextTitle: string) => void;
|
|
49
|
+
onRenameCancel?: () => void;
|
|
45
50
|
trailing?: Snippet;
|
|
46
51
|
};
|
|
47
52
|
|
|
@@ -68,10 +73,39 @@
|
|
|
68
73
|
titleAsCaption = false,
|
|
69
74
|
// Figma 514:52 — the title hugs its text (143 px for "Untitled widget", 201 px for "Black Friday countdown"), so it has no minimum width.
|
|
70
75
|
titleButtonClass = 'min-w-0',
|
|
76
|
+
isRenaming = false,
|
|
77
|
+
renameValue = '',
|
|
78
|
+
onRenameCommit,
|
|
79
|
+
onRenameCancel,
|
|
71
80
|
trailing,
|
|
72
81
|
...restProps
|
|
73
82
|
}: Props = $props();
|
|
74
83
|
|
|
84
|
+
let renameDraft = $state('');
|
|
85
|
+
let renameInputEl = $state<HTMLInputElement | null>(null);
|
|
86
|
+
let renameCanceled = false;
|
|
87
|
+
|
|
88
|
+
$effect(() => {
|
|
89
|
+
if (isRenaming) {
|
|
90
|
+
renameCanceled = false;
|
|
91
|
+
renameDraft = renameValue || title;
|
|
92
|
+
queueMicrotask(() => {
|
|
93
|
+
renameInputEl?.focus();
|
|
94
|
+
renameInputEl?.select();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
function commitRename() {
|
|
100
|
+
if (renameCanceled) return;
|
|
101
|
+
onRenameCommit?.(renameDraft);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function cancelRename() {
|
|
105
|
+
renameCanceled = true;
|
|
106
|
+
onRenameCancel?.();
|
|
107
|
+
}
|
|
108
|
+
|
|
75
109
|
const titleIsInteractive = $derived(
|
|
76
110
|
!titleAsCaption && (Boolean(titleMenu) || Boolean(onTitleClick) || showTitleChevron),
|
|
77
111
|
);
|
|
@@ -94,7 +128,26 @@
|
|
|
94
128
|
</IconButton>
|
|
95
129
|
{/if}
|
|
96
130
|
|
|
97
|
-
{#if
|
|
131
|
+
{#if isRenaming}
|
|
132
|
+
<input
|
|
133
|
+
bind:this={renameInputEl}
|
|
134
|
+
bind:value={renameDraft}
|
|
135
|
+
type="text"
|
|
136
|
+
data-testid="creator-bar-title-input"
|
|
137
|
+
aria-label="Rename widget"
|
|
138
|
+
class="border-input bg-background text-body-medium focus:border-ring h-8 w-52 max-w-[min(100%,16rem)] rounded-md border px-2.5 text-sm outline-none"
|
|
139
|
+
onkeydown={(e) => {
|
|
140
|
+
if (e.key === 'Enter') {
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
commitRename();
|
|
143
|
+
} else if (e.key === 'Escape') {
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
cancelRename();
|
|
146
|
+
}
|
|
147
|
+
}}
|
|
148
|
+
onblur={commitRename}
|
|
149
|
+
/>
|
|
150
|
+
{:else if titleAsCaption}
|
|
98
151
|
<span
|
|
99
152
|
data-testid="creator-bar-title"
|
|
100
153
|
class="text-caption text-muted-foreground max-w-[10rem] truncate px-2 leading-4"
|
|
@@ -28,6 +28,11 @@ type Props = HTMLAttributes<HTMLElement> & {
|
|
|
28
28
|
titleAsCaption?: boolean;
|
|
29
29
|
/** Figma title button min width varies by state (Failed 143px vs Ready 201px). */
|
|
30
30
|
titleButtonClass?: string;
|
|
31
|
+
/** Inline title rename state for the sketch bar. */
|
|
32
|
+
isRenaming?: boolean;
|
|
33
|
+
renameValue?: string;
|
|
34
|
+
onRenameCommit?: (nextTitle: string) => void;
|
|
35
|
+
onRenameCancel?: () => void;
|
|
31
36
|
trailing?: Snippet;
|
|
32
37
|
};
|
|
33
38
|
declare const CreatorBar: import("svelte").Component<Props, {}, "ref" | "titleMenuOpen">;
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
} from '../../utils/overlayMotion.js';
|
|
34
34
|
// A scrim drawn over another scrim only dims (the page is blurred once): see overlayStacking.ts.
|
|
35
35
|
import { stackedScrimMark } from '../../utils/overlayStacking.js';
|
|
36
|
+
// Enter inside the card presses the modal's main button (see utils/modalEnterKey.ts).
|
|
37
|
+
import { modalEnterKey } from '../../utils/modalEnterKey.js';
|
|
36
38
|
|
|
37
39
|
/* COMPONENT PROPS */
|
|
38
40
|
// class and style props
|
|
@@ -68,6 +70,12 @@
|
|
|
68
70
|
export let closeOnBackdropClick = true;
|
|
69
71
|
/** When false, Escape does not close. Default: Escape dismisses unless a nested control already handled the key. */
|
|
70
72
|
export let closeOnEscape = true;
|
|
73
|
+
/**
|
|
74
|
+
* When true (default), Enter inside the card presses the modal's main button: the last filled `Button` (or the one marked
|
|
75
|
+
* `data-modal-primary`), unless the control that has the focus keeps Enter for itself. See utils/modalEnterKey.ts.
|
|
76
|
+
* A modal that wants every Enter for its own content passes false.
|
|
77
|
+
*/
|
|
78
|
+
export let enterActivatesPrimary = true;
|
|
71
79
|
/** Spoken name of the dialog when there is no visible title row (a bare modal should pass one, for example the file's name). */
|
|
72
80
|
export let ariaLabel: string | undefined = undefined;
|
|
73
81
|
|
|
@@ -451,6 +459,7 @@
|
|
|
451
459
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
452
460
|
<div
|
|
453
461
|
bind:this={modalPanelEl}
|
|
462
|
+
use:modalEnterKey={{ enabled: enterActivatesPrimary && open }}
|
|
454
463
|
role="dialog"
|
|
455
464
|
aria-modal="true"
|
|
456
465
|
aria-labelledby={title ? titleElementId : undefined}
|
|
@@ -31,6 +31,11 @@ declare const BaseModal: $$__sveltets_2_IsomorphicComponent<{
|
|
|
31
31
|
bare?: boolean;
|
|
32
32
|
/** When false, clicks and taps on the scrim do not close (destructive confirms can set this). Default matches Figma: scrim dismisses. */ closeOnBackdropClick?: boolean;
|
|
33
33
|
/** When false, Escape does not close. Default: Escape dismisses unless a nested control already handled the key. */ closeOnEscape?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* When true (default), Enter inside the card presses the modal's main button: the last filled `Button` (or the one marked
|
|
36
|
+
* `data-modal-primary`), unless the control that has the focus keeps Enter for itself. See utils/modalEnterKey.ts.
|
|
37
|
+
* A modal that wants every Enter for its own content passes false.
|
|
38
|
+
*/ enterActivatesPrimary?: boolean;
|
|
34
39
|
/** Spoken name of the dialog when there is no visible title row (a bare modal should pass one, for example the file's name). */ ariaLabel?: string | undefined;
|
|
35
40
|
children: any;
|
|
36
41
|
}, {
|