mui-collage-fab 0.5.0 → 0.6.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 +26 -26
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/index.d.cts +3 -2
- package/dist-lib/index.d.ts +3 -2
- package/dist-lib/index.js +69 -66
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -71,31 +71,31 @@ const [open, setOpen] = useState(false);
|
|
|
71
71
|
|
|
72
72
|
<!-- api:props:start -->
|
|
73
73
|
|
|
74
|
-
| Prop | Type | Default | Description
|
|
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` or their own entry in `directions`.
|
|
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.
|
|
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.
|
|
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.
|
|
84
|
-
| `gap` | `number` | `16` | Main-axis gap in pixels between two buttons when expanded.
|
|
85
|
-
| `fadeWidth` | `number` | `12` | Width in pixels of the soft cut line between two slices.
|
|
86
|
-
| `trigger` | `'hover' \| 'click' \| 'manual'`
|
|
87
|
-
| `open` | `boolean` | — | If `true`, the group is expanded. Use it to control the component.
|
|
88
|
-
| `defaultOpen` | `boolean` | `false` | If `true`, the group is expanded by default (uncontrolled).
|
|
89
|
-
| `onOpen` | `(event: React.SyntheticEvent) => void` | — | Callback fired when the group is expanded.
|
|
90
|
-
| `onClose` | `(event: React.SyntheticEvent) => void` | — | Callback fired when the group is collapsed.
|
|
91
|
-
| `disableClickAway` | `boolean` | `false` | If `true`, the group does not collapse when the user clicks away from it.
|
|
92
|
-
| `transitionDuration` | `number` | `400` | Duration of the morph, in milliseconds.
|
|
93
|
-
| `transitionEasing` | `string` | `'cubic-bezier(0.4, 0, 0.2, 1)'` | Easing of the morph.
|
|
94
|
-
| `sx` | `SxProps<Theme>` | — | System prop that defines system overrides as well as additional CSS styles.
|
|
95
|
-
| `classes` | `Partial<CollageFabClasses>` | — | Override or extend the styles applied to the component.
|
|
96
|
-
| `slots` | `CollageFabSlots` | — | Custom components for the `root` and `item` slots.
|
|
97
|
-
| `slotProps` | `{ root?, item? }` | — | Props for each slot. `slotProps.item` accepts either a props object or an `(ownerState) => props` callback, which is the per-child escape hatch.
|
|
98
|
-
| `...divProps` | `React.HTMLAttributes<HTMLDivElement>` | — | The remaining div attributes are spread onto the root.
|
|
74
|
+
| Prop | Type | Default | Description |
|
|
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` or their own entry in `directions`. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
84
|
+
| `gap` | `number` | `16` | Main-axis gap in pixels between two buttons when expanded. |
|
|
85
|
+
| `fadeWidth` | `number` | `12` | Width in pixels of the soft cut line between two slices. |
|
|
86
|
+
| `trigger` | `'hover' \| 'click' \| 'manual' \| 'auto'` | `'hover'` | How the group reacts to pointers. `'hover'` opens on mouse enter, closes on mouse leave and toggles on touch or pen tap; `'click'` toggles on any click; `'manual'` disables all built-in pointer interaction; `'auto'` behaves like `'hover'` where the primary pointer can hover and like `'click'` elsewhere. |
|
|
87
|
+
| `open` | `boolean` | — | If `true`, the group is expanded. Use it to control the component. |
|
|
88
|
+
| `defaultOpen` | `boolean` | `false` | If `true`, the group is expanded by default (uncontrolled). |
|
|
89
|
+
| `onOpen` | `(event: React.SyntheticEvent) => void` | — | Callback fired when the group is expanded. |
|
|
90
|
+
| `onClose` | `(event: React.SyntheticEvent) => void` | — | Callback fired when the group is collapsed. |
|
|
91
|
+
| `disableClickAway` | `boolean` | `false` | If `true`, the group does not collapse when the user clicks away from it. |
|
|
92
|
+
| `transitionDuration` | `number` | `400` | Duration of the morph, in milliseconds. |
|
|
93
|
+
| `transitionEasing` | `string` | `'cubic-bezier(0.4, 0, 0.2, 1)'` | Easing of the morph. |
|
|
94
|
+
| `sx` | `SxProps<Theme>` | — | System prop that defines system overrides as well as additional CSS styles. |
|
|
95
|
+
| `classes` | `Partial<CollageFabClasses>` | — | Override or extend the styles applied to the component. |
|
|
96
|
+
| `slots` | `CollageFabSlots` | — | Custom components for the `root` and `item` slots. |
|
|
97
|
+
| `slotProps` | `{ root?, item? }` | — | Props for each slot. `slotProps.item` accepts either a props object or an `(ownerState) => props` callback, which is the per-child escape hatch. |
|
|
98
|
+
| `...divProps` | `React.HTMLAttributes<HTMLDivElement>` | — | The remaining div attributes are spread onto the root. |
|
|
99
99
|
|
|
100
100
|
<!-- api:props:end -->
|
|
101
101
|
|
|
@@ -134,7 +134,7 @@ const theme = createTheme({
|
|
|
134
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`.
|
|
135
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.
|
|
136
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`.
|
|
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.
|
|
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 — under `trigger="manual"` the anchor stays live so it can be the handle. 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.
|
|
138
138
|
6. **With a single child no mask is applied** — it behaves like a plain `Fab`.
|
|
139
139
|
7. **`direction` is physical, not logical.** It is not mirrored under RTL; right-to-left layouts should set `direction="left"` explicitly.
|
|
140
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.
|
package/dist-lib/index.cjs
CHANGED
|
@@ -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={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
|
|
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(){return typeof window>`u`||!window.matchMedia||window.matchMedia(`(hover: hover)`).matches}function N(e,t){return`${e}ms ${t}`}function P(e){return(0,m.default)(`MuiCollageFab`,e)}var ee=(e,t)=>(0,p.default)({root:[`root`,e?`expanded`:`collapsed`],item:[`item`]},P,t),te=(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=N(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`}}),ne=(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=N(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 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:k,slots:N,slotProps:P,className:I,...L}=(0,u.useThemeProps)({props:e,name:`MuiCollageFab`}),[R,z]=(0,d.useControlled)({controlled:b,default:x,name:`CollageFab`,state:`open`}),B=c.useMemo(()=>c.Children.toArray(n).filter(e=>c.isValidElement(e)),[n]),V=B.length,re=c.useMemo(()=>B.map((e,t)=>i?.[t]??r),[B,i,r]),H=y===`auto`?M()?`hover`:`click`:y,U={open:R,direction:r,directions:re,spread:a,radialStart:o,radialStep:s??360/Math.max(V-1,1),trigger:H,size:_(p),variant:m,cornerRadius:A[m],gap:g,fadeWidth:v,count:V,transitionDuration:T,transitionEasing:D},W=ee(R,k),G=c.useRef(null),K=c.useRef([]),q=c.useRef(!1),J=c.useRef(`mouse`),Y=c.useRef(!1),ie=(0,d.useForkRef)(G,t),X=c.useCallback((e,t)=>{e!==R&&(z(e),e?S?.(t):C?.(t))},[R,z,S,C]),ae=e=>{H===`hover`&&e.pointerType===`mouse`&&X(!0,e)},oe=e=>{H===`hover`&&e.pointerType===`mouse`&&X(!1,e)},se=e=>{H!==`manual`&&(J.current=e.pointerType,q.current=!1,e.pointerType===`mouse`||R||(q.current=!0,X(!0,e)))},ce=e=>{q.current&&(q.current=!1,e.stopPropagation(),e.preventDefault())},Z=e=>{H!==`manual`&&(H===`click`?X(!R,e):R&&J.current!==`mouse`&&X(!1,e))},le=e=>{if(H!==`manual`){if(R){if(e.key!==`Escape`)return;e.stopPropagation(),X(!1,e),G.current?.focus()}else(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Y.current=!0,X(!0,e))}},ue=e=>{X(!1,e)},Q=N?.root??te,de=N?.item??ne,fe=(0,f.default)({elementType:Q,externalForwardedProps:L,externalSlotProps:P?.root,ownerState:U,additionalProps:{ref:ie,role:`group`,tabIndex:!R&&H!==`manual`?0:-1,onPointerEnter:ae,onPointerLeave:oe,onPointerDown:se,onClick:Z,onClickCapture:ce,onKeyDown:le},className:[W.root,I]});if(c.useEffect(()=>{if(!R||!Y.current)return;Y.current=!1;let e=K.current[0];e&&(e.querySelector(j)??e).focus()},[R]),V===0)return null;let $=(0,h.jsx)(Q,{...fe,children:B.map((e,t)=>(0,h.jsx)(F,{index:t,ownerState:U,geometry:E(t,U),className:W.item,component:de,inert:!R&&(H!==`manual`||t>0),itemRefs:K,slotProps:P?.item,children:e},t))});return w||H===`manual`?$:(0,h.jsx)(l.ClickAwayListener,{onClickAway:ue,children:$})});exports.CollageFab=I;
|
package/dist-lib/index.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ type CollageFabDirection = 'left' | 'right' | 'up' | 'down';
|
|
|
9
9
|
/**
|
|
10
10
|
* How the group reacts to pointers.
|
|
11
11
|
*/
|
|
12
|
-
type CollageFabTrigger = 'hover' | 'click' | 'manual';
|
|
12
|
+
type CollageFabTrigger = 'hover' | 'click' | 'manual' | 'auto';
|
|
13
13
|
/**
|
|
14
14
|
* Diameter of every button. Named sizes resolve to small 40px, medium 48px and
|
|
15
15
|
* large 56px; numeric values are used verbatim.
|
|
@@ -188,7 +188,8 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
188
188
|
/**
|
|
189
189
|
* How the group reacts to pointers. `'hover'` opens on mouse enter, closes on
|
|
190
190
|
* mouse leave and toggles on touch or pen tap; `'click'` toggles on any click;
|
|
191
|
-
* `'manual'` disables all built-in pointer interaction
|
|
191
|
+
* `'manual'` disables all built-in pointer interaction; `'auto'` behaves like
|
|
192
|
+
* `'hover'` where the primary pointer can hover and like `'click'` elsewhere.
|
|
192
193
|
*/
|
|
193
194
|
trigger?: CollageFabTrigger;
|
|
194
195
|
/**
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type CollageFabDirection = 'left' | 'right' | 'up' | 'down';
|
|
|
9
9
|
/**
|
|
10
10
|
* How the group reacts to pointers.
|
|
11
11
|
*/
|
|
12
|
-
type CollageFabTrigger = 'hover' | 'click' | 'manual';
|
|
12
|
+
type CollageFabTrigger = 'hover' | 'click' | 'manual' | 'auto';
|
|
13
13
|
/**
|
|
14
14
|
* Diameter of every button. Named sizes resolve to small 40px, medium 48px and
|
|
15
15
|
* large 56px; numeric values are used verbatim.
|
|
@@ -188,7 +188,8 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
188
188
|
/**
|
|
189
189
|
* How the group reacts to pointers. `'hover'` opens on mouse enter, closes on
|
|
190
190
|
* mouse leave and toggles on touch or pen tap; `'click'` toggles on any click;
|
|
191
|
-
* `'manual'` disables all built-in pointer interaction
|
|
191
|
+
* `'manual'` disables all built-in pointer interaction; `'auto'` behaves like
|
|
192
|
+
* `'hover'` where the primary pointer can hover and like `'click'` elsewhere.
|
|
192
193
|
*/
|
|
193
194
|
trigger?: CollageFabTrigger;
|
|
194
195
|
/**
|
package/dist-lib/index.js
CHANGED
|
@@ -117,21 +117,24 @@ var S = {
|
|
|
117
117
|
rounded: "25%",
|
|
118
118
|
square: 0
|
|
119
119
|
}, ee = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
|
|
120
|
-
function T(
|
|
120
|
+
function T() {
|
|
121
|
+
return typeof window > "u" || !window.matchMedia || window.matchMedia("(hover: hover)").matches;
|
|
122
|
+
}
|
|
123
|
+
function E(e, t) {
|
|
121
124
|
return `${e}ms ${t}`;
|
|
122
125
|
}
|
|
123
|
-
function
|
|
126
|
+
function D(e) {
|
|
124
127
|
return c("MuiCollageFab", e);
|
|
125
128
|
}
|
|
126
|
-
var
|
|
129
|
+
var O = (e, t) => s({
|
|
127
130
|
root: ["root", e ? "expanded" : "collapsed"],
|
|
128
131
|
item: ["item"]
|
|
129
|
-
},
|
|
132
|
+
}, D, t), te = n("div", {
|
|
130
133
|
name: "MuiCollageFab",
|
|
131
134
|
slot: "root",
|
|
132
135
|
overridesResolver: (e, t) => t.root
|
|
133
136
|
})(({ ownerState: e }) => {
|
|
134
|
-
let { open: t, size: n, spread: r, gap: i, count: a, transitionDuration: o, transitionEasing: s } = e, { extent: c } = y(e), l =
|
|
137
|
+
let { open: t, size: n, spread: r, gap: i, count: a, transitionDuration: o, transitionEasing: s } = e, { extent: c } = y(e), l = E(o, s), u = t && r === "radial" && a > 1 ? n + i : 0;
|
|
135
138
|
return {
|
|
136
139
|
position: "relative",
|
|
137
140
|
...u > 0 && { "&::after": {
|
|
@@ -148,7 +151,7 @@ var D = (e, t) => s({
|
|
|
148
151
|
cursor: t ? "default" : "pointer",
|
|
149
152
|
WebkitTapHighlightColor: "transparent"
|
|
150
153
|
};
|
|
151
|
-
}),
|
|
154
|
+
}), ne = n("div", {
|
|
152
155
|
name: "MuiCollageFab",
|
|
153
156
|
slot: "item",
|
|
154
157
|
overridesResolver: (e, t) => t.item
|
|
@@ -162,7 +165,7 @@ var D = (e, t) => s({
|
|
|
162
165
|
top: "50%",
|
|
163
166
|
marginTop: -t / 2
|
|
164
167
|
} : { top: 0 }
|
|
165
|
-
}, p =
|
|
168
|
+
}, p = E(a, o);
|
|
166
169
|
return {
|
|
167
170
|
position: "absolute",
|
|
168
171
|
...f,
|
|
@@ -193,7 +196,7 @@ var D = (e, t) => s({
|
|
|
193
196
|
}
|
|
194
197
|
};
|
|
195
198
|
});
|
|
196
|
-
function
|
|
199
|
+
function re(t) {
|
|
197
200
|
let { index: n, ownerState: r, geometry: i, className: s, component: c, inert: u, itemRefs: d, slotProps: f, children: p } = t, m = e.useMemo(() => ({
|
|
198
201
|
...r,
|
|
199
202
|
index: n,
|
|
@@ -223,102 +226,102 @@ function te(t) {
|
|
|
223
226
|
});
|
|
224
227
|
return /* @__PURE__ */ l(c, { ...v });
|
|
225
228
|
}
|
|
226
|
-
var
|
|
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:
|
|
229
|
+
var k = e.forwardRef(function(n, s) {
|
|
230
|
+
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: E = S.defaultOpen, onOpen: D, onClose: k, disableClickAway: A = S.disableClickAway, transitionDuration: j = S.transitionDuration, transitionEasing: M = S.transitionEasing, classes: N, slots: P, slotProps: F, className: I, ...ie } = r({
|
|
228
231
|
props: n,
|
|
229
232
|
name: "MuiCollageFab"
|
|
230
|
-
}), [
|
|
233
|
+
}), [L, R] = i({
|
|
231
234
|
controlled: C,
|
|
232
|
-
default:
|
|
235
|
+
default: E,
|
|
233
236
|
name: "CollageFab",
|
|
234
237
|
state: "open"
|
|
235
|
-
}),
|
|
236
|
-
|
|
238
|
+
}), z = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), B = z.length, V = e.useMemo(() => z.map((e, t) => f?.[t] ?? u), [
|
|
239
|
+
z,
|
|
240
|
+
f,
|
|
241
|
+
u
|
|
242
|
+
]), H = x === "auto" ? T() ? "hover" : "click" : x, U = {
|
|
243
|
+
open: L,
|
|
237
244
|
direction: u,
|
|
238
|
-
directions:
|
|
239
|
-
B,
|
|
240
|
-
f,
|
|
241
|
-
u
|
|
242
|
-
]),
|
|
245
|
+
directions: V,
|
|
243
246
|
spread: p,
|
|
244
247
|
radialStart: m,
|
|
245
|
-
radialStep: h ?? 360 / Math.max(
|
|
246
|
-
trigger:
|
|
248
|
+
radialStep: h ?? 360 / Math.max(B - 1, 1),
|
|
249
|
+
trigger: H,
|
|
247
250
|
size: d(g),
|
|
248
251
|
variant: _,
|
|
249
252
|
cornerRadius: w[_],
|
|
250
253
|
gap: v,
|
|
251
254
|
fadeWidth: y,
|
|
252
|
-
count:
|
|
255
|
+
count: B,
|
|
253
256
|
transitionDuration: j,
|
|
254
257
|
transitionEasing: M
|
|
255
|
-
},
|
|
256
|
-
e !==
|
|
258
|
+
}, W = O(L, N), G = e.useRef(null), K = e.useRef([]), q = e.useRef(!1), J = e.useRef("mouse"), Y = e.useRef(!1), ae = a(G, s), X = e.useCallback((e, t) => {
|
|
259
|
+
e !== L && (R(e), e ? D?.(t) : k?.(t));
|
|
257
260
|
}, [
|
|
261
|
+
L,
|
|
258
262
|
R,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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());
|
|
263
|
+
D,
|
|
264
|
+
k
|
|
265
|
+
]), oe = (e) => {
|
|
266
|
+
H === "hover" && e.pointerType === "mouse" && X(!0, e);
|
|
270
267
|
}, se = (e) => {
|
|
271
|
-
|
|
268
|
+
H === "hover" && e.pointerType === "mouse" && X(!1, e);
|
|
272
269
|
}, ce = (e) => {
|
|
273
|
-
|
|
274
|
-
|
|
270
|
+
H !== "manual" && (J.current = e.pointerType, q.current = !1, e.pointerType === "mouse" || L || (q.current = !0, X(!0, e)));
|
|
271
|
+
}, le = (e) => {
|
|
272
|
+
q.current && (q.current = !1, e.stopPropagation(), e.preventDefault());
|
|
273
|
+
}, ue = (e) => {
|
|
274
|
+
H !== "manual" && (H === "click" ? X(!L, e) : L && J.current !== "mouse" && X(!1, e));
|
|
275
|
+
}, de = (e) => {
|
|
276
|
+
if (H !== "manual") {
|
|
277
|
+
if (L) {
|
|
275
278
|
if (e.key !== "Escape") return;
|
|
276
|
-
e.stopPropagation(), X(!1, e),
|
|
277
|
-
} else (e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
279
|
+
e.stopPropagation(), X(!1, e), G.current?.focus();
|
|
280
|
+
} else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), Y.current = !0, X(!0, e));
|
|
278
281
|
}
|
|
279
282
|
}, Z = (e) => {
|
|
280
283
|
X(!1, e);
|
|
281
|
-
}, Q = P?.root ??
|
|
284
|
+
}, Q = P?.root ?? te, fe = P?.item ?? ne, pe = o({
|
|
282
285
|
elementType: Q,
|
|
283
|
-
externalForwardedProps:
|
|
286
|
+
externalForwardedProps: ie,
|
|
284
287
|
externalSlotProps: F?.root,
|
|
285
|
-
ownerState:
|
|
288
|
+
ownerState: U,
|
|
286
289
|
additionalProps: {
|
|
287
|
-
ref:
|
|
290
|
+
ref: ae,
|
|
288
291
|
role: "group",
|
|
289
|
-
tabIndex: !
|
|
290
|
-
onPointerEnter:
|
|
291
|
-
onPointerLeave:
|
|
292
|
-
onPointerDown:
|
|
293
|
-
onClick:
|
|
294
|
-
onClickCapture:
|
|
295
|
-
onKeyDown:
|
|
292
|
+
tabIndex: !L && H !== "manual" ? 0 : -1,
|
|
293
|
+
onPointerEnter: oe,
|
|
294
|
+
onPointerLeave: se,
|
|
295
|
+
onPointerDown: ce,
|
|
296
|
+
onClick: ue,
|
|
297
|
+
onClickCapture: le,
|
|
298
|
+
onKeyDown: de
|
|
296
299
|
},
|
|
297
|
-
className: [
|
|
300
|
+
className: [W.root, I]
|
|
298
301
|
});
|
|
299
302
|
if (e.useEffect(() => {
|
|
300
|
-
if (!
|
|
301
|
-
|
|
302
|
-
let e =
|
|
303
|
+
if (!L || !Y.current) return;
|
|
304
|
+
Y.current = !1;
|
|
305
|
+
let e = K.current[0];
|
|
303
306
|
e && (e.querySelector(ee) ?? e).focus();
|
|
304
|
-
}, [
|
|
307
|
+
}, [L]), B === 0) return null;
|
|
305
308
|
let $ = /* @__PURE__ */ l(Q, {
|
|
306
|
-
...
|
|
307
|
-
children:
|
|
309
|
+
...pe,
|
|
310
|
+
children: z.map((e, t) => /* @__PURE__ */ l(re, {
|
|
308
311
|
index: t,
|
|
309
|
-
ownerState:
|
|
310
|
-
geometry: b(t,
|
|
311
|
-
className:
|
|
312
|
-
component:
|
|
313
|
-
inert: !
|
|
314
|
-
itemRefs:
|
|
312
|
+
ownerState: U,
|
|
313
|
+
geometry: b(t, U),
|
|
314
|
+
className: W.item,
|
|
315
|
+
component: fe,
|
|
316
|
+
inert: !L && (H !== "manual" || t > 0),
|
|
317
|
+
itemRefs: K,
|
|
315
318
|
slotProps: F?.item,
|
|
316
319
|
children: e
|
|
317
320
|
}, t))
|
|
318
321
|
});
|
|
319
|
-
return
|
|
322
|
+
return A || H === "manual" ? $ : /* @__PURE__ */ l(t, {
|
|
320
323
|
onClickAway: Z,
|
|
321
324
|
children: $
|
|
322
325
|
});
|
|
323
326
|
});
|
|
324
|
-
export {
|
|
327
|
+
export { k as CollageFab };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mui-collage-fab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
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",
|
|
@@ -93,9 +93,9 @@
|
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@emotion/react": "^11.0.0",
|
|
95
95
|
"@emotion/styled": "^11.0.0",
|
|
96
|
-
"@mui/material": "^5.0.0",
|
|
97
|
-
"react": "^18.0.0",
|
|
98
|
-
"react-dom": "^18.0.0"
|
|
96
|
+
"@mui/material": "^5.0.0 || ^9.0.0",
|
|
97
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
98
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
{
|
|
147
147
|
"name": "ESM build",
|
|
148
148
|
"path": "dist-lib/index.js",
|
|
149
|
-
"limit": "3.
|
|
149
|
+
"limit": "3.5 kB"
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
152
|
"name": "CJS build",
|