derive-dashboards 0.3.0 → 0.5.1
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 +6 -3
- package/dist/cli/check.mjs +36 -1
- package/dist/cli/doctor.mjs +2 -2
- package/dist/core/document/display-entries.mjs +48 -0
- package/dist/core/document/display.d.mts +15 -3
- package/dist/core/document/display.mjs +35 -11
- package/dist/core/engine/filter.mjs +4 -2
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +2 -0
- package/dist/core/error/codes.mjs +2 -0
- package/dist/core/index.d.mts +4 -3
- package/dist/core/index.mjs +8 -7
- package/dist/core/model/catalog/check.mjs +11 -5
- package/dist/core/model/member.mjs +6 -1
- package/dist/core/model/validate/members.mjs +31 -1
- package/dist/core/oracle/visibility.mjs +3 -1
- package/dist/core/query/drill/line.mjs +2 -2
- package/dist/core/query/to-wire.d.mts +7 -0
- package/dist/core/query/to-wire.mjs +18 -7
- package/dist/core/result/additive.d.mts +9 -0
- package/dist/core/result/additive.mjs +59 -0
- package/dist/core/result/columns.mjs +8 -2
- package/dist/core/result/types.d.mts +12 -0
- package/dist/core/schema/answer-parts.mjs +2 -1
- package/dist/core/schema/answers.d.mts +6 -0
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/handler.mjs +10 -2
- package/dist/index.mjs +1 -1
- package/dist/llms.txt +1 -1
- package/dist/react/History.mjs +1 -1
- package/dist/react/Tile.mjs +18 -10
- package/dist/react/builder/FilterEditor.mjs +2 -7
- package/dist/react/builder/Preview.mjs +1 -1
- package/dist/react/columns.mjs +15 -0
- package/dist/react/context.d.mts +7 -0
- package/dist/react/context.mjs +3 -0
- package/dist/react/digits.mjs +46 -0
- package/dist/react/drill/Bars.mjs +2 -1
- package/dist/react/drill/Controls.mjs +2 -1
- package/dist/react/drill/Header.mjs +2 -1
- package/dist/react/drill/Items.mjs +6 -1
- package/dist/react/drill/Notes.mjs +2 -1
- package/dist/react/drill/item-parts.mjs +2 -1
- package/dist/react/english.mjs +4 -0
- package/dist/react/export/ExportButton.mjs +23 -0
- package/dist/react/export/csv.d.mts +9 -0
- package/dist/react/export/csv.mjs +42 -0
- package/dist/react/export/download.d.mts +5 -0
- package/dist/react/export/download.mjs +61 -0
- package/dist/react/format-time.d.mts +15 -0
- package/dist/react/format-time.mjs +71 -0
- package/dist/react/format.d.mts +6 -10
- package/dist/react/format.mjs +55 -87
- package/dist/react/index.d.mts +10 -4
- package/dist/react/index.mjs +10 -4
- package/dist/react/messages.d.mts +8 -0
- package/dist/react/renderers/entries.mjs +15 -0
- package/dist/react/renderers/exact.d.mts +6 -0
- package/dist/react/renderers/exact.mjs +68 -0
- package/dist/react/renderers/index.d.mts +5 -5
- package/dist/react/renderers/index.mjs +72 -83
- package/dist/react/renderers/list.mjs +5 -17
- package/dist/react/renderers/table-cells.mjs +130 -0
- package/dist/react/renderers/table-fit.mjs +52 -0
- package/dist/react/renderers/table-head.mjs +47 -0
- package/dist/react/renderers/table-measure.mjs +49 -0
- package/dist/react/renderers/table-row.mjs +61 -0
- package/dist/react/renderers/table-scale.mjs +70 -0
- package/dist/react/renderers/table-sort.mjs +99 -0
- package/dist/react/renderers/table.d.mts +3 -0
- package/dist/react/renderers/table.mjs +121 -0
- package/dist/react/series-points.d.mts +18 -0
- package/dist/react/series-points.mjs +19 -0
- package/dist/react/series.d.mts +7 -10
- package/dist/react/series.mjs +7 -10
- package/dist/react/theme-unlayered.css +3144 -0
- package/dist/react/theme-unlayered.css.d.ts +1 -0
- package/dist/react/theme.css +379 -8
- package/dist/recharts/axes.mjs +13 -10
- package/dist/recharts/axis.mjs +25 -1
- package/dist/recharts/bar.d.mts +2 -1
- package/dist/recharts/bar.mjs +29 -6
- package/dist/recharts/parts.mjs +1 -1
- package/dist/recharts/table.mjs +10 -8
- package/dist/skills/derive-dashboards/SKILL.md +13 -1
- package/package.json +42 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/react/theme.css
CHANGED
|
@@ -19,9 +19,15 @@
|
|
|
19
19
|
--dd-gap: 16px;
|
|
20
20
|
--dd-row: 72px;
|
|
21
21
|
--dd-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
22
|
+
/* A rule at half strength, between a table's rows; the wash under a pointer; a table cell's padding. */
|
|
23
|
+
--dd-line-soft: color-mix(in srgb, var(--dd-line) 50%, transparent);
|
|
24
|
+
--dd-hover: rgb(127 127 127 / 6%);
|
|
25
|
+
--dd-table-pad-x: 12px;
|
|
26
|
+
--dd-table-pad-y: 8px;
|
|
22
27
|
}
|
|
23
28
|
/* Light by default, so an embedded dashboard always reads on a light page. The host opts in:
|
|
24
|
-
data-theme="dark" on <html> forces dark, data-theme="system" follows the viewer's OS
|
|
29
|
+
data-theme="dark" on <html> forces dark, data-theme="system" follows the viewer's OS, and
|
|
30
|
+
class="dark" on <html> (next-themes, shadcn, Tailwind's class strategy) is dark too. */
|
|
25
31
|
@media (prefers-color-scheme: dark) {
|
|
26
32
|
:root[data-theme="system"] {
|
|
27
33
|
--dd-bg: #09090b;
|
|
@@ -43,7 +49,8 @@
|
|
|
43
49
|
--dd-series-5: #d55181;
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
|
-
:root[data-theme="dark"]
|
|
52
|
+
:root[data-theme="dark"],
|
|
53
|
+
:root.dark:not([data-theme="light"]) {
|
|
47
54
|
--dd-bg: #09090b;
|
|
48
55
|
--dd-surface: #18181b;
|
|
49
56
|
--dd-ink: #fafafa;
|
|
@@ -368,6 +375,8 @@
|
|
|
368
375
|
box-sizing: border-box;
|
|
369
376
|
display: flex;
|
|
370
377
|
flex-direction: column;
|
|
378
|
+
/* Its own ink on its own surface, so a tile drawn outside a dashboard reads in either theme. */
|
|
379
|
+
color: var(--dd-ink);
|
|
371
380
|
background: var(--dd-surface);
|
|
372
381
|
border: 1px solid var(--dd-line);
|
|
373
382
|
border-radius: var(--dd-radius);
|
|
@@ -484,29 +493,381 @@
|
|
|
484
493
|
color: var(--dd-muted);
|
|
485
494
|
font-size: 13px;
|
|
486
495
|
}
|
|
496
|
+
/*
|
|
497
|
+
* A table. Its header is small, set in capitals and muted, so it reads as a label and the
|
|
498
|
+
* rows as the data; it stays in sight while the tile scrolls. Rows are parted by a rule at
|
|
499
|
+
* half the header rule's strength and washed under the pointer. Words keep to one line and
|
|
500
|
+
* are cut with an ellipsis (a cut text's whole self is its title); numbers are never cut.
|
|
501
|
+
*/
|
|
487
502
|
.dd-table {
|
|
488
503
|
width: 100%;
|
|
489
|
-
border-collapse:
|
|
504
|
+
border-collapse: separate;
|
|
505
|
+
border-spacing: 0;
|
|
490
506
|
font-size: 13px;
|
|
491
507
|
font-variant-numeric: tabular-nums;
|
|
492
508
|
}
|
|
493
509
|
.dd-table th,
|
|
494
510
|
.dd-table td {
|
|
495
511
|
text-align: start;
|
|
496
|
-
padding:
|
|
497
|
-
border-bottom: 1px solid var(--dd-line);
|
|
498
|
-
white-space: nowrap;
|
|
512
|
+
padding: var(--dd-table-pad-y) var(--dd-table-pad-x);
|
|
513
|
+
border-bottom: 1px solid var(--dd-line-soft);
|
|
499
514
|
}
|
|
500
|
-
.dd-table th {
|
|
515
|
+
.dd-table thead th {
|
|
516
|
+
position: sticky;
|
|
517
|
+
inset-block-start: 0;
|
|
518
|
+
z-index: 1;
|
|
519
|
+
background: var(--dd-surface);
|
|
501
520
|
color: var(--dd-muted);
|
|
521
|
+
font-size: 11px;
|
|
522
|
+
font-weight: 600;
|
|
523
|
+
letter-spacing: 0.05em;
|
|
524
|
+
text-transform: uppercase;
|
|
525
|
+
vertical-align: bottom;
|
|
526
|
+
border-bottom-color: var(--dd-line);
|
|
527
|
+
/* A name keeps to one line; a long one (`data-long`) breaks over lines of even length before the table outgrows its tile. */
|
|
528
|
+
white-space: nowrap;
|
|
529
|
+
}
|
|
530
|
+
.dd-table thead th[data-long="true"] {
|
|
531
|
+
min-inline-size: 9ch;
|
|
532
|
+
white-space: normal;
|
|
533
|
+
text-wrap: balance;
|
|
534
|
+
}
|
|
535
|
+
.dd-table tbody th {
|
|
536
|
+
color: var(--dd-ink);
|
|
537
|
+
font-weight: 500;
|
|
538
|
+
}
|
|
539
|
+
/*
|
|
540
|
+
* The first column of words names the row: it is a little heavier, and it takes the room the
|
|
541
|
+
* other columns leave, cut to that room, so the numbers keep theirs and stay in sight.
|
|
542
|
+
*/
|
|
543
|
+
.dd-table tbody td:first-child:not([data-numeric="true"]) {
|
|
544
|
+
inline-size: 100%;
|
|
545
|
+
max-inline-size: 0;
|
|
502
546
|
font-weight: 500;
|
|
503
547
|
}
|
|
548
|
+
.dd-table tbody td:first-child:not([data-numeric="true"]) .dd-table-text {
|
|
549
|
+
max-inline-size: none;
|
|
550
|
+
}
|
|
551
|
+
.dd-table thead th:first-child:not([data-numeric="true"]) {
|
|
552
|
+
min-inline-size: 14ch;
|
|
553
|
+
}
|
|
554
|
+
.dd-table tbody tr:last-child > * {
|
|
555
|
+
border-bottom: 0;
|
|
556
|
+
}
|
|
557
|
+
.dd-table tbody tr:hover > * {
|
|
558
|
+
background: var(--dd-hover);
|
|
559
|
+
}
|
|
504
560
|
.dd-table [data-numeric="true"] {
|
|
505
561
|
text-align: end;
|
|
506
562
|
}
|
|
507
|
-
|
|
563
|
+
/* A number is never broken over two lines; a long header may be, before the table outgrows its tile. */
|
|
564
|
+
.dd-table td[data-numeric="true"] {
|
|
565
|
+
white-space: nowrap;
|
|
566
|
+
}
|
|
567
|
+
.dd-table [data-empty="true"] {
|
|
568
|
+
color: var(--dd-muted);
|
|
569
|
+
}
|
|
570
|
+
.dd-table-text {
|
|
571
|
+
display: block;
|
|
572
|
+
max-inline-size: 32ch;
|
|
573
|
+
overflow: hidden;
|
|
574
|
+
text-overflow: ellipsis;
|
|
575
|
+
white-space: nowrap;
|
|
576
|
+
}
|
|
577
|
+
/* The rest, as Other, is context: its name is muted. A total is set apart by weight and a full rule over it. */
|
|
578
|
+
.dd-table .dd-table-summary[data-mark="other"] > th {
|
|
579
|
+
color: var(--dd-muted);
|
|
580
|
+
font-weight: 400;
|
|
581
|
+
}
|
|
582
|
+
.dd-table .dd-table-summary[data-mark="all"] > * {
|
|
508
583
|
font-weight: 600;
|
|
509
584
|
}
|
|
585
|
+
/* The row over a total is ruled in full. The row says so itself: a selector that looks at the next row is checked again for every row a sort moves. */
|
|
586
|
+
.dd-table tbody tr[data-rule="full"] > * {
|
|
587
|
+
border-bottom-color: var(--dd-line);
|
|
588
|
+
}
|
|
589
|
+
.dd-table[data-density="compact"] {
|
|
590
|
+
--dd-table-pad-y: 4px;
|
|
591
|
+
--dd-table-pad-x: 8px;
|
|
592
|
+
}
|
|
593
|
+
/* A header that sorts its column: the header's own look, with an arrow for the way it is sorted. */
|
|
594
|
+
.dd-table-sort {
|
|
595
|
+
display: inline-flex;
|
|
596
|
+
align-items: center;
|
|
597
|
+
gap: 4px;
|
|
598
|
+
min-block-size: 24px;
|
|
599
|
+
padding: 0;
|
|
600
|
+
border: 0;
|
|
601
|
+
background: none;
|
|
602
|
+
color: inherit;
|
|
603
|
+
font: inherit;
|
|
604
|
+
letter-spacing: inherit;
|
|
605
|
+
text-transform: inherit;
|
|
606
|
+
/* A name over two lines keeps to its column's side. */
|
|
607
|
+
text-align: inherit;
|
|
608
|
+
cursor: pointer;
|
|
609
|
+
}
|
|
610
|
+
.dd-table-sort:hover {
|
|
611
|
+
color: var(--dd-ink);
|
|
612
|
+
}
|
|
613
|
+
.dd-table-sort:focus-visible {
|
|
614
|
+
outline: 2px solid var(--dd-accent);
|
|
615
|
+
outline-offset: 2px;
|
|
616
|
+
border-radius: 2px;
|
|
617
|
+
}
|
|
618
|
+
/* The arrow is for the eye, in an element a screen reader passes over: `aria-sort` says the way a column is sorted. */
|
|
619
|
+
.dd-table-sort-mark::after {
|
|
620
|
+
content: "↕";
|
|
621
|
+
opacity: 0;
|
|
622
|
+
}
|
|
623
|
+
.dd-table-sort:hover .dd-table-sort-mark::after,
|
|
624
|
+
.dd-table-sort:focus-visible .dd-table-sort-mark::after {
|
|
625
|
+
opacity: 0.5;
|
|
626
|
+
}
|
|
627
|
+
.dd-table th[aria-sort="ascending"] .dd-table-sort,
|
|
628
|
+
.dd-table th[aria-sort="descending"] .dd-table-sort {
|
|
629
|
+
color: var(--dd-ink);
|
|
630
|
+
}
|
|
631
|
+
.dd-table th[aria-sort="ascending"] .dd-table-sort-mark::after {
|
|
632
|
+
content: "↑";
|
|
633
|
+
opacity: 1;
|
|
634
|
+
}
|
|
635
|
+
.dd-table th[aria-sort="descending"] .dd-table-sort-mark::after {
|
|
636
|
+
content: "↓";
|
|
637
|
+
opacity: 1;
|
|
638
|
+
}
|
|
639
|
+
/*
|
|
640
|
+
* A value with a bar. Every row's track is one length and every row's number keeps the room
|
|
641
|
+
* of the column's longest, so the bars start on one line and their lengths compare.
|
|
642
|
+
*/
|
|
643
|
+
.dd-table-bar {
|
|
644
|
+
display: inline-flex;
|
|
645
|
+
align-items: center;
|
|
646
|
+
justify-content: flex-end;
|
|
647
|
+
gap: 8px;
|
|
648
|
+
/* Room before the bar, three times what parts it from its number, so it reads as that number's and not the last column's. */
|
|
649
|
+
margin-inline-start: 24px;
|
|
650
|
+
}
|
|
651
|
+
.dd-table-bar-track {
|
|
652
|
+
inline-size: 56px;
|
|
653
|
+
block-size: 6px;
|
|
654
|
+
border-radius: 999px;
|
|
655
|
+
background: var(--dd-line);
|
|
656
|
+
overflow: hidden;
|
|
657
|
+
}
|
|
658
|
+
.dd-table-bar-track::before {
|
|
659
|
+
content: "";
|
|
660
|
+
display: block;
|
|
661
|
+
block-size: 100%;
|
|
662
|
+
inline-size: var(--dd-fill);
|
|
663
|
+
border-radius: 999px;
|
|
664
|
+
background: var(--dd-series-1, var(--dd-accent));
|
|
665
|
+
}
|
|
666
|
+
/* The muted ink, not the lighter grey a chart draws Other in: on its track a bar must stand at 3 to 1. */
|
|
667
|
+
.dd-table-bar[data-tone="other"] .dd-table-bar-track::before {
|
|
668
|
+
background: var(--dd-muted);
|
|
669
|
+
}
|
|
670
|
+
.dd-table-bar[data-tone="negative"] .dd-table-bar-track::before {
|
|
671
|
+
background: var(--dd-warn);
|
|
672
|
+
}
|
|
673
|
+
/* A digit is one `ch` wide; a percent sign or a currency sign is a little wider, so the room has some to spare. */
|
|
674
|
+
.dd-table-bar-value {
|
|
675
|
+
min-inline-size: calc((var(--dd-chars) + 0.75) * 1ch);
|
|
676
|
+
text-align: end;
|
|
677
|
+
}
|
|
678
|
+
/*
|
|
679
|
+
* A cell shaded by where its value stands between its column's least and most: the first
|
|
680
|
+
* series' colour, from a faint tint to a shade never so deep that the ink on it is hard to read.
|
|
681
|
+
*/
|
|
682
|
+
.dd-table td[data-heat="true"] {
|
|
683
|
+
background: color-mix(
|
|
684
|
+
in srgb,
|
|
685
|
+
var(--dd-series-1, var(--dd-accent)) calc(6% + var(--dd-heat) * 38%),
|
|
686
|
+
transparent
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
.dd-table tbody tr:hover > td[data-heat="true"] {
|
|
690
|
+
background: color-mix(
|
|
691
|
+
in srgb,
|
|
692
|
+
var(--dd-series-1, var(--dd-accent)) calc(11% + var(--dd-heat) * 38%),
|
|
693
|
+
transparent
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
/* A short word in a soft tint: yes and no in a table. */
|
|
697
|
+
.dd-badge {
|
|
698
|
+
display: inline-flex;
|
|
699
|
+
align-items: center;
|
|
700
|
+
padding: 1px 8px;
|
|
701
|
+
border-radius: 6px;
|
|
702
|
+
font-size: 12px;
|
|
703
|
+
font-weight: 500;
|
|
704
|
+
line-height: 18px;
|
|
705
|
+
}
|
|
706
|
+
/* Each word's colour is taken a quarter of the way to the ink, so it reads at 4.5 to 1 on its tint, under a pointer too. */
|
|
707
|
+
.dd-badge[data-tone="accent"] {
|
|
708
|
+
background: var(--dd-accent-soft);
|
|
709
|
+
color: color-mix(in srgb, var(--dd-accent) 75%, var(--dd-ink));
|
|
710
|
+
}
|
|
711
|
+
.dd-badge[data-tone="neutral"] {
|
|
712
|
+
background: var(--dd-hover);
|
|
713
|
+
color: color-mix(in srgb, var(--dd-muted) 75%, var(--dd-ink));
|
|
714
|
+
}
|
|
715
|
+
/* Under a long table that draws its first rows only: the button that draws the rest. */
|
|
716
|
+
.dd-table-more {
|
|
717
|
+
display: block;
|
|
718
|
+
margin: 8px auto;
|
|
719
|
+
padding: 4px 12px;
|
|
720
|
+
border: 1px solid var(--dd-line);
|
|
721
|
+
border-radius: 6px;
|
|
722
|
+
background: none;
|
|
723
|
+
color: var(--dd-ink);
|
|
724
|
+
font: inherit;
|
|
725
|
+
font-size: 12px;
|
|
726
|
+
cursor: pointer;
|
|
727
|
+
}
|
|
728
|
+
.dd-table-more:hover {
|
|
729
|
+
background: var(--dd-hover);
|
|
730
|
+
}
|
|
731
|
+
.dd-table-more:focus-visible {
|
|
732
|
+
outline: 2px solid var(--dd-accent);
|
|
733
|
+
outline-offset: 2px;
|
|
734
|
+
}
|
|
735
|
+
/*
|
|
736
|
+
* A table says how it is drawn in the room it has (`data-layout`), having measured: no width
|
|
737
|
+
* fits every table. Where its columns do not fit a tile that is not narrow, it scrolls
|
|
738
|
+
* sideways under its first column, which stays in sight with a rule at its edge.
|
|
739
|
+
*/
|
|
740
|
+
.dd-table[data-layout="scroll"] :is(thead th, tbody td, tbody th[colspan="1"]):first-child {
|
|
741
|
+
position: sticky;
|
|
742
|
+
inset-inline-start: 0;
|
|
743
|
+
background: var(--dd-surface);
|
|
744
|
+
border-inline-end: 1px solid var(--dd-line);
|
|
745
|
+
}
|
|
746
|
+
/* The pinned cells are over the cells that pass under them, and the pinned header over both. */
|
|
747
|
+
.dd-table[data-layout="scroll"] tbody :is(td, th[colspan="1"]):first-child {
|
|
748
|
+
z-index: 1;
|
|
749
|
+
}
|
|
750
|
+
.dd-table[data-layout="scroll"] thead th:first-child {
|
|
751
|
+
z-index: 2;
|
|
752
|
+
}
|
|
753
|
+
.dd-table[data-layout="scroll"] tbody tr:hover > :is(td, th[colspan="1"]):first-child {
|
|
754
|
+
background: linear-gradient(var(--dd-hover), var(--dd-hover)) var(--dd-surface);
|
|
755
|
+
}
|
|
756
|
+
/*
|
|
757
|
+
* A shade at the far edge says there are more columns that way. It is the box's own
|
|
758
|
+
* background, with a patch of the surface that rides on the table's last column and covers
|
|
759
|
+
* the shade once that column is in sight.
|
|
760
|
+
*/
|
|
761
|
+
.dd-tile-body:has(> .dd-table[data-layout="scroll"]) {
|
|
762
|
+
background:
|
|
763
|
+
linear-gradient(to left, var(--dd-surface) 40%, transparent) right / 40px 100% no-repeat local,
|
|
764
|
+
linear-gradient(to left, color-mix(in srgb, var(--dd-ink) 10%, transparent), transparent)
|
|
765
|
+
right / 14px 100% no-repeat scroll;
|
|
766
|
+
}
|
|
767
|
+
.dd-tile-body:has(> .dd-table[data-layout="scroll"]):dir(rtl) {
|
|
768
|
+
background:
|
|
769
|
+
linear-gradient(to right, var(--dd-surface) 40%, transparent) left / 40px 100% no-repeat local,
|
|
770
|
+
linear-gradient(to right, color-mix(in srgb, var(--dd-ink) 10%, transparent), transparent)
|
|
771
|
+
left / 14px 100% no-repeat scroll;
|
|
772
|
+
}
|
|
773
|
+
/*
|
|
774
|
+
* Where its columns do not fit a narrow tile, each row is a small card: its first cell as
|
|
775
|
+
* its name, then each value on a line of its own, named by its column. A name and its value
|
|
776
|
+
* share a line while both fit; a long one takes the next line, and nothing is cut.
|
|
777
|
+
*/
|
|
778
|
+
.dd-table[data-layout="cards"] thead {
|
|
779
|
+
position: absolute;
|
|
780
|
+
inline-size: 1px;
|
|
781
|
+
block-size: 1px;
|
|
782
|
+
overflow: hidden;
|
|
783
|
+
clip-path: inset(50%);
|
|
784
|
+
}
|
|
785
|
+
.dd-table[data-layout="cards"],
|
|
786
|
+
.dd-table[data-layout="cards"] tbody {
|
|
787
|
+
display: block;
|
|
788
|
+
}
|
|
789
|
+
.dd-table[data-layout="cards"] tbody tr {
|
|
790
|
+
display: grid;
|
|
791
|
+
grid-template-columns: minmax(0, 1fr);
|
|
792
|
+
padding-block: 6px;
|
|
793
|
+
border-bottom: 1px solid var(--dd-line-soft);
|
|
794
|
+
}
|
|
795
|
+
.dd-table[data-layout="cards"] tbody tr[data-rule="full"] {
|
|
796
|
+
border-bottom-color: var(--dd-line);
|
|
797
|
+
}
|
|
798
|
+
.dd-table[data-layout="cards"] tbody tr:last-child {
|
|
799
|
+
border-bottom: 0;
|
|
800
|
+
}
|
|
801
|
+
.dd-table[data-layout="cards"] tbody :is(td, th) {
|
|
802
|
+
display: flex;
|
|
803
|
+
flex-wrap: wrap;
|
|
804
|
+
justify-content: space-between;
|
|
805
|
+
align-items: center;
|
|
806
|
+
gap: 2px 16px;
|
|
807
|
+
padding-block: 2px;
|
|
808
|
+
border: 0;
|
|
809
|
+
white-space: normal;
|
|
810
|
+
}
|
|
811
|
+
.dd-table[data-layout="cards"] tbody td:first-child:not([data-numeric="true"]) {
|
|
812
|
+
inline-size: auto;
|
|
813
|
+
max-inline-size: none;
|
|
814
|
+
font-weight: 600;
|
|
815
|
+
}
|
|
816
|
+
/* The column's name before each cell but the card's own name. */
|
|
817
|
+
.dd-table-label {
|
|
818
|
+
flex: 0 1 auto;
|
|
819
|
+
min-inline-size: 0;
|
|
820
|
+
overflow-wrap: anywhere;
|
|
821
|
+
color: var(--dd-muted);
|
|
822
|
+
font-size: 12px;
|
|
823
|
+
font-weight: 400;
|
|
824
|
+
text-align: start;
|
|
825
|
+
}
|
|
826
|
+
.dd-table[data-layout="cards"] tbody td:first-child:not([data-numeric="true"]) .dd-table-label {
|
|
827
|
+
display: none;
|
|
828
|
+
}
|
|
829
|
+
/* A value sits at the end of its line, on the next when its name leaves it no room, and breaks before it is cut. */
|
|
830
|
+
.dd-table[data-layout="cards"]
|
|
831
|
+
:is(.dd-table-value, .dd-table-bar-value, .dd-table-text, .dd-badge) {
|
|
832
|
+
margin-inline-start: auto;
|
|
833
|
+
min-inline-size: 0;
|
|
834
|
+
max-inline-size: 100%;
|
|
835
|
+
overflow-wrap: anywhere;
|
|
836
|
+
text-align: end;
|
|
837
|
+
}
|
|
838
|
+
.dd-table[data-layout="cards"] tbody td:first-child .dd-table-text {
|
|
839
|
+
margin-inline-start: 0;
|
|
840
|
+
text-align: start;
|
|
841
|
+
}
|
|
842
|
+
/* A card has the room to write its words whole: they break over lines, and none is cut, since a tap shows no title. */
|
|
843
|
+
.dd-table[data-layout="cards"] .dd-table-text {
|
|
844
|
+
overflow: visible;
|
|
845
|
+
text-overflow: clip;
|
|
846
|
+
white-space: normal;
|
|
847
|
+
}
|
|
848
|
+
/* A bar takes a line of its own under its name and number, as wide as the card. */
|
|
849
|
+
.dd-table[data-layout="cards"] .dd-table-bar {
|
|
850
|
+
display: contents;
|
|
851
|
+
}
|
|
852
|
+
.dd-table[data-layout="cards"] .dd-table-bar-track {
|
|
853
|
+
order: 1;
|
|
854
|
+
flex: 1 0 100%;
|
|
855
|
+
block-size: 4px;
|
|
856
|
+
}
|
|
857
|
+
/* The shade is the value's own in a card, so the column's name stays on the plain surface. */
|
|
858
|
+
.dd-table[data-layout="cards"] td[data-heat="true"],
|
|
859
|
+
.dd-table[data-layout="cards"] tbody tr:hover > td[data-heat="true"] {
|
|
860
|
+
background: none;
|
|
861
|
+
}
|
|
862
|
+
.dd-table[data-layout="cards"] td[data-heat="true"] :is(.dd-table-value, .dd-table-bar-value) {
|
|
863
|
+
padding: 1px 6px;
|
|
864
|
+
border-radius: 4px;
|
|
865
|
+
background: color-mix(
|
|
866
|
+
in srgb,
|
|
867
|
+
var(--dd-series-1, var(--dd-accent)) calc(6% + var(--dd-heat) * 38%),
|
|
868
|
+
transparent
|
|
869
|
+
);
|
|
870
|
+
}
|
|
510
871
|
.dd-lines {
|
|
511
872
|
list-style: none;
|
|
512
873
|
margin: 0;
|
|
@@ -1114,6 +1475,16 @@
|
|
|
1114
1475
|
font-weight: 600;
|
|
1115
1476
|
color: var(--dd-muted);
|
|
1116
1477
|
}
|
|
1478
|
+
/* A second figure under the number: its value in ink, its label muted beside it. */
|
|
1479
|
+
.dd-number-secondary {
|
|
1480
|
+
color: var(--dd-muted);
|
|
1481
|
+
font-size: 13px;
|
|
1482
|
+
}
|
|
1483
|
+
.dd-number-secondary-value {
|
|
1484
|
+
color: var(--dd-ink);
|
|
1485
|
+
font-weight: 600;
|
|
1486
|
+
font-variant-numeric: tabular-nums;
|
|
1487
|
+
}
|
|
1117
1488
|
details.dd-builder-section > summary {
|
|
1118
1489
|
cursor: pointer;
|
|
1119
1490
|
font-size: 11px;
|
package/dist/recharts/axes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { yAxis } from "./axis.mjs";
|
|
1
|
+
import { axisWidth, yAxis } from "./axis.mjs";
|
|
2
2
|
import { YAxis } from "recharts";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
// src/axes.tsx
|
|
@@ -7,15 +7,18 @@ import { jsx } from "react/jsx-runtime";
|
|
|
7
7
|
* right, so dollars and counts are never read on one scale.
|
|
8
8
|
*/
|
|
9
9
|
function yAxes(drawn, locale) {
|
|
10
|
-
return ["left", "right"].filter((side) => drawn.series.some((s) => s.axis === side)).map((side) =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
return ["left", "right"].filter((side) => drawn.series.some((s) => s.axis === side)).map((side) => {
|
|
11
|
+
const axis = yAxis(drawn.series.filter((s) => s.axis === side), drawn.points, locale);
|
|
12
|
+
return /* @__PURE__ */ jsx(YAxis, {
|
|
13
|
+
yAxisId: side,
|
|
14
|
+
orientation: side,
|
|
15
|
+
tickLine: false,
|
|
16
|
+
axisLine: false,
|
|
17
|
+
stroke: "var(--dd-muted)",
|
|
18
|
+
width: axisWidth(axis),
|
|
19
|
+
...axis
|
|
20
|
+
}, side);
|
|
21
|
+
});
|
|
19
22
|
}
|
|
20
23
|
/** The values a chart leaves to the table (a third unit, or more than a split draws), named. */
|
|
21
24
|
function NotDrawn({ drawn, props }) {
|
package/dist/recharts/axis.mjs
CHANGED
|
@@ -81,4 +81,28 @@ function axisFormat(series, locale) {
|
|
|
81
81
|
const column = series[0]?.column;
|
|
82
82
|
return (value) => formatTick(value, column, locale);
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
/** About how wide a character of a tick's text is drawn, in pixels. */
|
|
85
|
+
const TICK_CHAR = 7;
|
|
86
|
+
/** The width a value axis is given when its ticks are short. */
|
|
87
|
+
const AXIS_WIDTH = 56;
|
|
88
|
+
/**
|
|
89
|
+
* A value axis's width up the side of a chart: the room its longest tick's text takes, and
|
|
90
|
+
* never under the usual. A tick is written whole on one line: "1.67 min" in the usual width
|
|
91
|
+
* broke over two and lost its end.
|
|
92
|
+
*/
|
|
93
|
+
function axisWidth(axis) {
|
|
94
|
+
const ticks = "ticks" in axis ? axis.ticks : [];
|
|
95
|
+
const longest = Math.max(0, ...ticks.map((tick) => axis.tickFormatter(tick).length));
|
|
96
|
+
return Math.max(AXIS_WIDTH, longest * TICK_CHAR + 12);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The room a chart whose bars lie down keeps past the end of its value axis. The last tick's
|
|
100
|
+
* text is centred on the end of the axis, so half of it stands past the end: with no room
|
|
101
|
+
* there it is cut ("6 se" for "6 sec"). `top` is the largest value, for an axis whose ticks
|
|
102
|
+
* are the kit's own.
|
|
103
|
+
*/
|
|
104
|
+
function endRoom(axis, top) {
|
|
105
|
+
const last = "ticks" in axis ? axis.ticks.at(-1) ?? top : top;
|
|
106
|
+
return Math.max(8, Math.ceil(axis.tickFormatter(last).length * TICK_CHAR / 2));
|
|
107
|
+
}
|
|
108
|
+
export { axisWidth, endRoom, niceTicks, percentTicks, yAxis };
|
package/dist/recharts/bar.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TileRendererProps } from "derive-dashboards/react";
|
|
2
2
|
/**
|
|
3
|
-
* Bars per x value; when a second field splits them, its values stack
|
|
3
|
+
* Bars per x value; when a second field splits them, its values stack where the measure adds
|
|
4
|
+
* up (Other on top) and stand side by side where it does not. Bars over
|
|
4
5
|
* time stand up, the bucket still running drawn faint; bars by category lie down, so every
|
|
5
6
|
* name has room to be read and none is skipped.
|
|
6
7
|
*/
|
package/dist/recharts/bar.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { yAxis } from "./axis.mjs";
|
|
1
|
+
import { axisWidth, endRoom, yAxis } from "./axis.mjs";
|
|
2
2
|
import { openPoint } from "./marks.mjs";
|
|
3
3
|
import { CHART, TOOLTIP, legendText, runningLabel, seriesColors, tooltipFormat, tooltipLabel } from "./parts.mjs";
|
|
4
4
|
import { toSeries } from "./series.mjs";
|
|
5
5
|
import { Beside } from "./table.mjs";
|
|
6
|
+
import { addsUp } from "derive-dashboards/core";
|
|
6
7
|
import { useState } from "react";
|
|
7
8
|
import { Bar, BarChart, CartesianGrid, Legend, Rectangle, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -58,7 +59,7 @@ function barAxes(overTime, values, points) {
|
|
|
58
59
|
minTickGap: 12
|
|
59
60
|
}), /* @__PURE__ */ jsx(YAxis, {
|
|
60
61
|
...AXIS,
|
|
61
|
-
width:
|
|
62
|
+
width: axisWidth(values),
|
|
62
63
|
...values
|
|
63
64
|
})] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(XAxis, {
|
|
64
65
|
type: "number",
|
|
@@ -73,8 +74,29 @@ function barAxes(overTime, values, points) {
|
|
|
73
74
|
tickFormatter: cut
|
|
74
75
|
})] });
|
|
75
76
|
}
|
|
77
|
+
/** The largest value drawn, whichever series holds it. */
|
|
78
|
+
const top = ({ points, series }) => Math.max(0, ...points.flatMap((point) => series.map((s) => point[s.key]).filter((v) => typeof v === "number")));
|
|
79
|
+
/** The chart's own settings, with room past the end of the value axis where the bars lie down along it. */
|
|
80
|
+
const chartOf = (overTime, axis, drawn) => overTime ? CHART : {
|
|
81
|
+
...CHART,
|
|
82
|
+
margin: {
|
|
83
|
+
...CHART.margin,
|
|
84
|
+
right: endRoom(axis, top(drawn))
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Whether a split's parts stack into a whole: only where the answer says its measure adds up,
|
|
89
|
+
* which core's `addsUp` reads. The parts of an average or a rate stand side by side, since a
|
|
90
|
+
* column of one on another would reach a total that means nothing; so do the parts of an
|
|
91
|
+
* answer that does not say (one from an older server).
|
|
92
|
+
*/
|
|
93
|
+
function stacksSplit(drawn) {
|
|
94
|
+
const [first] = drawn.series;
|
|
95
|
+
return drawn.split && first !== void 0 && addsUp(first.column);
|
|
96
|
+
}
|
|
76
97
|
/**
|
|
77
|
-
* Bars per x value; when a second field splits them, its values stack
|
|
98
|
+
* Bars per x value; when a second field splits them, its values stack where the measure adds
|
|
99
|
+
* up (Other on top) and stand side by side where it does not. Bars over
|
|
78
100
|
* time stand up, the bucket still running drawn faint; bars by category lie down, so every
|
|
79
101
|
* name has room to be read and none is skipped.
|
|
80
102
|
*/
|
|
@@ -82,7 +104,8 @@ function BarTile(props) {
|
|
|
82
104
|
const { answer, locale, drill } = props;
|
|
83
105
|
const [focused, setFocused] = useState(null);
|
|
84
106
|
const drawn = toSeries(answer, props, props.slots);
|
|
85
|
-
const { points, series
|
|
107
|
+
const { points, series } = drawn;
|
|
108
|
+
const split = stacksSplit(drawn);
|
|
86
109
|
const painted = seriesColors(props, series);
|
|
87
110
|
const overTime = answer.columns[0]?.type === "time" || answer.columns[0]?.grain !== void 0;
|
|
88
111
|
const running = overTime ? runningLabel(props, points) : void 0;
|
|
@@ -94,7 +117,7 @@ function BarTile(props) {
|
|
|
94
117
|
className: "dd-chart-picture",
|
|
95
118
|
"aria-hidden": "true",
|
|
96
119
|
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(BarChart, {
|
|
97
|
-
...
|
|
120
|
+
...chartOf(overTime, values, drawn),
|
|
98
121
|
data: points,
|
|
99
122
|
maxBarSize: overTime ? 56 : 28,
|
|
100
123
|
layout: overTime ? "horizontal" : "vertical",
|
|
@@ -138,4 +161,4 @@ function BarTile(props) {
|
|
|
138
161
|
})]
|
|
139
162
|
});
|
|
140
163
|
}
|
|
141
|
-
export { BarTile };
|
|
164
|
+
export { BarTile, stacksSplit };
|
package/dist/recharts/parts.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OTHER_KEY } from "./series.mjs";
|
|
2
2
|
import { cellText } from "./table.mjs";
|
|
3
|
+
import { displayOf } from "derive-dashboards/core";
|
|
3
4
|
import { chartColors, lastBucketOpen } from "derive-dashboards/react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import { displayOf } from "derive-dashboards/core";
|
|
6
6
|
// src/parts.tsx
|
|
7
7
|
/** Legend words in the text color: a series' hue marks its swatch, never its name. */
|
|
8
8
|
const legendText = (value) => /* @__PURE__ */ jsx("span", {
|
package/dist/recharts/table.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NotDrawn } from "./axes.mjs";
|
|
2
2
|
import { Marks } from "./marks.mjs";
|
|
3
|
-
import { formatCell } from "derive-dashboards/react";
|
|
3
|
+
import { formatCell, pointText } from "derive-dashboards/react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
// src/table.tsx
|
|
6
6
|
/**
|
|
@@ -8,10 +8,12 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
* reads exactly and each series keeps its unit; the drawn number when no row stands behind it.
|
|
9
9
|
*/
|
|
10
10
|
function cellText(props, drawn, at) {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const point = typeof at.place === "number" ? at.place : void 0;
|
|
12
|
+
const own = point === void 0 ? void 0 : pointText(props.answer, drawn, {
|
|
13
|
+
point,
|
|
14
|
+
series: at.series
|
|
15
|
+
}, props);
|
|
16
|
+
if (own !== void 0) return own;
|
|
15
17
|
if (typeof at.value === "number") return formatCell(at.value, at.series.column, props);
|
|
16
18
|
const v = at.value;
|
|
17
19
|
return typeof v === "string" || typeof v === "boolean" || typeof v === "bigint" ? String(v) : "";
|
|
@@ -23,9 +25,9 @@ function cellText(props, drawn, at) {
|
|
|
23
25
|
*/
|
|
24
26
|
function ChartTable({ drawn, props, kind }) {
|
|
25
27
|
const { points, series } = drawn;
|
|
26
|
-
return /* @__PURE__ */
|
|
28
|
+
return /* @__PURE__ */ jsx("div", {
|
|
27
29
|
className: "dd-sr-only",
|
|
28
|
-
children: [
|
|
30
|
+
children: /* @__PURE__ */ jsxs("table", { children: [
|
|
29
31
|
/* @__PURE__ */ jsx("caption", { children: props.messages.chartTable({
|
|
30
32
|
title: props.widget.title,
|
|
31
33
|
kind,
|
|
@@ -43,7 +45,7 @@ function ChartTable({ drawn, props, kind }) {
|
|
|
43
45
|
series: s,
|
|
44
46
|
value: point[s.key]
|
|
45
47
|
}) }, s.key))] }, point.x)) })
|
|
46
|
-
]
|
|
48
|
+
] })
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
/** What sits beside every chart: its keyboard path, what it does not draw, and its data table. */
|
|
@@ -15,7 +15,7 @@ the `derive-dashboards` CLI. Docs: https://github.com/derive-to/dashboards/tree/
|
|
|
15
15
|
Check, and say what you found:
|
|
16
16
|
- Postgres (node-postgres `Pool`, or PGlite with a folder) is reachable. Other databases: a custom
|
|
17
17
|
data layer (`docs/custom-data-layer.md`).
|
|
18
|
-
- React 18.
|
|
18
|
+
- React 18.2 or later (18 or 19) for the UI (the filter bar that `add` copies into the app needs React 19). Next.js: the provider and dashboards render from a `"use client"` file.
|
|
19
19
|
- How the app knows who is signed in: the handler needs a `viewer(request)` that returns the
|
|
20
20
|
person (with tenant values when the model has tenant keys) or `null`.
|
|
21
21
|
|
|
@@ -51,6 +51,18 @@ app's CSS wins). Options: wrap `FilterBar` with `pinned`, `icons`, `renderMark`,
|
|
|
51
51
|
pass it as `components={{ FilterBar }}`. Words: `messages.filterBar`. To own the code in a shadcn
|
|
52
52
|
app (Base UI or Radix), `npx derive-dashboards add filter-bar`.
|
|
53
53
|
|
|
54
|
+
## Tiles
|
|
55
|
+
|
|
56
|
+
A widget's `kind` picks its tile (`number`, `table`, `list`, `line`, `bar`) and its `display`
|
|
57
|
+
sets that tile's options, each typed (`docs/react.md`, Lists, Numbers and Tables). A number
|
|
58
|
+
takes `value` and `secondary` (which entry is large, and a second figure under it); a table
|
|
59
|
+
takes `bars`, `heat` and `compact`, and a viewer sorts it by a click on a header. An option
|
|
60
|
+
names a query entry by its own id, and a wrong name stops the server with the names it could
|
|
61
|
+
be. On a dashboard in code, `display: { ... } satisfies DisplayOf<"table">` has the compiler
|
|
62
|
+
check an option's name and type. Every tile with rows has a CSV button;
|
|
63
|
+
`<DashboardsProvider csv={false}>` leaves it out, and `downloadCsv(title, csvOf(answer, messages))`
|
|
64
|
+
saves the same file from a button of your own.
|
|
65
|
+
|
|
54
66
|
## Agents
|
|
55
67
|
|
|
56
68
|
Two MCP tools let an agent ask questions and edit as itself: `docs/mcp.md`.
|