mui-collage-fab 0.3.0 → 0.5.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
@@ -6,9 +6,9 @@
6
6
  | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
7
7
  | <img src="https://raw.githubusercontent.com/radomir-dev/mui-collage-fab/main/docs/collagefab-collapsed.png" alt="Three CollageFab buttons collapsed into a single stacked circle" height="104" /> | <img src="https://raw.githubusercontent.com/radomir-dev/mui-collage-fab/main/docs/collagefab-expanded.png" alt="Three CollageFab buttons fanned out into a horizontal row" height="104" /> |
8
8
 
9
- A Material UI floating action button that behaves like a collapsed stack of overlapping circles. Collapsed, a set of `Fab`s sits perfectly stacked and reads as a single button with soft gradient slices at the edges. On hover (mouse) or tap (touch), the parent expands its main-axis extent and the buttons fan out into a row while their CSS masks slide in lockstep with the movement — so the unfold reads as one continuous morph instead of a pop.
9
+ A Material UI floating action button that behaves like a collapsed stack of overlapping circles. Collapsed, a set of `Fab`s sits perfectly stacked and reads as a single button with soft gradient slices at the edges. On hover (mouse) or tap (touch), the parent grows into the box its children travel through and they fan out — into a row, into two axes with `directions`, or onto a ring with `spread="radial"` — while their CSS masks slide in lockstep with the movement, so the unfold reads as one continuous morph instead of a pop.
10
10
 
11
- The trick is that each child is a full circle clipped by a static linear-gradient mask. As the element translates along the main axis, the `mask-position` is translated back by the same amount, keeping the fade boundary fixed in container space. Because the fade is a gradient rather than a hard clip, the parent's `filter: drop-shadow(...)` traces the soft edges cleanly.
11
+ The trick is that each child is a full circle clipped by a static mask that the item slides through: a linear-gradient band for a row, a conic-gradient wedge whose apex sits on the anchor for a ring. As the element translates, the `mask-position` is translated back by the same amount, keeping the cut line fixed in container space. Because the cut is a gradient rather than a hard clip, the parent's `filter: drop-shadow(...)` traces the soft edges cleanly.
12
12
 
13
13
  Not affiliated with or endorsed by MUI.
14
14
 
@@ -76,6 +76,9 @@ const [open, setOpen] = useState(false);
76
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
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. |
79
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. |
80
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. |
81
84
  | `gap` | `number` | `16` | Main-axis gap in pixels between two buttons when expanded. |
@@ -109,7 +112,7 @@ const [open, setOpen] = useState(false);
109
112
 
110
113
  <!-- api:owner-state:start -->
111
114
 
112
- `CollageFabOwnerState` carries `open`, `direction`, `directions`, `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`.
113
116
  <!-- api:owner-state:end -->
114
117
 
115
118
  Theme-level defaults and overrides work through the `MuiCollageFab` component key:
@@ -127,13 +130,15 @@ const theme = createTheme({
127
130
 
128
131
  ## Notes
129
132
 
130
- 1. **The parent must pin the anchor edge.** The root animates its own main-axis extent, so it only fans out if its parent keeps the anchor edge fixed: `justify-content: flex-end` for `direction="left"`, `flex-start` for `"right"`, `align-items: flex-end` for `"up"`, `flex-start` for `"down"`. Otherwise the root grows in place and pushes surrounding content instead of fanning out.
133
+ 1. **The parent must pin the anchor.** The root animates its own extent, so it only fans out if its parent keeps the anchor still: the corner the fan leaves behind (`justify-content: flex-end` for `direction="left"`, `flex-start` for `"right"`, `align-items: flex-end` for `"up"`, `flex-start` for `"down"`), or the centre for an axis that fans both ways. A radial group keeps its single-button box and paints the ring outside it, so it only needs room around it. Otherwise the root grows in place and pushes surrounding content instead of fanning out.
131
134
  2. **Each child is forced to `box-shadow: none` and 100% size**, so the parent owns the global shadow shape. Pass visual styles via each child's `sx`; the component overrides sizing and shadow only. Overriding that reset requires `slotProps.item.sx['& > *']` with `!important`.
132
135
  3. **The single `drop-shadow` lives on the root**, because a filter traces the soft mask edges while a `box-shadow` would trace the wrapper rectangles. Setting `overflow: hidden` on the root via `sx` clips the fan-out.
133
136
  4. **Shapes.** `variant` covers the three common cases; children inherit the wrapper's corner radius, so the shape applies to the whole group rather than to each button's own `Fab` default. Any other radius is reachable with `slotProps.item.sx`.
134
137
  5. **Collapsed slices are hidden from assistive technology.** While collapsed, the item wrappers are `aria-hidden` and made non-focusable, so they leave the tab order and the accessibility tree. The root stays focusable: Enter or Space opens the group, focus moves to the first item, and Escape closes it and returns focus to the root.
135
138
  6. **With a single child no mask is applied** — it behaves like a plain `Fab`.
136
139
  7. **`direction` is physical, not logical.** It is not mirrored under RTL; right-to-left layouts should set `direction="left"` explicitly.
140
+ 8. **`directions` gives each child its own direction**, in child order; children that share one fan a pitch apart, so a group can split into a row and a column.
141
+ 9. **`spread="radial"` rings the children around the anchor** at one pitch, with `radialStart` rotating the ring and `radialStep` (default `360 / (count - 1)`) spacing the ring children evenly. The anchor stays at the centre and never moves: a wedge cuts each child so it emerges as a petal, each petal fades in from the one before it, and the last one fades back into the anchor's disc, which is the base the collapsed stack reads as.
137
142
 
138
143
  ## Demo site
139
144
 
@@ -159,7 +164,9 @@ the cut line stays pinned while the button travels. `tests/behaviour.test.tsx` r
159
164
  component in jsdom for triggers, keyboard flow, controlled state and click-away.
160
165
  `e2e/collagefab.spec.ts` is the browser-level check, because jsdom cannot compute masks:
161
166
  it reads the real `transform` and `mask-position` after hovering and verifies they move by
162
- the same pitch in opposite directions.
167
+ the same pitch in opposite directions, and checks the mixed-axis and radial layouts.
168
+ `e2e/conic-mask.spec.ts` proves the compensated conic mask clips the same in chromium,
169
+ firefox and webkit against a single shared screenshot baseline.
163
170
 
164
171
  ## Development
165
172
 
@@ -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){return t.directions[e]??t.direction}function x(e,t){let n=b(e,t),r=v[n],i=t.size+t.gap,a=0;for(let r=0;r<e;r+=1)b(r,t)===n&&(a+=1);let o=(a+(n===b(0,t)?0:1))*i;return{x:r.x*o,y:r.y*o}}function S(e){let t=e.some(e=>e<0),n=e.some(e=>e>0);return t&&n?`center`:t?`end`:`start`}function C(e){let{count:t,size:n}=e,r=Array.from({length:t},(t,n)=>x(n,e)),i=r.map(e=>e.x),a=r.map(e=>e.y),o=e=>{let t=Math.min(...e,0),r=Math.max(...e,0);return S(e)===`center`?2*Math.max(-t,r)+n:r-t+n};return{extent:{width:o(i),height:o(a)},align:{x:S(i),y:S(a)}}}function w(e,t){let{count:n,size:r,gap:i,fadeWidth:a,open:o}=t,s=r+i,c=(n-1)*s+r+a,l=v[b(e,t)],u=l.x!==0,d=(u?l.x:l.y)<0,f=o?x(e,t):{x:0,y:0},p=e===0?c:(n-e)*(r/n),m=e===0?-a/2:r/n*e,h=(d?p:m)-c-a/2,g=u?{x:h,y:0}:{x:0,y:h},_={x:g.x-f.x,y:g.y-f.y},S=d?`#000 0px, #000 ${c}px, transparent ${c+a}px, transparent ${2*c}px`:`transparent 0px, transparent ${c}px, #000 ${c+a}px, #000 ${2*c}px`;return{translate:y(f,u),maskImage:n>1?`linear-gradient(${u?`to right`:`to bottom`}, ${S})`:`none`,maskSize:u?`${2*c}px 100%`:`100% ${2*c}px`,maskPosition:`${_.x}px ${_.y}px`}}var T={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)`},E={circular:`50%`,rounded:`25%`,square:0},D=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`;function O(e,t){return`${e}ms ${t}`}function k(e){return(0,m.default)(`MuiCollageFab`,e)}var A=(e,t)=>(0,p.default)({root:[`root`,e?`expanded`:`collapsed`],item:[`item`]},k,t),j=(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}=C(e),o=O(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`}}),ee=(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}=C(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=O(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 te(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 M=c.forwardRef(function(e,t){let{children:n,direction:r=T.direction,directions:i,size:a=T.size,variant:o=T.variant,gap:s=T.gap,fadeWidth:p=T.fadeWidth,trigger:m=T.trigger,open:g,defaultOpen:v=T.defaultOpen,onOpen:y,onClose:b,disableClickAway:x=T.disableClickAway,transitionDuration:S=T.transitionDuration,transitionEasing:C=T.transitionEasing,classes:O,slots:k,slotProps:M,className:N,...P}=(0,u.useThemeProps)({props:e,name:`MuiCollageFab`}),[F,I]=(0,d.useControlled)({controlled:g,default:v,name:`CollageFab`,state:`open`}),L=c.useMemo(()=>c.Children.toArray(n).filter(e=>c.isValidElement(e)),[n]),R=L.length,z={open:F,direction:r,directions:c.useMemo(()=>L.map((e,t)=>i?.[t]??r),[L,i,r]),trigger:m,size:_(a),variant:o,cornerRadius:E[o],gap:s,fadeWidth:p,count:R,transitionDuration:S,transitionEasing:C},B=A(F,O),V=c.useRef(null),H=c.useRef([]),U=c.useRef(!1),W=c.useRef(`mouse`),G=c.useRef(!1),K=(0,d.useForkRef)(V,t),q=c.useCallback((e,t)=>{e!==F&&(I(e),e?y?.(t):b?.(t))},[F,I,y,b]),J=e=>{m===`hover`&&e.pointerType===`mouse`&&q(!0,e)},Y=e=>{m===`hover`&&e.pointerType===`mouse`&&q(!1,e)},X=e=>{m!==`manual`&&(W.current=e.pointerType,U.current=!1,e.pointerType===`mouse`||F||(U.current=!0,q(!0,e)))},Z=e=>{U.current&&(U.current=!1,e.stopPropagation(),e.preventDefault())},ne=e=>{m!==`manual`&&(m===`click`?q(!F,e):F&&W.current!==`mouse`&&q(!1,e))},re=e=>{if(m!==`manual`){if(F){if(e.key!==`Escape`)return;e.stopPropagation(),q(!1,e),V.current?.focus()}else(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),G.current=!0,q(!0,e))}},ie=e=>{q(!1,e)},Q=k?.root??j,ae=k?.item??ee,oe=(0,f.default)({elementType:Q,externalForwardedProps:P,externalSlotProps:M?.root,ownerState:z,additionalProps:{ref:K,role:`group`,tabIndex:!F&&m!==`manual`?0:-1,onPointerEnter:J,onPointerLeave:Y,onPointerDown:X,onClick:ne,onClickCapture:Z,onKeyDown:re},className:[B.root,N]});if(c.useEffect(()=>{if(!F||!G.current)return;G.current=!1;let e=H.current[0];e&&(e.querySelector(D)??e).focus()},[F]),R===0)return null;let $=(0,h.jsx)(Q,{...oe,children:L.map((e,t)=>(0,h.jsx)(te,{index:t,ownerState:z,geometry:w(t,z),className:B.item,component:ae,inert:!F&&m!==`manual`,itemRefs:H,slotProps:M?.item,children:e},t))});return x||m===`manual`?$:(0,h.jsx)(l.ClickAwayListener,{onClickAway:ie,children:$})});exports.CollageFab=M;
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)`},k=1.08,A={circular:`50%`,rounded:`25%`,square:0},j=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`;function M(e,t){return`${e}ms ${t}`}function N(e){return(0,m.default)(`MuiCollageFab`,e)}var P=(e,t)=>(0,p.default)({root:[`root`,e?`expanded`:`collapsed`],item:[`item`]},N,t),F=(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=M(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`}}),ee=(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,open:s,spread:c,count:l}=e,u=!s&&c===`radial`&&l>1&&n>0,{align:d}=T(e),f={...d.x===`end`?{right:0}:d.x===`center`?{left:`50%`,marginLeft:-t/2}:{left:0},...d.y===`end`?{bottom:0}:d.y===`center`?{top:`50%`,marginTop:-t/2}:{top:0}},p=M(a,o);return{position:`absolute`,...f,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} scale(${u?k:1})`,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 ${p}, -webkit-mask-position ${p}, mask-position ${p}`,"& > *":{boxShadow:`none !important`,borderRadius:`inherit !important`,width:`100%`,height:`100%`,margin:0}}});function I(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 L=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:k,slots:M,slotProps:N,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:A[m],gap:g,fadeWidth:v,count:H,transitionDuration:T,transitionEasing:D},W=P(z,k),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=M?.root??F,ce=M?.item??ee,le=(0,f.default)({elementType:Q,externalForwardedProps:R,externalSlotProps:N?.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(j)??e).focus()},[z]),H===0)return null;let $=(0,h.jsx)(Q,{...le,children:V.map((e,t)=>(0,h.jsx)(I,{index:t,ownerState:U,geometry:E(t,U),className:W.item,component:ce,inert:!z&&y!==`manual`,itemRefs:K,slotProps:N?.item,children:e},t))});return w||y===`manual`?$:(0,h.jsx)(l.ClickAwayListener,{onClickAway:se,children:$})});exports.CollageFab=L;
@@ -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
  */
@@ -57,6 +61,12 @@ interface CollageFabOwnerState {
57
61
  direction: CollageFabDirection;
58
62
  /** The resolved direction of each child, in child order. */
59
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;
60
70
  /** The resolved pointer trigger mode. */
61
71
  trigger: CollageFabTrigger;
62
72
  /** The button diameter in pixels, after resolving the named size. */
@@ -140,6 +150,21 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
140
150
  * missing or past the end of the list falls back to `direction`.
141
151
  */
142
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;
143
168
  /**
144
169
  * Diameter of every button. Named sizes resolve to small 40px, medium 48px,
145
170
  * large 56px; numeric values are used verbatim.
@@ -221,4 +246,4 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
221
246
  declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
222
247
 
223
248
  export { CollageFab };
224
- 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
  */
@@ -57,6 +61,12 @@ interface CollageFabOwnerState {
57
61
  direction: CollageFabDirection;
58
62
  /** The resolved direction of each child, in child order. */
59
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;
60
70
  /** The resolved pointer trigger mode. */
61
71
  trigger: CollageFabTrigger;
62
72
  /** The button diameter in pixels, after resolving the named size. */
@@ -140,6 +150,21 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
140
150
  * missing or past the end of the list falls back to `direction`.
141
151
  */
142
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;
143
168
  /**
144
169
  * Diameter of every button. Named sizes resolve to small 40px, medium 48px,
145
170
  * large 56px; numeric values are used verbatim.
@@ -221,4 +246,4 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
221
246
  declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
222
247
 
223
248
  export { CollageFab };
224
- 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,138 +16,156 @@ 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) {
33
+ function g(e, t) {
40
34
  return t.directions[e] ?? t.direction;
41
35
  }
42
- function h(e, t) {
43
- let n = m(e, t), r = f[n], i = t.size + t.gap, a = 0;
44
- for (let r = 0; r < e; r += 1) m(r, t) === n && (a += 1);
45
- let o = (a + (n === m(0, t) ? 0 : 1)) * i;
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;
46
49
  return {
47
- x: r.x * o,
48
- y: r.y * o
50
+ x: i * s,
51
+ y: a * s
49
52
  };
50
53
  }
51
- function g(e) {
52
- let t = e.some((e) => e < 0), n = e.some((e) => e > 0);
53
- return t && n ? "center" : t ? "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];
54
57
  }
55
- function _(e) {
56
- let { count: t, size: n } = e, r = Array.from({ length: t }, (t, n) => h(n, e)), i = r.map((e) => e.x), a = r.map((e) => e.y), o = (e) => {
57
- let t = Math.min(...e, 0), r = Math.max(...e, 0);
58
- return g(e) === "center" ? 2 * Math.max(-t, r) + n : r - t + n;
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
+ }
59
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);
60
71
  return {
61
72
  extent: {
62
- width: o(i),
63
- height: o(a)
73
+ width: o,
74
+ height: c
64
75
  },
65
76
  align: {
66
- x: g(i),
67
- y: g(a)
77
+ x: s,
78
+ y: l
68
79
  }
69
80
  };
70
81
  }
71
- function v(e, t) {
72
- let { count: n, size: r, gap: i, fadeWidth: a, open: o } = t, s = r + i, c = (n - 1) * s + r + a, l = f[m(e, t)], u = l.x !== 0, d = (u ? l.x : l.y) < 0, g = o ? h(e, t) : {
73
- x: 0,
74
- y: 0
75
- }, _ = e === 0 ? c : (n - e) * (r / n), v = e === 0 ? -a / 2 : r / n * e, y = (d ? _ : v) - c - a / 2, b = u ? {
76
- x: y,
77
- y: 0
78
- } : {
79
- x: 0,
80
- y
81
- }, x = {
82
- x: b.x - g.x,
83
- y: b.y - g.y
84
- }, S = d ? `#000 0px, #000 ${c}px, transparent ${c + a}px, transparent ${2 * c}px` : `transparent 0px, transparent ${c}px, #000 ${c + a}px, #000 ${2 * c}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);
85
94
  return {
86
- translate: p(g, u),
87
- maskImage: n > 1 ? `linear-gradient(${u ? "to right" : "to bottom"}, ${S})` : "none",
88
- maskSize: u ? `${2 * c}px 100%` : `100% ${2 * c}px`,
89
- 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`
90
99
  };
91
100
  }
92
101
  // src/components/collageFabDefaults.ts
93
- var y = {
102
+ var S = {
94
103
  direction: "left",
95
104
  size: "large",
96
105
  variant: "circular",
97
106
  gap: 16,
98
107
  fadeWidth: 12,
108
+ spread: "line",
109
+ radialStart: 0,
99
110
  trigger: "hover",
100
111
  defaultOpen: !1,
101
112
  disableClickAway: !1,
102
113
  transitionDuration: 400,
103
114
  transitionEasing: "cubic-bezier(0.4, 0, 0.2, 1)"
104
- }, b = {
115
+ }, C = 1.08, w = {
105
116
  circular: "50%",
106
117
  rounded: "25%",
107
118
  square: 0
108
- }, x = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
109
- function S(e, t) {
119
+ }, ee = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
120
+ function T(e, t) {
110
121
  return `${e}ms ${t}`;
111
122
  }
112
- function C(e) {
123
+ function E(e) {
113
124
  return c("MuiCollageFab", e);
114
125
  }
115
- var w = (e, t) => s({
126
+ var D = (e, t) => s({
116
127
  root: ["root", e ? "expanded" : "collapsed"],
117
128
  item: ["item"]
118
- }, C, t), T = n("div", {
129
+ }, E, t), O = n("div", {
119
130
  name: "MuiCollageFab",
120
131
  slot: "root",
121
132
  overridesResolver: (e, t) => t.root
122
133
  })(({ ownerState: e }) => {
123
- let { open: t, size: n, transitionDuration: r, transitionEasing: i } = e, { extent: a } = _(e), o = S(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;
124
135
  return {
125
136
  position: "relative",
126
- width: t ? a.width : n,
127
- height: t ? a.height : n,
128
- 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}`,
129
147
  filter: "drop-shadow(0px 6px 12px rgba(0,0,0,0.25))",
130
148
  cursor: t ? "default" : "pointer",
131
149
  WebkitTapHighlightColor: "transparent"
132
150
  };
133
- }), ee = n("div", {
151
+ }), k = n("div", {
134
152
  name: "MuiCollageFab",
135
153
  slot: "item",
136
154
  overridesResolver: (e, t) => t.item
137
155
  })(({ ownerState: e }) => {
138
- let { size: t, index: n, geometry: r, cornerRadius: i, transitionDuration: a, transitionEasing: o } = e, { align: s } = _(e), c = {
139
- ...s.x === "end" ? { right: 0 } : s.x === "center" ? {
156
+ let { size: t, index: n, geometry: r, cornerRadius: i, transitionDuration: a, transitionEasing: o, open: s, spread: c, count: l } = e, u = !s && c === "radial" && l > 1 && n > 0, { align: d } = y(e), f = {
157
+ ...d.x === "end" ? { right: 0 } : d.x === "center" ? {
140
158
  left: "50%",
141
159
  marginLeft: -t / 2
142
160
  } : { left: 0 },
143
- ...s.y === "end" ? { bottom: 0 } : s.y === "center" ? {
161
+ ...d.y === "end" ? { bottom: 0 } : d.y === "center" ? {
144
162
  top: "50%",
145
163
  marginTop: -t / 2
146
164
  } : { top: 0 }
147
- }, l = S(a, o);
165
+ }, p = T(a, o);
148
166
  return {
149
167
  position: "absolute",
150
- ...c,
168
+ ...f,
151
169
  width: t,
152
170
  height: t,
153
171
  borderRadius: i,
@@ -155,8 +173,8 @@ var w = (e, t) => s({
155
173
  display: "flex",
156
174
  alignItems: "center",
157
175
  justifyContent: "center",
158
- zIndex: n,
159
- transform: r.translate,
176
+ zIndex: e.spread === "radial" ? e.count - n : n,
177
+ transform: `${r.translate} scale(${u ? C : 1})`,
160
178
  WebkitMaskImage: r.maskImage,
161
179
  maskImage: r.maskImage,
162
180
  WebkitMaskSize: r.maskSize,
@@ -165,7 +183,7 @@ var w = (e, t) => s({
165
183
  maskPosition: r.maskPosition,
166
184
  WebkitMaskRepeat: "no-repeat",
167
185
  maskRepeat: "no-repeat",
168
- transition: `transform ${l}, -webkit-mask-position ${l}, mask-position ${l}`,
186
+ transition: `transform ${p}, -webkit-mask-position ${p}, mask-position ${p}`,
169
187
  "& > *": {
170
188
  boxShadow: "none !important",
171
189
  borderRadius: "inherit !important",
@@ -205,99 +223,102 @@ function te(t) {
205
223
  });
206
224
  return /* @__PURE__ */ l(c, { ...v });
207
225
  }
208
- var E = e.forwardRef(function(n, s) {
209
- let { children: c, direction: u = y.direction, directions: f, size: p = y.size, variant: m = y.variant, gap: h = y.gap, fadeWidth: g = y.fadeWidth, trigger: _ = y.trigger, open: S, defaultOpen: C = y.defaultOpen, onOpen: E, onClose: D, disableClickAway: O = y.disableClickAway, transitionDuration: k = y.transitionDuration, transitionEasing: A = y.transitionEasing, classes: j, slots: M, slotProps: N, className: P, ...F } = r({
226
+ var A = 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: C, defaultOpen: T = S.defaultOpen, onOpen: E, onClose: A, disableClickAway: ne = S.disableClickAway, transitionDuration: j = S.transitionDuration, transitionEasing: M = S.transitionEasing, classes: N, slots: P, slotProps: F, className: I, ...L } = r({
210
228
  props: n,
211
229
  name: "MuiCollageFab"
212
- }), [I, L] = i({
213
- controlled: S,
214
- default: C,
230
+ }), [R, z] = i({
231
+ controlled: C,
232
+ default: T,
215
233
  name: "CollageFab",
216
234
  state: "open"
217
- }), R = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), z = R.length, B = {
218
- open: I,
235
+ }), B = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), V = B.length, H = {
236
+ open: R,
219
237
  direction: u,
220
- directions: e.useMemo(() => R.map((e, t) => f?.[t] ?? u), [
221
- R,
238
+ directions: e.useMemo(() => B.map((e, t) => f?.[t] ?? u), [
239
+ B,
222
240
  f,
223
241
  u
224
242
  ]),
225
- trigger: _,
226
- size: d(p),
227
- variant: m,
228
- cornerRadius: b[m],
229
- gap: h,
230
- fadeWidth: g,
231
- count: z,
232
- transitionDuration: k,
233
- transitionEasing: A
234
- }, V = w(I, j), H = e.useRef(null), U = e.useRef([]), W = e.useRef(!1), G = e.useRef("mouse"), K = e.useRef(!1), q = a(H, s), J = e.useCallback((e, t) => {
235
- e !== I && (L(e), e ? E?.(t) : D?.(t));
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: w[_],
250
+ gap: v,
251
+ fadeWidth: y,
252
+ count: V,
253
+ transitionDuration: j,
254
+ transitionEasing: M
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 ? E?.(t) : A?.(t));
236
257
  }, [
237
- I,
238
- L,
258
+ R,
259
+ z,
239
260
  E,
240
- D
241
- ]), Y = (e) => {
242
- _ === "hover" && e.pointerType === "mouse" && J(!0, e);
243
- }, X = (e) => {
244
- _ === "hover" && e.pointerType === "mouse" && J(!1, e);
245
- }, Z = (e) => {
246
- _ !== "manual" && (G.current = e.pointerType, W.current = !1, e.pointerType === "mouse" || I || (W.current = !0, J(!0, e)));
247
- }, ne = (e) => {
248
- W.current && (W.current = !1, e.stopPropagation(), e.preventDefault());
249
- }, re = (e) => {
250
- _ !== "manual" && (_ === "click" ? J(!I, e) : I && G.current !== "mouse" && J(!1, e));
261
+ A
262
+ ]), re = (e) => {
263
+ x === "hover" && e.pointerType === "mouse" && X(!0, e);
251
264
  }, ie = (e) => {
252
- if (_ !== "manual") {
253
- if (I) {
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) {
254
275
  if (e.key !== "Escape") return;
255
- e.stopPropagation(), J(!1, e), H.current?.focus();
256
- } else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), K.current = !0, J(!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));
257
278
  }
258
- }, ae = (e) => {
259
- J(!1, e);
260
- }, Q = M?.root ?? T, oe = M?.item ?? ee, se = o({
279
+ }, Z = (e) => {
280
+ X(!1, e);
281
+ }, Q = P?.root ?? O, le = P?.item ?? k, ue = o({
261
282
  elementType: Q,
262
- externalForwardedProps: F,
263
- externalSlotProps: N?.root,
264
- ownerState: B,
283
+ externalForwardedProps: L,
284
+ externalSlotProps: F?.root,
285
+ ownerState: H,
265
286
  additionalProps: {
266
- ref: q,
287
+ ref: Y,
267
288
  role: "group",
268
- tabIndex: !I && _ !== "manual" ? 0 : -1,
269
- onPointerEnter: Y,
270
- onPointerLeave: X,
271
- onPointerDown: Z,
272
- onClick: re,
273
- onClickCapture: ne,
274
- onKeyDown: ie
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
275
296
  },
276
- className: [V.root, P]
297
+ className: [U.root, I]
277
298
  });
278
299
  if (e.useEffect(() => {
279
- if (!I || !K.current) return;
280
- K.current = !1;
281
- let e = U.current[0];
282
- e && (e.querySelector(x) ?? e).focus();
283
- }, [I]), z === 0) return null;
300
+ if (!R || !J.current) return;
301
+ J.current = !1;
302
+ let e = G.current[0];
303
+ e && (e.querySelector(ee) ?? e).focus();
304
+ }, [R]), V === 0) return null;
284
305
  let $ = /* @__PURE__ */ l(Q, {
285
- ...se,
286
- children: R.map((e, t) => /* @__PURE__ */ l(te, {
306
+ ...ue,
307
+ children: B.map((e, t) => /* @__PURE__ */ l(te, {
287
308
  index: t,
288
- ownerState: B,
289
- geometry: v(t, B),
290
- className: V.item,
291
- component: oe,
292
- inert: !I && _ !== "manual",
293
- itemRefs: U,
294
- slotProps: N?.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,
295
316
  children: e
296
317
  }, t))
297
318
  });
298
- return O || _ === "manual" ? $ : /* @__PURE__ */ l(t, {
299
- onClickAway: ae,
319
+ return ne || x === "manual" ? $ : /* @__PURE__ */ l(t, {
320
+ onClickAway: Z,
300
321
  children: $
301
322
  });
302
323
  });
303
- export { E as CollageFab };
324
+ export { A as CollageFab };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mui-collage-fab",
3
- "version": "0.3.0",
4
- "description": "Material UI floating action button that unfolds a stack of overlapping Fab circles into a row.",
3
+ "version": "0.5.0",
4
+ "description": "Material UI floating action button that unfolds a stack of overlapping Fab circles into a row, a fan or a ring.",
5
5
  "license": "MIT",
6
6
  "author": "Radomir Wojtera",
7
7
  "homepage": "https://www.radomir.dev/mui-collage-fab/",
@@ -146,12 +146,12 @@
146
146
  {
147
147
  "name": "ESM build",
148
148
  "path": "dist-lib/index.js",
149
- "limit": "3.6 kB"
149
+ "limit": "3.4 kB"
150
150
  },
151
151
  {
152
152
  "name": "CJS build",
153
153
  "path": "dist-lib/index.cjs",
154
- "limit": "3.1 kB"
154
+ "limit": "3.3 kB"
155
155
  }
156
156
  ]
157
157
  }