u0ui 0.3.15

Carbon UI: IBM Carbon v11 visuals with a shadcn-style API for GPUI Kit
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
//! [`QueuedRunsControl`] (`.t3-queue`, "Queue" in `t3.css`): messages queued
//! while the agent runs, numbered, each with Send now, Edit and Remove.
//!
//! The header toggles the list (open by default, as `useState(true)`); its
//! chevron turns −90° when closed (`.t3-rot`, no transition in the reference).
//!
//! Options for the u0 board `ThreadComposer` (`.tc-later*`): a head icon
//! and the caller's head text, a head that does not collapse (no chevron),
//! unnumbered rows on one line with an inline note, an "Earlier" action and
//! a hairline frame. Left unset, the control draws as above.
use crate::components::button::{Button, ButtonSize, ButtonVariant};
use crate::t3::press::{self, rem};
use crate::{icons::CarbonIcon, theme::color, tokens::ColorRole};
use gpui_kit::Focusable as _;
use gpui_kit::component::Sizable as _;
use gpui_kit::component::input::{Input, InputState};
use gpui_kit::{
    App, AppContext as _, CursorStyle, ElementId, Entity, InteractiveElement as _, IntoElement,
    KeyDownEvent, ParentElement, RenderOnce, SharedString, Styled, Window, div,
    prelude::FluentBuilder as _,
};
use std::rc::Rc;

/// One queued message (`{ text, editing, error, from }`).
#[derive(Clone, Default)]
pub struct QueuedRun {
    /// `text`.
    pub text: SharedString,
    /// `editing`: being edited in the composer.
    pub editing: bool,
    /// `error`: could not be sent.
    pub error: bool,
    /// `from`: where it was queued from.
    pub from: Option<SharedString>,
    /// A note of the caller's (e.g. "Saved"), in `text-error` with `error`.
    pub note: Option<SharedString>,
}

impl QueuedRun {
    /// A queued `text`.
    pub fn new(text: impl Into<SharedString>) -> Self {
        Self {
            text: text.into(),
            ..Default::default()
        }
    }

    /// `editing`.
    pub fn editing(mut self, editing: bool) -> Self {
        self.editing = editing;
        self
    }

    /// `error`.
    pub fn error(mut self, error: bool) -> Self {
        self.error = error;
        self
    }

    /// `from`.
    pub fn from(mut self, from: impl Into<SharedString>) -> Self {
        self.from = Some(from.into());
        self
    }

    /// A note of the caller's, in place of the `error` / `editing` / `from`
    /// note (`.tc-later-row small`; `.tc-later-err` with `error`).
    pub fn note(mut self, note: impl Into<SharedString>) -> Self {
        self.note = Some(note.into());
        self
    }
}

/// The control's user-facing strings (the reference's English defaults).
#[derive(Clone)]
pub struct QueuedRunsTexts {
    /// Header: `"{n} queued"`.
    pub count: Rc<dyn Fn(usize) -> SharedString>,
    /// `error` note.
    pub error: SharedString,
    /// `editing` note.
    pub editing: SharedString,
    /// Send now.
    pub send_now: SharedString,
    /// Edit (tooltip).
    pub edit: SharedString,
    /// Remove (tooltip).
    pub remove: SharedString,
    /// Earlier: move the row up one (with `on_earlier`).
    pub earlier: SharedString,
    /// Inline edit Cancel button (`"Cancel"`).
    pub cancel: SharedString,
    /// Inline edit Save button (`"Save"`).
    pub save: SharedString,
    /// Inline edit input accessible label (`"The waiting message, being edited"`).
    pub editing_aria: SharedString,
}

impl Default for QueuedRunsTexts {
    fn default() -> Self {
        Self {
            count: Rc::new(|n| format!("{n} queued").into()),
            error: "Could not send queued message".into(),
            editing: "Editing in the composer".into(),
            send_now: "Send now".into(),
            edit: "Edit".into(),
            remove: "Remove from queue".into(),
            earlier: "Earlier".into(),
            cancel: "Cancel".into(),
            save: "Save".into(),
            editing_aria: "The waiting message, being edited".into(),
        }
    }
}

type IndexHandler = Rc<dyn Fn(usize, &mut Window, &mut App)>;
type SaveEditHandler = Rc<dyn Fn(usize, SharedString, &mut Window, &mut App)>;

struct InlineEditState {
    active: Option<(usize, Entity<InputState>)>,
}

/// The queued-runs list. See the module docs.
#[derive(IntoElement)]
pub struct QueuedRunsControl {
    id: ElementId,
    items: Vec<QueuedRun>,
    texts: QueuedRunsTexts,
    on_send_now: Option<IndexHandler>,
    on_edit: Option<IndexHandler>,
    on_save_edit: Option<SaveEditHandler>,
    on_cancel_edit: Option<IndexHandler>,
    on_remove: Option<IndexHandler>,
    on_earlier: Option<IndexHandler>,
    icon: CarbonIcon,
    title: Option<SharedString>,
    collapsible: bool,
    numbered: bool,
    single_line: bool,
    bordered: bool,
}

impl QueuedRunsControl {
    /// The control for `items`.
    pub fn new(id: impl Into<ElementId>, items: Vec<QueuedRun>) -> Self {
        Self {
            id: id.into(),
            items,
            texts: QueuedRunsTexts::default(),
            on_send_now: None,
            on_edit: None,
            on_save_edit: None,
            on_cancel_edit: None,
            on_remove: None,
            on_earlier: None,
            icon: CarbonIcon::ListChecked,
            title: None,
            collapsible: true,
            numbered: true,
            single_line: false,
            bordered: false,
        }
    }

    /// The head's icon (default `ListChecked`; the u0 board's is `Time`).
    pub fn icon(mut self, icon: CarbonIcon) -> Self {
        self.icon = icon;
        self
    }

    /// The head's text, in place of `texts.count` (e.g. "2 wait their turn ·
    /// sent in order when Claude’s turn ends").
    pub fn title(mut self, title: impl Into<SharedString>) -> Self {
        self.title = Some(title.into());
        self
    }

    /// Whether the head opens and closes the list (default true). Off, the
    /// head is plain text with no chevron and the list always shows.
    pub fn collapsible(mut self, collapsible: bool) -> Self {
        self.collapsible = collapsible;
        self
    }

    /// Whether each row shows its number (default true).
    pub fn numbered(mut self, numbered: bool) -> Self {
        self.numbered = numbered;
        self
    }

    /// Each row on one line (`.tc-later-row`: min-height 32px, the text
    /// ellipsized, its note after it); default false (the note under the text).
    pub fn single_line(mut self, single_line: bool) -> Self {
        self.single_line = single_line;
        self
    }

    /// A 1px `border-subtle-01` frame (`.tc-later { box-shadow: inset 0 0 0 1px
    /// border-subtle-01 }`); default false.
    pub fn bordered(mut self, bordered: bool) -> Self {
        self.bordered = bordered;
        self
    }

    /// `onEarlier(i)`: an "Earlier" ghost action before Send now, on every
    /// row but the first.
    pub fn on_earlier(mut self, f: impl Fn(usize, &mut Window, &mut App) + 'static) -> Self {
        self.on_earlier = Some(Rc::new(f));
        self
    }

    /// Replace the strings.
    pub fn texts(mut self, texts: QueuedRunsTexts) -> Self {
        self.texts = texts;
        self
    }

    /// `onSendNow(i)`.
    pub fn on_send_now(mut self, f: impl Fn(usize, &mut Window, &mut App) + 'static) -> Self {
        self.on_send_now = Some(Rc::new(f));
        self
    }

    /// `onEdit(i)`.
    pub fn on_edit(mut self, f: impl Fn(usize, &mut Window, &mut App) + 'static) -> Self {
        self.on_edit = Some(Rc::new(f));
        self
    }

    /// Inline row edit (`ThreadComposer.dc.html` `.tc-later-row--edit`): clicking Edit
    /// (or passing `QueuedRun::editing(true)`) turns the row into a field with Cancel and Save.
    pub fn on_save_edit(
        mut self,
        f: impl Fn(usize, SharedString, &mut Window, &mut App) + 'static,
    ) -> Self {
        self.on_save_edit = Some(Rc::new(f));
        self
    }

    /// Optional callback when inline row editing is cancelled (`Esc` or Cancel).
    pub fn on_cancel_edit(mut self, f: impl Fn(usize, &mut Window, &mut App) + 'static) -> Self {
        self.on_cancel_edit = Some(Rc::new(f));
        self
    }

    /// `onRemove(i)`.
    pub fn on_remove(mut self, f: impl Fn(usize, &mut Window, &mut App) + 'static) -> Self {
        self.on_remove = Some(Rc::new(f));
        self
    }
}

impl RenderOnce for QueuedRunsControl {
    fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
        let id = self.id.clone();
        let open_state = window.use_keyed_state((id.clone(), "open"), cx, |_, _| true);
        let open = *open_state.read(cx);
        let (focus, ring) = press::focus((id.clone(), "head-focus"), window, cx);
        let secondary = color(ColorRole::TextSecondary);
        let texts = self.texts.clone();
        let count = self
            .title
            .clone()
            .unwrap_or_else(|| (texts.count)(self.items.len()));
        let collapsible = self.collapsible;
        let open = open || !collapsible;
        let single = self.single_line;
        let numbered = self.numbered;
        // `.tc-later-h svg { fill: icon-secondary }`.
        let head_ink = if single {
            color(ColorRole::IconSecondary)
        } else {
            secondary
        };
        // `.t3-queue-head { display: flex; align-items: center; gap: spacing-03; width: 100%;
        // height: size-sm; padding: 0 spacing-04; color: text-secondary; font-size: 0.75rem }`.
        let head = if collapsible {
            gpui_kit::base::Button::new((id.clone(), "head"))
                .track_focus(&focus)
                .accessibility_label(count.clone())
                .justify_start()
                .relative()
                .flex()
                .flex_row()
                .items_center()
                .gap(rem(8.))
                .w_full()
                .h(rem(32.))
                .px(rem(12.))
                .text_color(secondary)
                .text_size(rem(12.))
                .line_height(rem(16.))
                .cursor(CursorStyle::PointingHand)
                .on_click(move |_, _, cx| {
                    open_state.update(cx, |o, cx| {
                        *o = !*o;
                        cx.notify();
                    })
                })
                .child(press::icon(self.icon, 16., head_ink))
                .child(count)
                // `.t3-rot { transform: rotate(-90deg) }` when closed.
                .child(press::icon(CarbonIcon::ChevronDown, 12., secondary).rotate(
                    gpui_kit::radians(if open {
                        0.
                    } else {
                        -std::f32::consts::FRAC_PI_2
                    }),
                ))
                .when(ring, |this| this.child(press::ring()))
                .into_any_element()
        } else {
            // `.tc-later-h { display: flex; align-items: center; gap: 8px; height: 32px;
            // padding: 0 8px 0 12px; font-size: 12px; line-height: 16px; color: text-secondary }`.
            div()
                .flex()
                .flex_row()
                .items_center()
                .gap(rem(8.))
                .w_full()
                .h(rem(32.))
                .pl(rem(12.))
                .pr(rem(8.))
                .text_color(secondary)
                .text_size(rem(12.))
                .line_height(rem(16.))
                .child(press::icon(self.icon, 16., head_ink))
                .child(
                    div()
                        .flex_1()
                        .min_w_0()
                        .overflow_hidden()
                        .whitespace_nowrap()
                        .text_ellipsis()
                        .child(count),
                )
                .into_any_element()
        };
        let inline_state = window.use_keyed_state((id.clone(), "inline-edit"), cx, |_, _| {
            InlineEditState { active: None }
        });
        if self.on_save_edit.is_some() {
            let ext_editing = self.items.iter().position(|it| it.editing);
            let cur_idx = inline_state.read(cx).active.as_ref().map(|(k, _)| *k);
            if let Some(target) = ext_editing
                && cur_idx != Some(target)
            {
                let seed = self.items[target].text.clone();
                let input = cx.new(|cx| InputState::new(window, cx).default_value(seed));
                let focus = input.read(cx).focus_handle(cx);
                window.defer(cx, move |w, cx| focus.focus(w, cx));
                inline_state.update(cx, |s, _| s.active = Some((target, input)));
            } else if (self.on_edit.is_some() && ext_editing.is_none() && cur_idx.is_some())
                || cur_idx.is_some_and(|cur| cur >= self.items.len())
            {
                inline_state.update(cx, |s, _| s.active = None);
            }
        }
        let inline_active = inline_state
            .read(cx)
            .active
            .as_ref()
            .map(|(k, inp)| (*k, inp.clone()));
        let item_texts: Vec<SharedString> = self.items.iter().map(|it| it.text.clone()).collect();
        let rows = open.then(|| {
            self.items
                .into_iter()
                .enumerate()
                .map(|(i, item)| {
                    if self.on_save_edit.is_some()
                        && let Some((active_i, ref edit_input)) = inline_active
                        && active_i == i
                    {
                        let edit_input = edit_input.clone();
                        let save_cb = self.on_save_edit.clone();
                        let cancel_cb = self.on_cancel_edit.clone();
                        let st_cancel = inline_state.clone();
                        let st_save = inline_state.clone();
                        let st_key = inline_state.clone();
                        let cancel_key = cancel_cb.clone();
                        let cancel_save = cancel_cb.clone();
                        let save_key = save_cb.clone();
                        let key_inp = edit_input.clone();
                        let in_focus = edit_input.read(cx).focus_handle(cx).is_focused(window);
                        // `.tc-later-row--edit { padding: 4px 4px 4px 8px }`,
                        // `input { height: 32px; padding: 0 8px; border-bottom: 1px solid border-strong-01;
                        // outline: 2px solid focus; background: field-01 }`.
                        return div()
                            .id((id.clone(), SharedString::from(format!("edit-row-{i}"))))
                            .flex()
                            .flex_row()
                            .items_center()
                            .gap(rem(8.))
                            .py(rem(4.))
                            .pl(rem(8.))
                            .pr(rem(4.))
                            .border_t_1()
                            .border_color(color(ColorRole::BorderSubtle01))
                            .capture_key_down(move |e: &KeyDownEvent, w, cx| {
                                match e.keystroke.key.as_str() {
                                    "escape" => {
                                        st_key.update(cx, |s, cx| {
                                            s.active = None;
                                            cx.notify();
                                        });
                                        if let Some(f) = &cancel_key {
                                            f(i, w, cx);
                                        }
                                        cx.stop_propagation();
                                    }
                                    "enter" if !e.keystroke.modifiers.shift => {
                                        let val: SharedString =
                                            key_inp.read(cx).value().to_string().into();
                                        st_key.update(cx, |s, cx| {
                                            s.active = None;
                                            cx.notify();
                                        });
                                        if !val.trim().is_empty() {
                                            if let Some(f) = &save_key {
                                                f(i, val, w, cx);
                                            }
                                        } else if let Some(f) = &cancel_key {
                                            f(i, w, cx);
                                        }
                                        cx.stop_propagation();
                                    }
                                    _ => {}
                                }
                            })
                            .child(
                                div()
                                    .relative()
                                    .flex()
                                    .items_center()
                                    .flex_1()
                                    .min_w_0()
                                    .h(rem(32.))
                                    .px(rem(8.))
                                    .bg(color(ColorRole::Field01))
                                    .border_b_1()
                                    .border_color(color(ColorRole::BorderStrong01))
                                    .child(
                                        Input::new(&edit_input)
                                            .appearance(false)
                                            .with_size(gpui_kit::component::Size::XSmall)
                                            .aria_label(texts.editing_aria.clone())
                                            .p_0()
                                            .w_full()
                                            .text_size(rem(14.))
                                            .line_height(rem(18.))
                                            .text_color(color(ColorRole::TextPrimary)),
                                    )
                                    .when(in_focus, |d| d.child(press::ring())),
                            )
                            .child(
                                Button::new(
                                    (id.clone(), SharedString::from(format!("cancel-{i}"))),
                                    texts.cancel.clone(),
                                )
                                .variant(ButtonVariant::Ghost)
                                .size(ButtonSize::Sm)
                                .on_click(move |_, w, cx| {
                                    st_cancel.update(cx, |s, cx| {
                                        s.active = None;
                                        cx.notify();
                                    });
                                    if let Some(f) = &cancel_cb {
                                        f(i, w, cx);
                                    }
                                }),
                            )
                            .child({
                                let inp = edit_input.clone();
                                Button::new(
                                    (id.clone(), SharedString::from(format!("save-{i}"))),
                                    texts.save.clone(),
                                )
                                .variant(ButtonVariant::Primary)
                                .size(ButtonSize::Sm)
                                .on_click(move |_, w, cx| {
                                    let val: SharedString = inp.read(cx).value().to_string().into();
                                    st_save.update(cx, |s, cx| {
                                        s.active = None;
                                        cx.notify();
                                    });
                                    if !val.trim().is_empty() {
                                        if let Some(f) = &save_cb {
                                            f(i, val, w, cx);
                                        }
                                    } else if let Some(f) = &cancel_save {
                                        f(i, w, cx);
                                    }
                                })
                            })
                            .into_any_element();
                    }
                    let sub = if let Some(note) = item.note.clone() {
                        // `.tc-later-row small { font-size: 12px; line-height: 16px;
                        // color: text-secondary }`, `.tc-later-err { color: text-error }`.
                        Some(
                            div()
                                .flex()
                                .flex_none()
                                .text_size(rem(12.))
                                .line_height(rem(16.))
                                .text_color(if item.error {
                                    color(ColorRole::TextError)
                                } else {
                                    secondary
                                })
                                .when(single, |this| this.mr(rem(4.)))
                                .child(note),
                        )
                    } else if item.error {
                        // `.t3-queue-err { display: inline-flex; gap: spacing-02; align-items: center;
                        // font-size: 0.75rem; color: text-error }`, icon `support-error`.
                        Some(
                            div()
                                .flex()
                                .flex_row()
                                .items_center()
                                .gap(rem(4.))
                                .text_size(rem(12.))
                                .line_height(rem(16.))
                                .text_color(color(ColorRole::TextError))
                                .child(press::icon(
                                    CarbonIcon::ErrorFilled,
                                    12.,
                                    color(ColorRole::SupportError),
                                ))
                                .child(texts.error.clone()),
                        )
                    } else {
                        let note = if item.editing {
                            Some(texts.editing.clone())
                        } else {
                            item.from.clone()
                        };
                        // `.t3-queue-sub { font-size: 0.75rem; color: text-secondary }`.
                        note.map(|note| {
                            div()
                                .flex()
                                .when(single, |this| this.flex_none().mr(rem(4.)))
                                .text_size(rem(12.))
                                .line_height(rem(16.))
                                .text_color(secondary)
                                .child(note)
                        })
                    };
                    let send = self.on_send_now.clone();
                    let edit: Option<IndexHandler> = if self.on_save_edit.is_some() {
                        let st = inline_state.clone();
                        let seed = item_texts[i].clone();
                        let ext_edit = self.on_edit.clone();
                        Some(Rc::new(move |idx, window, cx| {
                            let input = cx
                                .new(|cx| InputState::new(window, cx).default_value(seed.clone()));
                            let focus = input.read(cx).focus_handle(cx);
                            focus.focus(window, cx);
                            st.update(cx, |s, cx| {
                                s.active = Some((idx, input));
                                cx.notify();
                            });
                            if let Some(f) = &ext_edit {
                                f(idx, window, cx);
                            }
                        }))
                    } else {
                        self.on_edit.clone()
                    };
                    let remove = self.on_remove.clone();
                    let earlier = self.on_earlier.clone().filter(|_| i > 0);
                    // `.t3-queue-item { display: flex; align-items: center; gap: spacing-03;
                    // padding: spacing-02 spacing-02 spacing-02 spacing-04; border-top: 1px solid border-subtle-01 }`.
                    // `.tc-later-row { min-height: 32px; padding: 0 4px 0 12px }` on one line.
                    div()
                        .flex()
                        .flex_row()
                        .items_center()
                        .gap(rem(8.))
                        .map(|this| {
                            if single {
                                this.min_h(rem(32.))
                            } else {
                                this.pt(rem(4.)).pb(rem(4.))
                            }
                        })
                        .pl(rem(12.))
                        .pr(rem(4.))
                        .border_t_1()
                        .border_color(color(ColorRole::BorderSubtle01))
                        // `.t3-queue-n { width: 1.25rem; height: 1.25rem; background: layer-accent-01; font-size: 0.6875rem }`.
                        .when(numbered, |this| {
                            this.child(
                                div()
                                    .flex()
                                    .flex_none()
                                    .items_center()
                                    .justify_center()
                                    .size(rem(20.))
                                    .bg(color(ColorRole::LayerAccent01))
                                    .text_size(rem(12.))
                                    .text_color(color(ColorRole::TextPrimary))
                                    .child(SharedString::from((i + 1).to_string())),
                            )
                        })
                        .map(|this| {
                            if single {
                                // `.tc-later-row > span { flex: 1; min-width: 0; white-space: nowrap;
                                // overflow: hidden; text-overflow: ellipsis }` (14/20).
                                this.child(
                                    div()
                                        .flex_1()
                                        .min_w_0()
                                        .overflow_hidden()
                                        .whitespace_nowrap()
                                        .text_ellipsis()
                                        .text_size(rem(14.))
                                        .line_height(rem(20.))
                                        .text_color(color(ColorRole::TextPrimary))
                                        .child(item.text),
                                )
                                .children(sub)
                            } else {
                                // `.t3-queue-text { display: flex; flex: 1; min-width: 0;
                                // flex-direction: column; font-size: 0.875rem }`.
                                this.child(
                                    div()
                                        .flex()
                                        .flex_col()
                                        .flex_1()
                                        .min_w_0()
                                        .text_size(rem(14.))
                                        .line_height(rem(18.))
                                        .text_color(color(ColorRole::TextPrimary))
                                        .child(item.text)
                                        .children(sub),
                                )
                            }
                        })
                        .when_some(earlier, |this, f| {
                            this.child(
                                Button::new(
                                    (id.clone(), SharedString::from(format!("earlier-{i}"))),
                                    texts.earlier.clone(),
                                )
                                .variant(ButtonVariant::Ghost)
                                .size(ButtonSize::Sm)
                                .on_click(move |_, w, cx| f(i, w, cx)),
                            )
                        })
                        .child(
                            Button::new(
                                (id.clone(), SharedString::from(format!("send-{i}"))),
                                texts.send_now.clone(),
                            )
                            .variant(ButtonVariant::Ghost)
                            .size(ButtonSize::Sm)
                            .when_some(send, |b, f| b.on_click(move |_, w, cx| f(i, w, cx))),
                        )
                        .child(
                            Button::new(
                                (id.clone(), SharedString::from(format!("edit-{i}"))),
                                texts.edit.clone(),
                            )
                            .icon(CarbonIcon::Edit)
                            .icon_only(true)
                            .variant(ButtonVariant::Ghost)
                            .size(ButtonSize::Sm)
                            .when_some(edit, |b, f| b.on_click(move |_, w, cx| f(i, w, cx))),
                        )
                        .child(
                            Button::new(
                                (id.clone(), SharedString::from(format!("remove-{i}"))),
                                texts.remove.clone(),
                            )
                            .icon(CarbonIcon::TrashCan)
                            .icon_only(true)
                            .variant(ButtonVariant::Ghost)
                            .size(ButtonSize::Sm)
                            .when_some(remove, |b, f| b.on_click(move |_, w, cx| f(i, w, cx))),
                        )
                        .into_any_element()
                })
                .collect::<Vec<_>>()
        });
        // `.t3-queue { background: layer-01 }`.
        div()
            .flex()
            .flex_col()
            .w_full()
            .bg(color(ColorRole::Layer01))
            .when(self.bordered, |this| {
                this.shadow(press::inset_frame(color(ColorRole::BorderSubtle01)))
            })
            .child(head)
            .when_some(rows, |this, rows| this.children(rows))
            .min_w_0()
    }
}