@shortstravelmgmt/component-lib 0.3.0-canary.70.g764f77e → 0.3.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/dist/index.d.ts +2 -1
- package/dist/index.esm.js +168 -175
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +168 -175
- package/dist/index.js.map +1 -1
- package/package.json +142 -142
package/dist/index.d.ts
CHANGED
|
@@ -4577,7 +4577,8 @@ interface GridTableProps<R = GridRow> {
|
|
|
4577
4577
|
* `key` is replaced by `content`, spanning the full width, where it sits in the
|
|
4578
4578
|
* sorted order (the row marker still lands before it). For editing a record
|
|
4579
4579
|
* inline, e.g. a trip opened from its row's edit button. The slot keeps the
|
|
4580
|
-
* row's `data-rowid` (and adds `data-editing`), and
|
|
4580
|
+
* row's `data-rowid` (and adds `data-editing`), and its borders follow the row
|
|
4581
|
+
* it replaces (`bordered`, and none below the last row).
|
|
4581
4582
|
*/
|
|
4582
4583
|
editRow?: {
|
|
4583
4584
|
key: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -8574,6 +8574,14 @@ const rootStyle = {
|
|
|
8574
8574
|
textTransform: 'none',
|
|
8575
8575
|
color: 'var(--color-ink, #1b2a41)',
|
|
8576
8576
|
},
|
|
8577
|
+
// The tab labels are bare spans too, so a host's span rule reaches them
|
|
8578
|
+
// directly (inheritance alone can't undo it): they take the tab's own type.
|
|
8579
|
+
// `:not([class])` leaves the classed icon and count spans their own sizes.
|
|
8580
|
+
'&& [role="tab"] > span:not([class])': {
|
|
8581
|
+
font: 'inherit',
|
|
8582
|
+
letterSpacing: 'inherit',
|
|
8583
|
+
textTransform: 'inherit',
|
|
8584
|
+
},
|
|
8577
8585
|
};
|
|
8578
8586
|
const tabRowStyle = {
|
|
8579
8587
|
label: 'TeamPicker-tabRowStyle',
|
|
@@ -12611,16 +12619,16 @@ GridHeaderRow.displayName = 'GridHeaderRow';
|
|
|
12611
12619
|
* where it wins on order, exactly as it did in the stylesheet.
|
|
12612
12620
|
*/
|
|
12613
12621
|
const tableStyle$8 = {
|
|
12614
|
-
label:
|
|
12615
|
-
position:
|
|
12622
|
+
label: 'GridTable-tableStyle',
|
|
12623
|
+
position: 'relative',
|
|
12616
12624
|
borderRadius: 12,
|
|
12617
|
-
|
|
12618
|
-
border:
|
|
12625
|
+
'@media (min-width: 768px)': {
|
|
12626
|
+
border: '1px solid var(--color-subtle, #eff0f0)',
|
|
12619
12627
|
},
|
|
12620
12628
|
};
|
|
12621
12629
|
const gridStyle$7 = {
|
|
12622
|
-
label:
|
|
12623
|
-
display:
|
|
12630
|
+
label: 'GridTable-gridStyle',
|
|
12631
|
+
display: 'grid',
|
|
12624
12632
|
};
|
|
12625
12633
|
/**
|
|
12626
12634
|
* The always-visible banner row above the heading. Spans the full width and
|
|
@@ -12629,15 +12637,15 @@ const gridStyle$7 = {
|
|
|
12629
12637
|
* Its background is left to the caller's node.
|
|
12630
12638
|
*/
|
|
12631
12639
|
const bannerStyle$2 = {
|
|
12632
|
-
label:
|
|
12633
|
-
width:
|
|
12640
|
+
label: 'GridTable-bannerStyle',
|
|
12641
|
+
width: '100%',
|
|
12634
12642
|
borderTopLeftRadius: 12,
|
|
12635
12643
|
borderTopRightRadius: 12,
|
|
12636
12644
|
// The wrapper is transparent, so its own radius rounds nothing — the caller's
|
|
12637
12645
|
// node paints the background. Round that direct child's top corners too, so a
|
|
12638
12646
|
// full-width banner background follows the table's rounded top edge instead of
|
|
12639
12647
|
// painting square corners over it. No overflow clip, so dropdowns still escape.
|
|
12640
|
-
|
|
12648
|
+
'& > *': {
|
|
12641
12649
|
borderTopLeftRadius: 12,
|
|
12642
12650
|
borderTopRightRadius: 12,
|
|
12643
12651
|
},
|
|
@@ -12647,72 +12655,72 @@ const bannerStyle$2 = {
|
|
|
12647
12655
|
* row becomes a card and every cell carries its own label instead.
|
|
12648
12656
|
*/
|
|
12649
12657
|
const headerStyle$x = {
|
|
12650
|
-
label:
|
|
12651
|
-
display:
|
|
12652
|
-
width:
|
|
12658
|
+
label: 'GridTable-headerStyle',
|
|
12659
|
+
display: 'none',
|
|
12660
|
+
width: '100%',
|
|
12653
12661
|
fontWeight: 500,
|
|
12654
12662
|
/* Navy brand ground with rail foreground ink, matching the widget headers. */
|
|
12655
|
-
background:
|
|
12656
|
-
color:
|
|
12657
|
-
|
|
12658
|
-
display:
|
|
12663
|
+
background: 'var(--color-primary, #19345f)',
|
|
12664
|
+
color: 'var(--nav-rail-fg, #8fa6c4)',
|
|
12665
|
+
'@media (min-width: 768px)': {
|
|
12666
|
+
display: 'block',
|
|
12659
12667
|
},
|
|
12660
12668
|
};
|
|
12661
12669
|
const headingStyle$2 = {
|
|
12662
|
-
label:
|
|
12663
|
-
display:
|
|
12664
|
-
alignItems:
|
|
12670
|
+
label: 'GridTable-headingStyle',
|
|
12671
|
+
display: 'flex',
|
|
12672
|
+
alignItems: 'flex-end',
|
|
12665
12673
|
minWidth: 0,
|
|
12666
|
-
padding:
|
|
12674
|
+
padding: '12px 16px',
|
|
12667
12675
|
fontSize: 14,
|
|
12668
12676
|
fontWeight: 500,
|
|
12669
|
-
color:
|
|
12670
|
-
textAlign:
|
|
12671
|
-
background:
|
|
12672
|
-
border:
|
|
12673
|
-
fontFamily:
|
|
12677
|
+
color: 'var(--nav-rail-fg, #8fa6c4)',
|
|
12678
|
+
textAlign: 'left',
|
|
12679
|
+
background: 'none',
|
|
12680
|
+
border: 'none',
|
|
12681
|
+
fontFamily: 'inherit',
|
|
12674
12682
|
};
|
|
12675
12683
|
/** Contests nothing in `headingStyle` — it sets neither cursor nor width. */
|
|
12676
12684
|
const sortableStyle = {
|
|
12677
|
-
label:
|
|
12678
|
-
cursor:
|
|
12679
|
-
width:
|
|
12685
|
+
label: 'GridTable-sortableStyle',
|
|
12686
|
+
cursor: 'pointer',
|
|
12687
|
+
width: '100%',
|
|
12680
12688
|
};
|
|
12681
12689
|
const headingInnerStyle = {
|
|
12682
|
-
label:
|
|
12683
|
-
display:
|
|
12684
|
-
alignItems:
|
|
12685
|
-
minWidth:
|
|
12690
|
+
label: 'GridTable-headingInnerStyle',
|
|
12691
|
+
display: 'flex',
|
|
12692
|
+
alignItems: 'center',
|
|
12693
|
+
minWidth: '100%',
|
|
12686
12694
|
};
|
|
12687
12695
|
const headingIconStyle = {
|
|
12688
|
-
label:
|
|
12696
|
+
label: 'GridTable-headingIconStyle',
|
|
12689
12697
|
marginRight: 8,
|
|
12690
12698
|
flexShrink: 0,
|
|
12691
|
-
display:
|
|
12699
|
+
display: 'inline-flex',
|
|
12692
12700
|
};
|
|
12693
12701
|
const sortIconStyle$1 = {
|
|
12694
|
-
label:
|
|
12702
|
+
label: 'GridTable-sortIconStyle',
|
|
12695
12703
|
marginLeft: 8,
|
|
12696
12704
|
flexShrink: 0,
|
|
12697
|
-
display:
|
|
12705
|
+
display: 'inline-flex',
|
|
12698
12706
|
};
|
|
12699
12707
|
const bodyStyle$5 = {
|
|
12700
|
-
label:
|
|
12701
|
-
display:
|
|
12702
|
-
flexDirection:
|
|
12708
|
+
label: 'GridTable-bodyStyle',
|
|
12709
|
+
display: 'flex',
|
|
12710
|
+
flexDirection: 'column',
|
|
12703
12711
|
gap: 16,
|
|
12704
|
-
|
|
12712
|
+
'@media (min-width: 768px)': {
|
|
12705
12713
|
gap: 0,
|
|
12706
12714
|
},
|
|
12707
12715
|
};
|
|
12708
12716
|
const rowStyle$5 = {
|
|
12709
|
-
label:
|
|
12717
|
+
label: 'GridTable-rowStyle',
|
|
12710
12718
|
padding: 8,
|
|
12711
12719
|
fontSize: 14,
|
|
12712
|
-
background:
|
|
12720
|
+
background: '#fff',
|
|
12713
12721
|
borderRadius: 12,
|
|
12714
|
-
|
|
12715
|
-
display:
|
|
12722
|
+
'@media (min-width: 768px)': {
|
|
12723
|
+
display: 'grid',
|
|
12716
12724
|
padding: 0,
|
|
12717
12725
|
borderRadius: 0,
|
|
12718
12726
|
},
|
|
@@ -12727,51 +12735,51 @@ const rowStyle$5 = {
|
|
|
12727
12735
|
* over `.row.bordered` (0,2,0).
|
|
12728
12736
|
*/
|
|
12729
12737
|
const borderedStyle = {
|
|
12730
|
-
label:
|
|
12731
|
-
border:
|
|
12732
|
-
|
|
12733
|
-
borderWidth:
|
|
12734
|
-
|
|
12738
|
+
label: 'GridTable-borderedStyle',
|
|
12739
|
+
border: '1px solid var(--border-color-dark, #d5d5d5)',
|
|
12740
|
+
'@media (min-width: 768px)': {
|
|
12741
|
+
borderWidth: '0 0 1px 0',
|
|
12742
|
+
'&:last-child': {
|
|
12735
12743
|
borderBottomWidth: 0,
|
|
12736
12744
|
},
|
|
12737
12745
|
},
|
|
12738
12746
|
};
|
|
12739
12747
|
const cellWrapStyle = {
|
|
12740
|
-
label:
|
|
12748
|
+
label: 'GridTable-cellWrapStyle',
|
|
12741
12749
|
minWidth: 0,
|
|
12742
|
-
background:
|
|
12743
|
-
|
|
12744
|
-
display:
|
|
12745
|
-
flexDirection:
|
|
12750
|
+
background: '#fff',
|
|
12751
|
+
'@media (min-width: 768px)': {
|
|
12752
|
+
display: 'flex',
|
|
12753
|
+
flexDirection: 'column',
|
|
12746
12754
|
},
|
|
12747
12755
|
};
|
|
12748
12756
|
const cellStyle$2 = {
|
|
12749
|
-
label:
|
|
12750
|
-
display:
|
|
12751
|
-
alignItems:
|
|
12752
|
-
minHeight:
|
|
12753
|
-
padding:
|
|
12754
|
-
|
|
12755
|
-
padding:
|
|
12757
|
+
label: 'GridTable-cellStyle',
|
|
12758
|
+
display: 'flex',
|
|
12759
|
+
alignItems: 'center',
|
|
12760
|
+
minHeight: '100%',
|
|
12761
|
+
padding: '4px 8px',
|
|
12762
|
+
'@media (min-width: 768px)': {
|
|
12763
|
+
padding: '12px 16px',
|
|
12756
12764
|
},
|
|
12757
12765
|
};
|
|
12758
12766
|
/** Top-aligns a cell's content; applied over `cellStyle` when `alignTop`. */
|
|
12759
12767
|
const cellTopStyle = {
|
|
12760
|
-
label:
|
|
12761
|
-
alignItems:
|
|
12768
|
+
label: 'GridTable-cellTopStyle',
|
|
12769
|
+
alignItems: 'flex-start',
|
|
12762
12770
|
};
|
|
12763
12771
|
const valueStyle$2 = {
|
|
12764
|
-
label:
|
|
12765
|
-
display:
|
|
12766
|
-
overflow:
|
|
12767
|
-
overflowWrap:
|
|
12772
|
+
label: 'GridTable-valueStyle',
|
|
12773
|
+
display: 'block',
|
|
12774
|
+
overflow: 'hidden',
|
|
12775
|
+
overflowWrap: 'break-word',
|
|
12768
12776
|
};
|
|
12769
12777
|
const stackedLabelStyle = {
|
|
12770
|
-
label:
|
|
12778
|
+
label: 'GridTable-stackedLabelStyle',
|
|
12771
12779
|
minWidth: 100,
|
|
12772
12780
|
/* The heading row is visible again, so per-cell labels would duplicate it. */
|
|
12773
|
-
|
|
12774
|
-
display:
|
|
12781
|
+
'@media (min-width: 768px)': {
|
|
12782
|
+
display: 'none',
|
|
12775
12783
|
},
|
|
12776
12784
|
};
|
|
12777
12785
|
/**
|
|
@@ -12779,11 +12787,21 @@ const stackedLabelStyle = {
|
|
|
12779
12787
|
* the top; on the desktop grid it carries a bottom rule so it reads as a row above
|
|
12780
12788
|
* the data. The caller styles and lays out the node inside it.
|
|
12781
12789
|
*/
|
|
12790
|
+
/**
|
|
12791
|
+
* The `editRow` slot: full width, and its borders are the row it replaces —
|
|
12792
|
+
* `borderedStyle` joins it only when the table is bordered, and that rule
|
|
12793
|
+
* already drops the last row's bottom border — unlike `draftRowStyle`, whose
|
|
12794
|
+
* separator is for a row pinned above the data.
|
|
12795
|
+
*/
|
|
12796
|
+
const editRowStyle = {
|
|
12797
|
+
label: 'GridTable-editRowStyle',
|
|
12798
|
+
width: '100%',
|
|
12799
|
+
};
|
|
12782
12800
|
const draftRowStyle = {
|
|
12783
|
-
label:
|
|
12784
|
-
width:
|
|
12785
|
-
|
|
12786
|
-
borderBottom:
|
|
12801
|
+
label: 'GridTable-draftRowStyle',
|
|
12802
|
+
width: '100%',
|
|
12803
|
+
'@media (min-width: 768px)': {
|
|
12804
|
+
borderBottom: '1px solid var(--border-color-dark, #d5d5d5)',
|
|
12787
12805
|
},
|
|
12788
12806
|
};
|
|
12789
12807
|
/**
|
|
@@ -12793,52 +12811,52 @@ const draftRowStyle = {
|
|
|
12793
12811
|
* white so it settles cleanly when the caller clears `flashRowKey`.
|
|
12794
12812
|
*/
|
|
12795
12813
|
const flashRowStyle = {
|
|
12796
|
-
label:
|
|
12797
|
-
|
|
12798
|
-
from: { backgroundColor:
|
|
12799
|
-
to: { backgroundColor:
|
|
12814
|
+
label: 'GridTable-flashRowStyle',
|
|
12815
|
+
'@keyframes gridtable-row-flash': {
|
|
12816
|
+
from: { backgroundColor: 'var(--color-alert-success-bg, #d1f0e0)' },
|
|
12817
|
+
to: { backgroundColor: '#fff' },
|
|
12800
12818
|
},
|
|
12801
|
-
|
|
12802
|
-
animation:
|
|
12819
|
+
'& > *': {
|
|
12820
|
+
animation: 'gridtable-row-flash 2.5s ease-out',
|
|
12803
12821
|
},
|
|
12804
12822
|
};
|
|
12805
12823
|
const emptyStyle$d = {
|
|
12806
|
-
label:
|
|
12807
|
-
padding:
|
|
12808
|
-
textAlign:
|
|
12809
|
-
color:
|
|
12824
|
+
label: 'GridTable-emptyStyle',
|
|
12825
|
+
padding: '12px 16px',
|
|
12826
|
+
textAlign: 'center',
|
|
12827
|
+
color: 'var(--color-slate, #5c5c5c)',
|
|
12810
12828
|
};
|
|
12811
12829
|
/** The leading control cell that holds a row's expand/collapse toggle. */
|
|
12812
12830
|
const expandCellStyle = {
|
|
12813
|
-
label:
|
|
12814
|
-
display:
|
|
12815
|
-
alignItems:
|
|
12816
|
-
justifyContent:
|
|
12817
|
-
padding:
|
|
12818
|
-
|
|
12831
|
+
label: 'GridTable-expandCellStyle',
|
|
12832
|
+
display: 'flex',
|
|
12833
|
+
alignItems: 'center',
|
|
12834
|
+
justifyContent: 'center',
|
|
12835
|
+
padding: '4px',
|
|
12836
|
+
'@media (min-width: 768px)': {
|
|
12819
12837
|
// 10px, not the cells' 12px: the 28px toggle then centres on the 24px
|
|
12820
12838
|
// first text line of the top-aligned cells beside it (10 + 14 = 12 + 12).
|
|
12821
|
-
padding:
|
|
12822
|
-
alignItems:
|
|
12839
|
+
padding: '10px 4px',
|
|
12840
|
+
alignItems: 'flex-start',
|
|
12823
12841
|
},
|
|
12824
12842
|
};
|
|
12825
12843
|
/** The toggle button itself: an icon-only target that inherits row ink. */
|
|
12826
12844
|
const expandButtonStyle$1 = {
|
|
12827
|
-
label:
|
|
12828
|
-
display:
|
|
12829
|
-
alignItems:
|
|
12830
|
-
justifyContent:
|
|
12845
|
+
label: 'GridTable-expandButtonStyle',
|
|
12846
|
+
display: 'inline-flex',
|
|
12847
|
+
alignItems: 'center',
|
|
12848
|
+
justifyContent: 'center',
|
|
12831
12849
|
width: 28,
|
|
12832
12850
|
height: 28,
|
|
12833
12851
|
padding: 0,
|
|
12834
|
-
color:
|
|
12835
|
-
background:
|
|
12836
|
-
border:
|
|
12852
|
+
color: 'var(--color-slate, #5c5c5c)',
|
|
12853
|
+
background: 'none',
|
|
12854
|
+
border: 'none',
|
|
12837
12855
|
borderRadius: 6,
|
|
12838
|
-
cursor:
|
|
12839
|
-
|
|
12840
|
-
color:
|
|
12841
|
-
background:
|
|
12856
|
+
cursor: 'pointer',
|
|
12857
|
+
'&:hover': {
|
|
12858
|
+
color: 'var(--color-primary, #19345f)',
|
|
12859
|
+
background: 'var(--color-subtle, #eff0f0)',
|
|
12842
12860
|
},
|
|
12843
12861
|
};
|
|
12844
12862
|
/**
|
|
@@ -12852,46 +12870,46 @@ const expandButtonStyle$1 = {
|
|
|
12852
12870
|
* Colour defaults to the brand success green.
|
|
12853
12871
|
*/
|
|
12854
12872
|
const markerStyle = {
|
|
12855
|
-
label:
|
|
12856
|
-
position:
|
|
12873
|
+
label: 'GridTable-markerStyle',
|
|
12874
|
+
position: 'relative',
|
|
12857
12875
|
height: 20,
|
|
12858
|
-
|
|
12876
|
+
'@media (min-width: 768px)': {
|
|
12859
12877
|
height: 0,
|
|
12860
12878
|
},
|
|
12861
12879
|
};
|
|
12862
12880
|
/** The rule itself: spans the full width, centred on the boundary. */
|
|
12863
12881
|
const markerLineStyle = {
|
|
12864
|
-
label:
|
|
12865
|
-
position:
|
|
12882
|
+
label: 'GridTable-markerLineStyle',
|
|
12883
|
+
position: 'absolute',
|
|
12866
12884
|
left: 0,
|
|
12867
12885
|
right: 0,
|
|
12868
|
-
top:
|
|
12869
|
-
transform:
|
|
12886
|
+
top: '50%',
|
|
12887
|
+
transform: 'translateY(-50%)',
|
|
12870
12888
|
height: 2,
|
|
12871
|
-
background:
|
|
12889
|
+
background: 'var(--color-success, #138660)',
|
|
12872
12890
|
};
|
|
12873
12891
|
/** The label, overlaid at the left with a solid ground that masks the rule behind it. */
|
|
12874
12892
|
const markerLabelStyle = {
|
|
12875
|
-
label:
|
|
12876
|
-
position:
|
|
12893
|
+
label: 'GridTable-markerLabelStyle',
|
|
12894
|
+
position: 'absolute',
|
|
12877
12895
|
left: 16,
|
|
12878
|
-
top:
|
|
12879
|
-
transform:
|
|
12896
|
+
top: '50%',
|
|
12897
|
+
transform: 'translateY(-50%)',
|
|
12880
12898
|
paddingRight: 8,
|
|
12881
|
-
background:
|
|
12899
|
+
background: '#fff',
|
|
12882
12900
|
fontSize: 12,
|
|
12883
12901
|
fontWeight: 700,
|
|
12884
12902
|
lineHeight: 1,
|
|
12885
|
-
color:
|
|
12903
|
+
color: 'var(--color-success, #138660)',
|
|
12886
12904
|
};
|
|
12887
12905
|
const totalCellStyle = {
|
|
12888
|
-
label:
|
|
12889
|
-
padding:
|
|
12906
|
+
label: 'GridTable-totalCellStyle',
|
|
12907
|
+
padding: '12px 16px',
|
|
12890
12908
|
};
|
|
12891
12909
|
const totalValueStyle = {
|
|
12892
|
-
label:
|
|
12893
|
-
padding:
|
|
12894
|
-
textAlign:
|
|
12910
|
+
label: 'GridTable-totalValueStyle',
|
|
12911
|
+
padding: '12px 16px',
|
|
12912
|
+
textAlign: 'right',
|
|
12895
12913
|
fontWeight: 600,
|
|
12896
12914
|
};
|
|
12897
12915
|
/**
|
|
@@ -12901,19 +12919,19 @@ const totalValueStyle = {
|
|
|
12901
12919
|
* it keeps its (0,3,0) rank over the plain `.totalCell` rule without doubling.
|
|
12902
12920
|
*/
|
|
12903
12921
|
const footerStyle$8 = {
|
|
12904
|
-
label:
|
|
12905
|
-
display:
|
|
12906
|
-
width:
|
|
12922
|
+
label: 'GridTable-footerStyle',
|
|
12923
|
+
display: 'none',
|
|
12924
|
+
width: '100%',
|
|
12907
12925
|
fontWeight: 500,
|
|
12908
|
-
background:
|
|
12909
|
-
borderTop:
|
|
12910
|
-
position:
|
|
12926
|
+
background: 'var(--color-subtle, #eff0f0)',
|
|
12927
|
+
borderTop: '1px solid var(--border-color, #ededed)',
|
|
12928
|
+
position: 'sticky',
|
|
12911
12929
|
bottom: 0,
|
|
12912
12930
|
[`& .${sx(totalCellStyle)}:first-child`]: {
|
|
12913
12931
|
fontWeight: 600,
|
|
12914
12932
|
},
|
|
12915
|
-
|
|
12916
|
-
display:
|
|
12933
|
+
'@media (min-width: 768px)': {
|
|
12934
|
+
display: 'block',
|
|
12917
12935
|
},
|
|
12918
12936
|
};
|
|
12919
12937
|
|
|
@@ -12921,7 +12939,7 @@ const ChevronUp = () => (jsx("svg", { width: "16", height: "16", viewBox: "0 0 2
|
|
|
12921
12939
|
const ChevronDown = () => (jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": "true", children: jsx("polyline", { points: "6 9 12 15 18 9" }) }));
|
|
12922
12940
|
const ChevronRight$3 = () => (jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", "aria-hidden": "true", children: jsx("polyline", { points: "9 18 15 12 9 6" }) }));
|
|
12923
12941
|
/** Width of the leading control column added when `expandable`. */
|
|
12924
|
-
const EXPAND_COLUMN_WIDTH =
|
|
12942
|
+
const EXPAND_COLUMN_WIDTH = '44px';
|
|
12925
12943
|
function defaultComparator(name) {
|
|
12926
12944
|
return (a, b) => {
|
|
12927
12945
|
const av = a[name];
|
|
@@ -12933,9 +12951,9 @@ function defaultComparator(name) {
|
|
|
12933
12951
|
}
|
|
12934
12952
|
/** Pulls a number out of a formatted value, so totals work on rendered text. */
|
|
12935
12953
|
function toNumber(value) {
|
|
12936
|
-
if (typeof value ===
|
|
12954
|
+
if (typeof value === 'number')
|
|
12937
12955
|
return value;
|
|
12938
|
-
const parsed = parseFloat(String(value).replace(/[^0-9.-]+/g,
|
|
12956
|
+
const parsed = parseFloat(String(value).replace(/[^0-9.-]+/g, ''));
|
|
12939
12957
|
return Number.isNaN(parsed) ? 0 : parsed;
|
|
12940
12958
|
}
|
|
12941
12959
|
/** The row's own key — `rowKey`, then `id` — or undefined when it has neither. */
|
|
@@ -12994,7 +13012,7 @@ function deriveKeys(rows, data, rowKey) {
|
|
|
12994
13012
|
* again to reverse — and an optional total row sums a column into a sticky
|
|
12995
13013
|
* footer.
|
|
12996
13014
|
*/
|
|
12997
|
-
function GridTable({ columns, data, gridTemplateColumns = `repeat(${columns.length}, minmax(0, 1fr))`, rowKey, header = {}, initialSortColumn, initialSortAscending, secondarySortComparator, bordered = true, hideHeader = false, emptyMessage =
|
|
13015
|
+
function GridTable({ columns, data, gridTemplateColumns = `repeat(${columns.length}, minmax(0, 1fr))`, rowKey, header = {}, initialSortColumn, initialSortAscending, secondarySortComparator, bordered = true, hideHeader = false, emptyMessage = 'No data available.', totalRow, expandable = false, defaultExpandedRowKeys, expandAll, expandLabel = 'row', banner, alignTop = false, rowMarker, draftRow, editRow, flashRowKey, className = '', }) {
|
|
12998
13016
|
const [sortColumn, setSortColumn] = useState(initialSortColumn);
|
|
12999
13017
|
// Ascending unless told otherwise: an omitted initial direction means the
|
|
13000
13018
|
// first sort column reads ascending (matching the sort itself and the
|
|
@@ -13022,9 +13040,7 @@ function GridTable({ columns, data, gridTemplateColumns = `repeat(${columns.leng
|
|
|
13022
13040
|
});
|
|
13023
13041
|
// The control column is a fixed leading track prepended to the caller's
|
|
13024
13042
|
// template, so every grid — heading, rows and footer — stays aligned.
|
|
13025
|
-
const template = expandable
|
|
13026
|
-
? `${EXPAND_COLUMN_WIDTH} ${gridTemplateColumns}`
|
|
13027
|
-
: gridTemplateColumns;
|
|
13043
|
+
const template = expandable ? `${EXPAND_COLUMN_WIDTH} ${gridTemplateColumns}` : gridTemplateColumns;
|
|
13028
13044
|
const sorted = useMemo(() => {
|
|
13029
13045
|
if (!sortColumn)
|
|
13030
13046
|
return data;
|
|
@@ -13089,11 +13105,11 @@ function GridTable({ columns, data, gridTemplateColumns = `repeat(${columns.leng
|
|
|
13089
13105
|
const heading = (column, { interactive }) => {
|
|
13090
13106
|
const sortable = interactive && !!column.sortable && !!column.name;
|
|
13091
13107
|
const isSorted = sortable && column.name === sortColumn;
|
|
13092
|
-
const content = (jsxs("span", { className: sx(headingInnerStyle), children: [column.icon &&
|
|
13108
|
+
const content = (jsxs("span", { className: sx(headingInnerStyle), children: [column.icon && jsx("span", { className: sx(headingIconStyle), children: column.icon }), column.label, column.labelAs?.({ name: column.name }), isSorted && jsx("span", { className: sx(sortIconStyle$1), children: ascending ? jsx(ChevronUp, {}) : jsx(ChevronDown, {}) })] }));
|
|
13093
13109
|
if (!sortable) {
|
|
13094
|
-
return
|
|
13110
|
+
return jsx("div", { className: cx(sx(headingStyle$2), column.labelClassName ?? ''), children: content });
|
|
13095
13111
|
}
|
|
13096
|
-
return (jsx("button", { type: "button", className: cx(sx(headingStyle$2), sx(sortableStyle), column.labelClassName ??
|
|
13112
|
+
return (jsx("button", { type: "button", className: cx(sx(headingStyle$2), sx(sortableStyle), column.labelClassName ?? ''), onClick: () => handleSort(column.name), "aria-sort": isSorted ? (ascending ? 'ascending' : 'descending') : 'none', children: content }));
|
|
13097
13113
|
};
|
|
13098
13114
|
const total = useMemo(() => {
|
|
13099
13115
|
if (!totalRow)
|
|
@@ -13101,25 +13117,21 @@ function GridTable({ columns, data, gridTemplateColumns = `repeat(${columns.leng
|
|
|
13101
13117
|
const column = columns.find((c) => c.name === totalRow.columnName);
|
|
13102
13118
|
return data.reduce((sum, row) => {
|
|
13103
13119
|
const raw = row[totalRow.columnName];
|
|
13104
|
-
return
|
|
13120
|
+
return sum + toNumber(column?.format ? column.format(raw, row) : raw);
|
|
13105
13121
|
}, 0);
|
|
13106
13122
|
}, [columns, data, totalRow]);
|
|
13107
|
-
const totalIndex = totalRow
|
|
13108
|
-
? columns.findIndex((c) => c.name === totalRow.columnName)
|
|
13109
|
-
: -1;
|
|
13123
|
+
const totalIndex = totalRow ? columns.findIndex((c) => c.name === totalRow.columnName) : -1;
|
|
13110
13124
|
// Only meaningful in a chronological order: shown when unsorted (the given
|
|
13111
13125
|
// order) or sorted ascending by the nominated column.
|
|
13112
13126
|
const markerActive = !!rowMarker &&
|
|
13113
|
-
(rowMarker.showWhenSortedBy === undefined ||
|
|
13114
|
-
|
|
13115
|
-
(sortColumn === rowMarker.showWhenSortedBy && ascending !== false));
|
|
13116
|
-
const marker = rowMarker && markerActive ? (jsxs("div", { className: sx(markerStyle), role: "separator", "aria-label": typeof rowMarker.label === "string" ? rowMarker.label : undefined, children: [jsx("span", { className: sx(markerLineStyle), "aria-hidden": "true" }), rowMarker.label != null && (jsx("span", { className: sx(markerLabelStyle), children: rowMarker.label }))] })) : null;
|
|
13127
|
+
(rowMarker.showWhenSortedBy === undefined || sortColumn === undefined || (sortColumn === rowMarker.showWhenSortedBy && ascending !== false));
|
|
13128
|
+
const marker = rowMarker && markerActive ? (jsxs("div", { className: sx(markerStyle), role: "separator", "aria-label": typeof rowMarker.label === 'string' ? rowMarker.label : undefined, children: [jsx("span", { className: sx(markerLineStyle), "aria-hidden": "true" }), rowMarker.label != null && jsx("span", { className: sx(markerLabelStyle), children: rowMarker.label })] })) : null;
|
|
13117
13129
|
// `atEnd` is the fallback for when no row matches, so it must not also fire when
|
|
13118
13130
|
// `beforeKey` does — otherwise a marker set with both would render twice. Test
|
|
13119
13131
|
// membership rather than truthiness so a legitimate empty-string key still
|
|
13120
13132
|
// counts as a match.
|
|
13121
13133
|
const markerBeforeMatches = rowMarker?.beforeKey != null && allKeys.includes(rowMarker.beforeKey);
|
|
13122
|
-
return (jsxs("div", { className: cx(sx(tableStyle$8), className), children: [banner && jsx("div", { className: sx(bannerStyle$2), children: banner }), !hideHeader && (jsxs("div", { className: sx(headerStyle$x), children: [header.above, jsxs("div", { className: sx(gridStyle$7), style: { gridTemplateColumns: template }, children: [expandable &&
|
|
13134
|
+
return (jsxs("div", { className: cx(sx(tableStyle$8), className), children: [banner && jsx("div", { className: sx(bannerStyle$2), children: banner }), !hideHeader && (jsxs("div", { className: sx(headerStyle$x), children: [header.above, jsxs("div", { className: sx(gridStyle$7), style: { gridTemplateColumns: template }, children: [expandable && jsx("div", { className: sx(headingStyle$2), "aria-hidden": "true" }), columns.map((column, i) => (jsx(React.Fragment, { children: heading(column, { interactive: true }) }, i)))] }), header.below] })), !sorted.length && !draftRow ? (jsx("div", { className: sx(emptyStyle$d), children: emptyMessage })) : (jsxs("div", { className: sx(bodyStyle$5), children: [draftRow && jsx("div", { className: sx(draftRowStyle), children: draftRow }), sorted.map((row, rowIndex) => {
|
|
13123
13135
|
const record = row;
|
|
13124
13136
|
const key = allKeys[rowIndex];
|
|
13125
13137
|
// Only an expandable table exposes expansion; without it, a lingering
|
|
@@ -13127,33 +13139,14 @@ function GridTable({ columns, data, gridTemplateColumns = `repeat(${columns.leng
|
|
|
13127
13139
|
// after expandable was turned off) must not leak `expanded: true` to
|
|
13128
13140
|
// renderers that have no toggle to collapse it.
|
|
13129
13141
|
const expanded = expandable && expandedKeys.has(key);
|
|
13130
|
-
return (jsxs(React.Fragment, { children: [marker && rowMarker?.beforeKey === key && marker, editRow?.key === key ? (jsx("div", { className: sx(
|
|
13131
|
-
const value = column.name
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
const formatted = column.format
|
|
13135
|
-
? column.format(value, row)
|
|
13136
|
-
: value;
|
|
13137
|
-
return (jsxs("div", { className: sx(cellWrapStyle), ...(column.name
|
|
13138
|
-
? { "data-colname": column.name }
|
|
13139
|
-
: {}), children: [column.label && (jsx("div", { className: sx(stackedLabelStyle), children: heading(column, { interactive: false }) })), jsx("div", { className: cx(sx(cellStyle$2), alignTop ? sx(cellTopStyle) : "", column.className ?? ""), children: column.as ? (column.as({
|
|
13140
|
-
row,
|
|
13141
|
-
rowIndex,
|
|
13142
|
-
name: column.name,
|
|
13143
|
-
expanded,
|
|
13144
|
-
})) : column.name ? (jsx("span", { className: sx(valueStyle$2), children: formatted || jsx(Fragment, { children: "\u2013" }) })) : null })] }, colIndex));
|
|
13142
|
+
return (jsxs(React.Fragment, { children: [marker && rowMarker?.beforeKey === key && marker, editRow?.key === key ? (jsx("div", { className: cx(sx(editRowStyle), bordered ? sx(borderedStyle) : ''), "data-rowid": key, "data-testid": `row-${key}`, "data-editing": "true", children: editRow.content })) : (jsxs("div", { className: cx(sx(rowStyle$5), bordered ? sx(borderedStyle) : '', flashRowKey === key ? sx(flashRowStyle) : ''), style: { gridTemplateColumns: template }, "data-rowid": key, "data-testid": `row-${key}`, "data-flash": flashRowKey === key ? 'true' : undefined, children: [expandable && (jsx("div", { className: sx(expandCellStyle), children: jsx("button", { type: "button", className: sx(expandButtonStyle$1), onClick: () => toggleRow(key), "aria-expanded": expanded, "aria-label": `${expanded ? 'Collapse' : 'Expand'} ${typeof expandLabel === 'function' ? expandLabel(row, rowIndex) : expandLabel}`, children: expanded ? jsx(ChevronDown, {}) : jsx(ChevronRight$3, {}) }) })), columns.map((column, colIndex) => {
|
|
13143
|
+
const value = column.name ? record[column.name] : undefined;
|
|
13144
|
+
const formatted = column.format ? column.format(value, row) : value;
|
|
13145
|
+
return (jsxs("div", { className: sx(cellWrapStyle), ...(column.name ? { 'data-colname': column.name } : {}), children: [column.label && jsx("div", { className: sx(stackedLabelStyle), children: heading(column, { interactive: false }) }), jsx("div", { className: cx(sx(cellStyle$2), alignTop ? sx(cellTopStyle) : '', column.className ?? ''), children: column.as ? (column.as({ row, rowIndex, name: column.name, expanded })) : column.name ? (jsx("span", { className: sx(valueStyle$2), children: formatted || jsx(Fragment, { children: "\u2013" }) })) : null })] }, colIndex));
|
|
13145
13146
|
})] }, key))] }, key));
|
|
13146
|
-
}), marker &&
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
sorted.length > 0 &&
|
|
13150
|
-
marker] })), totalRow && (jsx("div", { className: sx(footerStyle$8), children: jsxs("div", { className: sx(gridStyle$7), style: { gridTemplateColumns: template }, children: [expandable && (jsx("div", { className: sx(totalCellStyle), "aria-hidden": "true" })), columns.map((_, i) => (jsx("div", { className: i === totalIndex ? sx(totalValueStyle) : sx(totalCellStyle), children: i === 0
|
|
13151
|
-
? totalRow.label
|
|
13152
|
-
: i === totalIndex
|
|
13153
|
-
? total.toLocaleString()
|
|
13154
|
-
: null }, i)))] }) }))] }));
|
|
13155
|
-
}
|
|
13156
|
-
GridTable.displayName = "GridTable";
|
|
13147
|
+
}), marker && rowMarker?.atEnd && !markerBeforeMatches && sorted.length > 0 && marker] })), totalRow && (jsx("div", { className: sx(footerStyle$8), children: jsxs("div", { className: sx(gridStyle$7), style: { gridTemplateColumns: template }, children: [expandable && jsx("div", { className: sx(totalCellStyle), "aria-hidden": "true" }), columns.map((_, i) => (jsx("div", { className: i === totalIndex ? sx(totalValueStyle) : sx(totalCellStyle), children: i === 0 ? totalRow.label : i === totalIndex ? total.toLocaleString() : null }, i)))] }) }))] }));
|
|
13148
|
+
}
|
|
13149
|
+
GridTable.displayName = 'GridTable';
|
|
13157
13150
|
|
|
13158
13151
|
/**
|
|
13159
13152
|
* HubAppShell's compiled rules.
|