mui-collage-fab 0.1.2 → 0.1.3

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
@@ -68,37 +68,47 @@ const [open, setOpen] = useState(false);
68
68
 
69
69
  ## Props
70
70
 
71
- | Prop | Type | Default | Description |
72
- | -------------------- | ------------------------------------------ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
73
- | `children` | `React.ReactNode` | — | The buttons to stack. Order matters: index 0 is the anchor. |
74
- | `direction` | `'left' \| 'right' \| 'up' \| 'down'` | `'left'` | Which way the row fans out from the anchor. `'left'` pins the stack to the right edge and expands leftward. |
75
- | `size` | `'small' \| 'medium' \| 'large' \| number` | `'large'` | Diameter of each button. `small` 40, `medium` 48, `large` 56; numbers are used verbatim. |
76
- | `variant` | `'circular' \| 'rounded' \| 'square'` | `'circular'` | Shape of each button. `rounded` uses a 25% corner radius, which scales with `size`. For an arbitrary radius, use `slotProps.item.sx`. |
77
- | `gap` | `number` | `16` | Main-axis gap in pixels between buttons when expanded. |
78
- | `fadeWidth` | `number` | `12` | Width in pixels of the soft gradient ramp at each slice edge. `0` gives a hard cut. |
79
- | `trigger` | `'hover' \| 'click' \| 'manual'` | `'hover'` | `'hover'` opens on mouse enter, closes on leave, toggles on touch/pen tap. `'click'` toggles on any click. `'manual'` disables built-in pointer interaction. |
80
- | `open` | `boolean` | — | Controlled open state. Passing it makes the component controlled. |
81
- | `defaultOpen` | `boolean` | `false` | Initial state when uncontrolled. |
82
- | `onOpen` | `(event) => void` | — | Fired on the closed → open transition. |
83
- | `onClose` | `(event) => void` | — | Fired on the open → closed transition. |
84
- | `disableClickAway` | `boolean` | `false` | If `true`, an outside press does not close the group. |
85
- | `transitionDuration` | `number` | `400` | Duration of the morph in milliseconds. |
86
- | `transitionEasing` | `string` | `'cubic-bezier(0.4, 0, 0.2, 1)'` | Easing of the morph. |
87
- | `sx` | `SxProps<Theme>` | — | System overrides for the root. |
88
- | `classes` | `Partial<CollageFabClasses>` | — | Override the `root` / `item` / `expanded` / `collapsed` classes. |
89
- | `slots` | `Partial<CollageFabSlots>` | — | Replace the `root` or `item` slot component. |
90
- | `slotProps` | `CollageFabSlotProps` | — | Props for each slot, or a callback `(ownerState) => props`. |
91
-
92
- Remaining `div` attributes, including `aria-label` and `aria-labelledby`, are spread onto the root.
71
+ <!-- api:props:start -->
72
+
73
+ | Prop | Type | Default | Description |
74
+ | -------------------- | ------------------------------------------ | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
75
+ | `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
+ | `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. |
77
+ | `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. |
78
+ | `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. |
79
+ | `gap` | `number` | `16` | Main-axis gap in pixels between two buttons when expanded. |
80
+ | `fadeWidth` | `number` | `12` | Width in pixels of the soft cut line between two slices. |
81
+ | `trigger` | `'hover' \| 'click' \| 'manual'` | `'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. |
82
+ | `open` | `boolean` | — | If `true`, the group is expanded. Use it to control the component. |
83
+ | `defaultOpen` | `boolean` | `false` | If `true`, the group is expanded by default (uncontrolled). |
84
+ | `onOpen` | `(event: React.SyntheticEvent) => void` | — | Callback fired when the group is expanded. |
85
+ | `onClose` | `(event: React.SyntheticEvent) => void` | — | Callback fired when the group is collapsed. |
86
+ | `disableClickAway` | `boolean` | `false` | If `true`, the group does not collapse when the user clicks away from it. |
87
+ | `transitionDuration` | `number` | `400` | Duration of the morph, in milliseconds. |
88
+ | `transitionEasing` | `string` | `'cubic-bezier(0.4, 0, 0.2, 1)'` | Easing of the morph. |
89
+ | `sx` | `SxProps<Theme>` | — | System prop that defines system overrides as well as additional CSS styles. |
90
+ | `classes` | `Partial<CollageFabClasses>` | — | Override or extend the styles applied to the component. |
91
+ | `slots` | `CollageFabSlots` | — | Custom components for the `root` and `item` slots. |
92
+ | `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. |
93
+ | `...divProps` | `React.HTMLAttributes<HTMLDivElement>` | — | The remaining div attributes are spread onto the root. |
94
+
95
+ <!-- api:props:end -->
93
96
 
94
97
  ## Slots
95
98
 
96
- 1. `root` — the animated container. Owns the anchor-edge alignment, the animated main-axis extent, and the single `drop-shadow` filter. A replacement must forward `ref`, because the `ClickAwayListener` needs it.
97
- 2. `item` — one masked circular wrapper per child. `slotProps.item` accepts a props object or a callback `(ownerState) => props`, which is the per-child escape hatch: switch on `ownerState.index` or `ownerState.isAnchor` to style an individual button.
99
+ <!-- api:slots:start -->
100
+
101
+ 1. `root` — The animated container. A replacement must forward `ref`, which `ClickAwayListener` needs.
102
+ 2. `item` — One masked wrapper per child, shaped by `variant`.
103
+
104
+ <!-- api:slots:end -->
98
105
 
99
106
  ## ownerState
100
107
 
101
- `CollageFabOwnerState` carries `open`, `direction`, `trigger`, `size` (resolved pixels), `gap`, `fadeWidth`, `count`, `transitionDuration` and `transitionEasing`. `CollageFabItemOwnerState` adds `index` and `isAnchor`.
108
+ <!-- api:owner-state:start -->
109
+
110
+ `CollageFabOwnerState` carries `open`, `direction`, `trigger`, `size`, `variant`, `cornerRadius`, `gap`, `fadeWidth`, `count`, `transitionDuration` and `transitionEasing`. `CollageFabItemOwnerState` adds `index`, `isAnchor` and `geometry`.
111
+ <!-- api:owner-state:end -->
102
112
 
103
113
  Theme-level defaults and overrides work through the `MuiCollageFab` component key:
104
114
 
@@ -158,23 +168,26 @@ npm install
158
168
  npm run dev
159
169
  ```
160
170
 
161
- | Command | Description |
162
- | ----------------------- | ------------------------------------------------------------------------ |
163
- | `npm run dev` | Start the Vite dev server with HMR. |
164
- | `npm run build` | Type-check with `tsc --noEmit`, then build the demo to `dist/`. |
165
- | `npm run build:preview` | Same, with the asset base taken from `SITE_BASE_PATH`. |
166
- | `npm run build:lib` | Build the publishable package to `dist-lib/` (ESM + CJS + types). |
167
- | `npm run preview` | Serve the production build locally. |
168
- | `npm test` | Run the Vitest suite (geometry + behaviour in jsdom). |
169
- | `npm run test:coverage` | Same suite with a v8 coverage report. |
170
- | `npm run test:e2e` | Build, then run the Playwright checks against `vite preview`. |
171
- | `npm run types:test` | Type-check the public API surface (`expectTypeOf` + `@ts-expect-error`). |
172
- | `npm run check:package` | `publint`, `attw --pack` and a tarball content assertion. |
173
- | `npm run check:size` | Enforce the size-limit budgets for `dist-lib`. |
174
- | `npm run lint` | ESLint, type-aware, with hooks and jsx-a11y rules. |
175
- | `npm run format:check` | Prettier check. `npm run format` rewrites in place. |
176
- | `npm run doctor` | Run every check below in one pass. |
177
- | `npm run doctor:fast` | Same, minus the browser suite and `npm audit`. |
171
+ | Command | Description |
172
+ | -------------------------------- | ------------------------------------------------------------------------ |
173
+ | `npm run dev` | Start the Vite dev server with HMR. |
174
+ | `npm run build` | Type-check with `tsc --noEmit`, then build the demo to `dist/`. |
175
+ | `npm run build:preview` | Same, with the asset base taken from `SITE_BASE_PATH`. |
176
+ | `npm run build:lib` | Build the publishable package to `dist-lib/` (ESM + CJS + types). |
177
+ | `npm run preview` | Serve the production build locally. |
178
+ | `npm test` | Run the Vitest suite (geometry + behaviour in jsdom). |
179
+ | `npm run test:coverage` | Same suite with a v8 coverage report. |
180
+ | `npm run test:e2e` | Build, then run the Playwright checks against `vite preview`. |
181
+ | `npm run types:test` | Type-check the public API surface (`expectTypeOf` + `@ts-expect-error`). |
182
+ | `npm run check:package` | `publint`, `attw --pack` and a tarball content assertion. |
183
+ | `npm run check:size` | Enforce the size-limit budgets for `dist-lib`. |
184
+ | `npm run lint` | ESLint, type-aware, with hooks and jsx-a11y rules. |
185
+ | `npm run format:check` | Prettier check. `npm run format` rewrites in place. |
186
+ | `npm run check:unused` | Knip: unused files, exports and dependencies. |
187
+ | `npm run check:release` | `semantic-release --dry-run`, validating the release config. |
188
+ | `npm run check:actions-security` | Zizmor audit of the workflows. |
189
+ | `npm run doctor` | Run every check below in one pass. |
190
+ | `npm run doctor:fast` | Same, minus the browser suite and `npm audit`. |
178
191
 
179
192
  ### Checks
180
193
 
@@ -191,10 +204,19 @@ failure, so one pass reports everything that is broken:
191
204
  7. `docs:check`, `actionlint`, `audit` and `test:e2e` — skipped with a reason when
192
205
  the script exists but the tool is missing (for example `actionlint` locally).
193
206
 
207
+ Property tests (`fast-check`, `tests/geometry.property.test.ts`) generate sizes, gaps,
208
+ fade widths, counts and directions and assert the geometry invariants rather than
209
+ enumerating cases: one pitch of translation per slice, a cut line pinned in container
210
+ space, and a mask window wide enough to cover the fan. `check:unused` (knip) catches dead
211
+ files, exports and dependencies; `check:release` loads every semantic-release plugin
212
+ through `--dry-run`; the e2e suite also runs a Pixel-class mobile project with touch
213
+ gesture specs, and zizmor audits the workflows themselves in CI.
214
+
194
215
  `--fast` drops `test:e2e` and `audit`, `--only=lint,unit` runs a subset. Each failed
195
216
  step keeps its output in `node_modules/.cache/doctor/<step>.log`. CI runs
196
- `npm run doctor -- --fast` plus a separate e2e job covering chromium, firefox and
197
- webkit, and `dependency-review` on pull requests.
217
+ `npm run doctor -- --fast` plus a separate e2e job covering chromium, firefox, webkit and
218
+ a Pixel-class mobile viewport, `zizmor` on the workflows, and `dependency-review` on pull
219
+ requests.
198
220
 
199
221
  Deployment: `.github/workflows/deploy.yml` builds the demo on every push to
200
222
  `main` and pushes `dist/` to the `gh-pages` branch, which GitHub Pages serves.
@@ -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]}function v(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=e*c,d=s===`left`||s===`up`,f=s===`left`||s===`right`,p=e===0?l:(n-e)*(r/n),m=e===0?-a/2:r/n*e,h=o?u:0,g=d?p-l-a/2+h:m-l-a/2-h,_=d?`#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`,v=`${d?`-`:``}${h}`;return{translate:f?`translateX(${v}px)`:`translateY(${v}px)`,maskImage:n>1?`linear-gradient(${f?`to right`:`to bottom`}, ${_})`:`none`,maskSize:f?`${2*l}px 100%`:`100% ${2*l}px`,maskPosition:f?`${g}px 0px`:`0px ${g}px`}}var ee={circular:`50%`,rounded:`25%`,square:0},y=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`;function b(e,t){return`${e}ms ${t}`}function x(e){return(0,m.default)(`MuiCollageFab`,e)}var S=(e,t)=>(0,p.default)({root:[`root`,e?`expanded`:`collapsed`],item:[`item`]},x,t),C=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`root`,overridesResolver:(e,t)=>t.root})(({ownerState:e})=>{let{open:t,direction:n,size:r,gap:i,count:a,transitionDuration:o,transitionEasing:s}=e,c=n===`left`||n===`right`,l=n===`left`||n===`up`,u=t?a*r+Math.max(a-1,0)*i:r;return{position:`relative`,width:c?u:r,height:c?r:u,display:`flex`,flexDirection:c?`row`:`column`,justifyContent:l?`flex-end`:`flex-start`,transition:`${c?`width`:`height`} ${b(o,s)}`,filter:`drop-shadow(0px 6px 12px rgba(0,0,0,0.25))`,cursor:t?`default`:`pointer`,WebkitTapHighlightColor:`transparent`}}),w=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`item`,overridesResolver:(e,t)=>t.item})(({ownerState:e})=>{let{direction:t,size:n,index:r,geometry:i,cornerRadius:a,transitionDuration:o,transitionEasing:s}=e,c=t===`left`||t===`right`,l=t===`left`?{right:0}:t===`right`?{left:0}:t===`up`?{bottom:0}:{top:0},u=b(o,s);return{position:`absolute`,...l,...c?{top:0}:{left:0},width:n,height:n,borderRadius:a,overflow:`hidden`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:r,transform:i.translate,WebkitMaskImage:i.maskImage,maskImage:i.maskImage,WebkitMaskSize:i.maskSize,maskSize:i.maskSize,WebkitMaskPosition:i.maskPosition,maskPosition:i.maskPosition,WebkitMaskRepeat:`no-repeat`,maskRepeat:`no-repeat`,transition:`transform ${u}, -webkit-mask-position ${u}, mask-position ${u}`,"& > *":{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 T=c.forwardRef(function(e,t){let{children:n,direction:r=`left`,size:i=`large`,variant:a=`circular`,gap:o=16,fadeWidth:s=12,trigger:p=`hover`,open:m,defaultOpen:g=!1,onOpen:b,onClose:x,disableClickAway:T=!1,transitionDuration:E=400,transitionEasing:D=`cubic-bezier(0.4, 0, 0.2, 1)`,classes:O,slots:k,slotProps:A,className:j,...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:ee[a],gap:o,fadeWidth:s,count:I,transitionDuration:E,transitionEasing:D},R=S(N,O),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?b?.(t):x?.(t))},[N,P,b,x]),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))}},ne=e=>{G(!1,e)},Q=k?.root??C,re=k?.item??w,ie=(0,f.default)({elementType:Q,externalForwardedProps:M,externalSlotProps:A?.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,j]});if(c.useEffect(()=>{if(!N||!U.current)return;U.current=!1;let e=B.current[0];e&&(e.querySelector(y)??e).focus()},[N]),I===0)return null;let $=(0,h.jsx)(Q,{...ie,children:F.map((e,t)=>(0,h.jsx)(te,{index:t,ownerState:L,geometry:v(t,L),className:R.item,component:re,inert:!N&&p!==`manual`,itemRefs:B,slotProps:A?.item,children:e},t))});return T||p===`manual`?$:(0,h.jsx)(l.ClickAwayListener,{onClickAway:ne,children:$})});exports.CollageFab=T;
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]}function v(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=e*c,d=s===`left`||s===`up`,f=s===`left`||s===`right`,p=e===0?l:(n-e)*(r/n),m=e===0?-a/2:r/n*e,h=o?u:0,g=d?p-l-a/2+h:m-l-a/2-h,_=d?`#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`,v=`${d?`-`:``}${h}`;return{translate:f?`translateX(${v}px)`:`translateY(${v}px)`,maskImage:n>1?`linear-gradient(${f?`to right`:`to bottom`}, ${_})`:`none`,maskSize:f?`${2*l}px 100%`:`100% ${2*l}px`,maskPosition:f?`${g}px 0px`:`0px ${g}px`}}var y={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)`},b={circular:`50%`,rounded:`25%`,square:0},x=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`;function S(e,t){return`${e}ms ${t}`}function C(e){return(0,m.default)(`MuiCollageFab`,e)}var w=(e,t)=>(0,p.default)({root:[`root`,e?`expanded`:`collapsed`],item:[`item`]},C,t),T=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`root`,overridesResolver:(e,t)=>t.root})(({ownerState:e})=>{let{open:t,direction:n,size:r,gap:i,count:a,transitionDuration:o,transitionEasing:s}=e,c=n===`left`||n===`right`,l=n===`left`||n===`up`,u=t?a*r+Math.max(a-1,0)*i:r;return{position:`relative`,width:c?u:r,height:c?r:u,display:`flex`,flexDirection:c?`row`:`column`,justifyContent:l?`flex-end`:`flex-start`,transition:`${c?`width`:`height`} ${S(o,s)}`,filter:`drop-shadow(0px 6px 12px rgba(0,0,0,0.25))`,cursor:t?`default`:`pointer`,WebkitTapHighlightColor:`transparent`}}),E=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`item`,overridesResolver:(e,t)=>t.item})(({ownerState:e})=>{let{direction:t,size:n,index:r,geometry:i,cornerRadius:a,transitionDuration:o,transitionEasing:s}=e,c=t===`left`||t===`right`,l=t===`left`?{right:0}:t===`right`?{left:0}:t===`up`?{bottom:0}:{top:0},u=S(o,s);return{position:`absolute`,...l,...c?{top:0}:{left:0},width:n,height:n,borderRadius:a,overflow:`hidden`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:r,transform:i.translate,WebkitMaskImage:i.maskImage,maskImage:i.maskImage,WebkitMaskSize:i.maskSize,maskSize:i.maskSize,WebkitMaskPosition:i.maskPosition,maskPosition:i.maskPosition,WebkitMaskRepeat:`no-repeat`,maskRepeat:`no-repeat`,transition:`transform ${u}, -webkit-mask-position ${u}, mask-position ${u}`,"& > *":{boxShadow:`none !important`,borderRadius:`inherit !important`,width:`100%`,height:`100%`,margin:0}}});function D(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 O=c.forwardRef(function(e,t){let{children:n,direction:r=y.direction,size:i=y.size,variant:a=y.variant,gap:o=y.gap,fadeWidth:s=y.fadeWidth,trigger:p=y.trigger,open:m,defaultOpen:g=y.defaultOpen,onOpen:S,onClose:C,disableClickAway:O=y.disableClickAway,transitionDuration:k=y.transitionDuration,transitionEasing:A=y.transitionEasing,classes:j,slots:M,slotProps:N,className:P,...F}=(0,u.useThemeProps)({props:e,name:`MuiCollageFab`}),[I,L]=(0,d.useControlled)({controlled:m,default:g,name:`CollageFab`,state:`open`}),R=c.useMemo(()=>c.Children.toArray(n).filter(e=>c.isValidElement(e)),[n]),z=R.length,B={open:I,direction:r,trigger:p,size:_(i),variant:a,cornerRadius:b[a],gap:o,fadeWidth:s,count:z,transitionDuration:k,transitionEasing:A},V=w(I,j),H=c.useRef(null),U=c.useRef([]),W=c.useRef(!1),G=c.useRef(`mouse`),K=c.useRef(!1),q=(0,d.useForkRef)(H,t),J=c.useCallback((e,t)=>{e!==I&&(L(e),e?S?.(t):C?.(t))},[I,L,S,C]),Y=e=>{p===`hover`&&e.pointerType===`mouse`&&J(!0,e)},X=e=>{p===`hover`&&e.pointerType===`mouse`&&J(!1,e)},Z=e=>{p!==`manual`&&(G.current=e.pointerType,W.current=!1,e.pointerType===`mouse`||I||(W.current=!0,J(!0,e)))},ee=e=>{W.current&&(W.current=!1,e.stopPropagation(),e.preventDefault())},te=e=>{p!==`manual`&&(p===`click`?J(!I,e):I&&G.current!==`mouse`&&J(!1,e))},ne=e=>{if(p!==`manual`){if(I){if(e.key!==`Escape`)return;e.stopPropagation(),J(!1,e),H.current?.focus()}else(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),K.current=!0,J(!0,e))}},re=e=>{J(!1,e)},Q=M?.root??T,ie=M?.item??E,ae=(0,f.default)({elementType:Q,externalForwardedProps:F,externalSlotProps:N?.root,ownerState:B,additionalProps:{ref:q,role:`group`,tabIndex:!I&&p!==`manual`?0:-1,onPointerEnter:Y,onPointerLeave:X,onPointerDown:Z,onClick:te,onClickCapture:ee,onKeyDown:ne},className:[V.root,P]});if(c.useEffect(()=>{if(!I||!K.current)return;K.current=!1;let e=U.current[0];e&&(e.querySelector(x)??e).focus()},[I]),z===0)return null;let $=(0,h.jsx)(Q,{...ae,children:R.map((e,t)=>(0,h.jsx)(D,{index:t,ownerState:B,geometry:v(t,B),className:V.item,component:ie,inert:!I&&p!==`manual`,itemRefs:U,slotProps:N?.item,children:e},t))});return O||p===`manual`?$:(0,h.jsx)(l.ClickAwayListener,{onClickAway:re,children:$})});exports.CollageFab=O;
@@ -2,67 +2,139 @@ import * as React from 'react';
2
2
  import { SxProps, Theme } from '@mui/material/styles';
3
3
  import { CreateSlotsAndSlotProps, SlotProps } from '@mui/material/utils';
4
4
 
5
+ /**
6
+ * The axis the buttons fan out on, starting from the anchor child.
7
+ */
5
8
  type CollageFabDirection = 'left' | 'right' | 'up' | 'down';
9
+ /**
10
+ * How the group reacts to pointers.
11
+ */
6
12
  type CollageFabTrigger = 'hover' | 'click' | 'manual';
13
+ /**
14
+ * Diameter of every button. Named sizes resolve to small 40px, medium 48px and
15
+ * large 56px; numeric values are used verbatim.
16
+ */
7
17
  type CollageFabSize = 'small' | 'medium' | 'large' | number;
18
+ /**
19
+ * The shape of every button: a circle, a rounded square or a sharp-cornered
20
+ * square.
21
+ */
8
22
  type CollageFabVariant = 'circular' | 'rounded' | 'square';
23
+ /**
24
+ * Class names the component applies, and the accepted keys for `classes`.
25
+ */
9
26
  interface CollageFabClasses {
27
+ /** The animated container that holds every slice. */
10
28
  root: string;
29
+ /** One masked wrapper per child. */
11
30
  item: string;
31
+ /** Applied to the root while the group is expanded. */
12
32
  expanded: string;
33
+ /** Applied to the root while the group is collapsed. */
13
34
  collapsed: string;
14
35
  }
36
+ /**
37
+ * Every key accepted by `classes`.
38
+ */
15
39
  type CollageFabClassKey = keyof CollageFabClasses;
40
+ /**
41
+ * Slot props accepted by a custom `root` slot component.
42
+ */
16
43
  interface CollageFabRootSlotPropsOverrides {
17
44
  }
45
+ /**
46
+ * Slot props accepted by a custom `item` slot component.
47
+ */
18
48
  interface CollageFabItemSlotPropsOverrides {
19
49
  }
50
+ /**
51
+ * State shared by the root slot and the item slots while styling.
52
+ */
20
53
  interface CollageFabOwnerState {
54
+ /** Whether the group is currently expanded. */
21
55
  open: boolean;
56
+ /** The resolved fan-out direction. */
22
57
  direction: CollageFabDirection;
58
+ /** The resolved pointer trigger mode. */
23
59
  trigger: CollageFabTrigger;
60
+ /** The button diameter in pixels, after resolving the named size. */
24
61
  size: number;
62
+ /** The resolved shape of every button. */
25
63
  variant: CollageFabVariant;
64
+ /** The corner radius resolved from `variant`, inherited by every child. */
26
65
  cornerRadius: number | string;
66
+ /** The main-axis gap in pixels. */
27
67
  gap: number;
68
+ /** The fade width in pixels. */
28
69
  fadeWidth: number;
70
+ /** The number of valid children currently rendered. */
29
71
  count: number;
72
+ /** The morph duration in milliseconds. */
30
73
  transitionDuration: number;
74
+ /** The morph easing. */
31
75
  transitionEasing: string;
32
76
  }
77
+ /**
78
+ * The per-slice CSS computed for one child.
79
+ */
33
80
  interface CollageFabItemGeometry {
81
+ /** The translate that moves the slice along the main axis. */
34
82
  translate: string;
83
+ /** The gradient that cuts the slice out of the container. */
35
84
  maskImage: string;
85
+ /** The size of that gradient, wide enough to cover the expanded row. */
36
86
  maskSize: string;
87
+ /** The offset that pins the cut line in container space. */
37
88
  maskPosition: string;
38
89
  }
90
+ /**
91
+ * State handed to the item slot. It extends the shared state with the position
92
+ * of the child, so an item can be styled individually.
93
+ */
39
94
  interface CollageFabItemOwnerState extends CollageFabOwnerState {
95
+ /** The position of the child in the stack. 0 is the anchor. */
40
96
  index: number;
97
+ /** True for the anchor child (index 0). */
41
98
  isAnchor: boolean;
99
+ /** The computed translate, mask image, mask size and mask position for this slice. */
42
100
  geometry: CollageFabItemGeometry;
43
101
  }
102
+ /**
103
+ * Replaceable internal components.
104
+ */
44
105
  interface CollageFabSlots {
106
+ /** The animated container. A replacement must forward `ref`, which `ClickAwayListener` needs. */
45
107
  root?: React.ElementType;
108
+ /** One masked wrapper per child, shaped by `variant`. */
46
109
  item?: React.ElementType;
47
110
  }
111
+ /**
112
+ * The `slots` and `slotProps` props, typed per slot.
113
+ */
48
114
  type CollageFabSlotsAndSlotProps = CreateSlotsAndSlotProps<CollageFabSlots, {
115
+ /** Props for the root slot, or a resolver that receives the shared ownerState. */
49
116
  root: SlotProps<'div', CollageFabRootSlotPropsOverrides, CollageFabOwnerState>;
117
+ /** Props for the item slot, or a resolver that receives the item ownerState. */
50
118
  item: SlotProps<'div', CollageFabItemSlotPropsOverrides, CollageFabItemOwnerState>;
51
119
  }>;
52
- interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>, CollageFabSlotsAndSlotProps {
120
+ /**
121
+ * Props for the CollageFab component.
122
+ */
123
+ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
53
124
  /**
54
- * The buttons to stack. Order matters: index 0 is the anchor, the remaining
55
- * children fan out along `direction`.
125
+ * The buttons to stack. Every valid element is wrapped in a masked slot shaped
126
+ * by `variant`. Order matters: index 0 is the anchor, the rest fan out along
127
+ * `direction`.
56
128
  */
57
129
  children?: React.ReactNode;
58
130
  /**
59
- * The axis the buttons fan out on, starting from the anchor child.
60
- * @default 'left'
131
+ * The axis the buttons fan out on, starting from the anchor child. `left`
132
+ * matches the original right-anchored behaviour.
61
133
  */
62
134
  direction?: CollageFabDirection;
63
135
  /**
64
- * Diameter of every button, in pixels. Numeric values are used verbatim.
65
- * @default 'large'
136
+ * Diameter of every button. Named sizes resolve to small 40px, medium 48px,
137
+ * large 56px; numeric values are used verbatim.
66
138
  */
67
139
  size?: CollageFabSize;
68
140
  /**
@@ -70,24 +142,20 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
70
142
  * `'rounded'` to a rounded square and `'square'` to a sharp-cornered square.
71
143
  * The mask still slices the silhouette along the main axis, so the stack reads
72
144
  * as one shape when collapsed and as separate shapes when expanded.
73
- * @default 'circular'
74
145
  */
75
146
  variant?: CollageFabVariant;
76
147
  /**
77
- * Main axis gap between two buttons when expanded, in pixels.
78
- * @default 16
148
+ * Main-axis gap in pixels between two buttons when expanded.
79
149
  */
80
150
  gap?: number;
81
151
  /**
82
- * Width of the soft cut line between two slices, in pixels.
83
- * @default 12
152
+ * Width in pixels of the soft cut line between two slices.
84
153
  */
85
154
  fadeWidth?: number;
86
155
  /**
87
156
  * How the group reacts to pointers. `'hover'` opens on mouse enter, closes on
88
- * mouse leave and toggles on touch/pen tap. `'click'` toggles on any click.
157
+ * mouse leave and toggles on touch or pen tap; `'click'` toggles on any click;
89
158
  * `'manual'` disables all built-in pointer interaction.
90
- * @default 'hover'
91
159
  */
92
160
  trigger?: CollageFabTrigger;
93
161
  /**
@@ -95,8 +163,7 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
95
163
  */
96
164
  open?: boolean;
97
165
  /**
98
- * If `true`, the group is expanded by default.
99
- * @default false
166
+ * If `true`, the group is expanded by default (uncontrolled).
100
167
  */
101
168
  defaultOpen?: boolean;
102
169
  /**
@@ -109,28 +176,40 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
109
176
  onClose?: (event: React.SyntheticEvent) => void;
110
177
  /**
111
178
  * If `true`, the group does not collapse when the user clicks away from it.
112
- * @default false
113
179
  */
114
180
  disableClickAway?: boolean;
115
181
  /**
116
182
  * Duration of the morph, in milliseconds.
117
- * @default 400
118
183
  */
119
184
  transitionDuration?: number;
120
185
  /**
121
186
  * Easing of the morph.
122
- * @default 'cubic-bezier(0.4, 0, 0.2, 1)'
123
187
  */
124
188
  transitionEasing?: string;
125
189
  /**
126
- * The system prop that allows defining system overrides as well as additional CSS styles.
190
+ * System prop that defines system overrides as well as additional CSS styles.
127
191
  */
128
192
  sx?: SxProps<Theme>;
129
193
  /**
130
194
  * Override or extend the styles applied to the component.
131
195
  */
132
196
  classes?: Partial<CollageFabClasses>;
197
+ /**
198
+ * Custom components for the `root` and `item` slots.
199
+ */
200
+ slots?: CollageFabSlotsAndSlotProps['slots'];
201
+ /**
202
+ * Props for each slot. `slotProps.item` accepts either a props object or an
203
+ * `(ownerState) => props` callback, which is the per-child escape hatch.
204
+ */
205
+ slotProps?: CollageFabSlotsAndSlotProps['slotProps'];
133
206
  }
207
+ /**
208
+ * A floating action button that stacks several children into a single shape and
209
+ * unfolds them along a configurable direction on interaction. The root animates
210
+ * its own main-axis extent and applies one shared drop shadow, while each child
211
+ * is clipped by a moving gradient mask.
212
+ */
134
213
  declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
135
214
 
136
215
  export { CollageFab };
@@ -2,67 +2,139 @@ import * as React from 'react';
2
2
  import { SxProps, Theme } from '@mui/material/styles';
3
3
  import { CreateSlotsAndSlotProps, SlotProps } from '@mui/material/utils';
4
4
 
5
+ /**
6
+ * The axis the buttons fan out on, starting from the anchor child.
7
+ */
5
8
  type CollageFabDirection = 'left' | 'right' | 'up' | 'down';
9
+ /**
10
+ * How the group reacts to pointers.
11
+ */
6
12
  type CollageFabTrigger = 'hover' | 'click' | 'manual';
13
+ /**
14
+ * Diameter of every button. Named sizes resolve to small 40px, medium 48px and
15
+ * large 56px; numeric values are used verbatim.
16
+ */
7
17
  type CollageFabSize = 'small' | 'medium' | 'large' | number;
18
+ /**
19
+ * The shape of every button: a circle, a rounded square or a sharp-cornered
20
+ * square.
21
+ */
8
22
  type CollageFabVariant = 'circular' | 'rounded' | 'square';
23
+ /**
24
+ * Class names the component applies, and the accepted keys for `classes`.
25
+ */
9
26
  interface CollageFabClasses {
27
+ /** The animated container that holds every slice. */
10
28
  root: string;
29
+ /** One masked wrapper per child. */
11
30
  item: string;
31
+ /** Applied to the root while the group is expanded. */
12
32
  expanded: string;
33
+ /** Applied to the root while the group is collapsed. */
13
34
  collapsed: string;
14
35
  }
36
+ /**
37
+ * Every key accepted by `classes`.
38
+ */
15
39
  type CollageFabClassKey = keyof CollageFabClasses;
40
+ /**
41
+ * Slot props accepted by a custom `root` slot component.
42
+ */
16
43
  interface CollageFabRootSlotPropsOverrides {
17
44
  }
45
+ /**
46
+ * Slot props accepted by a custom `item` slot component.
47
+ */
18
48
  interface CollageFabItemSlotPropsOverrides {
19
49
  }
50
+ /**
51
+ * State shared by the root slot and the item slots while styling.
52
+ */
20
53
  interface CollageFabOwnerState {
54
+ /** Whether the group is currently expanded. */
21
55
  open: boolean;
56
+ /** The resolved fan-out direction. */
22
57
  direction: CollageFabDirection;
58
+ /** The resolved pointer trigger mode. */
23
59
  trigger: CollageFabTrigger;
60
+ /** The button diameter in pixels, after resolving the named size. */
24
61
  size: number;
62
+ /** The resolved shape of every button. */
25
63
  variant: CollageFabVariant;
64
+ /** The corner radius resolved from `variant`, inherited by every child. */
26
65
  cornerRadius: number | string;
66
+ /** The main-axis gap in pixels. */
27
67
  gap: number;
68
+ /** The fade width in pixels. */
28
69
  fadeWidth: number;
70
+ /** The number of valid children currently rendered. */
29
71
  count: number;
72
+ /** The morph duration in milliseconds. */
30
73
  transitionDuration: number;
74
+ /** The morph easing. */
31
75
  transitionEasing: string;
32
76
  }
77
+ /**
78
+ * The per-slice CSS computed for one child.
79
+ */
33
80
  interface CollageFabItemGeometry {
81
+ /** The translate that moves the slice along the main axis. */
34
82
  translate: string;
83
+ /** The gradient that cuts the slice out of the container. */
35
84
  maskImage: string;
85
+ /** The size of that gradient, wide enough to cover the expanded row. */
36
86
  maskSize: string;
87
+ /** The offset that pins the cut line in container space. */
37
88
  maskPosition: string;
38
89
  }
90
+ /**
91
+ * State handed to the item slot. It extends the shared state with the position
92
+ * of the child, so an item can be styled individually.
93
+ */
39
94
  interface CollageFabItemOwnerState extends CollageFabOwnerState {
95
+ /** The position of the child in the stack. 0 is the anchor. */
40
96
  index: number;
97
+ /** True for the anchor child (index 0). */
41
98
  isAnchor: boolean;
99
+ /** The computed translate, mask image, mask size and mask position for this slice. */
42
100
  geometry: CollageFabItemGeometry;
43
101
  }
102
+ /**
103
+ * Replaceable internal components.
104
+ */
44
105
  interface CollageFabSlots {
106
+ /** The animated container. A replacement must forward `ref`, which `ClickAwayListener` needs. */
45
107
  root?: React.ElementType;
108
+ /** One masked wrapper per child, shaped by `variant`. */
46
109
  item?: React.ElementType;
47
110
  }
111
+ /**
112
+ * The `slots` and `slotProps` props, typed per slot.
113
+ */
48
114
  type CollageFabSlotsAndSlotProps = CreateSlotsAndSlotProps<CollageFabSlots, {
115
+ /** Props for the root slot, or a resolver that receives the shared ownerState. */
49
116
  root: SlotProps<'div', CollageFabRootSlotPropsOverrides, CollageFabOwnerState>;
117
+ /** Props for the item slot, or a resolver that receives the item ownerState. */
50
118
  item: SlotProps<'div', CollageFabItemSlotPropsOverrides, CollageFabItemOwnerState>;
51
119
  }>;
52
- interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>, CollageFabSlotsAndSlotProps {
120
+ /**
121
+ * Props for the CollageFab component.
122
+ */
123
+ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
53
124
  /**
54
- * The buttons to stack. Order matters: index 0 is the anchor, the remaining
55
- * children fan out along `direction`.
125
+ * The buttons to stack. Every valid element is wrapped in a masked slot shaped
126
+ * by `variant`. Order matters: index 0 is the anchor, the rest fan out along
127
+ * `direction`.
56
128
  */
57
129
  children?: React.ReactNode;
58
130
  /**
59
- * The axis the buttons fan out on, starting from the anchor child.
60
- * @default 'left'
131
+ * The axis the buttons fan out on, starting from the anchor child. `left`
132
+ * matches the original right-anchored behaviour.
61
133
  */
62
134
  direction?: CollageFabDirection;
63
135
  /**
64
- * Diameter of every button, in pixels. Numeric values are used verbatim.
65
- * @default 'large'
136
+ * Diameter of every button. Named sizes resolve to small 40px, medium 48px,
137
+ * large 56px; numeric values are used verbatim.
66
138
  */
67
139
  size?: CollageFabSize;
68
140
  /**
@@ -70,24 +142,20 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
70
142
  * `'rounded'` to a rounded square and `'square'` to a sharp-cornered square.
71
143
  * The mask still slices the silhouette along the main axis, so the stack reads
72
144
  * as one shape when collapsed and as separate shapes when expanded.
73
- * @default 'circular'
74
145
  */
75
146
  variant?: CollageFabVariant;
76
147
  /**
77
- * Main axis gap between two buttons when expanded, in pixels.
78
- * @default 16
148
+ * Main-axis gap in pixels between two buttons when expanded.
79
149
  */
80
150
  gap?: number;
81
151
  /**
82
- * Width of the soft cut line between two slices, in pixels.
83
- * @default 12
152
+ * Width in pixels of the soft cut line between two slices.
84
153
  */
85
154
  fadeWidth?: number;
86
155
  /**
87
156
  * How the group reacts to pointers. `'hover'` opens on mouse enter, closes on
88
- * mouse leave and toggles on touch/pen tap. `'click'` toggles on any click.
157
+ * mouse leave and toggles on touch or pen tap; `'click'` toggles on any click;
89
158
  * `'manual'` disables all built-in pointer interaction.
90
- * @default 'hover'
91
159
  */
92
160
  trigger?: CollageFabTrigger;
93
161
  /**
@@ -95,8 +163,7 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
95
163
  */
96
164
  open?: boolean;
97
165
  /**
98
- * If `true`, the group is expanded by default.
99
- * @default false
166
+ * If `true`, the group is expanded by default (uncontrolled).
100
167
  */
101
168
  defaultOpen?: boolean;
102
169
  /**
@@ -109,28 +176,40 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
109
176
  onClose?: (event: React.SyntheticEvent) => void;
110
177
  /**
111
178
  * If `true`, the group does not collapse when the user clicks away from it.
112
- * @default false
113
179
  */
114
180
  disableClickAway?: boolean;
115
181
  /**
116
182
  * Duration of the morph, in milliseconds.
117
- * @default 400
118
183
  */
119
184
  transitionDuration?: number;
120
185
  /**
121
186
  * Easing of the morph.
122
- * @default 'cubic-bezier(0.4, 0, 0.2, 1)'
123
187
  */
124
188
  transitionEasing?: string;
125
189
  /**
126
- * The system prop that allows defining system overrides as well as additional CSS styles.
190
+ * System prop that defines system overrides as well as additional CSS styles.
127
191
  */
128
192
  sx?: SxProps<Theme>;
129
193
  /**
130
194
  * Override or extend the styles applied to the component.
131
195
  */
132
196
  classes?: Partial<CollageFabClasses>;
197
+ /**
198
+ * Custom components for the `root` and `item` slots.
199
+ */
200
+ slots?: CollageFabSlotsAndSlotProps['slots'];
201
+ /**
202
+ * Props for each slot. `slotProps.item` accepts either a props object or an
203
+ * `(ownerState) => props` callback, which is the per-child escape hatch.
204
+ */
205
+ slotProps?: CollageFabSlotsAndSlotProps['slotProps'];
133
206
  }
207
+ /**
208
+ * A floating action button that stacks several children into a single shape and
209
+ * unfolds them along a configurable direction on interaction. The root animates
210
+ * its own main-axis extent and applies one shared drop shadow, while each child
211
+ * is clipped by a moving gradient mask.
212
+ */
134
213
  declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
135
214
 
136
215
  export { CollageFab };
package/dist-lib/index.js CHANGED
@@ -24,22 +24,33 @@ function f(e, t) {
24
24
  maskPosition: f ? `${g}px 0px` : `0px ${g}px`
25
25
  };
26
26
  }
27
- // src/components/CollageFab.tsx
27
+ // src/components/collageFabDefaults.ts
28
28
  var p = {
29
+ direction: "left",
30
+ size: "large",
31
+ variant: "circular",
32
+ gap: 16,
33
+ fadeWidth: 12,
34
+ trigger: "hover",
35
+ defaultOpen: !1,
36
+ disableClickAway: !1,
37
+ transitionDuration: 400,
38
+ transitionEasing: "cubic-bezier(0.4, 0, 0.2, 1)"
39
+ }, m = {
29
40
  circular: "50%",
30
41
  rounded: "25%",
31
42
  square: 0
32
- }, m = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
33
- function h(e, t) {
43
+ }, h = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
44
+ function g(e, t) {
34
45
  return `${e}ms ${t}`;
35
46
  }
36
- function g(e) {
47
+ function _(e) {
37
48
  return c("MuiCollageFab", e);
38
49
  }
39
- var _ = (e, t) => s({
50
+ var v = (e, t) => s({
40
51
  root: ["root", e ? "expanded" : "collapsed"],
41
52
  item: ["item"]
42
- }, g, t), v = n("div", {
53
+ }, _, t), y = n("div", {
43
54
  name: "MuiCollageFab",
44
55
  slot: "root",
45
56
  overridesResolver: (e, t) => t.root
@@ -52,17 +63,17 @@ var _ = (e, t) => s({
52
63
  display: "flex",
53
64
  flexDirection: c ? "row" : "column",
54
65
  justifyContent: l ? "flex-end" : "flex-start",
55
- transition: `${c ? "width" : "height"} ${h(o, s)}`,
66
+ transition: `${c ? "width" : "height"} ${g(o, s)}`,
56
67
  filter: "drop-shadow(0px 6px 12px rgba(0,0,0,0.25))",
57
68
  cursor: t ? "default" : "pointer",
58
69
  WebkitTapHighlightColor: "transparent"
59
70
  };
60
- }), y = n("div", {
71
+ }), b = n("div", {
61
72
  name: "MuiCollageFab",
62
73
  slot: "item",
63
74
  overridesResolver: (e, t) => t.item
64
75
  })(({ ownerState: e }) => {
65
- let { direction: t, size: n, index: r, geometry: i, cornerRadius: a, transitionDuration: o, transitionEasing: s } = e, c = t === "left" || t === "right", l = t === "left" ? { right: 0 } : t === "right" ? { left: 0 } : t === "up" ? { bottom: 0 } : { top: 0 }, u = h(o, s);
76
+ let { direction: t, size: n, index: r, geometry: i, cornerRadius: a, transitionDuration: o, transitionEasing: s } = e, c = t === "left" || t === "right", l = t === "left" ? { right: 0 } : t === "right" ? { left: 0 } : t === "up" ? { bottom: 0 } : { top: 0 }, u = g(o, s);
66
77
  return {
67
78
  position: "absolute",
68
79
  ...l,
@@ -94,7 +105,7 @@ var _ = (e, t) => s({
94
105
  }
95
106
  };
96
107
  });
97
- function b(t) {
108
+ function x(t) {
98
109
  let { index: n, ownerState: r, geometry: i, className: s, component: c, inert: u, itemRefs: d, slotProps: f, children: p } = t, m = e.useMemo(() => ({
99
110
  ...r,
100
111
  index: n,
@@ -124,94 +135,94 @@ function b(t) {
124
135
  });
125
136
  return /* @__PURE__ */ l(c, { ...v });
126
137
  }
127
- var x = e.forwardRef(function(n, s) {
128
- let { children: c, direction: u = "left", size: h = "large", variant: g = "circular", gap: x = 16, fadeWidth: ee = 12, trigger: S = "hover", open: C, defaultOpen: w = !1, onOpen: T, onClose: E, disableClickAway: te = !1, transitionDuration: D = 400, transitionEasing: O = "cubic-bezier(0.4, 0, 0.2, 1)", classes: k, slots: A, slotProps: j, className: M, ...N } = r({
138
+ var S = e.forwardRef(function(n, s) {
139
+ let { children: c, direction: u = p.direction, size: g = p.size, variant: _ = p.variant, gap: S = p.gap, fadeWidth: C = p.fadeWidth, trigger: w = p.trigger, open: T, defaultOpen: E = p.defaultOpen, onOpen: D, onClose: O, disableClickAway: k = p.disableClickAway, transitionDuration: ee = p.transitionDuration, transitionEasing: te = p.transitionEasing, classes: A, slots: j, slotProps: M, className: N, ...P } = r({
129
140
  props: n,
130
141
  name: "MuiCollageFab"
131
- }), [P, F] = i({
132
- controlled: C,
133
- default: w,
142
+ }), [F, I] = i({
143
+ controlled: T,
144
+ default: E,
134
145
  name: "CollageFab",
135
146
  state: "open"
136
- }), I = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), L = I.length, R = {
137
- open: P,
147
+ }), L = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), R = L.length, z = {
148
+ open: F,
138
149
  direction: u,
139
- trigger: S,
140
- size: d(h),
141
- variant: g,
142
- cornerRadius: p[g],
143
- gap: x,
144
- fadeWidth: ee,
145
- count: L,
146
- transitionDuration: D,
147
- transitionEasing: O
148
- }, z = _(P, k), B = e.useRef(null), V = e.useRef([]), H = e.useRef(!1), U = e.useRef("mouse"), W = e.useRef(!1), G = a(B, s), K = e.useCallback((e, t) => {
149
- e !== P && (F(e), e ? T?.(t) : E?.(t));
150
+ trigger: w,
151
+ size: d(g),
152
+ variant: _,
153
+ cornerRadius: m[_],
154
+ gap: S,
155
+ fadeWidth: C,
156
+ count: R,
157
+ transitionDuration: ee,
158
+ transitionEasing: te
159
+ }, B = v(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) => {
160
+ e !== F && (I(e), e ? D?.(t) : O?.(t));
150
161
  }, [
151
- P,
152
162
  F,
153
- T,
154
- E
155
- ]), q = (e) => {
156
- S === "hover" && e.pointerType === "mouse" && K(!0, e);
157
- }, J = (e) => {
158
- S === "hover" && e.pointerType === "mouse" && K(!1, e);
163
+ I,
164
+ D,
165
+ O
166
+ ]), J = (e) => {
167
+ w === "hover" && e.pointerType === "mouse" && q(!0, e);
159
168
  }, Y = (e) => {
160
- S !== "manual" && (U.current = e.pointerType, H.current = !1, e.pointerType === "mouse" || P || (H.current = !0, K(!0, e)));
169
+ w === "hover" && e.pointerType === "mouse" && q(!1, e);
161
170
  }, X = (e) => {
162
- H.current && (H.current = !1, e.stopPropagation(), e.preventDefault());
171
+ w !== "manual" && (W.current = e.pointerType, U.current = !1, e.pointerType === "mouse" || F || (U.current = !0, q(!0, e)));
163
172
  }, Z = (e) => {
164
- S !== "manual" && (S === "click" ? K(!P, e) : P && U.current !== "mouse" && K(!1, e));
173
+ U.current && (U.current = !1, e.stopPropagation(), e.preventDefault());
165
174
  }, ne = (e) => {
166
- if (S !== "manual") {
167
- if (P) {
175
+ w !== "manual" && (w === "click" ? q(!F, e) : F && W.current !== "mouse" && q(!1, e));
176
+ }, re = (e) => {
177
+ if (w !== "manual") {
178
+ if (F) {
168
179
  if (e.key !== "Escape") return;
169
- e.stopPropagation(), K(!1, e), B.current?.focus();
170
- } else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), W.current = !0, K(!0, e));
180
+ e.stopPropagation(), q(!1, e), V.current?.focus();
181
+ } else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), G.current = !0, q(!0, e));
171
182
  }
172
- }, re = (e) => {
173
- K(!1, e);
174
- }, Q = A?.root ?? v, ie = A?.item ?? y, ae = o({
183
+ }, ie = (e) => {
184
+ q(!1, e);
185
+ }, Q = j?.root ?? y, ae = j?.item ?? b, oe = o({
175
186
  elementType: Q,
176
- externalForwardedProps: N,
177
- externalSlotProps: j?.root,
178
- ownerState: R,
187
+ externalForwardedProps: P,
188
+ externalSlotProps: M?.root,
189
+ ownerState: z,
179
190
  additionalProps: {
180
- ref: G,
191
+ ref: K,
181
192
  role: "group",
182
- tabIndex: !P && S !== "manual" ? 0 : -1,
183
- onPointerEnter: q,
184
- onPointerLeave: J,
185
- onPointerDown: Y,
186
- onClick: Z,
187
- onClickCapture: X,
188
- onKeyDown: ne
193
+ tabIndex: !F && w !== "manual" ? 0 : -1,
194
+ onPointerEnter: J,
195
+ onPointerLeave: Y,
196
+ onPointerDown: X,
197
+ onClick: ne,
198
+ onClickCapture: Z,
199
+ onKeyDown: re
189
200
  },
190
- className: [z.root, M]
201
+ className: [B.root, N]
191
202
  });
192
203
  if (e.useEffect(() => {
193
- if (!P || !W.current) return;
194
- W.current = !1;
195
- let e = V.current[0];
196
- e && (e.querySelector(m) ?? e).focus();
197
- }, [P]), L === 0) return null;
204
+ if (!F || !G.current) return;
205
+ G.current = !1;
206
+ let e = H.current[0];
207
+ e && (e.querySelector(h) ?? e).focus();
208
+ }, [F]), R === 0) return null;
198
209
  let $ = /* @__PURE__ */ l(Q, {
199
- ...ae,
200
- children: I.map((e, t) => /* @__PURE__ */ l(b, {
210
+ ...oe,
211
+ children: L.map((e, t) => /* @__PURE__ */ l(x, {
201
212
  index: t,
202
- ownerState: R,
203
- geometry: f(t, R),
204
- className: z.item,
205
- component: ie,
206
- inert: !P && S !== "manual",
207
- itemRefs: V,
208
- slotProps: j?.item,
213
+ ownerState: z,
214
+ geometry: f(t, z),
215
+ className: B.item,
216
+ component: ae,
217
+ inert: !F && w !== "manual",
218
+ itemRefs: H,
219
+ slotProps: M?.item,
209
220
  children: e
210
221
  }, t))
211
222
  });
212
- return te || S === "manual" ? $ : /* @__PURE__ */ l(t, {
213
- onClickAway: re,
223
+ return k || w === "manual" ? $ : /* @__PURE__ */ l(t, {
224
+ onClickAway: ie,
214
225
  children: $
215
226
  });
216
227
  });
217
- export { x as CollageFab };
228
+ export { S as CollageFab };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mui-collage-fab",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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",
@@ -65,6 +65,8 @@
65
65
  "test:coverage": "vitest run --coverage",
66
66
  "test:e2e": "npm run build && playwright test",
67
67
  "types:test": "vitest --run --typecheck",
68
+ "docs": "node scripts/write-readme-api.ts",
69
+ "docs:check": "node scripts/write-readme-api.ts --check",
68
70
  "fix": "npm run format && npm run lint -- --fix",
69
71
  "release": "semantic-release",
70
72
  "prepublishOnly": "npm run build:lib",
@@ -72,10 +74,13 @@
72
74
  "check:size": "size-limit",
73
75
  "doctor": "node scripts/doctor.mjs",
74
76
  "doctor:fast": "node scripts/doctor.mjs --fast",
75
- "check:actions": "actionlint"
77
+ "check:actions": "node scripts/actionlint.mjs",
78
+ "check:unused": "knip",
79
+ "check:release": "semantic-release --dry-run --no-ci",
80
+ "check:actions-security": "zizmor .github/workflows"
76
81
  },
77
82
  "dependencies": {
78
- "@mui/utils": "^5.15.0"
83
+ "@mui/utils": "^9.5.0"
79
84
  },
80
85
  "peerDependencies": {
81
86
  "@emotion/react": "^11.0.0",
@@ -102,6 +107,7 @@
102
107
  "@testing-library/react": "^16.3.3",
103
108
  "@testing-library/user-event": "^14.6.10",
104
109
  "@types/jest-axe": "^3.5.9",
110
+ "@types/node": "^22.20.5",
105
111
  "@types/react": "^18.3.12",
106
112
  "@types/react-dom": "^18.3.1",
107
113
  "@vitejs/plugin-react": "^6.3.0",
@@ -123,10 +129,13 @@
123
129
  "rollup-plugin-dts": "^6.5.1",
124
130
  "semantic-release": "^25.0.9",
125
131
  "size-limit": "^14.3.0",
132
+ "typedoc": "^0.28.20",
126
133
  "typescript": "~6.0.3",
127
134
  "typescript-eslint": "^8.72.2",
128
135
  "vite": "^8.3.4",
129
- "vitest": "^5.1.0"
136
+ "vitest": "^5.1.0",
137
+ "fast-check": "^4.5.0",
138
+ "knip": "^6.20.0"
130
139
  },
131
140
  "size-limit": [
132
141
  {