it-data-nexus-ui-library 2.10.11 → 2.10.12
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},p=["xs","sm","md","lg"],h={disableRipple:!0,disableFocusRipple:!0,sx:e=>({"&.Mui-focusVisible":{outline:`2px solid ${e.palette.primary.main}`,outlineOffset:2}})},
|
|
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},p=["xs","sm","md","lg"],h={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:w="Next",itemLabel:$,sx:A})=>{const L=r(null),S=r(null),W=r(null),j=o.toArray(b),B=j.length,[R,C]=i({start:!0,end:!0}),[O,k]=i(new Set),E=n(()=>{const e=L.current;e&&C({start:e.scrollLeft<=2,end:e.scrollLeft+e.clientWidth>=e.scrollWidth-2})},[]);l(()=>{const e=L.current;if(!e)return;E();const t=new ResizeObserver(E);t.observe(e),e.addEventListener("scroll",E,{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)}k(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",E)}},[B,E]),l(()=>{Array.from(L.current?.children??[]).forEach((e,t)=>{e.toggleAttribute("inert",O.size>0&&!O.has(t))})},[O,B]),l(()=>{const e=R.end?"next":R.start?"previous":null;if(e&&W.current===e){const t="next"===e?"previous":"next";S.current?.querySelector(`[data-control="${t}"]:not(:disabled)`)?.focus()}},[R]);const I=e=>{const t=L.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"})},F=Array.from(O).sort((e,t)=>e-t),N=0===F.length?"":1===F.length?`Showing ${F[0]+1} of ${B}`:`Showing ${F[0]+1}–${F[F.length-1]+1} of ${B}`,P=x&&Object.keys(x).length>0?x:f,z={xs:p.map(e=>P[e]).find(e=>void 0!==e),...P},M=e=>Object.fromEntries(Object.entries(z).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(A)?A:A?[A]:[]],children:[t(c,{ref:L,role:"region","aria-label":g,tabIndex:0,sx:e=>({display:"grid",gridAutoFlow:"column",gridAutoColumns:M(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:j.map((e,r)=>t(c,{"data-index":r,role:"group","aria-roledescription":"slide","aria-label":`${r+1} of ${B}`,sx:{minWidth:0,scrollSnapAlign:"start"},children:e},r))}),e(d,{ref:S,direction:"row",onFocus:e=>{W.current=e.target.dataset.control??null},sx:{justifyContent:"center",alignItems:"center",gap:1.5},children:[t(m,{...h,"data-control":"previous",title:y,onClick:()=>I(-1),disabled:R.start,children:t(s,{})}),t(u,{"aria-live":"polite",sx:{minWidth:"9ch",textAlign:"center"},children:$?`${B} ${$}`:N}),t(m,{...h,"data-control":"next",title:w,onClick:()=>I(1),disabled:R.end,children:t(a,{})})]})]})};b.displayName="Carousel";export{b as Carousel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="2.10.
|
|
1
|
+
const o="2.10.12";export{o as SAGE_NEXUS_UI_VERSION};
|
package/dist/index.d.ts
CHANGED
|
@@ -1727,6 +1727,8 @@ interface CarouselProps {
|
|
|
1727
1727
|
previousLabel?: string;
|
|
1728
1728
|
/** Accessible name of the next control. Defaults to "Next". */
|
|
1729
1729
|
nextLabel?: string;
|
|
1730
|
+
/** When provided, the controls bar shows "{count} {itemLabel}" instead of the scroll position. */
|
|
1731
|
+
itemLabel?: string;
|
|
1730
1732
|
sx?: SxProps<Theme>;
|
|
1731
1733
|
}
|
|
1732
1734
|
/**
|
|
@@ -1746,7 +1748,7 @@ interface CarouselProps {
|
|
|
1746
1748
|
* ```
|
|
1747
1749
|
*/
|
|
1748
1750
|
declare const Carousel: {
|
|
1749
|
-
({ children, "aria-label": ariaLabel, itemsPerView, gap, previousLabel, nextLabel, sx, }: CarouselProps): react.JSX.Element;
|
|
1751
|
+
({ children, "aria-label": ariaLabel, itemsPerView, gap, previousLabel, nextLabel, itemLabel, sx, }: CarouselProps): react.JSX.Element;
|
|
1750
1752
|
displayName: string;
|
|
1751
1753
|
};
|
|
1752
1754
|
|