@jsenv/navi 0.12.31 → 0.12.32
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/jsenv_navi.js +173 -49
- package/dist/jsenv_navi.js.map +10 -4
- package/package.json +1 -1
package/dist/jsenv_navi.js
CHANGED
|
@@ -15624,104 +15624,228 @@ const RouteLink = ({
|
|
|
15624
15624
|
});
|
|
15625
15625
|
};
|
|
15626
15626
|
|
|
15627
|
-
installImportMetaCss(import.meta);
|
|
15627
|
+
installImportMetaCss(import.meta);Object.assign(PSEUDO_CLASSES, {
|
|
15628
|
+
":-navi-selected": {
|
|
15629
|
+
attribute: "data-selected"
|
|
15630
|
+
}
|
|
15631
|
+
});
|
|
15632
|
+
import.meta.css = /* css */`
|
|
15633
|
+
@layer navi {
|
|
15634
|
+
.navi_tablist {
|
|
15635
|
+
--tablist-border-radius: 8px;
|
|
15636
|
+
--tablist-background: transparent;
|
|
15637
|
+
--tab-border-radius: calc(var(--tablist-border-radius) - 2px);
|
|
15638
|
+
|
|
15639
|
+
--tab-background: transparent;
|
|
15640
|
+
--tab-background-hover: #dae0e7;
|
|
15641
|
+
--tab-background-selected: transparent;
|
|
15642
|
+
--tab-color: inherit;
|
|
15643
|
+
--tab-color-hover: #010409;
|
|
15644
|
+
--tab-color-selected: inherit;
|
|
15645
|
+
--tab-marker-height: 2px;
|
|
15646
|
+
--tab-marker-color: rgb(205, 52, 37);
|
|
15647
|
+
}
|
|
15648
|
+
}
|
|
15649
|
+
|
|
15628
15650
|
.navi_tablist {
|
|
15629
15651
|
display: flex;
|
|
15630
|
-
|
|
15652
|
+
line-height: 2em;
|
|
15653
|
+
background: var(--tablist-background);
|
|
15654
|
+
border-radius: var(--tablist-border-radius);
|
|
15631
15655
|
overflow-x: auto;
|
|
15632
15656
|
overflow-y: hidden;
|
|
15633
15657
|
}
|
|
15634
|
-
|
|
15635
15658
|
.navi_tablist > ul {
|
|
15636
15659
|
display: flex;
|
|
15660
|
+
width: 100%;
|
|
15637
15661
|
margin: 0;
|
|
15638
15662
|
padding: 0;
|
|
15639
15663
|
align-items: center;
|
|
15640
15664
|
gap: 0.5rem;
|
|
15641
15665
|
list-style: none;
|
|
15642
15666
|
}
|
|
15643
|
-
|
|
15644
15667
|
.navi_tablist > ul > li {
|
|
15645
15668
|
position: relative;
|
|
15646
15669
|
display: inline-flex;
|
|
15647
15670
|
}
|
|
15648
15671
|
|
|
15649
15672
|
.navi_tab {
|
|
15673
|
+
--x-tab-background: var(--tab-background);
|
|
15674
|
+
--x-tab-color: var(--tab-color);
|
|
15675
|
+
|
|
15650
15676
|
display: flex;
|
|
15651
15677
|
flex-direction: column;
|
|
15652
15678
|
white-space: nowrap;
|
|
15653
|
-
|
|
15679
|
+
border-radius: var(--tab-border-radius);
|
|
15654
15680
|
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15681
|
+
.navi_tab_content {
|
|
15682
|
+
display: flex;
|
|
15683
|
+
padding: 0 0.5rem;
|
|
15684
|
+
color: var(--x-tab-color);
|
|
15685
|
+
background: var(--x-tab-background);
|
|
15686
|
+
border-radius: inherit;
|
|
15687
|
+
transition: background 0.12s ease-out;
|
|
15688
|
+
}
|
|
15689
|
+
/* Hidden bold clone to reserve space for bold width without affecting height */
|
|
15690
|
+
.navi_tab_content_bold_clone {
|
|
15691
|
+
display: block; /* in-flow so it contributes to width */
|
|
15692
|
+
height: 0; /* zero height so it doesn't change layout height */
|
|
15693
|
+
font-weight: 600; /* force bold to compute max width */
|
|
15694
|
+
visibility: hidden; /* not visible */
|
|
15695
|
+
pointer-events: none; /* inert */
|
|
15696
|
+
overflow: hidden; /* avoid any accidental height */
|
|
15697
|
+
}
|
|
15698
|
+
.navi_tab_selected_marker {
|
|
15699
|
+
z-index: 1;
|
|
15700
|
+
display: flex;
|
|
15701
|
+
width: 100%;
|
|
15702
|
+
height: var(--tab-marker-height);
|
|
15703
|
+
margin-top: 5px;
|
|
15704
|
+
background: transparent;
|
|
15705
|
+
border-radius: 0.1px;
|
|
15706
|
+
}
|
|
15668
15707
|
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15708
|
+
/* Interactive */
|
|
15709
|
+
&[data-interactive] {
|
|
15710
|
+
cursor: pointer;
|
|
15711
|
+
}
|
|
15712
|
+
/* Hover */
|
|
15713
|
+
&:hover {
|
|
15714
|
+
--x-tab-background: var(--tab-background-hover);
|
|
15715
|
+
--x-tab-color: var(--tab-color-hover);
|
|
15716
|
+
}
|
|
15717
|
+
/* Selected */
|
|
15718
|
+
&[data-selected] {
|
|
15719
|
+
--x-tab-background: var(--tab-background-selected);
|
|
15720
|
+
--x-tab-color: var(--tab-color-selected);
|
|
15678
15721
|
|
|
15679
|
-
|
|
15680
|
-
|
|
15681
|
-
|
|
15682
|
-
|
|
15683
|
-
|
|
15684
|
-
|
|
15685
|
-
|
|
15686
|
-
overflow: hidden; /* avoid any accidental height */
|
|
15722
|
+
.navi_tab_content {
|
|
15723
|
+
font-weight: 600;
|
|
15724
|
+
}
|
|
15725
|
+
.navi_tab_selected_marker {
|
|
15726
|
+
background: var(--tab-marker-color);
|
|
15727
|
+
}
|
|
15728
|
+
}
|
|
15687
15729
|
}
|
|
15688
15730
|
|
|
15689
|
-
.
|
|
15690
|
-
|
|
15691
|
-
|
|
15731
|
+
.navi_tablist[data-expand] {
|
|
15732
|
+
.navi_tab {
|
|
15733
|
+
flex: 1;
|
|
15734
|
+
align-items: center;
|
|
15735
|
+
}
|
|
15692
15736
|
|
|
15693
|
-
|
|
15694
|
-
|
|
15737
|
+
.navi_tab_content {
|
|
15738
|
+
width: 100%;
|
|
15739
|
+
justify-content: center;
|
|
15740
|
+
}
|
|
15695
15741
|
}
|
|
15696
15742
|
`;
|
|
15743
|
+
const TabListUnderlinerContext = createContext();
|
|
15744
|
+
const TabListStyleCSSVars = {
|
|
15745
|
+
borderRadius: "--tablist-border-radius",
|
|
15746
|
+
background: "--tablist-background"
|
|
15747
|
+
};
|
|
15697
15748
|
const TabList = ({
|
|
15698
15749
|
children,
|
|
15750
|
+
spacing,
|
|
15751
|
+
underline,
|
|
15752
|
+
expand,
|
|
15753
|
+
expandX,
|
|
15699
15754
|
...props
|
|
15700
15755
|
}) => {
|
|
15701
15756
|
return jsx(Box, {
|
|
15702
15757
|
as: "nav",
|
|
15703
15758
|
baseClassName: "navi_tablist",
|
|
15704
15759
|
role: "tablist",
|
|
15760
|
+
"data-expand": expand || expandX ? "" : undefined,
|
|
15761
|
+
expand: expand,
|
|
15762
|
+
expandX: expandX,
|
|
15705
15763
|
...props,
|
|
15706
|
-
|
|
15764
|
+
styleCSSVars: TabListStyleCSSVars,
|
|
15765
|
+
children: jsx(Box, {
|
|
15766
|
+
as: "ul",
|
|
15767
|
+
column: true,
|
|
15707
15768
|
role: "list",
|
|
15708
|
-
|
|
15709
|
-
|
|
15710
|
-
|
|
15711
|
-
|
|
15769
|
+
spacing: spacing,
|
|
15770
|
+
children: jsx(TabListUnderlinerContext.Provider, {
|
|
15771
|
+
value: underline,
|
|
15772
|
+
children: children.map(child => {
|
|
15773
|
+
return jsx(Box, {
|
|
15774
|
+
as: "li",
|
|
15775
|
+
column: true,
|
|
15776
|
+
expandX: expandX,
|
|
15777
|
+
expand: expand,
|
|
15778
|
+
children: child
|
|
15779
|
+
}, child.props.key);
|
|
15780
|
+
})
|
|
15712
15781
|
})
|
|
15713
15782
|
})
|
|
15714
15783
|
});
|
|
15715
15784
|
};
|
|
15716
|
-
const
|
|
15785
|
+
const TAB_STYLE_CSS_VARS = {
|
|
15786
|
+
"background": "--tab-background",
|
|
15787
|
+
"color": "--tab-color",
|
|
15788
|
+
":hover": {
|
|
15789
|
+
background: "--tab-background-hover",
|
|
15790
|
+
color: "--tab-color-hover"
|
|
15791
|
+
},
|
|
15792
|
+
":-navi-selected": {
|
|
15793
|
+
background: "--tab-color-selected",
|
|
15794
|
+
color: "--tab-color-selected"
|
|
15795
|
+
}
|
|
15796
|
+
};
|
|
15797
|
+
const TAB_PSEUDO_CLASSES = [":hover", ":-navi-selected"];
|
|
15798
|
+
const TAB_PSEUDO_ELEMENTS = ["::-navi-marker"];
|
|
15799
|
+
const Tab = props => {
|
|
15800
|
+
if (props.route) {
|
|
15801
|
+
return jsx(TabRoute, {
|
|
15802
|
+
...props
|
|
15803
|
+
});
|
|
15804
|
+
}
|
|
15805
|
+
return jsx(TabBasic, {
|
|
15806
|
+
...props
|
|
15807
|
+
});
|
|
15808
|
+
};
|
|
15809
|
+
const TabRoute = ({
|
|
15810
|
+
route,
|
|
15811
|
+
children,
|
|
15812
|
+
...props
|
|
15813
|
+
}) => {
|
|
15814
|
+
const {
|
|
15815
|
+
active
|
|
15816
|
+
} = useRouteStatus(route);
|
|
15817
|
+
return jsx(TabBasic, {
|
|
15818
|
+
selected: active,
|
|
15819
|
+
...props,
|
|
15820
|
+
children: jsx(RouteLink, {
|
|
15821
|
+
route: route,
|
|
15822
|
+
underline: false,
|
|
15823
|
+
color: "inherit",
|
|
15824
|
+
children: children
|
|
15825
|
+
})
|
|
15826
|
+
});
|
|
15827
|
+
};
|
|
15828
|
+
const TabBasic = ({
|
|
15717
15829
|
children,
|
|
15718
15830
|
selected,
|
|
15831
|
+
onClick,
|
|
15719
15832
|
...props
|
|
15720
15833
|
}) => {
|
|
15834
|
+
const tabListUnderline = useContext(TabListUnderlinerContext);
|
|
15721
15835
|
return jsxs(Box, {
|
|
15722
|
-
baseClassName: "navi_tab",
|
|
15723
15836
|
role: "tab",
|
|
15724
15837
|
"aria-selected": selected ? "true" : "false",
|
|
15838
|
+
"data-interactive": onClick ? "" : undefined,
|
|
15839
|
+
onClick: onClick
|
|
15840
|
+
// Style system
|
|
15841
|
+
,
|
|
15842
|
+
baseClassName: "navi_tab",
|
|
15843
|
+
styleCSSVars: TAB_STYLE_CSS_VARS,
|
|
15844
|
+
pseudoClasses: TAB_PSEUDO_CLASSES,
|
|
15845
|
+
pseudoElements: TAB_PSEUDO_ELEMENTS,
|
|
15846
|
+
basePseudoState: {
|
|
15847
|
+
":-navi-selected": selected
|
|
15848
|
+
},
|
|
15725
15849
|
...props,
|
|
15726
15850
|
children: [jsx("div", {
|
|
15727
15851
|
className: "navi_tab_content",
|
|
@@ -15730,8 +15854,8 @@ const Tab = ({
|
|
|
15730
15854
|
className: "navi_tab_content_bold_clone",
|
|
15731
15855
|
"aria-hidden": "true",
|
|
15732
15856
|
children: children
|
|
15733
|
-
}), jsx("span", {
|
|
15734
|
-
className: "
|
|
15857
|
+
}), tabListUnderline && jsx("span", {
|
|
15858
|
+
className: "navi_tab_selected_marker"
|
|
15735
15859
|
})]
|
|
15736
15860
|
});
|
|
15737
15861
|
};
|