mui-collage-fab 0.1.4 → 0.3.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 +20 -13
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/index.d.cts +10 -2
- package/dist-lib/index.d.ts +10 -2
- package/dist-lib/index.js +176 -101
- package/package.json +21 -22
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ npm install mui-collage-fab @mui/material @emotion/react @emotion/styled
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
`react`, `react-dom`, `@mui/material` and the two emotion packages are peer
|
|
22
|
-
dependencies, so the package never ships its own copy of React or MUI.
|
|
22
|
+
dependencies, so the package never ships its own copy of React or MUI. The
|
|
23
|
+
published bundle targets ES2020 and runs on Node.js 18 or newer when server rendered.
|
|
23
24
|
|
|
24
25
|
## Usage
|
|
25
26
|
|
|
@@ -72,8 +73,9 @@ const [open, setOpen] = useState(false);
|
|
|
72
73
|
|
|
73
74
|
| Prop | Type | Default | Description |
|
|
74
75
|
| -------------------- | ------------------------------------------ | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
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
|
+
| `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`. |
|
|
76
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`. |
|
|
77
79
|
| `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
80
|
| `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
81
|
| `gap` | `number` | `16` | Main-axis gap in pixels between two buttons when expanded. |
|
|
@@ -107,7 +109,7 @@ const [open, setOpen] = useState(false);
|
|
|
107
109
|
|
|
108
110
|
<!-- api:owner-state:start -->
|
|
109
111
|
|
|
110
|
-
`CollageFabOwnerState` carries `open`, `direction`, `trigger`, `size`, `variant`, `cornerRadius`, `gap`, `fadeWidth`, `count`, `transitionDuration` and `transitionEasing`. `CollageFabItemOwnerState` adds `index`, `isAnchor` and `geometry`.
|
|
112
|
+
`CollageFabOwnerState` carries `open`, `direction`, `directions`, `trigger`, `size`, `variant`, `cornerRadius`, `gap`, `fadeWidth`, `count`, `transitionDuration` and `transitionEasing`. `CollageFabItemOwnerState` adds `index`, `isAnchor` and `geometry`.
|
|
111
113
|
<!-- api:owner-state:end -->
|
|
112
114
|
|
|
113
115
|
Theme-level defaults and overrides work through the `MuiCollageFab` component key:
|
|
@@ -161,7 +163,7 @@ the same pitch in opposite directions.
|
|
|
161
163
|
|
|
162
164
|
## Development
|
|
163
165
|
|
|
164
|
-
Requires Node.js 22.
|
|
166
|
+
Requires Node.js 22.12 or newer. The development toolchain is pinned in `mise.toml`.
|
|
165
167
|
|
|
166
168
|
```bash
|
|
167
169
|
npm install
|
|
@@ -181,8 +183,10 @@ npm run dev
|
|
|
181
183
|
| `npm run types:test` | Type-check the public API surface (`expectTypeOf` + `@ts-expect-error`). |
|
|
182
184
|
| `npm run check:package` | `publint`, `attw --pack` and a tarball content assertion. |
|
|
183
185
|
| `npm run check:size` | Enforce the size-limit budgets for `dist-lib`. |
|
|
184
|
-
| `npm run lint` |
|
|
185
|
-
| `npm run format:check` |
|
|
186
|
+
| `npm run lint` | Oxlint, type-aware, with hooks and jsx-a11y rules. |
|
|
187
|
+
| `npm run format:check` | Oxfmt check. `npm run format` rewrites in place. |
|
|
188
|
+
| `npm run check:node` | Assert `@types/node`, `mise.toml` and `devEngines` share a major. |
|
|
189
|
+
| `npm run check:deps` | Dependency-cruiser: cycles, orphans and library/site imports. |
|
|
186
190
|
| `npm run check:unused` | Knip: unused files, exports and dependencies. |
|
|
187
191
|
| `npm run check:release` | `semantic-release --dry-run`, validating the release config. |
|
|
188
192
|
| `npm run check:actions-security` | Zizmor audit of the workflows. |
|
|
@@ -194,7 +198,8 @@ npm run dev
|
|
|
194
198
|
`npm run doctor` (listr2) runs the checks in sequence and keeps going after a
|
|
195
199
|
failure, so one pass reports everything that is broken:
|
|
196
200
|
|
|
197
|
-
1. `format:check`, `lint`, `typecheck` — style
|
|
201
|
+
1. `format:check`, `lint`, `typecheck`, `check:deps` — style, static analysis and the
|
|
202
|
+
dependency graph.
|
|
198
203
|
2. `types:test` — the public prop unions and slot overrides, pinned by type tests.
|
|
199
204
|
3. `test:coverage` — Vitest with coverage thresholds of 85 statements / 75 branches.
|
|
200
205
|
4. `build`, `build:lib` — demo and library bundles.
|
|
@@ -208,12 +213,14 @@ Property tests (`fast-check`, `tests/geometry.property.test.ts`) generate sizes,
|
|
|
208
213
|
fade widths, counts and directions and assert the geometry invariants rather than
|
|
209
214
|
enumerating cases: one pitch of translation per slice, a cut line pinned in container
|
|
210
215
|
space, and a mask window wide enough to cover the fan. `check:unused` (knip) catches dead
|
|
211
|
-
files, exports and dependencies; `check:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
files, exports and dependencies; `check:deps` (dependency-cruiser) rejects runtime cycles,
|
|
217
|
+
orphan modules and imports that reach from the published library into demo code;
|
|
218
|
+
`check:release` loads every semantic-release plugin through `--dry-run`; the e2e suite
|
|
219
|
+
also runs a Pixel-class mobile project with touch gesture specs, and zizmor audits the
|
|
220
|
+
workflows themselves in CI.
|
|
221
|
+
|
|
222
|
+
`--fast` drops `test:e2e` and `audit`, `--only=lint,unit` runs a subset. Each failed step
|
|
223
|
+
keeps its output in `node_modules/.cache/doctor/<step>.log`. CI runs
|
|
217
224
|
`npm run doctor -- --fast` plus a separate e2e job covering chromium, firefox, webkit and
|
|
218
225
|
a Pixel-class mobile viewport, `zizmor` on the workflows, and `dependency-review` on pull
|
|
219
226
|
requests.
|
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]}function v(e,t){let{count:n,size:r,gap:i,fadeWidth:a,open:o
|
|
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;
|
package/dist-lib/index.d.cts
CHANGED
|
@@ -53,8 +53,10 @@ interface CollageFabItemSlotPropsOverrides {
|
|
|
53
53
|
interface CollageFabOwnerState {
|
|
54
54
|
/** Whether the group is currently expanded. */
|
|
55
55
|
open: boolean;
|
|
56
|
-
/** The resolved fan-out direction. */
|
|
56
|
+
/** The resolved fan-out direction used by every child without a `directions` entry. */
|
|
57
57
|
direction: CollageFabDirection;
|
|
58
|
+
/** The resolved direction of each child, in child order. */
|
|
59
|
+
directions: CollageFabDirection[];
|
|
58
60
|
/** The resolved pointer trigger mode. */
|
|
59
61
|
trigger: CollageFabTrigger;
|
|
60
62
|
/** The button diameter in pixels, after resolving the named size. */
|
|
@@ -124,7 +126,7 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
124
126
|
/**
|
|
125
127
|
* The buttons to stack. Every valid element is wrapped in a masked slot shaped
|
|
126
128
|
* by `variant`. Order matters: index 0 is the anchor, the rest fan out along
|
|
127
|
-
* `direction`.
|
|
129
|
+
* `direction` or their own entry in `directions`.
|
|
128
130
|
*/
|
|
129
131
|
children?: React.ReactNode;
|
|
130
132
|
/**
|
|
@@ -132,6 +134,12 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
132
134
|
* matches the original right-anchored behaviour.
|
|
133
135
|
*/
|
|
134
136
|
direction?: CollageFabDirection;
|
|
137
|
+
/**
|
|
138
|
+
* A direction per child, in child order, so one group can fan over several axes.
|
|
139
|
+
* Entry 0 belongs to the anchor and has no visible effect; an entry that is
|
|
140
|
+
* missing or past the end of the list falls back to `direction`.
|
|
141
|
+
*/
|
|
142
|
+
directions?: CollageFabDirection[];
|
|
135
143
|
/**
|
|
136
144
|
* Diameter of every button. Named sizes resolve to small 40px, medium 48px,
|
|
137
145
|
* large 56px; numeric values are used verbatim.
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -53,8 +53,10 @@ interface CollageFabItemSlotPropsOverrides {
|
|
|
53
53
|
interface CollageFabOwnerState {
|
|
54
54
|
/** Whether the group is currently expanded. */
|
|
55
55
|
open: boolean;
|
|
56
|
-
/** The resolved fan-out direction. */
|
|
56
|
+
/** The resolved fan-out direction used by every child without a `directions` entry. */
|
|
57
57
|
direction: CollageFabDirection;
|
|
58
|
+
/** The resolved direction of each child, in child order. */
|
|
59
|
+
directions: CollageFabDirection[];
|
|
58
60
|
/** The resolved pointer trigger mode. */
|
|
59
61
|
trigger: CollageFabTrigger;
|
|
60
62
|
/** The button diameter in pixels, after resolving the named size. */
|
|
@@ -124,7 +126,7 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
124
126
|
/**
|
|
125
127
|
* The buttons to stack. Every valid element is wrapped in a masked slot shaped
|
|
126
128
|
* by `variant`. Order matters: index 0 is the anchor, the rest fan out along
|
|
127
|
-
* `direction`.
|
|
129
|
+
* `direction` or their own entry in `directions`.
|
|
128
130
|
*/
|
|
129
131
|
children?: React.ReactNode;
|
|
130
132
|
/**
|
|
@@ -132,6 +134,12 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
132
134
|
* matches the original right-anchored behaviour.
|
|
133
135
|
*/
|
|
134
136
|
direction?: CollageFabDirection;
|
|
137
|
+
/**
|
|
138
|
+
* A direction per child, in child order, so one group can fan over several axes.
|
|
139
|
+
* Entry 0 belongs to the anchor and has no visible effect; an entry that is
|
|
140
|
+
* missing or past the end of the list falls back to `direction`.
|
|
141
|
+
*/
|
|
142
|
+
directions?: CollageFabDirection[];
|
|
135
143
|
/**
|
|
136
144
|
* Diameter of every button. Named sizes resolve to small 40px, medium 48px,
|
|
137
145
|
* large 56px; numeric values are used verbatim.
|
package/dist-lib/index.js
CHANGED
|
@@ -15,17 +15,82 @@ var u = {
|
|
|
15
15
|
function d(e) {
|
|
16
16
|
return typeof e == "number" ? e : u[e];
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
}
|
|
35
|
+
};
|
|
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)`;
|
|
38
|
+
}
|
|
39
|
+
function m(e, t) {
|
|
40
|
+
return t.directions[e] ?? t.direction;
|
|
41
|
+
}
|
|
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;
|
|
46
|
+
return {
|
|
47
|
+
x: r.x * o,
|
|
48
|
+
y: r.y * o
|
|
49
|
+
};
|
|
50
|
+
}
|
|
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
|
+
}
|
|
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;
|
|
59
|
+
};
|
|
20
60
|
return {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
61
|
+
extent: {
|
|
62
|
+
width: o(i),
|
|
63
|
+
height: o(a)
|
|
64
|
+
},
|
|
65
|
+
align: {
|
|
66
|
+
x: g(i),
|
|
67
|
+
y: g(a)
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
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`;
|
|
85
|
+
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`
|
|
25
90
|
};
|
|
26
91
|
}
|
|
27
92
|
// src/components/collageFabDefaults.ts
|
|
28
|
-
var
|
|
93
|
+
var y = {
|
|
29
94
|
direction: "left",
|
|
30
95
|
size: "large",
|
|
31
96
|
variant: "circular",
|
|
@@ -36,66 +101,71 @@ var p = {
|
|
|
36
101
|
disableClickAway: !1,
|
|
37
102
|
transitionDuration: 400,
|
|
38
103
|
transitionEasing: "cubic-bezier(0.4, 0, 0.2, 1)"
|
|
39
|
-
},
|
|
104
|
+
}, b = {
|
|
40
105
|
circular: "50%",
|
|
41
106
|
rounded: "25%",
|
|
42
107
|
square: 0
|
|
43
|
-
},
|
|
44
|
-
function
|
|
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) {
|
|
45
110
|
return `${e}ms ${t}`;
|
|
46
111
|
}
|
|
47
|
-
function
|
|
112
|
+
function C(e) {
|
|
48
113
|
return c("MuiCollageFab", e);
|
|
49
114
|
}
|
|
50
|
-
var
|
|
115
|
+
var w = (e, t) => s({
|
|
51
116
|
root: ["root", e ? "expanded" : "collapsed"],
|
|
52
117
|
item: ["item"]
|
|
53
|
-
},
|
|
118
|
+
}, C, t), T = n("div", {
|
|
54
119
|
name: "MuiCollageFab",
|
|
55
120
|
slot: "root",
|
|
56
121
|
overridesResolver: (e, t) => t.root
|
|
57
122
|
})(({ ownerState: e }) => {
|
|
58
|
-
let { open: t,
|
|
123
|
+
let { open: t, size: n, transitionDuration: r, transitionEasing: i } = e, { extent: a } = _(e), o = S(r, i);
|
|
59
124
|
return {
|
|
60
125
|
position: "relative",
|
|
61
|
-
width:
|
|
62
|
-
height:
|
|
63
|
-
|
|
64
|
-
flexDirection: c ? "row" : "column",
|
|
65
|
-
justifyContent: l ? "flex-end" : "flex-start",
|
|
66
|
-
transition: `${c ? "width" : "height"} ${g(o, s)}`,
|
|
126
|
+
width: t ? a.width : n,
|
|
127
|
+
height: t ? a.height : n,
|
|
128
|
+
transition: `width ${o}, height ${o}`,
|
|
67
129
|
filter: "drop-shadow(0px 6px 12px rgba(0,0,0,0.25))",
|
|
68
130
|
cursor: t ? "default" : "pointer",
|
|
69
131
|
WebkitTapHighlightColor: "transparent"
|
|
70
132
|
};
|
|
71
|
-
}),
|
|
133
|
+
}), ee = n("div", {
|
|
72
134
|
name: "MuiCollageFab",
|
|
73
135
|
slot: "item",
|
|
74
136
|
overridesResolver: (e, t) => t.item
|
|
75
137
|
})(({ ownerState: e }) => {
|
|
76
|
-
let {
|
|
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" ? {
|
|
140
|
+
left: "50%",
|
|
141
|
+
marginLeft: -t / 2
|
|
142
|
+
} : { left: 0 },
|
|
143
|
+
...s.y === "end" ? { bottom: 0 } : s.y === "center" ? {
|
|
144
|
+
top: "50%",
|
|
145
|
+
marginTop: -t / 2
|
|
146
|
+
} : { top: 0 }
|
|
147
|
+
}, l = S(a, o);
|
|
77
148
|
return {
|
|
78
149
|
position: "absolute",
|
|
79
|
-
...
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
borderRadius: a,
|
|
150
|
+
...c,
|
|
151
|
+
width: t,
|
|
152
|
+
height: t,
|
|
153
|
+
borderRadius: i,
|
|
84
154
|
overflow: "hidden",
|
|
85
155
|
display: "flex",
|
|
86
156
|
alignItems: "center",
|
|
87
157
|
justifyContent: "center",
|
|
88
|
-
zIndex:
|
|
89
|
-
transform:
|
|
90
|
-
WebkitMaskImage:
|
|
91
|
-
maskImage:
|
|
92
|
-
WebkitMaskSize:
|
|
93
|
-
maskSize:
|
|
94
|
-
WebkitMaskPosition:
|
|
95
|
-
maskPosition:
|
|
158
|
+
zIndex: n,
|
|
159
|
+
transform: r.translate,
|
|
160
|
+
WebkitMaskImage: r.maskImage,
|
|
161
|
+
maskImage: r.maskImage,
|
|
162
|
+
WebkitMaskSize: r.maskSize,
|
|
163
|
+
maskSize: r.maskSize,
|
|
164
|
+
WebkitMaskPosition: r.maskPosition,
|
|
165
|
+
maskPosition: r.maskPosition,
|
|
96
166
|
WebkitMaskRepeat: "no-repeat",
|
|
97
167
|
maskRepeat: "no-repeat",
|
|
98
|
-
transition: `transform ${
|
|
168
|
+
transition: `transform ${l}, -webkit-mask-position ${l}, mask-position ${l}`,
|
|
99
169
|
"& > *": {
|
|
100
170
|
boxShadow: "none !important",
|
|
101
171
|
borderRadius: "inherit !important",
|
|
@@ -105,7 +175,7 @@ var v = (e, t) => s({
|
|
|
105
175
|
}
|
|
106
176
|
};
|
|
107
177
|
});
|
|
108
|
-
function
|
|
178
|
+
function te(t) {
|
|
109
179
|
let { index: n, ownerState: r, geometry: i, className: s, component: c, inert: u, itemRefs: d, slotProps: f, children: p } = t, m = e.useMemo(() => ({
|
|
110
180
|
...r,
|
|
111
181
|
index: n,
|
|
@@ -135,94 +205,99 @@ function x(t) {
|
|
|
135
205
|
});
|
|
136
206
|
return /* @__PURE__ */ l(c, { ...v });
|
|
137
207
|
}
|
|
138
|
-
var
|
|
139
|
-
let { children: c, direction: u =
|
|
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({
|
|
140
210
|
props: n,
|
|
141
211
|
name: "MuiCollageFab"
|
|
142
|
-
}), [
|
|
143
|
-
controlled:
|
|
144
|
-
default:
|
|
212
|
+
}), [I, L] = i({
|
|
213
|
+
controlled: S,
|
|
214
|
+
default: C,
|
|
145
215
|
name: "CollageFab",
|
|
146
216
|
state: "open"
|
|
147
|
-
}),
|
|
148
|
-
open:
|
|
217
|
+
}), R = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), z = R.length, B = {
|
|
218
|
+
open: I,
|
|
149
219
|
direction: u,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
220
|
+
directions: e.useMemo(() => R.map((e, t) => f?.[t] ?? u), [
|
|
221
|
+
R,
|
|
222
|
+
f,
|
|
223
|
+
u
|
|
224
|
+
]),
|
|
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));
|
|
161
236
|
}, [
|
|
162
|
-
F,
|
|
163
237
|
I,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
w === "hover" && e.pointerType === "mouse" && q(!1, e);
|
|
238
|
+
L,
|
|
239
|
+
E,
|
|
240
|
+
D
|
|
241
|
+
]), Y = (e) => {
|
|
242
|
+
_ === "hover" && e.pointerType === "mouse" && J(!0, e);
|
|
170
243
|
}, X = (e) => {
|
|
171
|
-
|
|
244
|
+
_ === "hover" && e.pointerType === "mouse" && J(!1, e);
|
|
172
245
|
}, Z = (e) => {
|
|
173
|
-
|
|
246
|
+
_ !== "manual" && (G.current = e.pointerType, W.current = !1, e.pointerType === "mouse" || I || (W.current = !0, J(!0, e)));
|
|
174
247
|
}, ne = (e) => {
|
|
175
|
-
|
|
248
|
+
W.current && (W.current = !1, e.stopPropagation(), e.preventDefault());
|
|
176
249
|
}, re = (e) => {
|
|
177
|
-
|
|
178
|
-
|
|
250
|
+
_ !== "manual" && (_ === "click" ? J(!I, e) : I && G.current !== "mouse" && J(!1, e));
|
|
251
|
+
}, ie = (e) => {
|
|
252
|
+
if (_ !== "manual") {
|
|
253
|
+
if (I) {
|
|
179
254
|
if (e.key !== "Escape") return;
|
|
180
|
-
e.stopPropagation(),
|
|
181
|
-
} else (e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
255
|
+
e.stopPropagation(), J(!1, e), H.current?.focus();
|
|
256
|
+
} else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), K.current = !0, J(!0, e));
|
|
182
257
|
}
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
}, Q =
|
|
258
|
+
}, ae = (e) => {
|
|
259
|
+
J(!1, e);
|
|
260
|
+
}, Q = M?.root ?? T, oe = M?.item ?? ee, se = o({
|
|
186
261
|
elementType: Q,
|
|
187
|
-
externalForwardedProps:
|
|
188
|
-
externalSlotProps:
|
|
189
|
-
ownerState:
|
|
262
|
+
externalForwardedProps: F,
|
|
263
|
+
externalSlotProps: N?.root,
|
|
264
|
+
ownerState: B,
|
|
190
265
|
additionalProps: {
|
|
191
|
-
ref:
|
|
266
|
+
ref: q,
|
|
192
267
|
role: "group",
|
|
193
|
-
tabIndex: !
|
|
194
|
-
onPointerEnter:
|
|
195
|
-
onPointerLeave:
|
|
196
|
-
onPointerDown:
|
|
197
|
-
onClick:
|
|
198
|
-
onClickCapture:
|
|
199
|
-
onKeyDown:
|
|
268
|
+
tabIndex: !I && _ !== "manual" ? 0 : -1,
|
|
269
|
+
onPointerEnter: Y,
|
|
270
|
+
onPointerLeave: X,
|
|
271
|
+
onPointerDown: Z,
|
|
272
|
+
onClick: re,
|
|
273
|
+
onClickCapture: ne,
|
|
274
|
+
onKeyDown: ie
|
|
200
275
|
},
|
|
201
|
-
className: [
|
|
276
|
+
className: [V.root, P]
|
|
202
277
|
});
|
|
203
278
|
if (e.useEffect(() => {
|
|
204
|
-
if (!
|
|
205
|
-
|
|
206
|
-
let e =
|
|
207
|
-
e && (e.querySelector(
|
|
208
|
-
}, [
|
|
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;
|
|
209
284
|
let $ = /* @__PURE__ */ l(Q, {
|
|
210
|
-
...
|
|
211
|
-
children:
|
|
285
|
+
...se,
|
|
286
|
+
children: R.map((e, t) => /* @__PURE__ */ l(te, {
|
|
212
287
|
index: t,
|
|
213
|
-
ownerState:
|
|
214
|
-
geometry:
|
|
215
|
-
className:
|
|
216
|
-
component:
|
|
217
|
-
inert: !
|
|
218
|
-
itemRefs:
|
|
219
|
-
slotProps:
|
|
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,
|
|
220
295
|
children: e
|
|
221
296
|
}, t))
|
|
222
297
|
});
|
|
223
|
-
return
|
|
224
|
-
onClickAway:
|
|
298
|
+
return O || _ === "manual" ? $ : /* @__PURE__ */ l(t, {
|
|
299
|
+
onClickAway: ae,
|
|
225
300
|
children: $
|
|
226
301
|
});
|
|
227
302
|
});
|
|
228
|
-
export {
|
|
303
|
+
export { E as CollageFab };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mui-collage-fab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Material UI floating action button that unfolds a stack of overlapping Fab circles into a row.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Radomir Wojtera",
|
|
@@ -48,7 +48,13 @@
|
|
|
48
48
|
"provenance": true
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
51
|
+
"node": ">=18.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devEngines": {
|
|
54
|
+
"runtime": {
|
|
55
|
+
"name": "node",
|
|
56
|
+
"version": ">=22.12.0"
|
|
57
|
+
}
|
|
52
58
|
},
|
|
53
59
|
"scripts": {
|
|
54
60
|
"dev": "vite",
|
|
@@ -56,9 +62,9 @@
|
|
|
56
62
|
"build:preview": "tsc --noEmit && vite build --base=\"${SITE_BASE_PATH:?set SITE_BASE_PATH to the deployed preview path}\"",
|
|
57
63
|
"build:lib": "vite build --config vite.lib.config.ts && node scripts/build-dts.mjs",
|
|
58
64
|
"preview": "vite preview",
|
|
59
|
-
"format:check": "
|
|
60
|
-
"format": "
|
|
61
|
-
"lint": "
|
|
65
|
+
"format:check": "oxfmt --check",
|
|
66
|
+
"format": "oxfmt",
|
|
67
|
+
"lint": "oxlint",
|
|
62
68
|
"typecheck": "tsc --noEmit",
|
|
63
69
|
"test": "vitest run",
|
|
64
70
|
"test:watch": "vitest",
|
|
@@ -75,6 +81,8 @@
|
|
|
75
81
|
"doctor": "node scripts/doctor.mjs",
|
|
76
82
|
"doctor:fast": "node scripts/doctor.mjs --fast",
|
|
77
83
|
"check:actions": "node scripts/actionlint.mjs",
|
|
84
|
+
"check:node": "node scripts/check-node.mjs",
|
|
85
|
+
"check:deps": "depcruise src --config .dependency-cruiser.mjs",
|
|
78
86
|
"check:unused": "knip",
|
|
79
87
|
"check:release": "semantic-release --dry-run --no-ci",
|
|
80
88
|
"check:actions-security": "zizmor .github/workflows"
|
|
@@ -94,7 +102,6 @@
|
|
|
94
102
|
"@axe-core/playwright": "^4.14.0",
|
|
95
103
|
"@emotion/react": "^11.13.3",
|
|
96
104
|
"@emotion/styled": "^11.13.0",
|
|
97
|
-
"@eslint/js": "^10.0.1",
|
|
98
105
|
"@mui/icons-material": "^5.16.7",
|
|
99
106
|
"@mui/material": "^5.16.7",
|
|
100
107
|
"@playwright/test": "^1.65.1",
|
|
@@ -113,15 +120,15 @@
|
|
|
113
120
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
114
121
|
"@vitejs/plugin-react": "^6.3.0",
|
|
115
122
|
"@vitest/coverage-v8": "^5.1.0",
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
119
|
-
"eslint-plugin-react-hooks": "^7.1.1",
|
|
120
|
-
"globals": "^17.14.0",
|
|
123
|
+
"dependency-cruiser": "^18.7.2",
|
|
124
|
+
"fast-check": "^4.5.0",
|
|
121
125
|
"jest-axe": "^11.0.0",
|
|
122
126
|
"jsdom": "^31.0.1",
|
|
127
|
+
"knip": "^6.20.0",
|
|
123
128
|
"listr2": "^11.4.1",
|
|
124
|
-
"
|
|
129
|
+
"oxfmt": "^0.78.0",
|
|
130
|
+
"oxlint": "^1.93.0",
|
|
131
|
+
"oxlint-tsgolint": "^7.0.2007",
|
|
125
132
|
"publint": "^0.3.25",
|
|
126
133
|
"react": "^18.3.1",
|
|
127
134
|
"react-dom": "^18.3.1",
|
|
@@ -132,11 +139,8 @@
|
|
|
132
139
|
"size-limit": "^14.3.0",
|
|
133
140
|
"typedoc": "^0.28.20",
|
|
134
141
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
135
|
-
"typescript-eslint": "^8.72.2",
|
|
136
142
|
"vite": "^8.3.4",
|
|
137
|
-
"vitest": "^5.1.0"
|
|
138
|
-
"fast-check": "^4.5.0",
|
|
139
|
-
"knip": "^6.20.0"
|
|
143
|
+
"vitest": "^5.1.0"
|
|
140
144
|
},
|
|
141
145
|
"size-limit": [
|
|
142
146
|
{
|
|
@@ -149,10 +153,5 @@
|
|
|
149
153
|
"path": "dist-lib/index.cjs",
|
|
150
154
|
"limit": "3.1 kB"
|
|
151
155
|
}
|
|
152
|
-
]
|
|
153
|
-
"overrides": {
|
|
154
|
-
"eslint-plugin-jsx-a11y": {
|
|
155
|
-
"eslint": "$eslint"
|
|
156
|
-
}
|
|
157
|
-
}
|
|
156
|
+
]
|
|
158
157
|
}
|