it-data-nexus-ui-library 2.10.13 → 2.10.14
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as r,Children as o,useState as i,useCallback as n,useEffect as l}from"react";import s from"@mui/icons-material/ChevronLeftRounded";import a from"@mui/icons-material/ChevronRightRounded";import c from"@mui/material/Box";import{Stack as d}from"./_Primitives/Stack.mjs";import{IconButton as m}from"./Buttons/IconButton.mjs";import{Caption as u}from"./Typography.mjs";const f={xs:1,sm:2,md:3,lg:4},
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as r,Children as o,useState as i,useCallback as n,useEffect as l}from"react";import s from"@mui/icons-material/ChevronLeftRounded";import a from"@mui/icons-material/ChevronRightRounded";import c from"@mui/material/Box";import{Stack as d}from"./_Primitives/Stack.mjs";import{IconButton as m}from"./Buttons/IconButton.mjs";import{Caption as u}from"./Typography.mjs";const f={xs:1,sm:2,md:3,lg:4},h=["xs","sm","md","lg"],p={disableRipple:!0,disableFocusRipple:!0,sx:e=>({"&.Mui-focusVisible":{outline:`2px solid ${e.palette.primary.main}`,outlineOffset:2}})},b=({children:b,"aria-label":g,itemsPerView:x,gap:v=2.5,previousLabel:y="Previous",nextLabel:$="Next",itemLabel:w,itemsPerGroup:A=1,sx:L})=>{const S=r(null),W=r(null),j=r(null),B=o.toArray(b),R=B.length,[C,O]=i({start:!0,end:!0}),[k,E]=i(new Set),I=n(()=>{const e=S.current;e&&O({start:e.scrollLeft<=2,end:e.scrollLeft+e.clientWidth>=e.scrollWidth-2})},[]);l(()=>{const e=S.current;if(!e)return;I();const t=new ResizeObserver(I);t.observe(e),e.addEventListener("scroll",I,{passive:!0});const r=new Set,o=new IntersectionObserver(e=>{for(const t of e){const e=Number(t.target.dataset.index);t.intersectionRatio>=.5?r.add(e):r.delete(e)}E(new Set(r))},{root:e,threshold:[0,.5,1]});for(const t of Array.from(e.children))o.observe(t);return()=>{t.disconnect(),o.disconnect(),e.removeEventListener("scroll",I)}},[R,I]),l(()=>{Array.from(S.current?.children??[]).forEach((e,t)=>{e.toggleAttribute("inert",k.size>0&&!k.has(t))})},[k,R]),l(()=>{const e=C.end?"next":C.start?"previous":null;if(e&&j.current===e){const t="next"===e?"previous":"next";W.current?.querySelector(`[data-control="${t}"]:not(:disabled)`)?.focus()}},[C]);const M=e=>{const t=S.current,r=t?.children[0];if(!t||!r)return;const o=t.children[1],i=o?o.offsetLeft-r.offsetLeft:r.offsetWidth;t.scrollBy({left:e*i,behavior:"undefined"!=typeof window&&Boolean(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)?"instant":"smooth"})},P=Array.from(k).sort((e,t)=>e-t),F=R*A,N=0===P.length?"":1===P.length?`Showing ${P[0]*A+1} of ${F}`:`Showing ${P[0]*A+1}–${Math.min((P[P.length-1]+1)*A,F)} of ${F}`,z=x&&Object.keys(x).length>0?x:f,T={xs:h.map(e=>z[e]).find(e=>void 0!==e),...z},V=e=>Object.fromEntries(Object.entries(T).filter(e=>void 0!==e[1]).map(([t,r])=>[t,`calc((100% - ${e.spacing(v)} * ${r-1}) / ${r})`]));return e(d,{sx:[{gap:1.5,minWidth:0,maxWidth:"100%"},...Array.isArray(L)?L:L?[L]:[]],children:[t(c,{ref:S,role:"region","aria-label":g,tabIndex:0,sx:e=>({display:"grid",gridAutoFlow:"column",gridAutoColumns:V(e),gap:v,minWidth:0,overflowX:"auto",overscrollBehaviorX:"contain",scrollSnapType:"x mandatory",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},scrollBehavior:"smooth","@media (prefers-reduced-motion: reduce)":{scrollBehavior:"auto"},"&:focus-visible":{outline:`2px solid ${e.palette.primary.main}`,outlineOffset:2,borderRadius:1}}),children:B.map((e,r)=>t(c,{"data-index":r,role:"group","aria-roledescription":"slide","aria-label":A>1?`${r*A+1}–${Math.min((r+1)*A,F)} of ${F}`:`${r+1} of ${R}`,sx:{minWidth:0,scrollSnapAlign:"start"},children:e},r))}),e(d,{ref:W,direction:"row",onFocus:e=>{j.current=e.target.dataset.control??null},sx:{justifyContent:"center",alignItems:"center",gap:1.5},children:[t(m,{...p,"data-control":"previous",title:y,onClick:()=>M(-1),disabled:C.start,children:t(s,{})}),t(u,{"aria-live":"polite",sx:{minWidth:"9ch",textAlign:"center"},children:w?N?`${N} ${w}`:`${F} ${w}`:N}),t(m,{...p,"data-control":"next",title:$,onClick:()=>M(1),disabled:C.end,children:t(a,{})})]})]})};b.displayName="Carousel";export{b as Carousel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as t,jsx as o}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i,useCallback as l}from"react";import s from"@mui/material/Box";import{Body2 as c}from"./Typography.mjs";const a="#main-content",d="h1, h2, h3, h4, h5, h6",p=e=>null===e?null:"string"==typeof e?document.querySelector(e):e??document.querySelector(a),u=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth",y=({items:y,"aria-label":m,scrollRoot:f=a,sticky:x=!0,stickyOffset:
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as o}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i,useCallback as l}from"react";import s from"@mui/material/Box";import{Body2 as c}from"./Typography.mjs";const a="#main-content",d="h1, h2, h3, h4, h5, h6",p=e=>null===e?null:"string"==typeof e?document.querySelector(e):e??document.querySelector(a),u=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth",y=({items:y,"aria-label":m,scrollRoot:f=a,sticky:x=!0,glass:h=!1,stickyOffset:b=0,justifyContent:v="center",sx:w})=>{const[g,k]=n(y[0]?.id),$=r(null),S=r(null),E=r(!1),I=r(void 0),T=y.map(e=>e.id).join("\n");i(()=>{const e=T?T.split("\n"):[],t=p(f),o=new Set,n=new IntersectionObserver(t=>{for(const e of t)e.isIntersecting?o.add(e.target.id):o.delete(e.target.id);const n=e.find(e=>o.has(e));n&&k(n)},{root:t,rootMargin:"-35% 0px -60% 0px"});for(const t of e){const e=document.getElementById(t);e&&n.observe(e)}return()=>n.disconnect()},[T,f]),i(()=>{if(!x)return;const e=$.current,t=S.current,o=p(f);if(!e||!t)return;let n=!1,r=o?o.scrollTop:window.scrollY;const i=()=>{const e=(o??document.documentElement).getBoundingClientRect();return{top:e.top+b,left:e.left,width:o?o.clientWidth:window.innerWidth}},l=()=>{t.style.display="none",e.style.position="",e.style.top="",e.style.left="",e.style.width="",e.style.boxSizing=""},s=()=>{e.style.opacity="",e.style.visibility="",e.style.pointerEvents=""},c=()=>{const c=o?o.scrollTop:window.scrollY,a=c-r;if(r=c,c>b&&!n)(()=>{const{top:o,left:n,width:r}=i();t.style.height=`${e.offsetHeight}px`,t.style.display="block",e.style.position="fixed",e.style.top=`${o}px`,e.style.left=`${n}px`,e.style.width=`${r}px`,e.style.boxSizing="border-box"})(),n=!0;else if(c<=b&&n)l(),n=!1;else if(n){const{top:t,left:o,width:n}=i();e.style.top=`${t}px`,e.style.left=`${o}px`,e.style.width=`${n}px`}E.current||(c<=b||a<-5?s():c>100&&a>8&&(e.style.opacity="0",e.style.visibility="hidden",e.style.pointerEvents="none"))},a=o??window;a.addEventListener("scroll",c,{passive:!0});const d=new ResizeObserver(()=>{if(n){const{top:t,left:o,width:n}=i();e.style.top=`${t}px`,e.style.left=`${o}px`,e.style.width=`${n}px`}});return d.observe(o??document.documentElement),()=>{a.removeEventListener("scroll",c),d.disconnect(),l(),s(),clearTimeout(I.current)}},[x,f,b]),i(()=>{const e=$.current,t=e?.querySelector('[aria-current="location"]');!e||!t||e.scrollWidth<=e.clientWidth||e.scrollTo({left:t.offsetLeft-(e.clientWidth-t.offsetWidth)/2,behavior:u()})},[g]);const W=l((e,t)=>{if(e.defaultPrevented||0!==e.button)return;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;const o=document.getElementById(t);if(!o)return;e.preventDefault();const n=o.matches(d)?o:o.querySelector(d)??o;n.hasAttribute("tabindex")||n.setAttribute("tabindex","-1");const r=$.current;r&&(r.style.opacity="",r.style.visibility="",r.style.pointerEvents=""),E.current=!0,clearTimeout(I.current),I.current=setTimeout(()=>{E.current=!1},1e3),o.scrollIntoView({block:"start",behavior:u()}),n.focus({preventScroll:!0}),k(t)},[]);return e(t,{children:[o("div",{ref:S,"aria-hidden":"true",style:{display:"none",flexShrink:0}}),o(s,{ref:$,component:"nav","aria-label":m,sx:[e=>({width:"100%",boxSizing:"border-box",overflowX:{xs:"auto",sm:"visible"},overscrollBehaviorX:"contain",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"},px:{xs:"16px",sm:x?"16px":0},maskImage:{xs:"linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent)",sm:"none"},zIndex:x?e.zIndex.appBar:void 0,backgroundColor:h?"transparent":x?"background.default":void 0,backgroundImage:h?e=>{const t=`color-mix(in srgb, ${e.palette.background.default} 70%, transparent)`;return`linear-gradient(to bottom, ${t} 0%, ${t} 70%, transparent 100%)`}:void 0,backdropFilter:h?"blur(8px)":void 0,...x&&{transition:"opacity 0.2s ease, visibility 0.2s ease","@media (prefers-reduced-motion: reduce)":{transition:"none"}}}),...Array.isArray(w)?w:w?[w]:[]],children:o(s,{component:"ul",role:"list",sx:{listStyle:"none",m:0,p:0,display:"flex",flexWrap:{xs:"nowrap",sm:"wrap"},justifyContent:v,columnGap:{xs:2.5,sm:3}},children:y.map(({id:e,label:t})=>{const n=e===g;return o(s,{component:"li",sx:{flex:"none"},children:o(s,{component:"a",href:`#${e}`,"aria-current":n?"location":void 0,onClick:t=>W(t,e),sx:{display:"block",py:1.25,whiteSpace:"nowrap",color:n?"text.primary":"text.secondary",textDecoration:n?"underline":"none",textDecorationColor:e=>e.palette.primary.main,textDecorationThickness:n?"3px":void 0,textUnderlineOffset:"4px",borderRadius:.5,"&:hover":{color:"text.primary",textDecoration:"underline",textDecorationColor:e=>e.palette.primary.main},"&:focus-visible":{outline:e=>`2px solid ${e.palette.primary.main}`,outlineOffset:2}},children:o(c,{component:"span",sx:{color:"inherit",letterSpacing:"0.015em"},children:t})})},e)})})})]})};export{y as SectionNav};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="2.10.
|
|
1
|
+
const o="2.10.14";export{o as SAGE_NEXUS_UI_VERSION};
|
package/dist/index.d.ts
CHANGED
|
@@ -1666,24 +1666,13 @@ interface SectionNavItem {
|
|
|
1666
1666
|
label: string;
|
|
1667
1667
|
}
|
|
1668
1668
|
interface SectionNavProps {
|
|
1669
|
-
/** Ordered sections. Each `id` must match an element on the page. */
|
|
1670
1669
|
items: SectionNavItem[];
|
|
1671
1670
|
"aria-label": string;
|
|
1672
|
-
/**
|
|
1673
|
-
* The element the page scrolls inside: a CSS selector or an element. Defaults to the
|
|
1674
|
-
* app's `#main-content` container, because Nexus pages scroll there and not in the window.
|
|
1675
|
-
* `null`, or a selector that matches nothing, falls back to the window.
|
|
1676
|
-
*/
|
|
1677
1671
|
scrollRoot?: string | HTMLElement | null;
|
|
1678
|
-
/** Pin the nav to the top of the scroll root while its sections scroll underneath. Defaults to `true`. */
|
|
1679
1672
|
sticky?: boolean;
|
|
1680
|
-
/**
|
|
1673
|
+
/** Give the nav a translucent background with a blur behind it. Defaults to `false`. */
|
|
1674
|
+
glass?: boolean;
|
|
1681
1675
|
stickyOffset?: number;
|
|
1682
|
-
/**
|
|
1683
|
-
* How items are distributed along the nav's horizontal axis. Defaults to `"center"`.
|
|
1684
|
-
* For `"flex-start"` or `"flex-end"`, add a matching `pl` or `pr` via `sx` to inset
|
|
1685
|
-
* items from the page edge by the page gutter.
|
|
1686
|
-
*/
|
|
1687
1676
|
justifyContent?: "center" | "flex-start" | "flex-end";
|
|
1688
1677
|
sx?: SxProps<Theme>;
|
|
1689
1678
|
}
|
|
@@ -1709,7 +1698,7 @@ interface SectionNavProps {
|
|
|
1709
1698
|
* />
|
|
1710
1699
|
* ```
|
|
1711
1700
|
*/
|
|
1712
|
-
declare const SectionNav: ({ items, "aria-label": ariaLabel, scrollRoot, sticky, stickyOffset, justifyContent, sx, }: SectionNavProps) => react.JSX.Element;
|
|
1701
|
+
declare const SectionNav: ({ items, "aria-label": ariaLabel, scrollRoot, sticky, glass, stickyOffset, justifyContent, sx, }: SectionNavProps) => react.JSX.Element;
|
|
1713
1702
|
|
|
1714
1703
|
type CarouselBreakpoint = "xs" | "sm" | "md" | "lg";
|
|
1715
1704
|
/** Cards visible at once per breakpoint. Fractions leave the next card peeking, e.g. `1.15`. */
|
|
@@ -1729,6 +1718,12 @@ interface CarouselProps {
|
|
|
1729
1718
|
nextLabel?: string;
|
|
1730
1719
|
/** When provided, the controls bar shows "{count} {itemLabel}" instead of the scroll position. */
|
|
1731
1720
|
itemLabel?: string;
|
|
1721
|
+
/**
|
|
1722
|
+
* Number of logical items each child represents — use when children are grouped, e.g. paired rows.
|
|
1723
|
+
* Scales all counts so status, aria-labels, and itemLabel reflect real items, not child slots.
|
|
1724
|
+
* Defaults to 1.
|
|
1725
|
+
*/
|
|
1726
|
+
itemsPerGroup?: number;
|
|
1732
1727
|
sx?: SxProps<Theme>;
|
|
1733
1728
|
}
|
|
1734
1729
|
/**
|
|
@@ -1748,7 +1743,7 @@ interface CarouselProps {
|
|
|
1748
1743
|
* ```
|
|
1749
1744
|
*/
|
|
1750
1745
|
declare const Carousel: {
|
|
1751
|
-
({ children, "aria-label": ariaLabel, itemsPerView, gap, previousLabel, nextLabel, itemLabel, sx, }: CarouselProps): react.JSX.Element;
|
|
1746
|
+
({ children, "aria-label": ariaLabel, itemsPerView, gap, previousLabel, nextLabel, itemLabel, itemsPerGroup, sx, }: CarouselProps): react.JSX.Element;
|
|
1752
1747
|
displayName: string;
|
|
1753
1748
|
};
|
|
1754
1749
|
|