mui-collage-fab 0.2.0 → 0.4.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/README.md CHANGED
@@ -73,8 +73,12 @@ const [open, setOpen] = useState(false);
73
73
 
74
74
  | Prop | Type | Default | Description |
75
75
  | -------------------- | ------------------------------------------ | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
76
- | `children` | `React.ReactNode` | — | The buttons to stack. Every valid element is wrapped in a masked slot shaped by `variant`. Order matters: index 0 is the anchor, the rest fan out along `direction`. |
76
+ | `children` | `React.ReactNode` | — | The buttons to stack. Every valid element is wrapped in a masked slot shaped by `variant`. Order matters: index 0 is the anchor, the rest fan out along `direction` or their own entry in `directions`. |
77
77
  | `direction` | `'left' \| 'right' \| 'up' \| 'down'` | `'left'` | The axis the buttons fan out on, starting from the anchor child. `left` matches the original right-anchored behaviour. |
78
+ | `directions` | `('left' \| 'right' \| 'up' \| 'down')[]` | — | A direction per child, in child order, so one group can fan over several axes. Entry 0 belongs to the anchor and has no visible effect; an entry that is missing or past the end of the list falls back to `direction`. |
79
+ | `spread` | `'line' \| 'radial'` | `'line'` | How the children leave the anchor. `'line'` fans them along their directions; `'radial'` sends them onto a ring one pitch around the anchor, each cut by a wedge that lets it emerge from behind the anchor. |
80
+ | `radialStart` | `number` | `0` | Angle in degrees the first ring child sits on when `spread` is `'radial'`. |
81
+ | `radialStep` | `number` | — | Angle in degrees between two ring children when `spread` is `'radial'`. Defaults to `360 / (count - 1)`, which spaces them evenly around the anchor. |
78
82
  | `size` | `'small' \| 'medium' \| 'large' \| number` | `'large'` | Diameter of every button. Named sizes resolve to small 40px, medium 48px, large 56px; numeric values are used verbatim. |
79
83
  | `variant` | `'circular' \| 'rounded' \| 'square'` | `'circular'` | The shape of every button. `'circular'` clips each slice to a circle, `'rounded'` to a rounded square and `'square'` to a sharp-cornered square. The mask still slices the silhouette along the main axis, so the stack reads as one shape when collapsed and as separate shapes when expanded. |
80
84
  | `gap` | `number` | `16` | Main-axis gap in pixels between two buttons when expanded. |
@@ -108,7 +112,7 @@ const [open, setOpen] = useState(false);
108
112
 
109
113
  <!-- api:owner-state:start -->
110
114
 
111
- `CollageFabOwnerState` carries `open`, `direction`, `trigger`, `size`, `variant`, `cornerRadius`, `gap`, `fadeWidth`, `count`, `transitionDuration` and `transitionEasing`. `CollageFabItemOwnerState` adds `index`, `isAnchor` and `geometry`.
115
+ `CollageFabOwnerState` carries `open`, `direction`, `directions`, `spread`, `radialStart`, `radialStep`, `trigger`, `size`, `variant`, `cornerRadius`, `gap`, `fadeWidth`, `count`, `transitionDuration` and `transitionEasing`. `CollageFabItemOwnerState` adds `index`, `isAnchor` and `geometry`.
112
116
  <!-- api:owner-state:end -->
113
117
 
114
118
  Theme-level defaults and overrides work through the `MuiCollageFab` component key:
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("@mui/material"),u=require("@mui/material/styles"),d=require("@mui/material/utils"),f=require("@mui/utils/useSlotProps");f=s(f,1);let p=require("@mui/utils/composeClasses");p=s(p,1);let m=require("@mui/utils/generateUtilityClass");m=s(m,1);let h=require("react/jsx-runtime");var g={small:40,medium:48,large:56};function _(e){return typeof e==`number`?e:g[e]}var v={left:{x:-1,y:0},right:{x:1,y:0},up:{x:0,y:-1},down:{x:0,y:1}};function y({x:e,y:t},n){return e!==0&&t!==0?`translate(${e}px, ${t}px)`:n?`translateX(${e}px)`:`translateY(${t}px)`}function b(e,t){let n=v[t.direction],r=e*(t.size+t.gap);return{x:n.x*r,y:n.y*r}}function x(e){return e.every(e=>e<=0)&&e.some(e=>e<0)?`end`:`start`}function S(e){let{count:t,size:n}=e,r=Array.from({length:t},(t,n)=>b(n,e)),i=r.map(e=>e.x),a=r.map(e=>e.y);return{extent:{width:Math.max(...i,0)-Math.min(...i,0)+n,height:Math.max(...a,0)-Math.min(...a,0)+n},align:{x:x(i),y:x(a)}}}function C(e,t){let{count:n,size:r,gap:i,fadeWidth:a,open:o,direction:s}=t,c=r+i,l=(n-1)*c+r+a,u=v[s],d=u.x!==0,f=(d?u.x:u.y)<0,p=o?b(e,t):{x:0,y:0},m=e===0?l:(n-e)*(r/n),h=e===0?-a/2:r/n*e,g=(f?m:h)-l-a/2,_=d?{x:g,y:0}:{x:0,y:g},x={x:_.x-p.x,y:_.y-p.y},S=f?`#000 0px, #000 ${l}px, transparent ${l+a}px, transparent ${2*l}px`:`transparent 0px, transparent ${l}px, #000 ${l+a}px, #000 ${2*l}px`;return{translate:y(p,d),maskImage:n>1?`linear-gradient(${d?`to right`:`to bottom`}, ${S})`:`none`,maskSize:d?`${2*l}px 100%`:`100% ${2*l}px`,maskPosition:`${x.x}px ${x.y}px`}}var w={direction:`left`,size:`large`,variant:`circular`,gap:16,fadeWidth:12,trigger:`hover`,defaultOpen:!1,disableClickAway:!1,transitionDuration:400,transitionEasing:`cubic-bezier(0.4, 0, 0.2, 1)`},T={circular:`50%`,rounded:`25%`,square:0},ee=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`;function E(e,t){return`${e}ms ${t}`}function D(e){return(0,m.default)(`MuiCollageFab`,e)}var te=(e,t)=>(0,p.default)({root:[`root`,e?`expanded`:`collapsed`],item:[`item`]},D,t),O=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`root`,overridesResolver:(e,t)=>t.root})(({ownerState:e})=>{let{open:t,size:n,transitionDuration:r,transitionEasing:i}=e,{extent:a}=S(e),o=E(r,i);return{position:`relative`,width:t?a.width:n,height:t?a.height:n,transition:`width ${o}, height ${o}`,filter:`drop-shadow(0px 6px 12px rgba(0,0,0,0.25))`,cursor:t?`default`:`pointer`,WebkitTapHighlightColor:`transparent`}}),k=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`item`,overridesResolver:(e,t)=>t.item})(({ownerState:e})=>{let{size:t,index:n,geometry:r,cornerRadius:i,transitionDuration:a,transitionEasing:o}=e,{align:s}=S(e),c={...s.x===`end`?{right:0}:{left:0},...s.y===`end`?{bottom:0}:{top:0}},l=E(a,o);return{position:`absolute`,...c,width:t,height:t,borderRadius:i,overflow:`hidden`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:n,transform:r.translate,WebkitMaskImage:r.maskImage,maskImage:r.maskImage,WebkitMaskSize:r.maskSize,maskSize:r.maskSize,WebkitMaskPosition:r.maskPosition,maskPosition:r.maskPosition,WebkitMaskRepeat:`no-repeat`,maskRepeat:`no-repeat`,transition:`transform ${l}, -webkit-mask-position ${l}, mask-position ${l}`,"& > *":{boxShadow:`none !important`,borderRadius:`inherit !important`,width:`100%`,height:`100%`,margin:0}}});function A(e){let{index:t,ownerState:n,geometry:r,className:i,component:a,inert:o,itemRefs:s,slotProps:l,children:u}=e,p=c.useMemo(()=>({...n,index:t,isAnchor:t===0,geometry:r}),[n,t,r]),m=c.useRef(null),g=c.useCallback(e=>{s.current[t]=e},[s,t]),_=(0,d.useForkRef)(g,m);c.useEffect(()=>{let e=m.current;e&&`inert`in HTMLElement.prototype&&(e.inert=o)},[o]);let v=(0,f.default)({elementType:a,externalSlotProps:l,ownerState:p,additionalProps:{ref:_,className:i,"aria-hidden":o||void 0,children:u}});return(0,h.jsx)(a,{...v})}var j=c.forwardRef(function(e,t){let{children:n,direction:r=w.direction,size:i=w.size,variant:a=w.variant,gap:o=w.gap,fadeWidth:s=w.fadeWidth,trigger:p=w.trigger,open:m,defaultOpen:g=w.defaultOpen,onOpen:v,onClose:y,disableClickAway:b=w.disableClickAway,transitionDuration:x=w.transitionDuration,transitionEasing:S=w.transitionEasing,classes:E,slots:D,slotProps:j,className:ne,...M}=(0,u.useThemeProps)({props:e,name:`MuiCollageFab`}),[N,P]=(0,d.useControlled)({controlled:m,default:g,name:`CollageFab`,state:`open`}),F=c.useMemo(()=>c.Children.toArray(n).filter(e=>c.isValidElement(e)),[n]),I=F.length,L={open:N,direction:r,trigger:p,size:_(i),variant:a,cornerRadius:T[a],gap:o,fadeWidth:s,count:I,transitionDuration:x,transitionEasing:S},R=te(N,E),z=c.useRef(null),B=c.useRef([]),V=c.useRef(!1),H=c.useRef(`mouse`),U=c.useRef(!1),W=(0,d.useForkRef)(z,t),G=c.useCallback((e,t)=>{e!==N&&(P(e),e?v?.(t):y?.(t))},[N,P,v,y]),K=e=>{p===`hover`&&e.pointerType===`mouse`&&G(!0,e)},q=e=>{p===`hover`&&e.pointerType===`mouse`&&G(!1,e)},J=e=>{p!==`manual`&&(H.current=e.pointerType,V.current=!1,e.pointerType===`mouse`||N||(V.current=!0,G(!0,e)))},Y=e=>{V.current&&(V.current=!1,e.stopPropagation(),e.preventDefault())},X=e=>{p!==`manual`&&(p===`click`?G(!N,e):N&&H.current!==`mouse`&&G(!1,e))},Z=e=>{if(p!==`manual`){if(N){if(e.key!==`Escape`)return;e.stopPropagation(),G(!1,e),z.current?.focus()}else(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),U.current=!0,G(!0,e))}},re=e=>{G(!1,e)},Q=D?.root??O,ie=D?.item??k,ae=(0,f.default)({elementType:Q,externalForwardedProps:M,externalSlotProps:j?.root,ownerState:L,additionalProps:{ref:W,role:`group`,tabIndex:!N&&p!==`manual`?0:-1,onPointerEnter:K,onPointerLeave:q,onPointerDown:J,onClick:X,onClickCapture:Y,onKeyDown:Z},className:[R.root,ne]});if(c.useEffect(()=>{if(!N||!U.current)return;U.current=!1;let e=B.current[0];e&&(e.querySelector(ee)??e).focus()},[N]),I===0)return null;let $=(0,h.jsx)(Q,{...ae,children:F.map((e,t)=>(0,h.jsx)(A,{index:t,ownerState:L,geometry:C(t,L),className:R.item,component:ie,inert:!N&&p!==`manual`,itemRefs:B,slotProps:j?.item,children:e},t))});return b||p===`manual`?$:(0,h.jsx)(l.ClickAwayListener,{onClickAway:re,children:$})});exports.CollageFab=j;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("@mui/material"),u=require("@mui/material/styles"),d=require("@mui/material/utils"),f=require("@mui/utils/useSlotProps");f=s(f,1);let p=require("@mui/utils/composeClasses");p=s(p,1);let m=require("@mui/utils/generateUtilityClass");m=s(m,1);let h=require("react/jsx-runtime");var g={small:40,medium:48,large:56};function _(e){return typeof e==`number`?e:g[e]}var v={x:0,y:0},y={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]};function b({x:e,y:t},n){return t===0&&(n||e!==0)?`translateX(${e}px)`:e===0?`translateY(${t}px)`:`translate(${e}px, ${t}px)`}function x(e){return+e.toFixed(4)}function S(e,t){return t.directions[e]??t.direction}function C(e,t){let n=t.size+t.gap;if(t.spread===`radial`){if(e===0)return v;let r=(t.radialStart+(e-1)*t.radialStep)*Math.PI/180;return{x:x(Math.sin(r)*n),y:x(-Math.cos(r)*n)}}let r=S(e,t),[i,a]=y[r],o=0;for(let n=0;n<e;n+=1)S(n,t)===r&&(o+=1);let s=(o+(r===S(0,t)?0:1))*n;return{x:i*s,y:a*s}}function w(e,t){let n=Math.min(...e,0),r=Math.max(...e,0),i=n<0&&r>0?`center`:n<0?`end`:`start`;return[i===`center`?2*Math.max(-n,r)+t:r-n+t,i]}function T(e){let{count:t,size:n}=e;if(e.spread===`radial`)return{extent:{width:n,height:n},align:{x:`center`,y:`center`}};let r=Array.from({length:t},(t,n)=>C(n,e)),i=r.map(e=>e.x),a=r.map(e=>e.y),[o,s]=w(i,n),[c,l]=w(a,n);return{extent:{width:o,height:c},align:{x:s,y:l}}}function E(e,t){if(t.spread===`radial`)return D(e,t);let{count:n,size:r,gap:i,fadeWidth:a,open:o}=t,s=(n-1)*(r+i)+r+a,[c,l]=y[S(e,t)],u=c!==0,d=(u?c:l)<0,f=o?C(e,t):v,p=e===0?s:(n-e)*(r/n),m=e===0?-a/2:r/n*e,h=(d?p:m)-s-a/2,g=u?h-f.x:-f.x,_=u?-f.y:h-f.y,x=d?`#000 0px, #000 ${s}px, transparent ${s+a}px, transparent ${2*s}px`:`transparent 0px, transparent ${s}px, #000 ${s+a}px, #000 ${2*s}px`;return{translate:b(f,u),maskImage:n>1?`linear-gradient(${u?`to right`:`to bottom`}, ${x})`:`none`,maskSize:u?`${2*s}px 100%`:`100% ${2*s}px`,maskPosition:`${g}px ${_}px`}}function D(e,t){let{count:n,size:r,gap:i,fadeWidth:a,open:o}=t,s=t.radialStep,c=o?C(e,t):v,l=n>1?r+i:0,u=r+2*l,d=a?a/(r/2)*180/Math.PI:0,f=t.radialStart+(e-1)*s-s/2-d/2,p=x(s+d);return{translate:b(c,!1),maskImage:n>1&&e>0?`conic-gradient(from ${x(f)}deg, #0000 0deg, #000 ${x(d)}deg, #000 ${x(e===n-1?s:s+d)}deg, transparent ${p}deg)`:`none`,maskSize:`${u}px ${u}px`,maskPosition:`${-c.x-l}px ${-c.y-l}px`}}var O={direction:`left`,size:`large`,variant:`circular`,gap:16,fadeWidth:12,spread:`line`,radialStart:0,trigger:`hover`,defaultOpen:!1,disableClickAway:!1,transitionDuration:400,transitionEasing:`cubic-bezier(0.4, 0, 0.2, 1)`},ee={circular:`50%`,rounded:`25%`,square:0},k=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`;function A(e,t){return`${e}ms ${t}`}function j(e){return(0,m.default)(`MuiCollageFab`,e)}var M=(e,t)=>(0,p.default)({root:[`root`,e?`expanded`:`collapsed`],item:[`item`]},j,t),N=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`root`,overridesResolver:(e,t)=>t.root})(({ownerState:e})=>{let{open:t,size:n,spread:r,gap:i,count:a,transitionDuration:o,transitionEasing:s}=e,{extent:c}=T(e),l=A(o,s),u=t&&r===`radial`&&a>1?n+i:0;return{position:`relative`,...u>0&&{"&::after":{content:`""`,position:`absolute`,inset:-u,borderRadius:`50%`,zIndex:-1}},width:t?c.width:n,height:t?c.height:n,transition:`width ${l}, height ${l}`,filter:`drop-shadow(0px 6px 12px rgba(0,0,0,0.25))`,cursor:t?`default`:`pointer`,WebkitTapHighlightColor:`transparent`}}),P=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`item`,overridesResolver:(e,t)=>t.item})(({ownerState:e})=>{let{size:t,index:n,geometry:r,cornerRadius:i,transitionDuration:a,transitionEasing:o}=e,{align:s}=T(e),c={...s.x===`end`?{right:0}:s.x===`center`?{left:`50%`,marginLeft:-t/2}:{left:0},...s.y===`end`?{bottom:0}:s.y===`center`?{top:`50%`,marginTop:-t/2}:{top:0}},l=A(a,o);return{position:`absolute`,...c,width:t,height:t,borderRadius:i,overflow:`hidden`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:e.spread===`radial`?e.count-n:n,transform:r.translate,WebkitMaskImage:r.maskImage,maskImage:r.maskImage,WebkitMaskSize:r.maskSize,maskSize:r.maskSize,WebkitMaskPosition:r.maskPosition,maskPosition:r.maskPosition,WebkitMaskRepeat:`no-repeat`,maskRepeat:`no-repeat`,transition:`transform ${l}, -webkit-mask-position ${l}, mask-position ${l}`,"& > *":{boxShadow:`none !important`,borderRadius:`inherit !important`,width:`100%`,height:`100%`,margin:0}}});function F(e){let{index:t,ownerState:n,geometry:r,className:i,component:a,inert:o,itemRefs:s,slotProps:l,children:u}=e,p=c.useMemo(()=>({...n,index:t,isAnchor:t===0,geometry:r}),[n,t,r]),m=c.useRef(null),g=c.useCallback(e=>{s.current[t]=e},[s,t]),_=(0,d.useForkRef)(g,m);c.useEffect(()=>{let e=m.current;e&&`inert`in HTMLElement.prototype&&(e.inert=o)},[o]);let v=(0,f.default)({elementType:a,externalSlotProps:l,ownerState:p,additionalProps:{ref:_,className:i,"aria-hidden":o||void 0,children:u}});return(0,h.jsx)(a,{...v})}var I=c.forwardRef(function(e,t){let{children:n,direction:r=O.direction,directions:i,spread:a=O.spread,radialStart:o=O.radialStart,radialStep:s,size:p=O.size,variant:m=O.variant,gap:g=O.gap,fadeWidth:v=O.fadeWidth,trigger:y=O.trigger,open:b,defaultOpen:x=O.defaultOpen,onOpen:S,onClose:C,disableClickAway:w=O.disableClickAway,transitionDuration:T=O.transitionDuration,transitionEasing:D=O.transitionEasing,classes:A,slots:j,slotProps:I,className:L,...R}=(0,u.useThemeProps)({props:e,name:`MuiCollageFab`}),[z,B]=(0,d.useControlled)({controlled:b,default:x,name:`CollageFab`,state:`open`}),V=c.useMemo(()=>c.Children.toArray(n).filter(e=>c.isValidElement(e)),[n]),H=V.length,U={open:z,direction:r,directions:c.useMemo(()=>V.map((e,t)=>i?.[t]??r),[V,i,r]),spread:a,radialStart:o,radialStep:s??360/Math.max(H-1,1),trigger:y,size:_(p),variant:m,cornerRadius:ee[m],gap:g,fadeWidth:v,count:H,transitionDuration:T,transitionEasing:D},W=M(z,A),G=c.useRef(null),K=c.useRef([]),q=c.useRef(!1),J=c.useRef(`mouse`),Y=c.useRef(!1),X=(0,d.useForkRef)(G,t),Z=c.useCallback((e,t)=>{e!==z&&(B(e),e?S?.(t):C?.(t))},[z,B,S,C]),te=e=>{y===`hover`&&e.pointerType===`mouse`&&Z(!0,e)},ne=e=>{y===`hover`&&e.pointerType===`mouse`&&Z(!1,e)},re=e=>{y!==`manual`&&(J.current=e.pointerType,q.current=!1,e.pointerType===`mouse`||z||(q.current=!0,Z(!0,e)))},ie=e=>{q.current&&(q.current=!1,e.stopPropagation(),e.preventDefault())},ae=e=>{y!==`manual`&&(y===`click`?Z(!z,e):z&&J.current!==`mouse`&&Z(!1,e))},oe=e=>{if(y!==`manual`){if(z){if(e.key!==`Escape`)return;e.stopPropagation(),Z(!1,e),G.current?.focus()}else(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Y.current=!0,Z(!0,e))}},se=e=>{Z(!1,e)},Q=j?.root??N,ce=j?.item??P,le=(0,f.default)({elementType:Q,externalForwardedProps:R,externalSlotProps:I?.root,ownerState:U,additionalProps:{ref:X,role:`group`,tabIndex:!z&&y!==`manual`?0:-1,onPointerEnter:te,onPointerLeave:ne,onPointerDown:re,onClick:ae,onClickCapture:ie,onKeyDown:oe},className:[W.root,L]});if(c.useEffect(()=>{if(!z||!Y.current)return;Y.current=!1;let e=K.current[0];e&&(e.querySelector(k)??e).focus()},[z]),H===0)return null;let $=(0,h.jsx)(Q,{...le,children:V.map((e,t)=>(0,h.jsx)(F,{index:t,ownerState:U,geometry:E(t,U),className:W.item,component:ce,inert:!z&&y!==`manual`,itemRefs:K,slotProps:I?.item,children:e},t))});return w||y===`manual`?$:(0,h.jsx)(l.ClickAwayListener,{onClickAway:se,children:$})});exports.CollageFab=I;
@@ -20,6 +20,10 @@ type CollageFabSize = 'small' | 'medium' | 'large' | number;
20
20
  * square.
21
21
  */
22
22
  type CollageFabVariant = 'circular' | 'rounded' | 'square';
23
+ /**
24
+ * How the children leave the anchor: along a line, or onto a ring around it.
25
+ */
26
+ type CollageFabSpread = 'line' | 'radial';
23
27
  /**
24
28
  * Class names the component applies, and the accepted keys for `classes`.
25
29
  */
@@ -53,8 +57,16 @@ interface CollageFabItemSlotPropsOverrides {
53
57
  interface CollageFabOwnerState {
54
58
  /** Whether the group is currently expanded. */
55
59
  open: boolean;
56
- /** The resolved fan-out direction. */
60
+ /** The resolved fan-out direction used by every child without a `directions` entry. */
57
61
  direction: CollageFabDirection;
62
+ /** The resolved direction of each child, in child order. */
63
+ directions: CollageFabDirection[];
64
+ /** How the children leave the anchor: along a line, or onto a ring. */
65
+ spread: CollageFabSpread;
66
+ /** The angle in degrees the first wedge is centred on when `spread` is `'radial'`. */
67
+ radialStart: number;
68
+ /** The angle in degrees between two wedges when `spread` is `'radial'`. */
69
+ radialStep: number;
58
70
  /** The resolved pointer trigger mode. */
59
71
  trigger: CollageFabTrigger;
60
72
  /** The button diameter in pixels, after resolving the named size. */
@@ -124,7 +136,7 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
124
136
  /**
125
137
  * The buttons to stack. Every valid element is wrapped in a masked slot shaped
126
138
  * by `variant`. Order matters: index 0 is the anchor, the rest fan out along
127
- * `direction`.
139
+ * `direction` or their own entry in `directions`.
128
140
  */
129
141
  children?: React.ReactNode;
130
142
  /**
@@ -132,6 +144,27 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
132
144
  * matches the original right-anchored behaviour.
133
145
  */
134
146
  direction?: CollageFabDirection;
147
+ /**
148
+ * A direction per child, in child order, so one group can fan over several axes.
149
+ * Entry 0 belongs to the anchor and has no visible effect; an entry that is
150
+ * missing or past the end of the list falls back to `direction`.
151
+ */
152
+ directions?: CollageFabDirection[];
153
+ /**
154
+ * How the children leave the anchor. `'line'` fans them along their directions;
155
+ * `'radial'` sends them onto a ring one pitch around the anchor, each cut by a wedge
156
+ * that lets it emerge from behind the anchor.
157
+ */
158
+ spread?: CollageFabSpread;
159
+ /**
160
+ * Angle in degrees the first ring child sits on when `spread` is `'radial'`.
161
+ */
162
+ radialStart?: number;
163
+ /**
164
+ * Angle in degrees between two ring children when `spread` is `'radial'`.
165
+ * Defaults to `360 / (count - 1)`, which spaces them evenly around the anchor.
166
+ */
167
+ radialStep?: number;
135
168
  /**
136
169
  * Diameter of every button. Named sizes resolve to small 40px, medium 48px,
137
170
  * large 56px; numeric values are used verbatim.
@@ -213,4 +246,4 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
213
246
  declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
214
247
 
215
248
  export { CollageFab };
216
- export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabTrigger, CollageFabVariant };
249
+ export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabSpread, CollageFabTrigger, CollageFabVariant };
@@ -20,6 +20,10 @@ type CollageFabSize = 'small' | 'medium' | 'large' | number;
20
20
  * square.
21
21
  */
22
22
  type CollageFabVariant = 'circular' | 'rounded' | 'square';
23
+ /**
24
+ * How the children leave the anchor: along a line, or onto a ring around it.
25
+ */
26
+ type CollageFabSpread = 'line' | 'radial';
23
27
  /**
24
28
  * Class names the component applies, and the accepted keys for `classes`.
25
29
  */
@@ -53,8 +57,16 @@ interface CollageFabItemSlotPropsOverrides {
53
57
  interface CollageFabOwnerState {
54
58
  /** Whether the group is currently expanded. */
55
59
  open: boolean;
56
- /** The resolved fan-out direction. */
60
+ /** The resolved fan-out direction used by every child without a `directions` entry. */
57
61
  direction: CollageFabDirection;
62
+ /** The resolved direction of each child, in child order. */
63
+ directions: CollageFabDirection[];
64
+ /** How the children leave the anchor: along a line, or onto a ring. */
65
+ spread: CollageFabSpread;
66
+ /** The angle in degrees the first wedge is centred on when `spread` is `'radial'`. */
67
+ radialStart: number;
68
+ /** The angle in degrees between two wedges when `spread` is `'radial'`. */
69
+ radialStep: number;
58
70
  /** The resolved pointer trigger mode. */
59
71
  trigger: CollageFabTrigger;
60
72
  /** The button diameter in pixels, after resolving the named size. */
@@ -124,7 +136,7 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
124
136
  /**
125
137
  * The buttons to stack. Every valid element is wrapped in a masked slot shaped
126
138
  * by `variant`. Order matters: index 0 is the anchor, the rest fan out along
127
- * `direction`.
139
+ * `direction` or their own entry in `directions`.
128
140
  */
129
141
  children?: React.ReactNode;
130
142
  /**
@@ -132,6 +144,27 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
132
144
  * matches the original right-anchored behaviour.
133
145
  */
134
146
  direction?: CollageFabDirection;
147
+ /**
148
+ * A direction per child, in child order, so one group can fan over several axes.
149
+ * Entry 0 belongs to the anchor and has no visible effect; an entry that is
150
+ * missing or past the end of the list falls back to `direction`.
151
+ */
152
+ directions?: CollageFabDirection[];
153
+ /**
154
+ * How the children leave the anchor. `'line'` fans them along their directions;
155
+ * `'radial'` sends them onto a ring one pitch around the anchor, each cut by a wedge
156
+ * that lets it emerge from behind the anchor.
157
+ */
158
+ spread?: CollageFabSpread;
159
+ /**
160
+ * Angle in degrees the first ring child sits on when `spread` is `'radial'`.
161
+ */
162
+ radialStart?: number;
163
+ /**
164
+ * Angle in degrees between two ring children when `spread` is `'radial'`.
165
+ * Defaults to `360 / (count - 1)`, which spaces them evenly around the anchor.
166
+ */
167
+ radialStep?: number;
135
168
  /**
136
169
  * Diameter of every button. Named sizes resolve to small 40px, medium 48px,
137
170
  * large 56px; numeric values are used verbatim.
@@ -213,4 +246,4 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
213
246
  declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
214
247
 
215
248
  export { CollageFab };
216
- export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabTrigger, CollageFabVariant };
249
+ export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabSpread, CollageFabTrigger, CollageFabVariant };
package/dist-lib/index.js CHANGED
@@ -16,120 +16,153 @@ function d(e) {
16
16
  return typeof e == "number" ? e : u[e];
17
17
  }
18
18
  var f = {
19
- left: {
20
- x: -1,
21
- y: 0
22
- },
23
- right: {
24
- x: 1,
25
- y: 0
26
- },
27
- up: {
28
- x: 0,
29
- y: -1
30
- },
31
- down: {
32
- x: 0,
33
- y: 1
34
- }
19
+ x: 0,
20
+ y: 0
21
+ }, p = {
22
+ left: [-1, 0],
23
+ right: [1, 0],
24
+ up: [0, -1],
25
+ down: [0, 1]
35
26
  };
36
- function p({ x: e, y: t }, n) {
37
- return e !== 0 && t !== 0 ? `translate(${e}px, ${t}px)` : n ? `translateX(${e}px)` : `translateY(${t}px)`;
27
+ function m({ x: e, y: t }, n) {
28
+ return t === 0 && (n || e !== 0) ? `translateX(${e}px)` : e === 0 ? `translateY(${t}px)` : `translate(${e}px, ${t}px)`;
29
+ }
30
+ function h(e) {
31
+ return +e.toFixed(4);
38
32
  }
39
- function m(e, t) {
40
- let n = f[t.direction], r = e * (t.size + t.gap);
33
+ function g(e, t) {
34
+ return t.directions[e] ?? t.direction;
35
+ }
36
+ function _(e, t) {
37
+ let n = t.size + t.gap;
38
+ if (t.spread === "radial") {
39
+ if (e === 0) return f;
40
+ let r = (t.radialStart + (e - 1) * t.radialStep) * Math.PI / 180;
41
+ return {
42
+ x: h(Math.sin(r) * n),
43
+ y: h(-Math.cos(r) * n)
44
+ };
45
+ }
46
+ let r = g(e, t), [i, a] = p[r], o = 0;
47
+ for (let n = 0; n < e; n += 1) g(n, t) === r && (o += 1);
48
+ let s = (o + (r === g(0, t) ? 0 : 1)) * n;
41
49
  return {
42
- x: n.x * r,
43
- y: n.y * r
50
+ x: i * s,
51
+ y: a * s
44
52
  };
45
53
  }
46
- function h(e) {
47
- return e.every((e) => e <= 0) && e.some((e) => e < 0) ? "end" : "start";
54
+ function v(e, t) {
55
+ let n = Math.min(...e, 0), r = Math.max(...e, 0), i = n < 0 && r > 0 ? "center" : n < 0 ? "end" : "start";
56
+ return [i === "center" ? 2 * Math.max(-n, r) + t : r - n + t, i];
48
57
  }
49
- function g(e) {
50
- let { count: t, size: n } = e, r = Array.from({ length: t }, (t, n) => m(n, e)), i = r.map((e) => e.x), a = r.map((e) => e.y);
58
+ function y(e) {
59
+ let { count: t, size: n } = e;
60
+ if (e.spread === "radial") return {
61
+ extent: {
62
+ width: n,
63
+ height: n
64
+ },
65
+ align: {
66
+ x: "center",
67
+ y: "center"
68
+ }
69
+ };
70
+ let r = Array.from({ length: t }, (t, n) => _(n, e)), i = r.map((e) => e.x), a = r.map((e) => e.y), [o, s] = v(i, n), [c, l] = v(a, n);
51
71
  return {
52
72
  extent: {
53
- width: Math.max(...i, 0) - Math.min(...i, 0) + n,
54
- height: Math.max(...a, 0) - Math.min(...a, 0) + n
73
+ width: o,
74
+ height: c
55
75
  },
56
76
  align: {
57
- x: h(i),
58
- y: h(a)
77
+ x: s,
78
+ y: l
59
79
  }
60
80
  };
61
81
  }
62
- function _(e, t) {
63
- let { count: n, size: r, gap: i, fadeWidth: a, open: o, direction: s } = t, c = r + i, l = (n - 1) * c + r + a, u = f[s], d = u.x !== 0, h = (d ? u.x : u.y) < 0, g = o ? m(e, t) : {
64
- x: 0,
65
- y: 0
66
- }, _ = e === 0 ? l : (n - e) * (r / n), v = e === 0 ? -a / 2 : r / n * e, y = (h ? _ : v) - l - a / 2, b = d ? {
67
- x: y,
68
- y: 0
69
- } : {
70
- x: 0,
71
- y
72
- }, x = {
73
- x: b.x - g.x,
74
- y: b.y - g.y
75
- }, S = h ? `#000 0px, #000 ${l}px, transparent ${l + a}px, transparent ${2 * l}px` : `transparent 0px, transparent ${l}px, #000 ${l + a}px, #000 ${2 * l}px`;
82
+ function b(e, t) {
83
+ if (t.spread === "radial") return x(e, t);
84
+ let { count: n, size: r, gap: i, fadeWidth: a, open: o } = t, s = (n - 1) * (r + i) + r + a, [c, l] = p[g(e, t)], u = c !== 0, d = (u ? c : l) < 0, h = o ? _(e, t) : f, v = e === 0 ? s : (n - e) * (r / n), y = e === 0 ? -a / 2 : r / n * e, b = (d ? v : y) - s - a / 2, S = u ? b - h.x : -h.x, C = u ? -h.y : b - h.y, w = d ? `#000 0px, #000 ${s}px, transparent ${s + a}px, transparent ${2 * s}px` : `transparent 0px, transparent ${s}px, #000 ${s + a}px, #000 ${2 * s}px`;
85
+ return {
86
+ translate: m(h, u),
87
+ maskImage: n > 1 ? `linear-gradient(${u ? "to right" : "to bottom"}, ${w})` : "none",
88
+ maskSize: u ? `${2 * s}px 100%` : `100% ${2 * s}px`,
89
+ maskPosition: `${S}px ${C}px`
90
+ };
91
+ }
92
+ function x(e, t) {
93
+ let { count: n, size: r, gap: i, fadeWidth: a, open: o } = t, s = t.radialStep, c = o ? _(e, t) : f, l = n > 1 ? r + i : 0, u = r + 2 * l, d = a ? a / (r / 2) * 180 / Math.PI : 0, p = t.radialStart + (e - 1) * s - s / 2 - d / 2, g = h(s + d);
76
94
  return {
77
- translate: p(g, d),
78
- maskImage: n > 1 ? `linear-gradient(${d ? "to right" : "to bottom"}, ${S})` : "none",
79
- maskSize: d ? `${2 * l}px 100%` : `100% ${2 * l}px`,
80
- maskPosition: `${x.x}px ${x.y}px`
95
+ translate: m(c, !1),
96
+ maskImage: n > 1 && e > 0 ? `conic-gradient(from ${h(p)}deg, #0000 0deg, #000 ${h(d)}deg, #000 ${h(e === n - 1 ? s : s + d)}deg, transparent ${g}deg)` : "none",
97
+ maskSize: `${u}px ${u}px`,
98
+ maskPosition: `${-c.x - l}px ${-c.y - l}px`
81
99
  };
82
100
  }
83
101
  // src/components/collageFabDefaults.ts
84
- var v = {
102
+ var S = {
85
103
  direction: "left",
86
104
  size: "large",
87
105
  variant: "circular",
88
106
  gap: 16,
89
107
  fadeWidth: 12,
108
+ spread: "line",
109
+ radialStart: 0,
90
110
  trigger: "hover",
91
111
  defaultOpen: !1,
92
112
  disableClickAway: !1,
93
113
  transitionDuration: 400,
94
114
  transitionEasing: "cubic-bezier(0.4, 0, 0.2, 1)"
95
- }, y = {
115
+ }, C = {
96
116
  circular: "50%",
97
117
  rounded: "25%",
98
118
  square: 0
99
- }, b = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
100
- function x(e, t) {
119
+ }, w = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
120
+ function T(e, t) {
101
121
  return `${e}ms ${t}`;
102
122
  }
103
- function S(e) {
123
+ function E(e) {
104
124
  return c("MuiCollageFab", e);
105
125
  }
106
- var C = (e, t) => s({
126
+ var D = (e, t) => s({
107
127
  root: ["root", e ? "expanded" : "collapsed"],
108
128
  item: ["item"]
109
- }, S, t), w = n("div", {
129
+ }, E, t), O = n("div", {
110
130
  name: "MuiCollageFab",
111
131
  slot: "root",
112
132
  overridesResolver: (e, t) => t.root
113
133
  })(({ ownerState: e }) => {
114
- let { open: t, size: n, transitionDuration: r, transitionEasing: i } = e, { extent: a } = g(e), o = x(r, i);
134
+ let { open: t, size: n, spread: r, gap: i, count: a, transitionDuration: o, transitionEasing: s } = e, { extent: c } = y(e), l = T(o, s), u = t && r === "radial" && a > 1 ? n + i : 0;
115
135
  return {
116
136
  position: "relative",
117
- width: t ? a.width : n,
118
- height: t ? a.height : n,
119
- transition: `width ${o}, height ${o}`,
137
+ ...u > 0 && { "&::after": {
138
+ content: "\"\"",
139
+ position: "absolute",
140
+ inset: -u,
141
+ borderRadius: "50%",
142
+ zIndex: -1
143
+ } },
144
+ width: t ? c.width : n,
145
+ height: t ? c.height : n,
146
+ transition: `width ${l}, height ${l}`,
120
147
  filter: "drop-shadow(0px 6px 12px rgba(0,0,0,0.25))",
121
148
  cursor: t ? "default" : "pointer",
122
149
  WebkitTapHighlightColor: "transparent"
123
150
  };
124
- }), T = n("div", {
151
+ }), k = n("div", {
125
152
  name: "MuiCollageFab",
126
153
  slot: "item",
127
154
  overridesResolver: (e, t) => t.item
128
155
  })(({ ownerState: e }) => {
129
- let { size: t, index: n, geometry: r, cornerRadius: i, transitionDuration: a, transitionEasing: o } = e, { align: s } = g(e), c = {
130
- ...s.x === "end" ? { right: 0 } : { left: 0 },
131
- ...s.y === "end" ? { bottom: 0 } : { top: 0 }
132
- }, l = x(a, o);
156
+ let { size: t, index: n, geometry: r, cornerRadius: i, transitionDuration: a, transitionEasing: o } = e, { align: s } = y(e), c = {
157
+ ...s.x === "end" ? { right: 0 } : s.x === "center" ? {
158
+ left: "50%",
159
+ marginLeft: -t / 2
160
+ } : { left: 0 },
161
+ ...s.y === "end" ? { bottom: 0 } : s.y === "center" ? {
162
+ top: "50%",
163
+ marginTop: -t / 2
164
+ } : { top: 0 }
165
+ }, l = T(a, o);
133
166
  return {
134
167
  position: "absolute",
135
168
  ...c,
@@ -140,7 +173,7 @@ var C = (e, t) => s({
140
173
  display: "flex",
141
174
  alignItems: "center",
142
175
  justifyContent: "center",
143
- zIndex: n,
176
+ zIndex: e.spread === "radial" ? e.count - n : n,
144
177
  transform: r.translate,
145
178
  WebkitMaskImage: r.maskImage,
146
179
  maskImage: r.maskImage,
@@ -160,7 +193,7 @@ var C = (e, t) => s({
160
193
  }
161
194
  };
162
195
  });
163
- function E(t) {
196
+ function A(t) {
164
197
  let { index: n, ownerState: r, geometry: i, className: s, component: c, inert: u, itemRefs: d, slotProps: f, children: p } = t, m = e.useMemo(() => ({
165
198
  ...r,
166
199
  index: n,
@@ -190,94 +223,102 @@ function E(t) {
190
223
  });
191
224
  return /* @__PURE__ */ l(c, { ...v });
192
225
  }
193
- var D = e.forwardRef(function(n, s) {
194
- let { children: c, direction: u = v.direction, size: f = v.size, variant: p = v.variant, gap: m = v.gap, fadeWidth: h = v.fadeWidth, trigger: g = v.trigger, open: x, defaultOpen: S = v.defaultOpen, onOpen: D, onClose: O, disableClickAway: k = v.disableClickAway, transitionDuration: ee = v.transitionDuration, transitionEasing: te = v.transitionEasing, classes: A, slots: j, slotProps: M, className: N, ...P } = r({
226
+ var j = e.forwardRef(function(n, s) {
227
+ let { children: c, direction: u = S.direction, directions: f, spread: p = S.spread, radialStart: m = S.radialStart, radialStep: h, size: g = S.size, variant: _ = S.variant, gap: v = S.gap, fadeWidth: y = S.fadeWidth, trigger: x = S.trigger, open: T, defaultOpen: E = S.defaultOpen, onOpen: j, onClose: M, disableClickAway: ee = S.disableClickAway, transitionDuration: te = S.transitionDuration, transitionEasing: ne = S.transitionEasing, classes: N, slots: P, slotProps: F, className: I, ...L } = r({
195
228
  props: n,
196
229
  name: "MuiCollageFab"
197
- }), [F, I] = i({
198
- controlled: x,
199
- default: S,
230
+ }), [R, z] = i({
231
+ controlled: T,
232
+ default: E,
200
233
  name: "CollageFab",
201
234
  state: "open"
202
- }), L = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), R = L.length, z = {
203
- open: F,
235
+ }), B = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), V = B.length, H = {
236
+ open: R,
204
237
  direction: u,
205
- trigger: g,
206
- size: d(f),
207
- variant: p,
208
- cornerRadius: y[p],
209
- gap: m,
210
- fadeWidth: h,
211
- count: R,
212
- transitionDuration: ee,
213
- transitionEasing: te
214
- }, B = C(F, A), V = e.useRef(null), H = e.useRef([]), U = e.useRef(!1), W = e.useRef("mouse"), G = e.useRef(!1), K = a(V, s), q = e.useCallback((e, t) => {
215
- e !== F && (I(e), e ? D?.(t) : O?.(t));
238
+ directions: e.useMemo(() => B.map((e, t) => f?.[t] ?? u), [
239
+ B,
240
+ f,
241
+ u
242
+ ]),
243
+ spread: p,
244
+ radialStart: m,
245
+ radialStep: h ?? 360 / Math.max(V - 1, 1),
246
+ trigger: x,
247
+ size: d(g),
248
+ variant: _,
249
+ cornerRadius: C[_],
250
+ gap: v,
251
+ fadeWidth: y,
252
+ count: V,
253
+ transitionDuration: te,
254
+ transitionEasing: ne
255
+ }, U = D(R, N), W = e.useRef(null), G = e.useRef([]), K = e.useRef(!1), q = e.useRef("mouse"), J = e.useRef(!1), Y = a(W, s), X = e.useCallback((e, t) => {
256
+ e !== R && (z(e), e ? j?.(t) : M?.(t));
216
257
  }, [
217
- F,
218
- I,
219
- D,
220
- O
221
- ]), J = (e) => {
222
- g === "hover" && e.pointerType === "mouse" && q(!0, e);
223
- }, Y = (e) => {
224
- g === "hover" && e.pointerType === "mouse" && q(!1, e);
225
- }, X = (e) => {
226
- g !== "manual" && (W.current = e.pointerType, U.current = !1, e.pointerType === "mouse" || F || (U.current = !0, q(!0, e)));
227
- }, Z = (e) => {
228
- U.current && (U.current = !1, e.stopPropagation(), e.preventDefault());
229
- }, ne = (e) => {
230
- g !== "manual" && (g === "click" ? q(!F, e) : F && W.current !== "mouse" && q(!1, e));
231
- }, re = (e) => {
232
- if (g !== "manual") {
233
- if (F) {
258
+ R,
259
+ z,
260
+ j,
261
+ M
262
+ ]), re = (e) => {
263
+ x === "hover" && e.pointerType === "mouse" && X(!0, e);
264
+ }, ie = (e) => {
265
+ x === "hover" && e.pointerType === "mouse" && X(!1, e);
266
+ }, ae = (e) => {
267
+ x !== "manual" && (q.current = e.pointerType, K.current = !1, e.pointerType === "mouse" || R || (K.current = !0, X(!0, e)));
268
+ }, oe = (e) => {
269
+ K.current && (K.current = !1, e.stopPropagation(), e.preventDefault());
270
+ }, se = (e) => {
271
+ x !== "manual" && (x === "click" ? X(!R, e) : R && q.current !== "mouse" && X(!1, e));
272
+ }, ce = (e) => {
273
+ if (x !== "manual") {
274
+ if (R) {
234
275
  if (e.key !== "Escape") return;
235
- e.stopPropagation(), q(!1, e), V.current?.focus();
236
- } else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), G.current = !0, q(!0, e));
276
+ e.stopPropagation(), X(!1, e), W.current?.focus();
277
+ } else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), J.current = !0, X(!0, e));
237
278
  }
238
- }, ie = (e) => {
239
- q(!1, e);
240
- }, Q = j?.root ?? w, ae = j?.item ?? T, oe = o({
279
+ }, Z = (e) => {
280
+ X(!1, e);
281
+ }, Q = P?.root ?? O, le = P?.item ?? k, ue = o({
241
282
  elementType: Q,
242
- externalForwardedProps: P,
243
- externalSlotProps: M?.root,
244
- ownerState: z,
283
+ externalForwardedProps: L,
284
+ externalSlotProps: F?.root,
285
+ ownerState: H,
245
286
  additionalProps: {
246
- ref: K,
287
+ ref: Y,
247
288
  role: "group",
248
- tabIndex: !F && g !== "manual" ? 0 : -1,
249
- onPointerEnter: J,
250
- onPointerLeave: Y,
251
- onPointerDown: X,
252
- onClick: ne,
253
- onClickCapture: Z,
254
- onKeyDown: re
289
+ tabIndex: !R && x !== "manual" ? 0 : -1,
290
+ onPointerEnter: re,
291
+ onPointerLeave: ie,
292
+ onPointerDown: ae,
293
+ onClick: se,
294
+ onClickCapture: oe,
295
+ onKeyDown: ce
255
296
  },
256
- className: [B.root, N]
297
+ className: [U.root, I]
257
298
  });
258
299
  if (e.useEffect(() => {
259
- if (!F || !G.current) return;
260
- G.current = !1;
261
- let e = H.current[0];
262
- e && (e.querySelector(b) ?? e).focus();
263
- }, [F]), R === 0) return null;
300
+ if (!R || !J.current) return;
301
+ J.current = !1;
302
+ let e = G.current[0];
303
+ e && (e.querySelector(w) ?? e).focus();
304
+ }, [R]), V === 0) return null;
264
305
  let $ = /* @__PURE__ */ l(Q, {
265
- ...oe,
266
- children: L.map((e, t) => /* @__PURE__ */ l(E, {
306
+ ...ue,
307
+ children: B.map((e, t) => /* @__PURE__ */ l(A, {
267
308
  index: t,
268
- ownerState: z,
269
- geometry: _(t, z),
270
- className: B.item,
271
- component: ae,
272
- inert: !F && g !== "manual",
273
- itemRefs: H,
274
- slotProps: M?.item,
309
+ ownerState: H,
310
+ geometry: b(t, H),
311
+ className: U.item,
312
+ component: le,
313
+ inert: !R && x !== "manual",
314
+ itemRefs: G,
315
+ slotProps: F?.item,
275
316
  children: e
276
317
  }, t))
277
318
  });
278
- return k || g === "manual" ? $ : /* @__PURE__ */ l(t, {
279
- onClickAway: ie,
319
+ return ee || x === "manual" ? $ : /* @__PURE__ */ l(t, {
320
+ onClickAway: Z,
280
321
  children: $
281
322
  });
282
323
  });
283
- export { D as CollageFab };
324
+ export { j as CollageFab };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mui-collage-fab",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Material UI floating action button that unfolds a stack of overlapping Fab circles into a row.",
5
5
  "license": "MIT",
6
6
  "author": "Radomir Wojtera",
@@ -151,7 +151,7 @@
151
151
  {
152
152
  "name": "CJS build",
153
153
  "path": "dist-lib/index.cjs",
154
- "limit": "3.1 kB"
154
+ "limit": "3.2 kB"
155
155
  }
156
156
  ]
157
157
  }