mui-collage-fab 0.1.1 → 0.1.2
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 +104 -49
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/{types/components/CollageFab.d.ts → index.d.cts} +21 -18
- package/dist-lib/index.d.ts +137 -0
- package/dist-lib/index.js +211 -265
- package/package.json +71 -13
- package/dist-lib/.nojekyll +0 -0
- package/dist-lib/types/components/CollageFab.d.ts.map +0 -1
- package/dist-lib/types/index.d.ts +0 -2
- package/dist-lib/types/index.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# MUI CollageFab
|
|
2
2
|
|
|
3
|
-
**[Live demo →](https://
|
|
3
|
+
**[Live demo →](https://radomir.dev/mui-collage-fab/)**
|
|
4
4
|
|
|
5
|
-
| Collapsed
|
|
6
|
-
|
|
|
7
|
-
| <img src="https://raw.githubusercontent.com/radomir-dev/mui-collage-fab/main/docs/collagefab-collapsed.png" alt="Three CollageFab buttons collapsed into a single stacked circle"
|
|
5
|
+
| Collapsed | Expanded |
|
|
6
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
7
|
+
| <img src="https://raw.githubusercontent.com/radomir-dev/mui-collage-fab/main/docs/collagefab-collapsed.png" alt="Three CollageFab buttons collapsed into a single stacked circle" height="104" /> | <img src="https://raw.githubusercontent.com/radomir-dev/mui-collage-fab/main/docs/collagefab-expanded.png" alt="Three CollageFab buttons fanned out into a horizontal row" height="104" /> |
|
|
8
8
|
|
|
9
9
|
A Material UI floating action button that behaves like a collapsed stack of overlapping circles. Collapsed, a set of `Fab`s sits perfectly stacked and reads as a single button with soft gradient slices at the edges. On hover (mouse) or tap (touch), the parent expands its main-axis extent and the buttons fan out into a row while their CSS masks slide in lockstep with the movement — so the unfold reads as one continuous morph instead of a pop.
|
|
10
10
|
|
|
@@ -35,15 +35,20 @@ import { CollageFab } from 'mui-collage-fab';
|
|
|
35
35
|
fadeWidth={12}
|
|
36
36
|
aria-label="Tools"
|
|
37
37
|
slotProps={{
|
|
38
|
-
item: (ownerState) =>
|
|
39
|
-
ownerState.isAnchor ? { sx: { outline: '2px solid white' } } : {},
|
|
38
|
+
item: (ownerState) => (ownerState.isAnchor ? { sx: { outline: '2px solid white' } } : {}),
|
|
40
39
|
}}
|
|
41
40
|
>
|
|
42
41
|
{/* Index 0 is the anchor: it never moves and is never clipped. */}
|
|
43
|
-
<Fab color="primary"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
<Fab color="primary">
|
|
43
|
+
<Settings />
|
|
44
|
+
</Fab>
|
|
45
|
+
<Fab color="secondary">
|
|
46
|
+
<BugReport />
|
|
47
|
+
</Fab>
|
|
48
|
+
<Fab color="success">
|
|
49
|
+
<Speed />
|
|
50
|
+
</Fab>
|
|
51
|
+
</CollageFab>;
|
|
47
52
|
```
|
|
48
53
|
|
|
49
54
|
Controlled usage, when the open state has to live in your own state:
|
|
@@ -58,31 +63,31 @@ const [open, setOpen] = useState(false);
|
|
|
58
63
|
onClose={() => setOpen(false)}
|
|
59
64
|
>
|
|
60
65
|
{/* children */}
|
|
61
|
-
</CollageFab
|
|
66
|
+
</CollageFab>;
|
|
62
67
|
```
|
|
63
68
|
|
|
64
69
|
## Props
|
|
65
70
|
|
|
66
|
-
| Prop
|
|
67
|
-
|
|
|
68
|
-
| `children`
|
|
69
|
-
| `direction`
|
|
70
|
-
| `size`
|
|
71
|
-
| `variant`
|
|
72
|
-
| `gap`
|
|
73
|
-
| `fadeWidth`
|
|
74
|
-
| `trigger`
|
|
75
|
-
| `open`
|
|
76
|
-
| `defaultOpen`
|
|
77
|
-
| `onOpen`
|
|
78
|
-
| `onClose`
|
|
79
|
-
| `disableClickAway`
|
|
80
|
-
| `transitionDuration` | `number`
|
|
81
|
-
| `transitionEasing`
|
|
82
|
-
| `sx`
|
|
83
|
-
| `classes`
|
|
84
|
-
| `slots`
|
|
85
|
-
| `slotProps`
|
|
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`. |
|
|
86
91
|
|
|
87
92
|
Remaining `div` attributes, including `aria-label` and `aria-labelledby`, are spread onto the root.
|
|
88
93
|
|
|
@@ -120,39 +125,89 @@ const theme = createTheme({
|
|
|
120
125
|
|
|
121
126
|
## Demo site
|
|
122
127
|
|
|
123
|
-
1. Demo — <https://
|
|
124
|
-
2. Components API — <https://
|
|
125
|
-
3. Playground — <https://
|
|
128
|
+
1. Demo — <https://radomir.dev/mui-collage-fab/>
|
|
129
|
+
2. Components API — <https://radomir.dev/mui-collage-fab/#/docs>
|
|
130
|
+
3. Playground — <https://radomir.dev/mui-collage-fab/#/playground>
|
|
126
131
|
|
|
127
132
|
Routing is hash-based, so the built site works on any static host without a
|
|
128
133
|
server-side fallback.
|
|
129
134
|
|
|
130
|
-
| URL
|
|
131
|
-
|
|
|
132
|
-
| `/`
|
|
133
|
-
| `#/docs`
|
|
134
|
-
| anything else | Redirects to `#/`.
|
|
135
|
+
| URL | Page |
|
|
136
|
+
| ------------- | --------------------------------------------------------- |
|
|
137
|
+
| `/` | Demo — the component across button counts and directions. |
|
|
138
|
+
| `#/docs` | Components API reference for `CollageFab`. |
|
|
139
|
+
| anything else | Redirects to `#/`. |
|
|
140
|
+
|
|
141
|
+
## Testing
|
|
142
|
+
|
|
143
|
+
`src/components/collageFabGeometry.ts` holds the mask and translation maths, so it can be
|
|
144
|
+
tested without a DOM: `tests/geometry.test.ts` asserts the translate offsets, the mask axis
|
|
145
|
+
and stop order, and the invariant that a slice's mask position and translation cancel out —
|
|
146
|
+
the cut line stays pinned while the button travels. `tests/behaviour.test.tsx` runs the
|
|
147
|
+
component in jsdom for triggers, keyboard flow, controlled state and click-away.
|
|
148
|
+
`e2e/collagefab.spec.ts` is the browser-level check, because jsdom cannot compute masks:
|
|
149
|
+
it reads the real `transform` and `mask-position` after hovering and verifies they move by
|
|
150
|
+
the same pitch in opposite directions.
|
|
135
151
|
|
|
136
152
|
## Development
|
|
137
153
|
|
|
138
|
-
Requires Node.js
|
|
154
|
+
Requires Node.js 22.13 or newer.
|
|
139
155
|
|
|
140
156
|
```bash
|
|
141
157
|
npm install
|
|
142
158
|
npm run dev
|
|
143
159
|
```
|
|
144
160
|
|
|
145
|
-
| Command
|
|
146
|
-
|
|
|
147
|
-
| `npm run dev`
|
|
148
|
-
| `npm run build`
|
|
149
|
-
| `npm run build:
|
|
150
|
-
| `npm run
|
|
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`. |
|
|
178
|
+
|
|
179
|
+
### Checks
|
|
180
|
+
|
|
181
|
+
`npm run doctor` (listr2) runs the checks in sequence and keeps going after a
|
|
182
|
+
failure, so one pass reports everything that is broken:
|
|
183
|
+
|
|
184
|
+
1. `format:check`, `lint`, `typecheck` — style and static analysis.
|
|
185
|
+
2. `types:test` — the public prop unions and slot overrides, pinned by type tests.
|
|
186
|
+
3. `test:coverage` — Vitest with coverage thresholds of 85 statements / 75 branches.
|
|
187
|
+
4. `build`, `build:lib` — demo and library bundles.
|
|
188
|
+
5. `check:package` — `publint`, `attw --pack` and a tarball assertion, so the
|
|
189
|
+
published `exports`/types map and file list stay correct.
|
|
190
|
+
6. `check:size` — size-limit budgets for the ESM and CJS bundles.
|
|
191
|
+
7. `docs:check`, `actionlint`, `audit` and `test:e2e` — skipped with a reason when
|
|
192
|
+
the script exists but the tool is missing (for example `actionlint` locally).
|
|
193
|
+
|
|
194
|
+
`--fast` drops `test:e2e` and `audit`, `--only=lint,unit` runs a subset. Each failed
|
|
195
|
+
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.
|
|
151
198
|
|
|
152
199
|
Deployment: `.github/workflows/deploy.yml` builds the demo on every push to
|
|
153
|
-
`main` and
|
|
154
|
-
|
|
155
|
-
|
|
200
|
+
`main` and pushes `dist/` to the `gh-pages` branch, which GitHub Pages serves.
|
|
201
|
+
The branch holds nothing but built files. Every pull request gets that same
|
|
202
|
+
build one directory deeper, at
|
|
203
|
+
`https://radomir.dev/mui-collage-fab/pr-preview/pr-<number>/`:
|
|
204
|
+
`.github/workflows/preview.yml` builds it with `SITE_BASE_PATH` set to that
|
|
205
|
+
path, the preview action writes it to `gh-pages`, comments the URL on the pull
|
|
206
|
+
request, and removes the directory again when the pull request closes. The
|
|
207
|
+
deploy workflow keeps `pr-preview/` intact rather than cleaning the branch, so
|
|
208
|
+
a push to `main` does not take the open previews with it.
|
|
209
|
+
|
|
210
|
+
`.github/workflows/publish.yml` runs `semantic-release` on
|
|
156
211
|
every push to `main`: conventional commit subjects decide the version (`fix:`
|
|
157
212
|
patch, `feat:` minor, `BREAKING CHANGE:` major), and a release publishes the
|
|
158
213
|
package, writes `CHANGELOG.md`, and commits the bump back with `[skip ci]`.
|
package/dist-lib/index.cjs
CHANGED
|
@@ -1 +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,22 +1,23 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { CreateSlotsAndSlotProps, SlotProps } from '@mui/material/utils';
|
|
4
|
+
|
|
5
|
+
type CollageFabDirection = 'left' | 'right' | 'up' | 'down';
|
|
6
|
+
type CollageFabTrigger = 'hover' | 'click' | 'manual';
|
|
7
|
+
type CollageFabSize = 'small' | 'medium' | 'large' | number;
|
|
8
|
+
type CollageFabVariant = 'circular' | 'rounded' | 'square';
|
|
9
|
+
interface CollageFabClasses {
|
|
9
10
|
root: string;
|
|
10
11
|
item: string;
|
|
11
12
|
expanded: string;
|
|
12
13
|
collapsed: string;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
type CollageFabClassKey = keyof CollageFabClasses;
|
|
16
|
+
interface CollageFabRootSlotPropsOverrides {
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
interface CollageFabItemSlotPropsOverrides {
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
interface CollageFabOwnerState {
|
|
20
21
|
open: boolean;
|
|
21
22
|
direction: CollageFabDirection;
|
|
22
23
|
trigger: CollageFabTrigger;
|
|
@@ -29,26 +30,26 @@ export interface CollageFabOwnerState {
|
|
|
29
30
|
transitionDuration: number;
|
|
30
31
|
transitionEasing: string;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
interface CollageFabItemGeometry {
|
|
33
34
|
translate: string;
|
|
34
35
|
maskImage: string;
|
|
35
36
|
maskSize: string;
|
|
36
37
|
maskPosition: string;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
interface CollageFabItemOwnerState extends CollageFabOwnerState {
|
|
39
40
|
index: number;
|
|
40
41
|
isAnchor: boolean;
|
|
41
42
|
geometry: CollageFabItemGeometry;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
+
interface CollageFabSlots {
|
|
44
45
|
root?: React.ElementType;
|
|
45
46
|
item?: React.ElementType;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
type CollageFabSlotsAndSlotProps = CreateSlotsAndSlotProps<CollageFabSlots, {
|
|
48
49
|
root: SlotProps<'div', CollageFabRootSlotPropsOverrides, CollageFabOwnerState>;
|
|
49
50
|
item: SlotProps<'div', CollageFabItemSlotPropsOverrides, CollageFabItemOwnerState>;
|
|
50
51
|
}>;
|
|
51
|
-
|
|
52
|
+
interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>, CollageFabSlotsAndSlotProps {
|
|
52
53
|
/**
|
|
53
54
|
* The buttons to stack. Order matters: index 0 is the anchor, the remaining
|
|
54
55
|
* children fan out along `direction`.
|
|
@@ -130,5 +131,7 @@ export interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElemen
|
|
|
130
131
|
*/
|
|
131
132
|
classes?: Partial<CollageFabClasses>;
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
|
|
135
|
+
|
|
136
|
+
export { CollageFab };
|
|
137
|
+
export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabTrigger, CollageFabVariant };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { CreateSlotsAndSlotProps, SlotProps } from '@mui/material/utils';
|
|
4
|
+
|
|
5
|
+
type CollageFabDirection = 'left' | 'right' | 'up' | 'down';
|
|
6
|
+
type CollageFabTrigger = 'hover' | 'click' | 'manual';
|
|
7
|
+
type CollageFabSize = 'small' | 'medium' | 'large' | number;
|
|
8
|
+
type CollageFabVariant = 'circular' | 'rounded' | 'square';
|
|
9
|
+
interface CollageFabClasses {
|
|
10
|
+
root: string;
|
|
11
|
+
item: string;
|
|
12
|
+
expanded: string;
|
|
13
|
+
collapsed: string;
|
|
14
|
+
}
|
|
15
|
+
type CollageFabClassKey = keyof CollageFabClasses;
|
|
16
|
+
interface CollageFabRootSlotPropsOverrides {
|
|
17
|
+
}
|
|
18
|
+
interface CollageFabItemSlotPropsOverrides {
|
|
19
|
+
}
|
|
20
|
+
interface CollageFabOwnerState {
|
|
21
|
+
open: boolean;
|
|
22
|
+
direction: CollageFabDirection;
|
|
23
|
+
trigger: CollageFabTrigger;
|
|
24
|
+
size: number;
|
|
25
|
+
variant: CollageFabVariant;
|
|
26
|
+
cornerRadius: number | string;
|
|
27
|
+
gap: number;
|
|
28
|
+
fadeWidth: number;
|
|
29
|
+
count: number;
|
|
30
|
+
transitionDuration: number;
|
|
31
|
+
transitionEasing: string;
|
|
32
|
+
}
|
|
33
|
+
interface CollageFabItemGeometry {
|
|
34
|
+
translate: string;
|
|
35
|
+
maskImage: string;
|
|
36
|
+
maskSize: string;
|
|
37
|
+
maskPosition: string;
|
|
38
|
+
}
|
|
39
|
+
interface CollageFabItemOwnerState extends CollageFabOwnerState {
|
|
40
|
+
index: number;
|
|
41
|
+
isAnchor: boolean;
|
|
42
|
+
geometry: CollageFabItemGeometry;
|
|
43
|
+
}
|
|
44
|
+
interface CollageFabSlots {
|
|
45
|
+
root?: React.ElementType;
|
|
46
|
+
item?: React.ElementType;
|
|
47
|
+
}
|
|
48
|
+
type CollageFabSlotsAndSlotProps = CreateSlotsAndSlotProps<CollageFabSlots, {
|
|
49
|
+
root: SlotProps<'div', CollageFabRootSlotPropsOverrides, CollageFabOwnerState>;
|
|
50
|
+
item: SlotProps<'div', CollageFabItemSlotPropsOverrides, CollageFabItemOwnerState>;
|
|
51
|
+
}>;
|
|
52
|
+
interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>, CollageFabSlotsAndSlotProps {
|
|
53
|
+
/**
|
|
54
|
+
* The buttons to stack. Order matters: index 0 is the anchor, the remaining
|
|
55
|
+
* children fan out along `direction`.
|
|
56
|
+
*/
|
|
57
|
+
children?: React.ReactNode;
|
|
58
|
+
/**
|
|
59
|
+
* The axis the buttons fan out on, starting from the anchor child.
|
|
60
|
+
* @default 'left'
|
|
61
|
+
*/
|
|
62
|
+
direction?: CollageFabDirection;
|
|
63
|
+
/**
|
|
64
|
+
* Diameter of every button, in pixels. Numeric values are used verbatim.
|
|
65
|
+
* @default 'large'
|
|
66
|
+
*/
|
|
67
|
+
size?: CollageFabSize;
|
|
68
|
+
/**
|
|
69
|
+
* The shape of every button. `'circular'` clips each slice to a circle,
|
|
70
|
+
* `'rounded'` to a rounded square and `'square'` to a sharp-cornered square.
|
|
71
|
+
* The mask still slices the silhouette along the main axis, so the stack reads
|
|
72
|
+
* as one shape when collapsed and as separate shapes when expanded.
|
|
73
|
+
* @default 'circular'
|
|
74
|
+
*/
|
|
75
|
+
variant?: CollageFabVariant;
|
|
76
|
+
/**
|
|
77
|
+
* Main axis gap between two buttons when expanded, in pixels.
|
|
78
|
+
* @default 16
|
|
79
|
+
*/
|
|
80
|
+
gap?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Width of the soft cut line between two slices, in pixels.
|
|
83
|
+
* @default 12
|
|
84
|
+
*/
|
|
85
|
+
fadeWidth?: number;
|
|
86
|
+
/**
|
|
87
|
+
* 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.
|
|
89
|
+
* `'manual'` disables all built-in pointer interaction.
|
|
90
|
+
* @default 'hover'
|
|
91
|
+
*/
|
|
92
|
+
trigger?: CollageFabTrigger;
|
|
93
|
+
/**
|
|
94
|
+
* If `true`, the group is expanded. Use it to control the component.
|
|
95
|
+
*/
|
|
96
|
+
open?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* If `true`, the group is expanded by default.
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
defaultOpen?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Callback fired when the group is expanded.
|
|
104
|
+
*/
|
|
105
|
+
onOpen?: (event: React.SyntheticEvent) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Callback fired when the group is collapsed.
|
|
108
|
+
*/
|
|
109
|
+
onClose?: (event: React.SyntheticEvent) => void;
|
|
110
|
+
/**
|
|
111
|
+
* If `true`, the group does not collapse when the user clicks away from it.
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
114
|
+
disableClickAway?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Duration of the morph, in milliseconds.
|
|
117
|
+
* @default 400
|
|
118
|
+
*/
|
|
119
|
+
transitionDuration?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Easing of the morph.
|
|
122
|
+
* @default 'cubic-bezier(0.4, 0, 0.2, 1)'
|
|
123
|
+
*/
|
|
124
|
+
transitionEasing?: string;
|
|
125
|
+
/**
|
|
126
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
127
|
+
*/
|
|
128
|
+
sx?: SxProps<Theme>;
|
|
129
|
+
/**
|
|
130
|
+
* Override or extend the styles applied to the component.
|
|
131
|
+
*/
|
|
132
|
+
classes?: Partial<CollageFabClasses>;
|
|
133
|
+
}
|
|
134
|
+
declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
|
|
135
|
+
|
|
136
|
+
export { CollageFab };
|
|
137
|
+
export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabTrigger, CollageFabVariant };
|
package/dist-lib/index.js
CHANGED
|
@@ -1,271 +1,217 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, lt = [
|
|
18
|
-
"a[href]",
|
|
19
|
-
"button:not([disabled])",
|
|
20
|
-
"input:not([disabled])",
|
|
21
|
-
"select:not([disabled])",
|
|
22
|
-
"textarea:not([disabled])",
|
|
23
|
-
'[tabindex]:not([tabindex="-1"])'
|
|
24
|
-
].join(",");
|
|
25
|
-
function ct(o) {
|
|
26
|
-
return typeof o == "number" ? o : st[o];
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import { ClickAwayListener as t } from "@mui/material";
|
|
3
|
+
import { styled as n, useThemeProps as r } from "@mui/material/styles";
|
|
4
|
+
import { useControlled as i, useForkRef as a } from "@mui/material/utils";
|
|
5
|
+
import o from "@mui/utils/useSlotProps";
|
|
6
|
+
import s from "@mui/utils/composeClasses";
|
|
7
|
+
import c from "@mui/utils/generateUtilityClass";
|
|
8
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
9
|
+
// src/components/collageFabGeometry.ts
|
|
10
|
+
var u = {
|
|
11
|
+
small: 40,
|
|
12
|
+
medium: 48,
|
|
13
|
+
large: 56
|
|
14
|
+
};
|
|
15
|
+
function d(e) {
|
|
16
|
+
return typeof e == "number" ? e : u[e];
|
|
27
17
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
18
|
+
function f(e, t) {
|
|
19
|
+
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}`;
|
|
20
|
+
return {
|
|
21
|
+
translate: f ? `translateX(${v}px)` : `translateY(${v}px)`,
|
|
22
|
+
maskImage: n > 1 ? `linear-gradient(${f ? "to right" : "to bottom"}, ${_})` : "none",
|
|
23
|
+
maskSize: f ? `${2 * l}px 100%` : `100% ${2 * l}px`,
|
|
24
|
+
maskPosition: f ? `${g}px 0px` : `0px ${g}px`
|
|
25
|
+
};
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
// src/components/CollageFab.tsx
|
|
28
|
+
var p = {
|
|
29
|
+
circular: "50%",
|
|
30
|
+
rounded: "25%",
|
|
31
|
+
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) {
|
|
34
|
+
return `${e}ms ${t}`;
|
|
39
35
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
36
|
+
function g(e) {
|
|
37
|
+
return c("MuiCollageFab", e);
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})(({ ownerState:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// silhouette, so the root controls the global 3D shape.
|
|
101
|
-
"& > *": {
|
|
102
|
-
boxShadow: "none !important",
|
|
103
|
-
borderRadius: "inherit !important",
|
|
104
|
-
width: "100%",
|
|
105
|
-
height: "100%",
|
|
106
|
-
margin: 0
|
|
107
|
-
}
|
|
108
|
-
};
|
|
39
|
+
var _ = (e, t) => s({
|
|
40
|
+
root: ["root", e ? "expanded" : "collapsed"],
|
|
41
|
+
item: ["item"]
|
|
42
|
+
}, g, t), v = n("div", {
|
|
43
|
+
name: "MuiCollageFab",
|
|
44
|
+
slot: "root",
|
|
45
|
+
overridesResolver: (e, t) => t.root
|
|
46
|
+
})(({ ownerState: e }) => {
|
|
47
|
+
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;
|
|
48
|
+
return {
|
|
49
|
+
position: "relative",
|
|
50
|
+
width: c ? u : r,
|
|
51
|
+
height: c ? r : u,
|
|
52
|
+
display: "flex",
|
|
53
|
+
flexDirection: c ? "row" : "column",
|
|
54
|
+
justifyContent: l ? "flex-end" : "flex-start",
|
|
55
|
+
transition: `${c ? "width" : "height"} ${h(o, s)}`,
|
|
56
|
+
filter: "drop-shadow(0px 6px 12px rgba(0,0,0,0.25))",
|
|
57
|
+
cursor: t ? "default" : "pointer",
|
|
58
|
+
WebkitTapHighlightColor: "transparent"
|
|
59
|
+
};
|
|
60
|
+
}), y = n("div", {
|
|
61
|
+
name: "MuiCollageFab",
|
|
62
|
+
slot: "item",
|
|
63
|
+
overridesResolver: (e, t) => t.item
|
|
64
|
+
})(({ 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);
|
|
66
|
+
return {
|
|
67
|
+
position: "absolute",
|
|
68
|
+
...l,
|
|
69
|
+
...c ? { top: 0 } : { left: 0 },
|
|
70
|
+
width: n,
|
|
71
|
+
height: n,
|
|
72
|
+
borderRadius: a,
|
|
73
|
+
overflow: "hidden",
|
|
74
|
+
display: "flex",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
justifyContent: "center",
|
|
77
|
+
zIndex: r,
|
|
78
|
+
transform: i.translate,
|
|
79
|
+
WebkitMaskImage: i.maskImage,
|
|
80
|
+
maskImage: i.maskImage,
|
|
81
|
+
WebkitMaskSize: i.maskSize,
|
|
82
|
+
maskSize: i.maskSize,
|
|
83
|
+
WebkitMaskPosition: i.maskPosition,
|
|
84
|
+
maskPosition: i.maskPosition,
|
|
85
|
+
WebkitMaskRepeat: "no-repeat",
|
|
86
|
+
maskRepeat: "no-repeat",
|
|
87
|
+
transition: `transform ${u}, -webkit-mask-position ${u}, mask-position ${u}`,
|
|
88
|
+
"& > *": {
|
|
89
|
+
boxShadow: "none !important",
|
|
90
|
+
borderRadius: "inherit !important",
|
|
91
|
+
width: "100%",
|
|
92
|
+
height: "100%",
|
|
93
|
+
margin: 0
|
|
94
|
+
}
|
|
95
|
+
};
|
|
109
96
|
});
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
ref: C,
|
|
140
|
-
className: i,
|
|
141
|
-
"aria-hidden": f || void 0,
|
|
142
|
-
children: a
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return /* @__PURE__ */ $(l, { ...b });
|
|
97
|
+
function b(t) {
|
|
98
|
+
let { index: n, ownerState: r, geometry: i, className: s, component: c, inert: u, itemRefs: d, slotProps: f, children: p } = t, m = e.useMemo(() => ({
|
|
99
|
+
...r,
|
|
100
|
+
index: n,
|
|
101
|
+
isAnchor: n === 0,
|
|
102
|
+
geometry: i
|
|
103
|
+
}), [
|
|
104
|
+
r,
|
|
105
|
+
n,
|
|
106
|
+
i
|
|
107
|
+
]), h = e.useRef(null), g = e.useCallback((e) => {
|
|
108
|
+
d.current[n] = e;
|
|
109
|
+
}, [d, n]), _ = a(g, h);
|
|
110
|
+
e.useEffect(() => {
|
|
111
|
+
let e = h.current;
|
|
112
|
+
e && "inert" in HTMLElement.prototype && (e.inert = u);
|
|
113
|
+
}, [u]);
|
|
114
|
+
let v = o({
|
|
115
|
+
elementType: c,
|
|
116
|
+
externalSlotProps: f,
|
|
117
|
+
ownerState: m,
|
|
118
|
+
additionalProps: {
|
|
119
|
+
ref: _,
|
|
120
|
+
className: s,
|
|
121
|
+
"aria-hidden": u || void 0,
|
|
122
|
+
children: p
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return /* @__PURE__ */ l(c, { ...v });
|
|
146
126
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
},
|
|
239
|
-
className: [M.root, q]
|
|
240
|
-
});
|
|
241
|
-
if (c.useEffect(() => {
|
|
242
|
-
if (!m || !F.current)
|
|
243
|
-
return;
|
|
244
|
-
F.current = !1;
|
|
245
|
-
const t = N.current[0];
|
|
246
|
-
if (!t)
|
|
247
|
-
return;
|
|
248
|
-
(t.querySelector(lt) ?? t).focus();
|
|
249
|
-
}, [m]), D === 0)
|
|
250
|
-
return null;
|
|
251
|
-
const O = /* @__PURE__ */ $(L, { ...tt, children: T.map((t, d) => /* @__PURE__ */ $(
|
|
252
|
-
gt,
|
|
253
|
-
{
|
|
254
|
-
index: d,
|
|
255
|
-
ownerState: I,
|
|
256
|
-
geometry: ut(d, I),
|
|
257
|
-
className: M.item,
|
|
258
|
-
component: Q,
|
|
259
|
-
inert: !m && n !== "manual",
|
|
260
|
-
itemRefs: N,
|
|
261
|
-
slotProps: P == null ? void 0 : P.item,
|
|
262
|
-
children: t
|
|
263
|
-
},
|
|
264
|
-
d
|
|
265
|
-
)) });
|
|
266
|
-
return R || n === "manual" ? O : /* @__PURE__ */ $(et, { onClickAway: J, children: O });
|
|
267
|
-
}
|
|
268
|
-
);
|
|
269
|
-
export {
|
|
270
|
-
Pt as CollageFab
|
|
271
|
-
};
|
|
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({
|
|
129
|
+
props: n,
|
|
130
|
+
name: "MuiCollageFab"
|
|
131
|
+
}), [P, F] = i({
|
|
132
|
+
controlled: C,
|
|
133
|
+
default: w,
|
|
134
|
+
name: "CollageFab",
|
|
135
|
+
state: "open"
|
|
136
|
+
}), I = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), L = I.length, R = {
|
|
137
|
+
open: P,
|
|
138
|
+
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
|
+
}, [
|
|
151
|
+
P,
|
|
152
|
+
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);
|
|
159
|
+
}, Y = (e) => {
|
|
160
|
+
S !== "manual" && (U.current = e.pointerType, H.current = !1, e.pointerType === "mouse" || P || (H.current = !0, K(!0, e)));
|
|
161
|
+
}, X = (e) => {
|
|
162
|
+
H.current && (H.current = !1, e.stopPropagation(), e.preventDefault());
|
|
163
|
+
}, Z = (e) => {
|
|
164
|
+
S !== "manual" && (S === "click" ? K(!P, e) : P && U.current !== "mouse" && K(!1, e));
|
|
165
|
+
}, ne = (e) => {
|
|
166
|
+
if (S !== "manual") {
|
|
167
|
+
if (P) {
|
|
168
|
+
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));
|
|
171
|
+
}
|
|
172
|
+
}, re = (e) => {
|
|
173
|
+
K(!1, e);
|
|
174
|
+
}, Q = A?.root ?? v, ie = A?.item ?? y, ae = o({
|
|
175
|
+
elementType: Q,
|
|
176
|
+
externalForwardedProps: N,
|
|
177
|
+
externalSlotProps: j?.root,
|
|
178
|
+
ownerState: R,
|
|
179
|
+
additionalProps: {
|
|
180
|
+
ref: G,
|
|
181
|
+
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
|
|
189
|
+
},
|
|
190
|
+
className: [z.root, M]
|
|
191
|
+
});
|
|
192
|
+
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;
|
|
198
|
+
let $ = /* @__PURE__ */ l(Q, {
|
|
199
|
+
...ae,
|
|
200
|
+
children: I.map((e, t) => /* @__PURE__ */ l(b, {
|
|
201
|
+
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,
|
|
209
|
+
children: e
|
|
210
|
+
}, t))
|
|
211
|
+
});
|
|
212
|
+
return te || S === "manual" ? $ : /* @__PURE__ */ l(t, {
|
|
213
|
+
onClickAway: re,
|
|
214
|
+
children: $
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
export { x as CollageFab };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mui-collage-fab",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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",
|
|
@@ -29,12 +29,17 @@
|
|
|
29
29
|
],
|
|
30
30
|
"main": "./dist-lib/index.cjs",
|
|
31
31
|
"module": "./dist-lib/index.js",
|
|
32
|
-
"types": "./dist-lib/
|
|
32
|
+
"types": "./dist-lib/index.d.ts",
|
|
33
33
|
"exports": {
|
|
34
34
|
".": {
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist-lib/index.d.ts",
|
|
37
|
+
"default": "./dist-lib/index.js"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist-lib/index.d.cts",
|
|
41
|
+
"default": "./dist-lib/index.cjs"
|
|
42
|
+
}
|
|
38
43
|
},
|
|
39
44
|
"./package.json": "./package.json"
|
|
40
45
|
},
|
|
@@ -43,15 +48,31 @@
|
|
|
43
48
|
"provenance": true
|
|
44
49
|
},
|
|
45
50
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
51
|
+
"node": ">=22.13.0"
|
|
47
52
|
},
|
|
48
53
|
"scripts": {
|
|
49
54
|
"dev": "vite",
|
|
50
55
|
"build": "tsc --noEmit && vite build",
|
|
51
|
-
"build:
|
|
52
|
-
"
|
|
56
|
+
"build:preview": "tsc --noEmit && vite build --base=\"${SITE_BASE_PATH:?set SITE_BASE_PATH to the deployed preview path}\"",
|
|
57
|
+
"build:lib": "vite build --config vite.lib.config.ts && node scripts/build-dts.mjs",
|
|
53
58
|
"preview": "vite preview",
|
|
54
|
-
"
|
|
59
|
+
"format:check": "prettier --check .",
|
|
60
|
+
"format": "prettier --write .",
|
|
61
|
+
"lint": "eslint .",
|
|
62
|
+
"typecheck": "tsc --noEmit",
|
|
63
|
+
"test": "vitest run",
|
|
64
|
+
"test:watch": "vitest",
|
|
65
|
+
"test:coverage": "vitest run --coverage",
|
|
66
|
+
"test:e2e": "npm run build && playwright test",
|
|
67
|
+
"types:test": "vitest --run --typecheck",
|
|
68
|
+
"fix": "npm run format && npm run lint -- --fix",
|
|
69
|
+
"release": "semantic-release",
|
|
70
|
+
"prepublishOnly": "npm run build:lib",
|
|
71
|
+
"check:package": "publint && attw --pack . && node scripts/check-pack.mjs",
|
|
72
|
+
"check:size": "size-limit",
|
|
73
|
+
"doctor": "node scripts/doctor.mjs",
|
|
74
|
+
"doctor:fast": "node scripts/doctor.mjs --fast",
|
|
75
|
+
"check:actions": "actionlint"
|
|
55
76
|
},
|
|
56
77
|
"dependencies": {
|
|
57
78
|
"@mui/utils": "^5.15.0"
|
|
@@ -64,22 +85,59 @@
|
|
|
64
85
|
"react-dom": "^18.0.0"
|
|
65
86
|
},
|
|
66
87
|
"devDependencies": {
|
|
88
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
89
|
+
"@axe-core/playwright": "^4.14.0",
|
|
67
90
|
"@emotion/react": "^11.13.3",
|
|
68
91
|
"@emotion/styled": "^11.13.0",
|
|
92
|
+
"@eslint/js": "^9.39.5",
|
|
69
93
|
"@mui/icons-material": "^5.16.7",
|
|
70
94
|
"@mui/material": "^5.16.7",
|
|
95
|
+
"@playwright/test": "^1.65.1",
|
|
71
96
|
"@semantic-release/changelog": "^7.0.0",
|
|
72
97
|
"@semantic-release/git": "^11.0.1",
|
|
73
98
|
"@semantic-release/github": "^12.0.11",
|
|
74
99
|
"@semantic-release/npm": "^13.2.0",
|
|
100
|
+
"@size-limit/file": "^14.3.0",
|
|
101
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
102
|
+
"@testing-library/react": "^16.3.3",
|
|
103
|
+
"@testing-library/user-event": "^14.6.10",
|
|
104
|
+
"@types/jest-axe": "^3.5.9",
|
|
75
105
|
"@types/react": "^18.3.12",
|
|
76
106
|
"@types/react-dom": "^18.3.1",
|
|
77
|
-
"@vitejs/plugin-react": "^
|
|
107
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
108
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
109
|
+
"eslint": "^9.39.5",
|
|
110
|
+
"eslint-config-prettier": "^10.1.8",
|
|
111
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
112
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
113
|
+
"globals": "^17.14.0",
|
|
114
|
+
"jest-axe": "^11.0.0",
|
|
115
|
+
"jsdom": "^31.0.1",
|
|
116
|
+
"listr2": "^11.4.1",
|
|
117
|
+
"prettier": "^3.10.1",
|
|
118
|
+
"publint": "^0.3.25",
|
|
78
119
|
"react": "^18.3.1",
|
|
79
120
|
"react-dom": "^18.3.1",
|
|
80
121
|
"react-router-dom": "^7.18.4",
|
|
122
|
+
"rollup": "^4.68.3",
|
|
123
|
+
"rollup-plugin-dts": "^6.5.1",
|
|
81
124
|
"semantic-release": "^25.0.9",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
|
|
125
|
+
"size-limit": "^14.3.0",
|
|
126
|
+
"typescript": "~6.0.3",
|
|
127
|
+
"typescript-eslint": "^8.72.2",
|
|
128
|
+
"vite": "^8.3.4",
|
|
129
|
+
"vitest": "^5.1.0"
|
|
130
|
+
},
|
|
131
|
+
"size-limit": [
|
|
132
|
+
{
|
|
133
|
+
"name": "ESM build",
|
|
134
|
+
"path": "dist-lib/index.js",
|
|
135
|
+
"limit": "3.6 kB"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "CJS build",
|
|
139
|
+
"path": "dist-lib/index.cjs",
|
|
140
|
+
"limit": "3.1 kB"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
85
143
|
}
|
package/dist-lib/.nojekyll
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CollageFab.d.ts","sourceRoot":"","sources":["../../../src/components/CollageFab.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|