@molecule/app-ui-react 3.0.4 → 3.1.0
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 +215 -6
- package/dist/components/OptimisticToggleButton.d.ts +45 -0
- package/dist/components/OptimisticToggleButton.d.ts.map +1 -0
- package/dist/components/OptimisticToggleButton.js +42 -0
- package/dist/components/OptimisticToggleButton.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-11-11T02:37:03.267Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-ui-react
|
|
@@ -13,6 +13,12 @@ React UI components for molecule.dev.
|
|
|
13
13
|
Provides React implementations of the `@molecule/app-ui` component
|
|
14
14
|
interfaces using the UIClassMap abstraction from `@molecule/app-ui`.
|
|
15
15
|
|
|
16
|
+
Server-backed boolean actions use `OptimisticToggleButton`: pass a loaded `value`, a
|
|
17
|
+
`commit(desired)` returning the confirmed boolean, and translated `activeLabel` and
|
|
18
|
+
`inactiveLabel`. The label and pressed state change on the first tap; saves run in order
|
|
19
|
+
and the newest failure rolls back. Mount after the initial record loads, key by record,
|
|
20
|
+
and keep it mounted during refetches. Authorization and self-record checks stay in the app.
|
|
21
|
+
|
|
16
22
|
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
17
23
|
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
18
24
|
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
@@ -87,14 +93,17 @@ interface BaseProps {
|
|
|
87
93
|
* Additional CSS class name(s).
|
|
88
94
|
*/
|
|
89
95
|
className?: string
|
|
96
|
+
|
|
90
97
|
/**
|
|
91
98
|
* Inline styles.
|
|
92
99
|
*/
|
|
93
100
|
style?: CSSProperties
|
|
101
|
+
|
|
94
102
|
/**
|
|
95
103
|
* Test ID for automated testing.
|
|
96
104
|
*/
|
|
97
105
|
testId?: string
|
|
106
|
+
|
|
98
107
|
/**
|
|
99
108
|
* Automation ID for AI agents and E2E tests. Maps to the `data-mol-id`
|
|
100
109
|
* HTML attribute. Use `molId()` from `./automation.js` to generate
|
|
@@ -102,6 +111,7 @@ interface BaseProps {
|
|
|
102
111
|
* attributes; accessible names come from labels/`aria-*`.)
|
|
103
112
|
*/
|
|
104
113
|
automationId?: string
|
|
114
|
+
|
|
105
115
|
/**
|
|
106
116
|
* Whether the component is disabled.
|
|
107
117
|
*/
|
|
@@ -250,34 +260,42 @@ interface ButtonProps extends ButtonElementProps {
|
|
|
250
260
|
* Button content.
|
|
251
261
|
*/
|
|
252
262
|
children?: Children
|
|
263
|
+
|
|
253
264
|
/**
|
|
254
265
|
* Visual variant.
|
|
255
266
|
*/
|
|
256
267
|
variant?: ButtonVariant
|
|
268
|
+
|
|
257
269
|
/**
|
|
258
270
|
* Color scheme.
|
|
259
271
|
*/
|
|
260
272
|
color?: ColorVariant
|
|
273
|
+
|
|
261
274
|
/**
|
|
262
275
|
* Button size.
|
|
263
276
|
*/
|
|
264
277
|
size?: ButtonSize
|
|
278
|
+
|
|
265
279
|
/**
|
|
266
280
|
* Whether the button is in a loading state.
|
|
267
281
|
*/
|
|
268
282
|
loading?: boolean
|
|
283
|
+
|
|
269
284
|
/**
|
|
270
285
|
* Loading text to display.
|
|
271
286
|
*/
|
|
272
287
|
loadingText?: string
|
|
288
|
+
|
|
273
289
|
/**
|
|
274
290
|
* Whether the button takes full width.
|
|
275
291
|
*/
|
|
276
292
|
fullWidth?: boolean
|
|
293
|
+
|
|
277
294
|
/**
|
|
278
295
|
* Icon to display before the label.
|
|
279
296
|
*/
|
|
280
297
|
leftIcon?: Children
|
|
298
|
+
|
|
281
299
|
/**
|
|
282
300
|
* Icon to display after the label.
|
|
283
301
|
*/
|
|
@@ -295,43 +313,53 @@ interface InputProps extends InputElementProps {
|
|
|
295
313
|
* Input type.
|
|
296
314
|
*/
|
|
297
315
|
type?: InputType
|
|
316
|
+
|
|
298
317
|
/**
|
|
299
318
|
* Input size.
|
|
300
319
|
*/
|
|
301
320
|
size?: Size
|
|
321
|
+
|
|
302
322
|
/**
|
|
303
323
|
* Horizontal text alignment inside the input (see
|
|
304
324
|
* {@link InputClassOptions.align}). Defaults to the bond's own style.
|
|
305
325
|
*/
|
|
306
326
|
align?: 'left' | 'center'
|
|
327
|
+
|
|
307
328
|
/**
|
|
308
329
|
* Label text.
|
|
309
330
|
*/
|
|
310
331
|
label?: string
|
|
332
|
+
|
|
311
333
|
/**
|
|
312
334
|
* Error message.
|
|
313
335
|
*/
|
|
314
336
|
error?: string
|
|
337
|
+
|
|
315
338
|
/**
|
|
316
339
|
* Hint/help text.
|
|
317
340
|
*/
|
|
318
341
|
hint?: string
|
|
342
|
+
|
|
319
343
|
/**
|
|
320
344
|
* Element to display on the left.
|
|
321
345
|
*/
|
|
322
346
|
leftElement?: Children
|
|
347
|
+
|
|
323
348
|
/**
|
|
324
349
|
* Element to display on the right.
|
|
325
350
|
*/
|
|
326
351
|
rightElement?: Children
|
|
352
|
+
|
|
327
353
|
/**
|
|
328
354
|
* Whether to show a clear button.
|
|
329
355
|
*/
|
|
330
356
|
clearable?: boolean
|
|
357
|
+
|
|
331
358
|
/**
|
|
332
359
|
* Called when the clear button is clicked.
|
|
333
360
|
*/
|
|
334
361
|
onClear?: () => void
|
|
362
|
+
|
|
335
363
|
/**
|
|
336
364
|
* Accessible label for the clear button.
|
|
337
365
|
* @default 'Clear'
|
|
@@ -351,26 +379,32 @@ interface TextareaProps extends TextareaElementProps {
|
|
|
351
379
|
* `size` as a neighboring Input for identical font sizes.
|
|
352
380
|
*/
|
|
353
381
|
size?: Size
|
|
382
|
+
|
|
354
383
|
/**
|
|
355
384
|
* Label text.
|
|
356
385
|
*/
|
|
357
386
|
label?: string
|
|
387
|
+
|
|
358
388
|
/**
|
|
359
389
|
* Error message.
|
|
360
390
|
*/
|
|
361
391
|
error?: string
|
|
392
|
+
|
|
362
393
|
/**
|
|
363
394
|
* Hint/help text.
|
|
364
395
|
*/
|
|
365
396
|
hint?: string
|
|
397
|
+
|
|
366
398
|
/**
|
|
367
399
|
* Whether the textarea auto-resizes.
|
|
368
400
|
*/
|
|
369
401
|
autoResize?: boolean
|
|
402
|
+
|
|
370
403
|
/**
|
|
371
404
|
* Minimum number of rows.
|
|
372
405
|
*/
|
|
373
406
|
minRows?: number
|
|
407
|
+
|
|
374
408
|
/**
|
|
375
409
|
* Maximum number of rows.
|
|
376
410
|
*/
|
|
@@ -388,14 +422,17 @@ interface SelectOption<T = string> {
|
|
|
388
422
|
* Option value.
|
|
389
423
|
*/
|
|
390
424
|
value: T
|
|
425
|
+
|
|
391
426
|
/**
|
|
392
427
|
* Display label.
|
|
393
428
|
*/
|
|
394
429
|
label: string
|
|
430
|
+
|
|
395
431
|
/**
|
|
396
432
|
* Whether the option is disabled.
|
|
397
433
|
*/
|
|
398
434
|
disabled?: boolean
|
|
435
|
+
|
|
399
436
|
/**
|
|
400
437
|
* Option group (for grouped selects).
|
|
401
438
|
*/
|
|
@@ -413,34 +450,42 @@ interface SelectProps<T = string> extends SelectElementProps {
|
|
|
413
450
|
* Select options.
|
|
414
451
|
*/
|
|
415
452
|
options: SelectOption<T>[]
|
|
453
|
+
|
|
416
454
|
/**
|
|
417
455
|
* Current value.
|
|
418
456
|
*/
|
|
419
457
|
value?: T
|
|
458
|
+
|
|
420
459
|
/**
|
|
421
460
|
* Change handler (with typed value).
|
|
422
461
|
*/
|
|
423
462
|
onValueChange?: (value: T) => void
|
|
463
|
+
|
|
424
464
|
/**
|
|
425
465
|
* Select size.
|
|
426
466
|
*/
|
|
427
467
|
size?: Size
|
|
468
|
+
|
|
428
469
|
/**
|
|
429
470
|
* Label text.
|
|
430
471
|
*/
|
|
431
472
|
label?: string
|
|
473
|
+
|
|
432
474
|
/**
|
|
433
475
|
* Placeholder text.
|
|
434
476
|
*/
|
|
435
477
|
placeholder?: string
|
|
478
|
+
|
|
436
479
|
/**
|
|
437
480
|
* Error message.
|
|
438
481
|
*/
|
|
439
482
|
error?: string
|
|
483
|
+
|
|
440
484
|
/**
|
|
441
485
|
* Hint/help text.
|
|
442
486
|
*/
|
|
443
487
|
hint?: string
|
|
488
|
+
|
|
444
489
|
/**
|
|
445
490
|
* Whether to allow clearing the selection.
|
|
446
491
|
*/
|
|
@@ -458,18 +503,22 @@ interface CheckboxProps extends InputElementProps {
|
|
|
458
503
|
* Checkbox label.
|
|
459
504
|
*/
|
|
460
505
|
label?: Children
|
|
506
|
+
|
|
461
507
|
/**
|
|
462
508
|
* Whether the checkbox is checked.
|
|
463
509
|
*/
|
|
464
510
|
checked?: boolean
|
|
511
|
+
|
|
465
512
|
/**
|
|
466
513
|
* Whether the checkbox is in an indeterminate state.
|
|
467
514
|
*/
|
|
468
515
|
indeterminate?: boolean
|
|
516
|
+
|
|
469
517
|
/**
|
|
470
518
|
* Checkbox size.
|
|
471
519
|
*/
|
|
472
520
|
size?: Size
|
|
521
|
+
|
|
473
522
|
/**
|
|
474
523
|
* Error message.
|
|
475
524
|
*/
|
|
@@ -487,10 +536,12 @@ interface RadioOption<T = string> {
|
|
|
487
536
|
* Option value.
|
|
488
537
|
*/
|
|
489
538
|
value: T
|
|
539
|
+
|
|
490
540
|
/**
|
|
491
541
|
* Display label.
|
|
492
542
|
*/
|
|
493
543
|
label: Children
|
|
544
|
+
|
|
494
545
|
/**
|
|
495
546
|
* Whether the option is disabled.
|
|
496
547
|
*/
|
|
@@ -508,22 +559,27 @@ interface RadioGroupProps<T = string> extends BaseProps {
|
|
|
508
559
|
* Radio options.
|
|
509
560
|
*/
|
|
510
561
|
options: RadioOption<T>[]
|
|
562
|
+
|
|
511
563
|
/**
|
|
512
564
|
* Current value.
|
|
513
565
|
*/
|
|
514
566
|
value?: T
|
|
567
|
+
|
|
515
568
|
/**
|
|
516
569
|
* Change handler.
|
|
517
570
|
*/
|
|
518
571
|
onChange?: (value: T) => void
|
|
572
|
+
|
|
519
573
|
/**
|
|
520
574
|
* Radio size.
|
|
521
575
|
*/
|
|
522
576
|
size?: Size
|
|
577
|
+
|
|
523
578
|
/**
|
|
524
579
|
* Group label.
|
|
525
580
|
*/
|
|
526
581
|
label?: string
|
|
582
|
+
|
|
527
583
|
/**
|
|
528
584
|
* Shared `name` attribute for the group's radio inputs (used for native
|
|
529
585
|
* form submission). When omitted, a unique per-instance name is generated
|
|
@@ -533,10 +589,12 @@ interface RadioGroupProps<T = string> extends BaseProps {
|
|
|
533
589
|
* deselect each other.
|
|
534
590
|
*/
|
|
535
591
|
name?: string
|
|
592
|
+
|
|
536
593
|
/**
|
|
537
594
|
* Layout direction.
|
|
538
595
|
*/
|
|
539
596
|
direction?: 'horizontal' | 'vertical'
|
|
597
|
+
|
|
540
598
|
/**
|
|
541
599
|
* Error message.
|
|
542
600
|
*/
|
|
@@ -554,14 +612,17 @@ interface SwitchProps extends InputElementProps {
|
|
|
554
612
|
* Switch label.
|
|
555
613
|
*/
|
|
556
614
|
label?: Children
|
|
615
|
+
|
|
557
616
|
/**
|
|
558
617
|
* Whether the switch is on.
|
|
559
618
|
*/
|
|
560
619
|
checked?: boolean
|
|
620
|
+
|
|
561
621
|
/**
|
|
562
622
|
* Switch size.
|
|
563
623
|
*/
|
|
564
624
|
size?: Size
|
|
625
|
+
|
|
565
626
|
/**
|
|
566
627
|
* Color when on.
|
|
567
628
|
*/
|
|
@@ -579,46 +640,57 @@ interface ModalProps extends HTMLElementProps {
|
|
|
579
640
|
* Whether the modal is open.
|
|
580
641
|
*/
|
|
581
642
|
open: boolean
|
|
643
|
+
|
|
582
644
|
/**
|
|
583
645
|
* Called when the modal should close.
|
|
584
646
|
*/
|
|
585
647
|
onClose: () => void
|
|
648
|
+
|
|
586
649
|
/**
|
|
587
650
|
* Modal title.
|
|
588
651
|
*/
|
|
589
652
|
title?: string
|
|
653
|
+
|
|
590
654
|
/**
|
|
591
655
|
* Modal content.
|
|
592
656
|
*/
|
|
593
657
|
children?: Children
|
|
658
|
+
|
|
594
659
|
/**
|
|
595
660
|
* Modal size.
|
|
596
661
|
*/
|
|
597
662
|
size?: ModalSize
|
|
663
|
+
|
|
598
664
|
/**
|
|
599
665
|
* Whether to show a close button.
|
|
600
666
|
*/
|
|
601
667
|
showCloseButton?: boolean
|
|
668
|
+
|
|
602
669
|
/**
|
|
603
670
|
* Whether clicking the overlay closes the modal.
|
|
604
671
|
*/
|
|
605
672
|
closeOnOverlayClick?: boolean
|
|
673
|
+
|
|
606
674
|
/**
|
|
607
675
|
* Whether pressing Escape closes the modal.
|
|
608
676
|
*/
|
|
609
677
|
closeOnEscape?: boolean
|
|
678
|
+
|
|
610
679
|
/**
|
|
611
680
|
* Footer content (typically action buttons).
|
|
612
681
|
*/
|
|
613
682
|
footer?: Children
|
|
683
|
+
|
|
614
684
|
/**
|
|
615
685
|
* Whether the modal is centered vertically.
|
|
616
686
|
*/
|
|
617
687
|
centered?: boolean
|
|
688
|
+
|
|
618
689
|
/**
|
|
619
690
|
* Whether to prevent body scroll when open.
|
|
620
691
|
*/
|
|
621
692
|
preventScroll?: boolean
|
|
693
|
+
|
|
622
694
|
/**
|
|
623
695
|
* Accessible label for the close button.
|
|
624
696
|
* @default 'Close'
|
|
@@ -637,14 +709,17 @@ interface SpinnerProps extends BaseProps {
|
|
|
637
709
|
* Spinner size.
|
|
638
710
|
*/
|
|
639
711
|
size?: Size
|
|
712
|
+
|
|
640
713
|
/**
|
|
641
714
|
* Spinner color.
|
|
642
715
|
*/
|
|
643
716
|
color?: ColorVariant | string
|
|
717
|
+
|
|
644
718
|
/**
|
|
645
719
|
* Loading label (for accessibility).
|
|
646
720
|
*/
|
|
647
721
|
label?: string
|
|
722
|
+
|
|
648
723
|
/**
|
|
649
724
|
* Spinner thickness.
|
|
650
725
|
*/
|
|
@@ -662,22 +737,27 @@ interface AvatarProps extends HTMLElementProps {
|
|
|
662
737
|
* Image source URL.
|
|
663
738
|
*/
|
|
664
739
|
src?: string
|
|
740
|
+
|
|
665
741
|
/**
|
|
666
742
|
* Alt text for the image.
|
|
667
743
|
*/
|
|
668
744
|
alt?: string
|
|
745
|
+
|
|
669
746
|
/**
|
|
670
747
|
* Name for fallback initials.
|
|
671
748
|
*/
|
|
672
749
|
name?: string
|
|
750
|
+
|
|
673
751
|
/**
|
|
674
752
|
* Avatar size.
|
|
675
753
|
*/
|
|
676
754
|
size?: Size | number
|
|
755
|
+
|
|
677
756
|
/**
|
|
678
757
|
* Whether the avatar is rounded.
|
|
679
758
|
*/
|
|
680
759
|
rounded?: boolean
|
|
760
|
+
|
|
681
761
|
/**
|
|
682
762
|
* Fallback element when no image.
|
|
683
763
|
*/
|
|
@@ -695,18 +775,22 @@ interface BadgeProps extends HTMLElementProps {
|
|
|
695
775
|
* Badge content.
|
|
696
776
|
*/
|
|
697
777
|
children?: Children
|
|
778
|
+
|
|
698
779
|
/**
|
|
699
780
|
* Badge color.
|
|
700
781
|
*/
|
|
701
782
|
color?: ColorVariant
|
|
783
|
+
|
|
702
784
|
/**
|
|
703
785
|
* Badge variant.
|
|
704
786
|
*/
|
|
705
787
|
variant?: 'solid' | 'outline' | 'subtle'
|
|
788
|
+
|
|
706
789
|
/**
|
|
707
790
|
* Badge size.
|
|
708
791
|
*/
|
|
709
792
|
size?: Size
|
|
793
|
+
|
|
710
794
|
/**
|
|
711
795
|
* Whether the badge is rounded.
|
|
712
796
|
*/
|
|
@@ -724,18 +808,22 @@ interface TooltipProps extends HTMLElementProps {
|
|
|
724
808
|
* Tooltip content.
|
|
725
809
|
*/
|
|
726
810
|
content: Children
|
|
811
|
+
|
|
727
812
|
/**
|
|
728
813
|
* Element that triggers the tooltip.
|
|
729
814
|
*/
|
|
730
815
|
children: Children
|
|
816
|
+
|
|
731
817
|
/**
|
|
732
818
|
* Tooltip placement.
|
|
733
819
|
*/
|
|
734
820
|
placement?: TooltipPlacement
|
|
821
|
+
|
|
735
822
|
/**
|
|
736
823
|
* Delay before showing (ms).
|
|
737
824
|
*/
|
|
738
825
|
delay?: number
|
|
826
|
+
|
|
739
827
|
/**
|
|
740
828
|
* Whether the tooltip has an arrow.
|
|
741
829
|
*/
|
|
@@ -753,14 +841,17 @@ interface CardProps extends HTMLElementProps {
|
|
|
753
841
|
* Card content.
|
|
754
842
|
*/
|
|
755
843
|
children?: Children
|
|
844
|
+
|
|
756
845
|
/**
|
|
757
846
|
* Card variant.
|
|
758
847
|
*/
|
|
759
848
|
variant?: 'elevated' | 'outlined' | 'filled'
|
|
849
|
+
|
|
760
850
|
/**
|
|
761
851
|
* Whether the card is interactive (clickable).
|
|
762
852
|
*/
|
|
763
853
|
interactive?: boolean
|
|
854
|
+
|
|
764
855
|
/**
|
|
765
856
|
* Padding size.
|
|
766
857
|
*/
|
|
@@ -778,14 +869,17 @@ interface ContainerProps extends HTMLElementProps {
|
|
|
778
869
|
* Container content.
|
|
779
870
|
*/
|
|
780
871
|
children?: Children
|
|
872
|
+
|
|
781
873
|
/**
|
|
782
874
|
* Maximum width.
|
|
783
875
|
*/
|
|
784
876
|
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | string
|
|
877
|
+
|
|
785
878
|
/**
|
|
786
879
|
* Whether to center the container.
|
|
787
880
|
*/
|
|
788
881
|
centered?: boolean
|
|
882
|
+
|
|
789
883
|
/**
|
|
790
884
|
* Horizontal padding.
|
|
791
885
|
*/
|
|
@@ -803,22 +897,27 @@ interface FlexProps extends HTMLElementProps {
|
|
|
803
897
|
* Flex content.
|
|
804
898
|
*/
|
|
805
899
|
children?: Children
|
|
900
|
+
|
|
806
901
|
/**
|
|
807
902
|
* Flex direction.
|
|
808
903
|
*/
|
|
809
904
|
direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse'
|
|
905
|
+
|
|
810
906
|
/**
|
|
811
907
|
* Justify content.
|
|
812
908
|
*/
|
|
813
909
|
justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'
|
|
910
|
+
|
|
814
911
|
/**
|
|
815
912
|
* Align items.
|
|
816
913
|
*/
|
|
817
914
|
align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch'
|
|
915
|
+
|
|
818
916
|
/**
|
|
819
917
|
* Flex wrap.
|
|
820
918
|
*/
|
|
821
919
|
wrap?: 'wrap' | 'nowrap' | 'wrap-reverse'
|
|
920
|
+
|
|
822
921
|
/**
|
|
823
922
|
* Gap between items.
|
|
824
923
|
*/
|
|
@@ -836,22 +935,27 @@ interface GridProps extends HTMLElementProps {
|
|
|
836
935
|
* Grid content.
|
|
837
936
|
*/
|
|
838
937
|
children?: Children
|
|
938
|
+
|
|
839
939
|
/**
|
|
840
940
|
* Number of columns.
|
|
841
941
|
*/
|
|
842
942
|
columns?: number | string
|
|
943
|
+
|
|
843
944
|
/**
|
|
844
945
|
* Number of rows.
|
|
845
946
|
*/
|
|
846
947
|
rows?: number | string
|
|
948
|
+
|
|
847
949
|
/**
|
|
848
950
|
* Gap between items.
|
|
849
951
|
*/
|
|
850
952
|
gap?: Size | string | number
|
|
953
|
+
|
|
851
954
|
/**
|
|
852
955
|
* Column gap.
|
|
853
956
|
*/
|
|
854
957
|
columnGap?: Size | string | number
|
|
958
|
+
|
|
855
959
|
/**
|
|
856
960
|
* Row gap.
|
|
857
961
|
*/
|
|
@@ -869,6 +973,7 @@ interface SpacerProps extends BaseProps {
|
|
|
869
973
|
* Space size.
|
|
870
974
|
*/
|
|
871
975
|
size?: Size | string | number
|
|
976
|
+
|
|
872
977
|
/**
|
|
873
978
|
* Whether the spacer is horizontal.
|
|
874
979
|
*/
|
|
@@ -886,10 +991,12 @@ interface FormProps extends FormElementProps {
|
|
|
886
991
|
* Form content.
|
|
887
992
|
*/
|
|
888
993
|
children?: Children
|
|
994
|
+
|
|
889
995
|
/**
|
|
890
996
|
* Submit handler with form data.
|
|
891
997
|
*/
|
|
892
998
|
onFormSubmit?: (data: Record<string, unknown>) => void | Promise<void>
|
|
999
|
+
|
|
893
1000
|
/**
|
|
894
1001
|
* Whether the form is submitting.
|
|
895
1002
|
*/
|
|
@@ -907,22 +1014,27 @@ interface FormFieldProps extends HTMLElementProps {
|
|
|
907
1014
|
* Field content.
|
|
908
1015
|
*/
|
|
909
1016
|
children?: Children
|
|
1017
|
+
|
|
910
1018
|
/**
|
|
911
1019
|
* Field label.
|
|
912
1020
|
*/
|
|
913
1021
|
label?: string
|
|
1022
|
+
|
|
914
1023
|
/**
|
|
915
1024
|
* Field name.
|
|
916
1025
|
*/
|
|
917
1026
|
name?: string
|
|
1027
|
+
|
|
918
1028
|
/**
|
|
919
1029
|
* Error message.
|
|
920
1030
|
*/
|
|
921
1031
|
error?: string
|
|
1032
|
+
|
|
922
1033
|
/**
|
|
923
1034
|
* Hint/help text.
|
|
924
1035
|
*/
|
|
925
1036
|
hint?: string
|
|
1037
|
+
|
|
926
1038
|
/**
|
|
927
1039
|
* Whether the field is required.
|
|
928
1040
|
*/
|
|
@@ -940,30 +1052,37 @@ interface AlertProps extends HTMLElementProps {
|
|
|
940
1052
|
* Alert content.
|
|
941
1053
|
*/
|
|
942
1054
|
children?: Children
|
|
1055
|
+
|
|
943
1056
|
/**
|
|
944
1057
|
* Alert title.
|
|
945
1058
|
*/
|
|
946
1059
|
title?: string
|
|
1060
|
+
|
|
947
1061
|
/**
|
|
948
1062
|
* Alert status/type.
|
|
949
1063
|
*/
|
|
950
1064
|
status?: ColorVariant
|
|
1065
|
+
|
|
951
1066
|
/**
|
|
952
1067
|
* Alert variant.
|
|
953
1068
|
*/
|
|
954
1069
|
variant?: 'solid' | 'subtle' | 'outline' | 'left-accent'
|
|
1070
|
+
|
|
955
1071
|
/**
|
|
956
1072
|
* Whether the alert is dismissible.
|
|
957
1073
|
*/
|
|
958
1074
|
dismissible?: boolean
|
|
1075
|
+
|
|
959
1076
|
/**
|
|
960
1077
|
* Called when dismissed.
|
|
961
1078
|
*/
|
|
962
1079
|
onDismiss?: () => void
|
|
1080
|
+
|
|
963
1081
|
/**
|
|
964
1082
|
* Icon to display.
|
|
965
1083
|
*/
|
|
966
1084
|
icon?: Children
|
|
1085
|
+
|
|
967
1086
|
/**
|
|
968
1087
|
* Accessible label for the dismiss button.
|
|
969
1088
|
* @default 'Dismiss'
|
|
@@ -982,34 +1101,42 @@ interface ToastProps extends HTMLElementProps {
|
|
|
982
1101
|
* Toast content.
|
|
983
1102
|
*/
|
|
984
1103
|
children?: Children
|
|
1104
|
+
|
|
985
1105
|
/**
|
|
986
1106
|
* Toast title.
|
|
987
1107
|
*/
|
|
988
1108
|
title?: string
|
|
1109
|
+
|
|
989
1110
|
/**
|
|
990
1111
|
* Toast description.
|
|
991
1112
|
*/
|
|
992
1113
|
description?: string
|
|
1114
|
+
|
|
993
1115
|
/**
|
|
994
1116
|
* Toast status/type.
|
|
995
1117
|
*/
|
|
996
1118
|
status?: ColorVariant
|
|
1119
|
+
|
|
997
1120
|
/**
|
|
998
1121
|
* Duration in milliseconds (0 for persistent).
|
|
999
1122
|
*/
|
|
1000
1123
|
duration?: number
|
|
1124
|
+
|
|
1001
1125
|
/**
|
|
1002
1126
|
* Whether the toast is dismissible.
|
|
1003
1127
|
*/
|
|
1004
1128
|
dismissible?: boolean
|
|
1129
|
+
|
|
1005
1130
|
/**
|
|
1006
1131
|
* Called when dismissed.
|
|
1007
1132
|
*/
|
|
1008
1133
|
onDismiss?: () => void
|
|
1134
|
+
|
|
1009
1135
|
/**
|
|
1010
1136
|
* Toast position.
|
|
1011
1137
|
*/
|
|
1012
1138
|
position?: 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left'
|
|
1139
|
+
|
|
1013
1140
|
/**
|
|
1014
1141
|
* Accessible label for the close button.
|
|
1015
1142
|
* @default 'Close'
|
|
@@ -1028,18 +1155,22 @@ interface TabItem<T = string> {
|
|
|
1028
1155
|
* Tab value/id.
|
|
1029
1156
|
*/
|
|
1030
1157
|
value: T
|
|
1158
|
+
|
|
1031
1159
|
/**
|
|
1032
1160
|
* Tab label.
|
|
1033
1161
|
*/
|
|
1034
1162
|
label: Children
|
|
1163
|
+
|
|
1035
1164
|
/**
|
|
1036
1165
|
* Tab content.
|
|
1037
1166
|
*/
|
|
1038
1167
|
content?: Children
|
|
1168
|
+
|
|
1039
1169
|
/**
|
|
1040
1170
|
* Whether the tab is disabled.
|
|
1041
1171
|
*/
|
|
1042
1172
|
disabled?: boolean
|
|
1173
|
+
|
|
1043
1174
|
/**
|
|
1044
1175
|
* Icon to display.
|
|
1045
1176
|
*/
|
|
@@ -1057,26 +1188,32 @@ interface TabsProps<T = string> extends BaseProps {
|
|
|
1057
1188
|
* Tab items.
|
|
1058
1189
|
*/
|
|
1059
1190
|
items: TabItem<T>[]
|
|
1191
|
+
|
|
1060
1192
|
/**
|
|
1061
1193
|
* Current active tab.
|
|
1062
1194
|
*/
|
|
1063
1195
|
value?: T
|
|
1196
|
+
|
|
1064
1197
|
/**
|
|
1065
1198
|
* Default active tab.
|
|
1066
1199
|
*/
|
|
1067
1200
|
defaultValue?: T
|
|
1201
|
+
|
|
1068
1202
|
/**
|
|
1069
1203
|
* Change handler.
|
|
1070
1204
|
*/
|
|
1071
1205
|
onChange?: (value: T) => void
|
|
1206
|
+
|
|
1072
1207
|
/**
|
|
1073
1208
|
* Tab variant.
|
|
1074
1209
|
*/
|
|
1075
1210
|
variant?: 'line' | 'enclosed' | 'soft-rounded' | 'solid-rounded'
|
|
1211
|
+
|
|
1076
1212
|
/**
|
|
1077
1213
|
* Tab size.
|
|
1078
1214
|
*/
|
|
1079
1215
|
size?: Size
|
|
1216
|
+
|
|
1080
1217
|
/**
|
|
1081
1218
|
* Whether tabs are fitted (take full width).
|
|
1082
1219
|
*/
|
|
@@ -1094,14 +1231,17 @@ interface AccordionItem<T = string> {
|
|
|
1094
1231
|
* Item value/id.
|
|
1095
1232
|
*/
|
|
1096
1233
|
value: T
|
|
1234
|
+
|
|
1097
1235
|
/**
|
|
1098
1236
|
* Item header/trigger.
|
|
1099
1237
|
*/
|
|
1100
1238
|
header: Children
|
|
1239
|
+
|
|
1101
1240
|
/**
|
|
1102
1241
|
* Item content.
|
|
1103
1242
|
*/
|
|
1104
1243
|
content: Children
|
|
1244
|
+
|
|
1105
1245
|
/**
|
|
1106
1246
|
* Whether the item is disabled.
|
|
1107
1247
|
*/
|
|
@@ -1119,22 +1259,27 @@ interface AccordionProps<T = string> extends BaseProps {
|
|
|
1119
1259
|
* Accordion items.
|
|
1120
1260
|
*/
|
|
1121
1261
|
items: AccordionItem<T>[]
|
|
1262
|
+
|
|
1122
1263
|
/**
|
|
1123
1264
|
* Expanded item(s).
|
|
1124
1265
|
*/
|
|
1125
1266
|
value?: T | T[]
|
|
1267
|
+
|
|
1126
1268
|
/**
|
|
1127
1269
|
* Default expanded item(s).
|
|
1128
1270
|
*/
|
|
1129
1271
|
defaultValue?: T | T[]
|
|
1272
|
+
|
|
1130
1273
|
/**
|
|
1131
1274
|
* Change handler.
|
|
1132
1275
|
*/
|
|
1133
1276
|
onChange?: (value: T | T[]) => void
|
|
1277
|
+
|
|
1134
1278
|
/**
|
|
1135
1279
|
* Whether multiple items can be expanded.
|
|
1136
1280
|
*/
|
|
1137
1281
|
multiple?: boolean
|
|
1282
|
+
|
|
1138
1283
|
/**
|
|
1139
1284
|
* Whether items can be collapsed.
|
|
1140
1285
|
*/
|
|
@@ -1152,22 +1297,27 @@ interface TableColumn<T> {
|
|
|
1152
1297
|
* Column key (data property).
|
|
1153
1298
|
*/
|
|
1154
1299
|
key: keyof T | string
|
|
1300
|
+
|
|
1155
1301
|
/**
|
|
1156
1302
|
* Column header.
|
|
1157
1303
|
*/
|
|
1158
1304
|
header: Children
|
|
1305
|
+
|
|
1159
1306
|
/**
|
|
1160
1307
|
* Custom cell renderer.
|
|
1161
1308
|
*/
|
|
1162
1309
|
render?: (value: unknown, row: T, index: number) => Children
|
|
1310
|
+
|
|
1163
1311
|
/**
|
|
1164
1312
|
* Column width.
|
|
1165
1313
|
*/
|
|
1166
1314
|
width?: string | number
|
|
1315
|
+
|
|
1167
1316
|
/**
|
|
1168
1317
|
* Whether the column is sortable.
|
|
1169
1318
|
*/
|
|
1170
1319
|
sortable?: boolean
|
|
1320
|
+
|
|
1171
1321
|
/**
|
|
1172
1322
|
* Text alignment.
|
|
1173
1323
|
*/
|
|
@@ -1185,49 +1335,57 @@ interface TableProps<T> extends HTMLElementProps {
|
|
|
1185
1335
|
* Table data.
|
|
1186
1336
|
*/
|
|
1187
1337
|
data: T[]
|
|
1338
|
+
|
|
1188
1339
|
/**
|
|
1189
1340
|
* Column definitions.
|
|
1190
1341
|
*/
|
|
1191
1342
|
columns: TableColumn<T>[]
|
|
1343
|
+
|
|
1192
1344
|
/**
|
|
1193
1345
|
* Row key extractor.
|
|
1194
1346
|
*/
|
|
1195
1347
|
rowKey?: keyof T | ((row: T) => string | number)
|
|
1348
|
+
|
|
1196
1349
|
/**
|
|
1197
1350
|
* Whether to show borders.
|
|
1198
1351
|
*/
|
|
1199
1352
|
bordered?: boolean
|
|
1353
|
+
|
|
1200
1354
|
/**
|
|
1201
1355
|
* Whether rows are striped.
|
|
1202
1356
|
*/
|
|
1203
1357
|
striped?: boolean
|
|
1358
|
+
|
|
1204
1359
|
/**
|
|
1205
1360
|
* Whether rows are hoverable.
|
|
1206
1361
|
*/
|
|
1207
1362
|
hoverable?: boolean
|
|
1363
|
+
|
|
1208
1364
|
/**
|
|
1209
1365
|
* Table size.
|
|
1210
1366
|
*/
|
|
1211
1367
|
size?: Size
|
|
1368
|
+
|
|
1212
1369
|
/**
|
|
1213
1370
|
* Empty state content.
|
|
1214
1371
|
*/
|
|
1215
1372
|
emptyContent?: Children
|
|
1373
|
+
|
|
1216
1374
|
/**
|
|
1217
1375
|
* Loading state.
|
|
1218
1376
|
*/
|
|
1219
1377
|
loading?: boolean
|
|
1378
|
+
|
|
1220
1379
|
/**
|
|
1221
1380
|
* Sort configuration.
|
|
1222
1381
|
*/
|
|
1223
|
-
sort?: {
|
|
1224
|
-
|
|
1225
|
-
direction: 'asc' | 'desc'
|
|
1226
|
-
}
|
|
1382
|
+
sort?: { key: string; direction: 'asc' | 'desc' }
|
|
1383
|
+
|
|
1227
1384
|
/**
|
|
1228
1385
|
* Sort change handler.
|
|
1229
1386
|
*/
|
|
1230
1387
|
onSort?: (key: string, direction: 'asc' | 'desc') => void
|
|
1388
|
+
|
|
1231
1389
|
/**
|
|
1232
1390
|
* Row click handler.
|
|
1233
1391
|
*/
|
|
@@ -1245,34 +1403,42 @@ interface PaginationProps extends BaseProps {
|
|
|
1245
1403
|
* Current page (1-indexed).
|
|
1246
1404
|
*/
|
|
1247
1405
|
page: number
|
|
1406
|
+
|
|
1248
1407
|
/**
|
|
1249
1408
|
* Total number of pages.
|
|
1250
1409
|
*/
|
|
1251
1410
|
totalPages: number
|
|
1411
|
+
|
|
1252
1412
|
/**
|
|
1253
1413
|
* Page change handler.
|
|
1254
1414
|
*/
|
|
1255
1415
|
onChange: (page: number) => void
|
|
1416
|
+
|
|
1256
1417
|
/**
|
|
1257
1418
|
* Number of sibling pages to show.
|
|
1258
1419
|
*/
|
|
1259
1420
|
siblings?: number
|
|
1421
|
+
|
|
1260
1422
|
/**
|
|
1261
1423
|
* Number of boundary pages to show.
|
|
1262
1424
|
*/
|
|
1263
1425
|
boundaries?: number
|
|
1426
|
+
|
|
1264
1427
|
/**
|
|
1265
1428
|
* Pagination size.
|
|
1266
1429
|
*/
|
|
1267
1430
|
size?: Size
|
|
1431
|
+
|
|
1268
1432
|
/**
|
|
1269
1433
|
* Whether to show first/last buttons.
|
|
1270
1434
|
*/
|
|
1271
1435
|
showFirstLast?: boolean
|
|
1436
|
+
|
|
1272
1437
|
/**
|
|
1273
1438
|
* Whether to show previous/next buttons.
|
|
1274
1439
|
*/
|
|
1275
1440
|
showPrevNext?: boolean
|
|
1441
|
+
|
|
1276
1442
|
/**
|
|
1277
1443
|
* Accessible labels for pagination controls.
|
|
1278
1444
|
*/
|
|
@@ -1297,18 +1463,22 @@ interface SkeletonProps extends BaseProps {
|
|
|
1297
1463
|
* Skeleton width.
|
|
1298
1464
|
*/
|
|
1299
1465
|
width?: string | number
|
|
1466
|
+
|
|
1300
1467
|
/**
|
|
1301
1468
|
* Skeleton height.
|
|
1302
1469
|
*/
|
|
1303
1470
|
height?: string | number
|
|
1471
|
+
|
|
1304
1472
|
/**
|
|
1305
1473
|
* Whether the skeleton is circular.
|
|
1306
1474
|
*/
|
|
1307
1475
|
circle?: boolean
|
|
1476
|
+
|
|
1308
1477
|
/**
|
|
1309
1478
|
* Border radius.
|
|
1310
1479
|
*/
|
|
1311
1480
|
borderRadius?: string | number
|
|
1481
|
+
|
|
1312
1482
|
/**
|
|
1313
1483
|
* Animation type.
|
|
1314
1484
|
*/
|
|
@@ -1538,6 +1708,28 @@ interface LoadErrorBannerProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
1538
1708
|
}
|
|
1539
1709
|
```
|
|
1540
1710
|
|
|
1711
|
+
#### `OptimisticToggleButtonProps`
|
|
1712
|
+
|
|
1713
|
+
Props for {@link OptimisticToggleButton}. Labels come from the application's translations.
|
|
1714
|
+
|
|
1715
|
+
```typescript
|
|
1716
|
+
interface OptimisticToggleButtonProps extends Omit<
|
|
1717
|
+
ButtonProps,
|
|
1718
|
+
'children' | 'onClick' | 'loading' | 'loadingText' | 'type' | 'value'
|
|
1719
|
+
> {
|
|
1720
|
+
/** The loaded server value. Mount the button only after its initial record exists. */
|
|
1721
|
+
value: boolean
|
|
1722
|
+
/** Saves the desired boolean and returns the server-confirmed boolean; reject on failure. */
|
|
1723
|
+
commit: (desired: boolean) => Promise<boolean>
|
|
1724
|
+
/** Label when the displayed value is true. */
|
|
1725
|
+
activeLabel: React.ReactNode
|
|
1726
|
+
/** Label when the displayed value is false. */
|
|
1727
|
+
inactiveLabel: React.ReactNode
|
|
1728
|
+
/** Receives a failed save after the controller has restored the last confirmed value. */
|
|
1729
|
+
onError?: (error: unknown) => void
|
|
1730
|
+
}
|
|
1731
|
+
```
|
|
1732
|
+
|
|
1541
1733
|
#### `PanelCloseProviderProps`
|
|
1542
1734
|
|
|
1543
1735
|
Props for {@link PanelCloseProvider}.
|
|
@@ -2665,7 +2857,7 @@ function UserMenuPopoverSignOut({
|
|
|
2665
2857
|
Merge class name strings, filtering out falsy values (undefined, null, false).
|
|
2666
2858
|
|
|
2667
2859
|
```typescript
|
|
2668
|
-
function cn(inputs
|
|
2860
|
+
function cn(...inputs: (string | undefined | null | false)[]): string
|
|
2669
2861
|
```
|
|
2670
2862
|
|
|
2671
2863
|
- `inputs` — Class name strings or falsy values to be filtered out.
|
|
@@ -3003,6 +3195,23 @@ const Modal: React.ForwardRefExoticComponent<
|
|
|
3003
3195
|
>
|
|
3004
3196
|
```
|
|
3005
3197
|
|
|
3198
|
+
#### `OptimisticToggleButton`
|
|
3199
|
+
|
|
3200
|
+
An optimistic server-backed toggle: the first tap changes its label and pressed state,
|
|
3201
|
+
including while a previous save is pending. Saves run in order, using the latest desired
|
|
3202
|
+
boolean. The newest failure rolls back; `onError` lets the app show its own error message.
|
|
3203
|
+
|
|
3204
|
+
Render this button after the record loads, give it a key per record, and keep it mounted
|
|
3205
|
+
during same-record refetches. Keep authorization and self-record checks in the app.
|
|
3206
|
+
`disabled` is for those permissions, never for a pending save. Local UI switches use Button
|
|
3207
|
+
or Switch without a server commit.
|
|
3208
|
+
|
|
3209
|
+
```typescript
|
|
3210
|
+
const OptimisticToggleButton: React.ForwardRefExoticComponent<
|
|
3211
|
+
OptimisticToggleButtonProps & React.RefAttributes<HTMLButtonElement>
|
|
3212
|
+
>
|
|
3213
|
+
```
|
|
3214
|
+
|
|
3006
3215
|
#### `PageHeader`
|
|
3007
3216
|
|
|
3008
3217
|
PageHeader component.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A server-backed boolean button that changes its label immediately and saves in order.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import type { ButtonProps } from '@molecule/app-ui';
|
|
8
|
+
/** Props for {@link OptimisticToggleButton}. Labels come from the application's translations. */
|
|
9
|
+
export interface OptimisticToggleButtonProps extends Omit<ButtonProps, 'children' | 'onClick' | 'loading' | 'loadingText' | 'type' | 'value'> {
|
|
10
|
+
/** The loaded server value. Mount the button only after its initial record exists. */
|
|
11
|
+
value: boolean;
|
|
12
|
+
/** Saves the desired boolean and returns the server-confirmed boolean; reject on failure. */
|
|
13
|
+
commit: (desired: boolean) => Promise<boolean>;
|
|
14
|
+
/** Label when the displayed value is true. */
|
|
15
|
+
activeLabel: React.ReactNode;
|
|
16
|
+
/** Label when the displayed value is false. */
|
|
17
|
+
inactiveLabel: React.ReactNode;
|
|
18
|
+
/** Receives a failed save after the controller has restored the last confirmed value. */
|
|
19
|
+
onError?: (error: unknown) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* An optimistic server-backed toggle: the first tap changes its label and pressed state,
|
|
23
|
+
* including while a previous save is pending. Saves run in order, using the latest desired
|
|
24
|
+
* boolean. The newest failure rolls back; `onError` lets the app show its own error message.
|
|
25
|
+
*
|
|
26
|
+
* Render this button after the record loads, give it a key per record, and keep it mounted
|
|
27
|
+
* during same-record refetches. Keep authorization and self-record checks in the app.
|
|
28
|
+
* `disabled` is for those permissions, never for a pending save. Local UI switches use Button
|
|
29
|
+
* or Switch without a server commit.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* {repository && canStar && (
|
|
34
|
+
* <OptimisticToggleButton
|
|
35
|
+
* key={repository.id}
|
|
36
|
+
* value={repository.starred}
|
|
37
|
+
* commit={async (desired) => (await saveStar(repository.id, desired)).starred}
|
|
38
|
+
* activeLabel={t('repository.unstar', undefined, { defaultValue: 'Unstar' })}
|
|
39
|
+
* inactiveLabel={t('repository.star', undefined, { defaultValue: 'Star' })}
|
|
40
|
+
* />
|
|
41
|
+
* )}
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const OptimisticToggleButton: React.ForwardRefExoticComponent<OptimisticToggleButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
//# sourceMappingURL=OptimisticToggleButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptimisticToggleButton.d.ts","sourceRoot":"","sources":["../../src/components/OptimisticToggleButton.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAGzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD,iGAAiG;AACjG,MAAM,WAAW,2BAA4B,SAAQ,IAAI,CACvD,WAAW,EACX,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,OAAO,CACtE;IACC,sFAAsF;IACtF,KAAK,EAAE,OAAO,CAAA;IACd,6FAA6F;IAC7F,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9C,8CAA8C;IAC9C,WAAW,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B,+CAA+C;IAC/C,aAAa,EAAE,KAAK,CAAC,SAAS,CAAA;IAC9B,yFAAyF;IACzF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,sBAAsB,uGAqBlC,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A server-backed boolean button that changes its label immediately and saves in order.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { forwardRef } from 'react';
|
|
8
|
+
import { useOptimisticValue } from '@molecule/app-react';
|
|
9
|
+
import { Button } from './Button.js';
|
|
10
|
+
/**
|
|
11
|
+
* An optimistic server-backed toggle: the first tap changes its label and pressed state,
|
|
12
|
+
* including while a previous save is pending. Saves run in order, using the latest desired
|
|
13
|
+
* boolean. The newest failure rolls back; `onError` lets the app show its own error message.
|
|
14
|
+
*
|
|
15
|
+
* Render this button after the record loads, give it a key per record, and keep it mounted
|
|
16
|
+
* during same-record refetches. Keep authorization and self-record checks in the app.
|
|
17
|
+
* `disabled` is for those permissions, never for a pending save. Local UI switches use Button
|
|
18
|
+
* or Switch without a server commit.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* {repository && canStar && (
|
|
23
|
+
* <OptimisticToggleButton
|
|
24
|
+
* key={repository.id}
|
|
25
|
+
* value={repository.starred}
|
|
26
|
+
* commit={async (desired) => (await saveStar(repository.id, desired)).starred}
|
|
27
|
+
* activeLabel={t('repository.unstar', undefined, { defaultValue: 'Unstar' })}
|
|
28
|
+
* inactiveLabel={t('repository.star', undefined, { defaultValue: 'Star' })}
|
|
29
|
+
* />
|
|
30
|
+
* )}
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const OptimisticToggleButton = forwardRef(({ value, commit, activeLabel, inactiveLabel, onError, ...props }, ref) => {
|
|
34
|
+
const toggle = useOptimisticValue({
|
|
35
|
+
value,
|
|
36
|
+
commit: (desired) => commit(desired),
|
|
37
|
+
onError: (error) => onError?.(error),
|
|
38
|
+
});
|
|
39
|
+
return (_jsx(Button, { "data-mol-id": "optimistic-toggle", ...props, ref: ref, type: "button", "aria-pressed": toggle.value, "aria-busy": toggle.pending, onClick: () => toggle.update((current) => !current), children: toggle.value ? activeLabel : inactiveLabel }));
|
|
40
|
+
});
|
|
41
|
+
OptimisticToggleButton.displayName = 'OptimisticToggleButton';
|
|
42
|
+
//# sourceMappingURL=OptimisticToggleButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptimisticToggleButton.js","sourceRoot":"","sources":["../../src/components/OptimisticToggleButton.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAmBpC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAC9C,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACxE,MAAM,MAAM,GAAG,kBAAkB,CAAC;QAChC,KAAK;QACL,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;QACpC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;KACrC,CAAC,CAAA;IACF,OAAO,CACL,KAAC,MAAM,mBACO,mBAAmB,KAC3B,KAAK,EACT,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,QAAQ,kBACC,MAAM,CAAC,KAAK,eACf,MAAM,CAAC,OAAO,EACzB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,YAElD,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,GACpC,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAED,sBAAsB,CAAC,WAAW,GAAG,wBAAwB,CAAA"}
|
|
@@ -23,6 +23,7 @@ export * from './LanguagePicker.js';
|
|
|
23
23
|
export * from './Layout.js';
|
|
24
24
|
export * from './LoadErrorBanner.js';
|
|
25
25
|
export * from './Modal.js';
|
|
26
|
+
export * from './OptimisticToggleButton.js';
|
|
26
27
|
export * from './PageHeader.js';
|
|
27
28
|
export * from './PageShell.js';
|
|
28
29
|
export * from './Pagination.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
package/dist/components/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export * from './LanguagePicker.js';
|
|
|
23
23
|
export * from './Layout.js';
|
|
24
24
|
export * from './LoadErrorBanner.js';
|
|
25
25
|
export * from './Modal.js';
|
|
26
|
+
export * from './OptimisticToggleButton.js';
|
|
26
27
|
export * from './PageHeader.js';
|
|
27
28
|
export * from './PageShell.js';
|
|
28
29
|
export * from './Pagination.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* Provides React implementations of the `@molecule/app-ui` component
|
|
5
5
|
* interfaces using the UIClassMap abstraction from `@molecule/app-ui`.
|
|
6
6
|
*
|
|
7
|
+
* Server-backed boolean actions use `OptimisticToggleButton`: pass a loaded `value`, a
|
|
8
|
+
* `commit(desired)` returning the confirmed boolean, and translated `activeLabel` and
|
|
9
|
+
* `inactiveLabel`. The label and pressed state change on the first tap; saves run in order
|
|
10
|
+
* and the newest failure rolls back. Mount after the initial record loads, key by record,
|
|
11
|
+
* and keep it mounted during refetches. Authorization and self-record checks stay in the app.
|
|
12
|
+
*
|
|
7
13
|
* @example
|
|
8
14
|
* ```tsx
|
|
9
15
|
* import { setClassMap } from '@molecule/app-ui'
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoIG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* Provides React implementations of the `@molecule/app-ui` component
|
|
5
5
|
* interfaces using the UIClassMap abstraction from `@molecule/app-ui`.
|
|
6
6
|
*
|
|
7
|
+
* Server-backed boolean actions use `OptimisticToggleButton`: pass a loaded `value`, a
|
|
8
|
+
* `commit(desired)` returning the confirmed boolean, and translated `activeLabel` and
|
|
9
|
+
* `inactiveLabel`. The label and pressed state change on the first tap; saves run in order
|
|
10
|
+
* and the newest failure rolls back. Mount after the initial record loads, key by record,
|
|
11
|
+
* and keep it mounted during refetches. Authorization and self-record checks stay in the app.
|
|
12
|
+
*
|
|
7
13
|
* @example
|
|
8
14
|
* ```tsx
|
|
9
15
|
* import { setClassMap } from '@molecule/app-ui'
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoIG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-ui-react",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "React UI components for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@molecule/app-i18n": "1.1.2",
|
|
46
46
|
"@molecule/app-icons": "1.0.3",
|
|
47
|
-
"@molecule/app-react": "3.
|
|
47
|
+
"@molecule/app-react": "3.5.0",
|
|
48
48
|
"@testing-library/react": "16.3.3",
|
|
49
49
|
"@types/node": "26.6.5",
|
|
50
50
|
"@types/react": "19.3.0",
|