lurq 0.41.2

A Rust UI toolkit with typed components, retained state, reactive signals, GPU rendering, and DevTools.
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
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
mod button;
#[cfg(feature = "canvas")]
mod canvas;
mod checkbox;
mod column;
mod drag_container;
mod draggable;
mod drop_zone;
#[cfg(feature = "form")]
mod form;
#[cfg(all(feature = "raster", feature = "wgpu"))]
mod gpu_viewport;
#[cfg(feature = "raster")]
mod image;
#[cfg(feature = "router")]
mod link;
#[cfg(feature = "markdown")]
mod markdown;
#[cfg(feature = "router")]
mod outlet;
mod popup;
mod rect;
#[cfg(feature = "router")]
mod router_component;
mod row;
mod scroll;
mod select;
mod slider;
mod slot;
mod spacer;
mod stack;
#[cfg(feature = "svg")]
mod svg;
mod text;
mod text_input;
#[cfg(feature = "raster")]
mod video;
mod virtualized_list;
mod window_chrome;
mod window_controls;

pub use button::Button;
#[cfg(feature = "canvas")]
pub use canvas::Canvas;
pub use checkbox::Checkbox;
pub use column::Column;
pub use drag_container::{DragBounds, DragContainer, DragContainerProps};
pub use draggable::{DragMovement, DragOverridePolicy, Draggable, DraggableProps, DropMissBehavior};
pub use drop_zone::{DropZone, DropZoneProps};
#[cfg(feature = "form")]
pub(crate) use form::FormContext;
#[cfg(feature = "form")]
pub use form::{
  Control, ControlOptions, ControlState, ErrorVisibility, Form, FormCheckboxInput, FormCheckboxInputProps,
  FormControlField, FormData, FormErrors, FormField, FormFieldProps, FormHandle, FormOptions, FormPrimaryButton,
  FormPrimaryButtonProps, FormProps, FormSecondaryButton, FormSecondaryButtonProps, FormSliderInput,
  FormSliderInputProps, FormTextInput, FormTextInputProps, FormValue, FormValues, ResolvedControl, ValidationResult,
  validators,
};
#[cfg(all(feature = "raster", feature = "wgpu"))]
pub use gpu_viewport::GpuViewport;
#[cfg(feature = "raster")]
pub use image::Image;
#[cfg(feature = "router")]
pub use link::Link;
#[cfg(feature = "markdown")]
pub use markdown::{Markdown, MarkdownLink, MarkdownProps};
#[cfg(feature = "router")]
pub use outlet::Outlet;
pub use popup::{Popover, Popup};
pub use rect::Rect;
#[cfg(feature = "router")]
pub use router_component::{Router, RouterProps};
pub use row::Row;
pub use scroll::{ScrollBoth, ScrollHorizontal, ScrollVertical};
pub use select::{Select, SelectOption};
pub use slider::Slider;
pub use slot::Slot;
pub use spacer::Spacer;
pub use stack::Stack;
#[cfg(feature = "svg")]
pub use svg::Svg;
pub use text::{Text, TextOverflow};
pub use text_input::{TextInput, TextInputOverflow, TextInputOverflowAnchor};
#[cfg(feature = "raster")]
pub use video::Video;
pub use virtualized_list::VirtualizedList;
pub use window_chrome::{
  ChromeBorderPolicy, ChromeTitleBar, ResizeHandlePlacement, ResizeHandlePolicy, WindowChrome, WindowChromeMetrics,
  WindowChromeMode, WindowChromeProps,
};
pub use window_controls::{
  TrafficLightColors, WindowControlColors, WindowControlContent, WindowControlKind, WindowControlStyle, WindowControls,
};

pub use crate::app::ctx::{
  CollisionStrategy, Modal, ModalTarget, OpenState, OutsidePress, Overlay, Parent, Placement, Root,
};

#[macro_export]
macro_rules! impl_into_node {
  ($struct_name:ident) => {
    pub struct $struct_name {
      pub(crate) node: Box<$crate::node::Node>,
    }

    impl $struct_name {
      pub(crate) fn from_node(node: $crate::node::Node) -> Self {
        Self {
          node: Box::new(node.with_tag_name(Self::tag_name())),
        }
      }

      pub(crate) fn update_node(&mut self, f: impl FnOnce(&mut $crate::node::Node)) {
        f(&mut *self.node);
      }

      pub(crate) fn tag_name() -> std::sync::Arc<str> {
        std::sync::Arc::from(stringify!($struct_name))
      }

      pub fn node_id(&self) -> $crate::core::NodeId {
        self.node.node_id()
      }

      pub fn key(mut self, key: impl Into<std::sync::Arc<str>>) -> Self {
        let key = key.into();
        self.update_node(|node| node.set_component_key(Some(&key)));
        self
      }

      /// Attach a semantic annotation surfaced to tooling — the devtools
      /// tree and the MCP `lurq_read_tree` — so agents can find and target
      /// this element, e.g. `.describe("role", "save-button")`. A no-op
      /// unless a tooling feature (`devtools`/`mcp`) is enabled.
      pub fn describe(mut self, name: impl Into<std::sync::Arc<str>>, value: impl Into<std::sync::Arc<str>>) -> Self {
        let name = name.into();
        let value = value.into();
        self.update_node(|node| $crate::node::NodeUpdate::describe(node, name, value));
        self
      }

      /// HTML-like `id` attribute for `Tree::get_element_by_id` lookup.
      /// Also participates in retained-node identity across sibling changes.
      /// Keep IDs stable; changing one can reset the node's runtime state.
      pub fn id(mut self, id: impl Into<std::sync::Arc<str>>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::id(node, id));
        self
      }

      /// Appends an HTML-like class for `Tree::get_elements_by_class_name`
      /// lookup. Classes do not affect reconciliation or styling.
      pub fn class(mut self, class: impl Into<std::sync::Arc<str>>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::class(node, class));
        self
      }

      /// Appends several classes at once; see `class`.
      pub fn classes<C: Into<std::sync::Arc<str>>>(mut self, classes: impl IntoIterator<Item = C>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::classes(node, classes));
        self
      }

      pub fn background(mut self, color: impl Into<$crate::node::BackgroundColor>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::background(node, color));
        self
      }

      pub fn background_gradient(mut self, gradient: impl Into<$crate::node::Gradient>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::background_gradient(node, gradient));
        self
      }

      /// CSS-like `box-shadow`: a [`ShadowStyle`](crate::app::theme::ShadowStyle)
      /// theme role, one [`BoxShadow`](crate::node::BoxShadow), or a list
      /// (the first on top). Paint only: it does not change layout or hit testing.
      pub fn box_shadow(mut self, shadow: impl Into<$crate::node::BoxShadowValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::box_shadow(node, shadow));
        self
      }

      pub fn size(
        mut self,
        width: impl Into<$crate::node::dimension::Dimension>,
        height: impl Into<$crate::node::dimension::Dimension>,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::size(node, width, height));
        self
      }

      pub fn width(mut self, width: impl Into<$crate::node::dimension::Dimension>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::width(node, width));
        self
      }

      pub fn height(mut self, height: impl Into<$crate::node::dimension::Dimension>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::height(node, height));
        self
      }

      pub fn min_width(mut self, width: impl Into<$crate::node::dimension::Dimension>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::min_width(node, width));
        self
      }

      pub fn max_width(mut self, width: impl Into<$crate::node::dimension::Dimension>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::max_width(node, width));
        self
      }

      pub fn min_height(mut self, height: impl Into<$crate::node::dimension::Dimension>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::min_height(node, height));
        self
      }

      pub fn max_height(mut self, height: impl Into<$crate::node::dimension::Dimension>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::max_height(node, height));
        self
      }

      pub fn min_size(
        mut self,
        width: impl Into<$crate::node::dimension::Dimension>,
        height: impl Into<$crate::node::dimension::Dimension>,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::min_size(node, width, height));
        self
      }

      pub fn max_size(
        mut self,
        width: impl Into<$crate::node::dimension::Dimension>,
        height: impl Into<$crate::node::dimension::Dimension>,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::max_size(node, width, height));
        self
      }

      pub fn padding_left(mut self, val: impl Into<$crate::node::SpacingValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::padding_left(node, val));
        self
      }

      pub fn padding_right(mut self, val: impl Into<$crate::node::SpacingValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::padding_right(node, val));
        self
      }

      pub fn padding_top(mut self, val: impl Into<$crate::node::SpacingValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::padding_top(node, val));
        self
      }

      pub fn padding_bottom(mut self, val: impl Into<$crate::node::SpacingValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::padding_bottom(node, val));
        self
      }

      pub fn padding_horizontal(mut self, val: impl Into<$crate::node::SpacingValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::padding_horizontal(node, val));
        self
      }

      pub fn padding_vertical(mut self, val: impl Into<$crate::node::SpacingValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::padding_vertical(node, val));
        self
      }

      pub fn padding(mut self, padding: impl Into<$crate::node::padding::Padding>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::padding(node, padding));
        self
      }

      pub fn padding_custom(mut self, padding: $crate::node::padding::Padding) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::padding_custom(node, padding));
        self
      }

      pub fn frame(mut self, frame: $crate::layout::layout_kind::FrameConstraints) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::frame(node, frame));
        self
      }

      pub fn offset(mut self, x: f32, y: f32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::offset(node, x, y));
        self
      }

      pub fn relative(mut self, x: f32, y: f32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::relative(node, x, y));
        self
      }

      pub fn absolute(
        mut self,
        x: f32,
        y: f32,
        width: impl Into<$crate::node::dimension::Dimension>,
        height: impl Into<$crate::node::dimension::Dimension>,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::absolute(node, x, y, width, height));
        self
      }

      pub fn absolute_position(mut self, x: f32, y: f32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::absolute_position(node, x, y));
        self
      }

      pub fn align(mut self, alignment: $crate::layout::Alignment) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::align(node, alignment));
        self
      }

      pub fn flex(mut self, factor: f32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::flex(node, factor));
        self
      }

      pub fn flex_shrink(mut self, factor: f32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::flex_shrink(node, factor));
        self
      }

      pub fn flex_full(mut self, grow: f32, shrink: f32, basis: Option<f32>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::flex_full(node, grow, shrink, basis));
        self
      }

      /// The give-way order of a shrinking child (one with a `flex_shrink`
      /// factor) in a single-line `Row`/`Column`; 0 by default. When the line
      /// overflows, the children with the lowest order give way first, down
      /// to their [`ShrinkLimit`](crate::layout::layout_kind::ShrinkLimit),
      /// before any child of the next order shrinks at all. Children of one
      /// order share their part of the overflow by shrink factor, in whole
      /// pixels except for the child with the largest factor.
      pub fn shrink_order(mut self, order: i32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::shrink_order(node, order));
        self
      }

      /// How far a shrinking child (one with a `flex_shrink` factor) of a
      /// single-line `Row`/`Column` gives way: down to its minimum size (the
      /// default), down to its content, or not at all and then dropped. See
      /// [`ShrinkLimit`](crate::layout::layout_kind::ShrinkLimit).
      pub fn shrink_limit(mut self, limit: $crate::layout::layout_kind::ShrinkLimit) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::shrink_limit(node, limit));
        self
      }

      /// Lets a shrinking child (one with a `flex_shrink` factor) of a
      /// single-line `Row`/`Column` give way in two steps: it first shrinks
      /// like its [`ShrinkLimit`](crate::layout::layout_kind::ShrinkLimit),
      /// but no further than `size` on the main axis, and when its order
      /// still cannot absorb the overflow with every shrinking child at its
      /// floor, it drops like `ShrinkLimit::Drop` before the next order
      /// shrinks. A child narrower than `size` drops without shrinking. A
      /// negative or NaN `size` counts as 0.
      pub fn shrink_drop_below(mut self, size: f32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::shrink_drop_below(node, size));
        self
      }

      pub fn corner_radius(mut self, radius: impl Into<$crate::node::RadiusValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::corner_radius(node, radius));
        self
      }

      pub fn corner_radius_custom(mut self, radius: $crate::node::border::BorderRadius) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::corner_radius_custom(node, radius));
        self
      }

      pub fn corner_radius_top_left(mut self, radius: impl Into<$crate::node::RadiusValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::corner_radius_top_left(node, radius));
        self
      }

      pub fn corner_radius_top_right(mut self, radius: impl Into<$crate::node::RadiusValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::corner_radius_top_right(node, radius));
        self
      }

      pub fn corner_radius_bottom_right(mut self, radius: impl Into<$crate::node::RadiusValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::corner_radius_bottom_right(node, radius));
        self
      }

      pub fn corner_radius_bottom_left(mut self, radius: impl Into<$crate::node::RadiusValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::corner_radius_bottom_left(node, radius));
        self
      }

      pub fn rounded(mut self, radius: impl Into<$crate::node::RadiusValue>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::rounded(node, radius));
        self
      }

      pub fn border_inside(
        mut self,
        width: impl Into<$crate::node::BorderSizeValue>,
        color: impl Into<$crate::node::BackgroundColor>,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border_inside(node, width, color));
        self
      }

      pub fn border_outside(
        mut self,
        width: impl Into<$crate::node::BorderSizeValue>,
        color: impl Into<$crate::node::BackgroundColor>,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border_outside(node, width, color));
        self
      }

      pub fn border_center(
        mut self,
        width: impl Into<$crate::node::BorderSizeValue>,
        color: impl Into<$crate::node::BackgroundColor>,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border_center(node, width, color));
        self
      }

      pub fn border(mut self, border: $crate::node::border::Border) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border(node, border));
        self
      }

      pub fn border_custom(mut self, border: $crate::node::border::Borders) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border_custom(node, border));
        self
      }

      pub fn border_top(mut self, border: $crate::node::border::Border) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border_top(node, border));
        self
      }

      pub fn border_right(mut self, border: $crate::node::border::Border) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border_right(node, border));
        self
      }

      pub fn border_bottom(mut self, border: $crate::node::border::Border) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border_bottom(node, border));
        self
      }

      pub fn border_left(mut self, border: $crate::node::border::Border) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::border_left(node, border));
        self
      }

      #[cfg(feature = "raster")]
      pub fn background_image(mut self, data: impl Into<$crate::images::ImageKind>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::background_image(node, data));
        self
      }

      #[cfg(feature = "raster")]
      pub fn background_size(mut self, size: $crate::node::BackgroundSize) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::background_size(node, size));
        self
      }

      #[cfg(feature = "raster")]
      pub fn background_cover(mut self) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::background_cover(node));
        self
      }

      #[cfg(feature = "raster")]
      pub fn background_contain(mut self) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::background_contain(node));
        self
      }

      pub fn cursor(mut self, cursor: $crate::node::CursorIcon) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::cursor(node, cursor));
        self
      }

      pub fn hovered_style(mut self, style: $crate::node::Style) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::hovered_style(node, style));
        self
      }

      pub fn active_style(mut self, style: $crate::node::Style) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::active_style(node, style));
        self
      }

      pub fn focused_style(mut self, style: $crate::node::Style) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::focused_style(node, style));
        self
      }

      pub fn hovered(mut self, f: impl FnOnce($crate::node::Style) -> $crate::node::Style) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::hovered(node, f));
        self
      }

      pub fn active(mut self, f: impl FnOnce($crate::node::Style) -> $crate::node::Style) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::active(node, f));
        self
      }

      pub fn focused(mut self, f: impl FnOnce($crate::node::Style) -> $crate::node::Style) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::focused(node, f));
        self
      }

      pub fn on_click(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_click(node, f));
        self
      }

      pub fn off_click(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_click(node, f));
        self
      }

      pub fn on_mouse_click(
        mut self,
        button: $crate::app::events::MouseButton,
        f: impl $crate::node::IntoMouseEventHandler,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_mouse_click(node, button, f));
        self
      }

      pub fn off_mouse_click(
        mut self,
        button: $crate::app::events::MouseButton,
        f: impl $crate::node::IntoMouseEventHandler,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_mouse_click(node, button, f));
        self
      }

      pub fn on_dblclick(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_dblclick(node, f));
        self
      }

      pub fn off_dblclick(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_dblclick(node, f));
        self
      }

      pub fn on_mouse_down(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_mouse_down(node, f));
        self
      }

      pub fn off_mouse_down(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_mouse_down(node, f));
        self
      }

      pub fn on_mouse_up(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_mouse_up(node, f));
        self
      }

      pub fn off_mouse_up(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_mouse_up(node, f));
        self
      }

      pub fn on_mouse_move(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_mouse_move(node, f));
        self
      }

      pub fn off_mouse_move(mut self, f: impl $crate::node::IntoMouseEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_mouse_move(node, f));
        self
      }

      pub fn start_drag_buttons(mut self, buttons: $crate::app::events::MouseButtonMask) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::start_drag_buttons(node, buttons));
        self
      }

      pub fn on_drag_start(mut self, f: impl $crate::node::IntoDragEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_drag_start(node, f));
        self
      }

      pub fn off_drag_start(mut self, f: impl $crate::node::IntoDragEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_drag_start(node, f));
        self
      }

      pub fn on_drag_move(mut self, f: impl $crate::node::IntoDragEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_drag_move(node, f));
        self
      }

      pub fn off_drag_move(mut self, f: impl $crate::node::IntoDragEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_drag_move(node, f));
        self
      }

      pub fn on_drag_end(mut self, f: impl $crate::node::IntoDragEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_drag_end(node, f));
        self
      }

      pub fn off_drag_end(mut self, f: impl $crate::node::IntoDragEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_drag_end(node, f));
        self
      }

      pub fn on_drop(mut self, f: impl $crate::node::IntoDropEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_drop(node, f));
        self
      }

      pub fn off_drop(mut self, f: impl $crate::node::IntoDropEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_drop(node, f));
        self
      }

      pub fn on_mouse_enter(mut self, f: impl $crate::node::IntoVoidEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_mouse_enter(node, f));
        self
      }

      pub fn off_mouse_enter(mut self, f: impl $crate::node::IntoVoidEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_mouse_enter(node, f));
        self
      }

      pub fn on_mouse_leave(mut self, f: impl $crate::node::IntoVoidEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_mouse_leave(node, f));
        self
      }

      pub fn off_mouse_leave(mut self, f: impl $crate::node::IntoVoidEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_mouse_leave(node, f));
        self
      }

      pub fn on_key_down(mut self, f: impl $crate::node::IntoKeyboardEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_key_down(node, f));
        self
      }

      pub fn off_key_down(mut self, f: impl $crate::node::IntoKeyboardEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_key_down(node, f));
        self
      }

      pub fn on_key_up(mut self, f: impl $crate::node::IntoKeyboardEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_key_up(node, f));
        self
      }

      pub fn off_key_up(mut self, f: impl $crate::node::IntoKeyboardEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_key_up(node, f));
        self
      }

      pub fn on_focus(mut self, f: impl $crate::node::IntoVoidEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_focus(node, f));
        self
      }

      pub fn off_focus(mut self, f: impl $crate::node::IntoVoidEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_focus(node, f));
        self
      }

      pub fn on_blur(mut self, f: impl $crate::node::IntoVoidEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_blur(node, f));
        self
      }

      pub fn off_blur(mut self, f: impl $crate::node::IntoVoidEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_blur(node, f));
        self
      }

      pub fn on_scroll(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_scroll(node, f));
        self
      }

      pub fn off_scroll(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_scroll(node, f));
        self
      }

      pub fn on_scroll_start(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_scroll_start(node, f));
        self
      }

      pub fn off_scroll_start(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_scroll_start(node, f));
        self
      }

      pub fn on_scroll_end(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_scroll_end(node, f));
        self
      }

      pub fn off_scroll_end(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_scroll_end(node, f));
        self
      }

      pub fn on_scroll_reach_top(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_scroll_reach_top(node, f));
        self
      }

      pub fn off_scroll_reach_top(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_scroll_reach_top(node, f));
        self
      }

      pub fn on_scroll_reach_bottom(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::on_scroll_reach_bottom(node, f));
        self
      }

      pub fn off_scroll_reach_bottom(mut self, f: impl $crate::node::IntoScrollEventHandler) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::off_scroll_reach_bottom(node, f));
        self
      }

      pub fn scrollbar(mut self, style: $crate::layout::scrollbar::ScrollBarStyle) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::scrollbar(node, style));
        self
      }

      pub fn scrollbar_hovered(
        mut self,
        f: impl Fn($crate::layout::scrollbar::ScrollBarStyle) -> $crate::layout::scrollbar::ScrollBarStyle
        + Send
        + Sync
        + 'static,
      ) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::scrollbar_hovered(node, f));
        self
      }

      pub fn hit_test(mut self, behavior: $crate::node::HitTestBehavior) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::hit_test(node, behavior));
        self
      }

      pub fn pointer_events_none(mut self) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::pointer_events_none(node));
        self
      }

      pub fn ref_element(mut self, element_ref: impl Into<$crate::core::ElementRef>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::ref_element(node, element_ref));
        self
      }

      pub fn interactive(mut self, state: $crate::node::interaction_state::InteractionState) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::interactive(node, state));
        self
      }

      /// Whether the element can take focus. Buttons, text inputs,
      /// checkboxes, sliders, selects and elements with a `tab_index` are
      /// focusable by default. `focusable(true)` makes any element focusable
      /// by click and `Ctx::focus`; `focusable(false)` keeps it from ever
      /// taking focus, by click, Tab or request.
      pub fn focusable(mut self, focusable: bool) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::focusable(node, focusable));
        self
      }

      /// HTML `tabindex`. Inside a form, controls are in the Tab order
      /// without one; outside a form, only elements with `tab_index(0)` or
      /// higher are. Positive values come first in ascending order, then `0`
      /// (and unset form controls) in tree order. `-1` removes the element
      /// from the Tab order but keeps it focusable by click. Setting a tab
      /// index makes the element focusable unless it is `focusable(false)`.
      pub fn tab_index(mut self, tab_index: i32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::tab_index(node, tab_index));
        self
      }

      #[cfg(feature = "form")]
      pub fn name(mut self, name: impl Into<std::sync::Arc<str>>) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::name(node, name));
        self
      }

      pub fn clip(mut self) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::clip(node));
        self
      }

      pub fn overflow_visible(mut self) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::overflow_visible(node));
        self
      }

      pub fn intrinsic(mut self, width: f32, height: f32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::intrinsic(node, width, height));
        self
      }

      pub fn opacity(mut self, value: f32) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::opacity(node, value));
        self
      }

      pub fn transition(mut self, spec: $crate::animation::Transition) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::transition(node, spec));
        self
      }

      pub fn animation(mut self, spec: $crate::animation::Animation) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::animation(node, spec));
        self
      }

      pub fn transform(mut self, t: $crate::node::transform::Transform2D) -> Self {
        self.update_node(|node| $crate::node::NodeUpdate::transform(node, t));
        self
      }
    }

    impl From<$struct_name> for $crate::node::Element {
      fn from(component: $struct_name) -> Self {
        $crate::node::Element::from_boxed_node(component.node)
      }
    }
  };
}