mui-collage-fab 0.3.0 → 0.4.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 +4 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/index.d.cts +26 -1
- package/dist-lib/index.d.ts +26 -1
- package/dist-lib/index.js +161 -140
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -76,6 +76,9 @@ const [open, setOpen] = useState(false);
|
|
|
76
76
|
| `children` | `React.ReactNode` | — | The buttons to stack. Every valid element is wrapped in a masked slot shaped by `variant`. Order matters: index 0 is the anchor, the rest fan out along `direction` or their own entry in `directions`. |
|
|
77
77
|
| `direction` | `'left' \| 'right' \| 'up' \| 'down'` | `'left'` | The axis the buttons fan out on, starting from the anchor child. `left` matches the original right-anchored behaviour. |
|
|
78
78
|
| `directions` | `('left' \| 'right' \| 'up' \| 'down')[]` | — | A direction per child, in child order, so one group can fan over several axes. Entry 0 belongs to the anchor and has no visible effect; an entry that is missing or past the end of the list falls back to `direction`. |
|
|
79
|
+
| `spread` | `'line' \| 'radial'` | `'line'` | How the children leave the anchor. `'line'` fans them along their directions; `'radial'` sends them onto a ring one pitch around the anchor, each cut by a wedge that lets it emerge from behind the anchor. |
|
|
80
|
+
| `radialStart` | `number` | `0` | Angle in degrees the first ring child sits on when `spread` is `'radial'`. |
|
|
81
|
+
| `radialStep` | `number` | — | Angle in degrees between two ring children when `spread` is `'radial'`. Defaults to `360 / (count - 1)`, which spaces them evenly around the anchor. |
|
|
79
82
|
| `size` | `'small' \| 'medium' \| 'large' \| number` | `'large'` | Diameter of every button. Named sizes resolve to small 40px, medium 48px, large 56px; numeric values are used verbatim. |
|
|
80
83
|
| `variant` | `'circular' \| 'rounded' \| 'square'` | `'circular'` | The shape of every button. `'circular'` clips each slice to a circle, `'rounded'` to a rounded square and `'square'` to a sharp-cornered square. The mask still slices the silhouette along the main axis, so the stack reads as one shape when collapsed and as separate shapes when expanded. |
|
|
81
84
|
| `gap` | `number` | `16` | Main-axis gap in pixels between two buttons when expanded. |
|
|
@@ -109,7 +112,7 @@ const [open, setOpen] = useState(false);
|
|
|
109
112
|
|
|
110
113
|
<!-- api:owner-state:start -->
|
|
111
114
|
|
|
112
|
-
`CollageFabOwnerState` carries `open`, `direction`, `directions`, `trigger`, `size`, `variant`, `cornerRadius`, `gap`, `fadeWidth`, `count`, `transitionDuration` and `transitionEasing`. `CollageFabItemOwnerState` adds `index`, `isAnchor` and `geometry`.
|
|
115
|
+
`CollageFabOwnerState` carries `open`, `direction`, `directions`, `spread`, `radialStart`, `radialStep`, `trigger`, `size`, `variant`, `cornerRadius`, `gap`, `fadeWidth`, `count`, `transitionDuration` and `transitionEasing`. `CollageFabItemOwnerState` adds `index`, `isAnchor` and `geometry`.
|
|
113
116
|
<!-- api:owner-state:end -->
|
|
114
117
|
|
|
115
118
|
Theme-level defaults and overrides work through the `MuiCollageFab` component key:
|
package/dist-lib/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("@mui/material"),u=require("@mui/material/styles"),d=require("@mui/material/utils"),f=require("@mui/utils/useSlotProps");f=s(f,1);let p=require("@mui/utils/composeClasses");p=s(p,1);let m=require("@mui/utils/generateUtilityClass");m=s(m,1);let h=require("react/jsx-runtime");var g={small:40,medium:48,large:56};function _(e){return typeof e==`number`?e:g[e]}var v={
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("react");c=s(c,1);let l=require("@mui/material"),u=require("@mui/material/styles"),d=require("@mui/material/utils"),f=require("@mui/utils/useSlotProps");f=s(f,1);let p=require("@mui/utils/composeClasses");p=s(p,1);let m=require("@mui/utils/generateUtilityClass");m=s(m,1);let h=require("react/jsx-runtime");var g={small:40,medium:48,large:56};function _(e){return typeof e==`number`?e:g[e]}var v={x:0,y:0},y={left:[-1,0],right:[1,0],up:[0,-1],down:[0,1]};function b({x:e,y:t},n){return t===0&&(n||e!==0)?`translateX(${e}px)`:e===0?`translateY(${t}px)`:`translate(${e}px, ${t}px)`}function x(e){return+e.toFixed(4)}function S(e,t){return t.directions[e]??t.direction}function C(e,t){let n=t.size+t.gap;if(t.spread===`radial`){if(e===0)return v;let r=(t.radialStart+(e-1)*t.radialStep)*Math.PI/180;return{x:x(Math.sin(r)*n),y:x(-Math.cos(r)*n)}}let r=S(e,t),[i,a]=y[r],o=0;for(let n=0;n<e;n+=1)S(n,t)===r&&(o+=1);let s=(o+(r===S(0,t)?0:1))*n;return{x:i*s,y:a*s}}function w(e,t){let n=Math.min(...e,0),r=Math.max(...e,0),i=n<0&&r>0?`center`:n<0?`end`:`start`;return[i===`center`?2*Math.max(-n,r)+t:r-n+t,i]}function T(e){let{count:t,size:n}=e;if(e.spread===`radial`)return{extent:{width:n,height:n},align:{x:`center`,y:`center`}};let r=Array.from({length:t},(t,n)=>C(n,e)),i=r.map(e=>e.x),a=r.map(e=>e.y),[o,s]=w(i,n),[c,l]=w(a,n);return{extent:{width:o,height:c},align:{x:s,y:l}}}function E(e,t){if(t.spread===`radial`)return D(e,t);let{count:n,size:r,gap:i,fadeWidth:a,open:o}=t,s=(n-1)*(r+i)+r+a,[c,l]=y[S(e,t)],u=c!==0,d=(u?c:l)<0,f=o?C(e,t):v,p=e===0?s:(n-e)*(r/n),m=e===0?-a/2:r/n*e,h=(d?p:m)-s-a/2,g=u?h-f.x:-f.x,_=u?-f.y:h-f.y,x=d?`#000 0px, #000 ${s}px, transparent ${s+a}px, transparent ${2*s}px`:`transparent 0px, transparent ${s}px, #000 ${s+a}px, #000 ${2*s}px`;return{translate:b(f,u),maskImage:n>1?`linear-gradient(${u?`to right`:`to bottom`}, ${x})`:`none`,maskSize:u?`${2*s}px 100%`:`100% ${2*s}px`,maskPosition:`${g}px ${_}px`}}function D(e,t){let{count:n,size:r,gap:i,fadeWidth:a,open:o}=t,s=t.radialStep,c=o?C(e,t):v,l=n>1?r+i:0,u=r+2*l,d=a?a/(r/2)*180/Math.PI:0,f=t.radialStart+(e-1)*s-s/2-d/2,p=x(s+d);return{translate:b(c,!1),maskImage:n>1&&e>0?`conic-gradient(from ${x(f)}deg, #0000 0deg, #000 ${x(d)}deg, #000 ${x(e===n-1?s:s+d)}deg, transparent ${p}deg)`:`none`,maskSize:`${u}px ${u}px`,maskPosition:`${-c.x-l}px ${-c.y-l}px`}}var O={direction:`left`,size:`large`,variant:`circular`,gap:16,fadeWidth:12,spread:`line`,radialStart:0,trigger:`hover`,defaultOpen:!1,disableClickAway:!1,transitionDuration:400,transitionEasing:`cubic-bezier(0.4, 0, 0.2, 1)`},ee={circular:`50%`,rounded:`25%`,square:0},k=`a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])`;function A(e,t){return`${e}ms ${t}`}function j(e){return(0,m.default)(`MuiCollageFab`,e)}var M=(e,t)=>(0,p.default)({root:[`root`,e?`expanded`:`collapsed`],item:[`item`]},j,t),N=(0,u.styled)(`div`,{name:`MuiCollageFab`,slot:`root`,overridesResolver:(e,t)=>t.root})(({ownerState:e})=>{let{open:t,size:n,spread:r,gap:i,count:a,transitionDuration:o,transitionEasing:s}=e,{extent:c}=T(e),l=A(o,s),u=t&&r===`radial`&&a>1?n+i:0;return{position:`relative`,...u>0&&{"&::after":{content:`""`,position:`absolute`,inset:-u,borderRadius:`50%`,zIndex:-1}},width:t?c.width:n,height:t?c.height:n,transition:`width ${l}, height ${l}`,filter:`drop-shadow(0px 6px 12px rgba(0,0,0,0.25))`,cursor:t?`default`:`pointer`,WebkitTapHighlightColor:`transparent`}}),P=(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}=T(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=A(a,o);return{position:`absolute`,...c,width:t,height:t,borderRadius:i,overflow:`hidden`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:e.spread===`radial`?e.count-n:n,transform:r.translate,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 F(e){let{index:t,ownerState:n,geometry:r,className:i,component:a,inert:o,itemRefs:s,slotProps:l,children:u}=e,p=c.useMemo(()=>({...n,index:t,isAnchor:t===0,geometry:r}),[n,t,r]),m=c.useRef(null),g=c.useCallback(e=>{s.current[t]=e},[s,t]),_=(0,d.useForkRef)(g,m);c.useEffect(()=>{let e=m.current;e&&`inert`in HTMLElement.prototype&&(e.inert=o)},[o]);let v=(0,f.default)({elementType:a,externalSlotProps:l,ownerState:p,additionalProps:{ref:_,className:i,"aria-hidden":o||void 0,children:u}});return(0,h.jsx)(a,{...v})}var I=c.forwardRef(function(e,t){let{children:n,direction:r=O.direction,directions:i,spread:a=O.spread,radialStart:o=O.radialStart,radialStep:s,size:p=O.size,variant:m=O.variant,gap:g=O.gap,fadeWidth:v=O.fadeWidth,trigger:y=O.trigger,open:b,defaultOpen:x=O.defaultOpen,onOpen:S,onClose:C,disableClickAway:w=O.disableClickAway,transitionDuration:T=O.transitionDuration,transitionEasing:D=O.transitionEasing,classes:A,slots:j,slotProps:I,className:L,...R}=(0,u.useThemeProps)({props:e,name:`MuiCollageFab`}),[z,B]=(0,d.useControlled)({controlled:b,default:x,name:`CollageFab`,state:`open`}),V=c.useMemo(()=>c.Children.toArray(n).filter(e=>c.isValidElement(e)),[n]),H=V.length,U={open:z,direction:r,directions:c.useMemo(()=>V.map((e,t)=>i?.[t]??r),[V,i,r]),spread:a,radialStart:o,radialStep:s??360/Math.max(H-1,1),trigger:y,size:_(p),variant:m,cornerRadius:ee[m],gap:g,fadeWidth:v,count:H,transitionDuration:T,transitionEasing:D},W=M(z,A),G=c.useRef(null),K=c.useRef([]),q=c.useRef(!1),J=c.useRef(`mouse`),Y=c.useRef(!1),X=(0,d.useForkRef)(G,t),Z=c.useCallback((e,t)=>{e!==z&&(B(e),e?S?.(t):C?.(t))},[z,B,S,C]),te=e=>{y===`hover`&&e.pointerType===`mouse`&&Z(!0,e)},ne=e=>{y===`hover`&&e.pointerType===`mouse`&&Z(!1,e)},re=e=>{y!==`manual`&&(J.current=e.pointerType,q.current=!1,e.pointerType===`mouse`||z||(q.current=!0,Z(!0,e)))},ie=e=>{q.current&&(q.current=!1,e.stopPropagation(),e.preventDefault())},ae=e=>{y!==`manual`&&(y===`click`?Z(!z,e):z&&J.current!==`mouse`&&Z(!1,e))},oe=e=>{if(y!==`manual`){if(z){if(e.key!==`Escape`)return;e.stopPropagation(),Z(!1,e),G.current?.focus()}else(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Y.current=!0,Z(!0,e))}},se=e=>{Z(!1,e)},Q=j?.root??N,ce=j?.item??P,le=(0,f.default)({elementType:Q,externalForwardedProps:R,externalSlotProps:I?.root,ownerState:U,additionalProps:{ref:X,role:`group`,tabIndex:!z&&y!==`manual`?0:-1,onPointerEnter:te,onPointerLeave:ne,onPointerDown:re,onClick:ae,onClickCapture:ie,onKeyDown:oe},className:[W.root,L]});if(c.useEffect(()=>{if(!z||!Y.current)return;Y.current=!1;let e=K.current[0];e&&(e.querySelector(k)??e).focus()},[z]),H===0)return null;let $=(0,h.jsx)(Q,{...le,children:V.map((e,t)=>(0,h.jsx)(F,{index:t,ownerState:U,geometry:E(t,U),className:W.item,component:ce,inert:!z&&y!==`manual`,itemRefs:K,slotProps:I?.item,children:e},t))});return w||y===`manual`?$:(0,h.jsx)(l.ClickAwayListener,{onClickAway:se,children:$})});exports.CollageFab=I;
|
package/dist-lib/index.d.cts
CHANGED
|
@@ -20,6 +20,10 @@ type CollageFabSize = 'small' | 'medium' | 'large' | number;
|
|
|
20
20
|
* square.
|
|
21
21
|
*/
|
|
22
22
|
type CollageFabVariant = 'circular' | 'rounded' | 'square';
|
|
23
|
+
/**
|
|
24
|
+
* How the children leave the anchor: along a line, or onto a ring around it.
|
|
25
|
+
*/
|
|
26
|
+
type CollageFabSpread = 'line' | 'radial';
|
|
23
27
|
/**
|
|
24
28
|
* Class names the component applies, and the accepted keys for `classes`.
|
|
25
29
|
*/
|
|
@@ -57,6 +61,12 @@ interface CollageFabOwnerState {
|
|
|
57
61
|
direction: CollageFabDirection;
|
|
58
62
|
/** The resolved direction of each child, in child order. */
|
|
59
63
|
directions: CollageFabDirection[];
|
|
64
|
+
/** How the children leave the anchor: along a line, or onto a ring. */
|
|
65
|
+
spread: CollageFabSpread;
|
|
66
|
+
/** The angle in degrees the first wedge is centred on when `spread` is `'radial'`. */
|
|
67
|
+
radialStart: number;
|
|
68
|
+
/** The angle in degrees between two wedges when `spread` is `'radial'`. */
|
|
69
|
+
radialStep: number;
|
|
60
70
|
/** The resolved pointer trigger mode. */
|
|
61
71
|
trigger: CollageFabTrigger;
|
|
62
72
|
/** The button diameter in pixels, after resolving the named size. */
|
|
@@ -140,6 +150,21 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
140
150
|
* missing or past the end of the list falls back to `direction`.
|
|
141
151
|
*/
|
|
142
152
|
directions?: CollageFabDirection[];
|
|
153
|
+
/**
|
|
154
|
+
* How the children leave the anchor. `'line'` fans them along their directions;
|
|
155
|
+
* `'radial'` sends them onto a ring one pitch around the anchor, each cut by a wedge
|
|
156
|
+
* that lets it emerge from behind the anchor.
|
|
157
|
+
*/
|
|
158
|
+
spread?: CollageFabSpread;
|
|
159
|
+
/**
|
|
160
|
+
* Angle in degrees the first ring child sits on when `spread` is `'radial'`.
|
|
161
|
+
*/
|
|
162
|
+
radialStart?: number;
|
|
163
|
+
/**
|
|
164
|
+
* Angle in degrees between two ring children when `spread` is `'radial'`.
|
|
165
|
+
* Defaults to `360 / (count - 1)`, which spaces them evenly around the anchor.
|
|
166
|
+
*/
|
|
167
|
+
radialStep?: number;
|
|
143
168
|
/**
|
|
144
169
|
* Diameter of every button. Named sizes resolve to small 40px, medium 48px,
|
|
145
170
|
* large 56px; numeric values are used verbatim.
|
|
@@ -221,4 +246,4 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
221
246
|
declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
|
|
222
247
|
|
|
223
248
|
export { CollageFab };
|
|
224
|
-
export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabTrigger, CollageFabVariant };
|
|
249
|
+
export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabSpread, CollageFabTrigger, CollageFabVariant };
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ type CollageFabSize = 'small' | 'medium' | 'large' | number;
|
|
|
20
20
|
* square.
|
|
21
21
|
*/
|
|
22
22
|
type CollageFabVariant = 'circular' | 'rounded' | 'square';
|
|
23
|
+
/**
|
|
24
|
+
* How the children leave the anchor: along a line, or onto a ring around it.
|
|
25
|
+
*/
|
|
26
|
+
type CollageFabSpread = 'line' | 'radial';
|
|
23
27
|
/**
|
|
24
28
|
* Class names the component applies, and the accepted keys for `classes`.
|
|
25
29
|
*/
|
|
@@ -57,6 +61,12 @@ interface CollageFabOwnerState {
|
|
|
57
61
|
direction: CollageFabDirection;
|
|
58
62
|
/** The resolved direction of each child, in child order. */
|
|
59
63
|
directions: CollageFabDirection[];
|
|
64
|
+
/** How the children leave the anchor: along a line, or onto a ring. */
|
|
65
|
+
spread: CollageFabSpread;
|
|
66
|
+
/** The angle in degrees the first wedge is centred on when `spread` is `'radial'`. */
|
|
67
|
+
radialStart: number;
|
|
68
|
+
/** The angle in degrees between two wedges when `spread` is `'radial'`. */
|
|
69
|
+
radialStep: number;
|
|
60
70
|
/** The resolved pointer trigger mode. */
|
|
61
71
|
trigger: CollageFabTrigger;
|
|
62
72
|
/** The button diameter in pixels, after resolving the named size. */
|
|
@@ -140,6 +150,21 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
140
150
|
* missing or past the end of the list falls back to `direction`.
|
|
141
151
|
*/
|
|
142
152
|
directions?: CollageFabDirection[];
|
|
153
|
+
/**
|
|
154
|
+
* How the children leave the anchor. `'line'` fans them along their directions;
|
|
155
|
+
* `'radial'` sends them onto a ring one pitch around the anchor, each cut by a wedge
|
|
156
|
+
* that lets it emerge from behind the anchor.
|
|
157
|
+
*/
|
|
158
|
+
spread?: CollageFabSpread;
|
|
159
|
+
/**
|
|
160
|
+
* Angle in degrees the first ring child sits on when `spread` is `'radial'`.
|
|
161
|
+
*/
|
|
162
|
+
radialStart?: number;
|
|
163
|
+
/**
|
|
164
|
+
* Angle in degrees between two ring children when `spread` is `'radial'`.
|
|
165
|
+
* Defaults to `360 / (count - 1)`, which spaces them evenly around the anchor.
|
|
166
|
+
*/
|
|
167
|
+
radialStep?: number;
|
|
143
168
|
/**
|
|
144
169
|
* Diameter of every button. Named sizes resolve to small 40px, medium 48px,
|
|
145
170
|
* large 56px; numeric values are used verbatim.
|
|
@@ -221,4 +246,4 @@ interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'ch
|
|
|
221
246
|
declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
|
|
222
247
|
|
|
223
248
|
export { CollageFab };
|
|
224
|
-
export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabTrigger, CollageFabVariant };
|
|
249
|
+
export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabSpread, CollageFabTrigger, CollageFabVariant };
|
package/dist-lib/index.js
CHANGED
|
@@ -16,126 +16,144 @@ function d(e) {
|
|
|
16
16
|
return typeof e == "number" ? e : u[e];
|
|
17
17
|
}
|
|
18
18
|
var f = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
right:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
up: {
|
|
28
|
-
x: 0,
|
|
29
|
-
y: -1
|
|
30
|
-
},
|
|
31
|
-
down: {
|
|
32
|
-
x: 0,
|
|
33
|
-
y: 1
|
|
34
|
-
}
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 0
|
|
21
|
+
}, p = {
|
|
22
|
+
left: [-1, 0],
|
|
23
|
+
right: [1, 0],
|
|
24
|
+
up: [0, -1],
|
|
25
|
+
down: [0, 1]
|
|
35
26
|
};
|
|
36
|
-
function
|
|
37
|
-
return
|
|
27
|
+
function m({ x: e, y: t }, n) {
|
|
28
|
+
return t === 0 && (n || e !== 0) ? `translateX(${e}px)` : e === 0 ? `translateY(${t}px)` : `translate(${e}px, ${t}px)`;
|
|
29
|
+
}
|
|
30
|
+
function h(e) {
|
|
31
|
+
return +e.toFixed(4);
|
|
38
32
|
}
|
|
39
|
-
function
|
|
33
|
+
function g(e, t) {
|
|
40
34
|
return t.directions[e] ?? t.direction;
|
|
41
35
|
}
|
|
42
|
-
function
|
|
43
|
-
let n =
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
function _(e, t) {
|
|
37
|
+
let n = t.size + t.gap;
|
|
38
|
+
if (t.spread === "radial") {
|
|
39
|
+
if (e === 0) return f;
|
|
40
|
+
let r = (t.radialStart + (e - 1) * t.radialStep) * Math.PI / 180;
|
|
41
|
+
return {
|
|
42
|
+
x: h(Math.sin(r) * n),
|
|
43
|
+
y: h(-Math.cos(r) * n)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let r = g(e, t), [i, a] = p[r], o = 0;
|
|
47
|
+
for (let n = 0; n < e; n += 1) g(n, t) === r && (o += 1);
|
|
48
|
+
let s = (o + (r === g(0, t) ? 0 : 1)) * n;
|
|
46
49
|
return {
|
|
47
|
-
x:
|
|
48
|
-
y:
|
|
50
|
+
x: i * s,
|
|
51
|
+
y: a * s
|
|
49
52
|
};
|
|
50
53
|
}
|
|
51
|
-
function
|
|
52
|
-
let
|
|
53
|
-
return
|
|
54
|
+
function v(e, t) {
|
|
55
|
+
let n = Math.min(...e, 0), r = Math.max(...e, 0), i = n < 0 && r > 0 ? "center" : n < 0 ? "end" : "start";
|
|
56
|
+
return [i === "center" ? 2 * Math.max(-n, r) + t : r - n + t, i];
|
|
54
57
|
}
|
|
55
|
-
function
|
|
56
|
-
let { count: t, size: n } = e
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
function y(e) {
|
|
59
|
+
let { count: t, size: n } = e;
|
|
60
|
+
if (e.spread === "radial") return {
|
|
61
|
+
extent: {
|
|
62
|
+
width: n,
|
|
63
|
+
height: n
|
|
64
|
+
},
|
|
65
|
+
align: {
|
|
66
|
+
x: "center",
|
|
67
|
+
y: "center"
|
|
68
|
+
}
|
|
59
69
|
};
|
|
70
|
+
let r = Array.from({ length: t }, (t, n) => _(n, e)), i = r.map((e) => e.x), a = r.map((e) => e.y), [o, s] = v(i, n), [c, l] = v(a, n);
|
|
60
71
|
return {
|
|
61
72
|
extent: {
|
|
62
|
-
width: o
|
|
63
|
-
height:
|
|
73
|
+
width: o,
|
|
74
|
+
height: c
|
|
64
75
|
},
|
|
65
76
|
align: {
|
|
66
|
-
x:
|
|
67
|
-
y:
|
|
77
|
+
x: s,
|
|
78
|
+
y: l
|
|
68
79
|
}
|
|
69
80
|
};
|
|
70
81
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
y: b.y - g.y
|
|
84
|
-
}, S = d ? `#000 0px, #000 ${c}px, transparent ${c + a}px, transparent ${2 * c}px` : `transparent 0px, transparent ${c}px, #000 ${c + a}px, #000 ${2 * c}px`;
|
|
82
|
+
function b(e, t) {
|
|
83
|
+
if (t.spread === "radial") return x(e, t);
|
|
84
|
+
let { count: n, size: r, gap: i, fadeWidth: a, open: o } = t, s = (n - 1) * (r + i) + r + a, [c, l] = p[g(e, t)], u = c !== 0, d = (u ? c : l) < 0, h = o ? _(e, t) : f, v = e === 0 ? s : (n - e) * (r / n), y = e === 0 ? -a / 2 : r / n * e, b = (d ? v : y) - s - a / 2, S = u ? b - h.x : -h.x, C = u ? -h.y : b - h.y, w = d ? `#000 0px, #000 ${s}px, transparent ${s + a}px, transparent ${2 * s}px` : `transparent 0px, transparent ${s}px, #000 ${s + a}px, #000 ${2 * s}px`;
|
|
85
|
+
return {
|
|
86
|
+
translate: m(h, u),
|
|
87
|
+
maskImage: n > 1 ? `linear-gradient(${u ? "to right" : "to bottom"}, ${w})` : "none",
|
|
88
|
+
maskSize: u ? `${2 * s}px 100%` : `100% ${2 * s}px`,
|
|
89
|
+
maskPosition: `${S}px ${C}px`
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function x(e, t) {
|
|
93
|
+
let { count: n, size: r, gap: i, fadeWidth: a, open: o } = t, s = t.radialStep, c = o ? _(e, t) : f, l = n > 1 ? r + i : 0, u = r + 2 * l, d = a ? a / (r / 2) * 180 / Math.PI : 0, p = t.radialStart + (e - 1) * s - s / 2 - d / 2, g = h(s + d);
|
|
85
94
|
return {
|
|
86
|
-
translate:
|
|
87
|
-
maskImage: n > 1 ? `
|
|
88
|
-
maskSize:
|
|
89
|
-
maskPosition: `${
|
|
95
|
+
translate: m(c, !1),
|
|
96
|
+
maskImage: n > 1 && e > 0 ? `conic-gradient(from ${h(p)}deg, #0000 0deg, #000 ${h(d)}deg, #000 ${h(e === n - 1 ? s : s + d)}deg, transparent ${g}deg)` : "none",
|
|
97
|
+
maskSize: `${u}px ${u}px`,
|
|
98
|
+
maskPosition: `${-c.x - l}px ${-c.y - l}px`
|
|
90
99
|
};
|
|
91
100
|
}
|
|
92
101
|
// src/components/collageFabDefaults.ts
|
|
93
|
-
var
|
|
102
|
+
var S = {
|
|
94
103
|
direction: "left",
|
|
95
104
|
size: "large",
|
|
96
105
|
variant: "circular",
|
|
97
106
|
gap: 16,
|
|
98
107
|
fadeWidth: 12,
|
|
108
|
+
spread: "line",
|
|
109
|
+
radialStart: 0,
|
|
99
110
|
trigger: "hover",
|
|
100
111
|
defaultOpen: !1,
|
|
101
112
|
disableClickAway: !1,
|
|
102
113
|
transitionDuration: 400,
|
|
103
114
|
transitionEasing: "cubic-bezier(0.4, 0, 0.2, 1)"
|
|
104
|
-
},
|
|
115
|
+
}, C = {
|
|
105
116
|
circular: "50%",
|
|
106
117
|
rounded: "25%",
|
|
107
118
|
square: 0
|
|
108
|
-
},
|
|
109
|
-
function
|
|
119
|
+
}, w = "a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex=\"-1\"])";
|
|
120
|
+
function T(e, t) {
|
|
110
121
|
return `${e}ms ${t}`;
|
|
111
122
|
}
|
|
112
|
-
function
|
|
123
|
+
function E(e) {
|
|
113
124
|
return c("MuiCollageFab", e);
|
|
114
125
|
}
|
|
115
|
-
var
|
|
126
|
+
var D = (e, t) => s({
|
|
116
127
|
root: ["root", e ? "expanded" : "collapsed"],
|
|
117
128
|
item: ["item"]
|
|
118
|
-
},
|
|
129
|
+
}, E, t), O = n("div", {
|
|
119
130
|
name: "MuiCollageFab",
|
|
120
131
|
slot: "root",
|
|
121
132
|
overridesResolver: (e, t) => t.root
|
|
122
133
|
})(({ ownerState: e }) => {
|
|
123
|
-
let { open: t, size: n,
|
|
134
|
+
let { open: t, size: n, spread: r, gap: i, count: a, transitionDuration: o, transitionEasing: s } = e, { extent: c } = y(e), l = T(o, s), u = t && r === "radial" && a > 1 ? n + i : 0;
|
|
124
135
|
return {
|
|
125
136
|
position: "relative",
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
...u > 0 && { "&::after": {
|
|
138
|
+
content: "\"\"",
|
|
139
|
+
position: "absolute",
|
|
140
|
+
inset: -u,
|
|
141
|
+
borderRadius: "50%",
|
|
142
|
+
zIndex: -1
|
|
143
|
+
} },
|
|
144
|
+
width: t ? c.width : n,
|
|
145
|
+
height: t ? c.height : n,
|
|
146
|
+
transition: `width ${l}, height ${l}`,
|
|
129
147
|
filter: "drop-shadow(0px 6px 12px rgba(0,0,0,0.25))",
|
|
130
148
|
cursor: t ? "default" : "pointer",
|
|
131
149
|
WebkitTapHighlightColor: "transparent"
|
|
132
150
|
};
|
|
133
|
-
}),
|
|
151
|
+
}), k = n("div", {
|
|
134
152
|
name: "MuiCollageFab",
|
|
135
153
|
slot: "item",
|
|
136
154
|
overridesResolver: (e, t) => t.item
|
|
137
155
|
})(({ ownerState: e }) => {
|
|
138
|
-
let { size: t, index: n, geometry: r, cornerRadius: i, transitionDuration: a, transitionEasing: o } = e, { align: s } =
|
|
156
|
+
let { size: t, index: n, geometry: r, cornerRadius: i, transitionDuration: a, transitionEasing: o } = e, { align: s } = y(e), c = {
|
|
139
157
|
...s.x === "end" ? { right: 0 } : s.x === "center" ? {
|
|
140
158
|
left: "50%",
|
|
141
159
|
marginLeft: -t / 2
|
|
@@ -144,7 +162,7 @@ var w = (e, t) => s({
|
|
|
144
162
|
top: "50%",
|
|
145
163
|
marginTop: -t / 2
|
|
146
164
|
} : { top: 0 }
|
|
147
|
-
}, l =
|
|
165
|
+
}, l = T(a, o);
|
|
148
166
|
return {
|
|
149
167
|
position: "absolute",
|
|
150
168
|
...c,
|
|
@@ -155,7 +173,7 @@ var w = (e, t) => s({
|
|
|
155
173
|
display: "flex",
|
|
156
174
|
alignItems: "center",
|
|
157
175
|
justifyContent: "center",
|
|
158
|
-
zIndex: n,
|
|
176
|
+
zIndex: e.spread === "radial" ? e.count - n : n,
|
|
159
177
|
transform: r.translate,
|
|
160
178
|
WebkitMaskImage: r.maskImage,
|
|
161
179
|
maskImage: r.maskImage,
|
|
@@ -175,7 +193,7 @@ var w = (e, t) => s({
|
|
|
175
193
|
}
|
|
176
194
|
};
|
|
177
195
|
});
|
|
178
|
-
function
|
|
196
|
+
function A(t) {
|
|
179
197
|
let { index: n, ownerState: r, geometry: i, className: s, component: c, inert: u, itemRefs: d, slotProps: f, children: p } = t, m = e.useMemo(() => ({
|
|
180
198
|
...r,
|
|
181
199
|
index: n,
|
|
@@ -205,99 +223,102 @@ function te(t) {
|
|
|
205
223
|
});
|
|
206
224
|
return /* @__PURE__ */ l(c, { ...v });
|
|
207
225
|
}
|
|
208
|
-
var
|
|
209
|
-
let { children: c, direction: u =
|
|
226
|
+
var j = e.forwardRef(function(n, s) {
|
|
227
|
+
let { children: c, direction: u = S.direction, directions: f, spread: p = S.spread, radialStart: m = S.radialStart, radialStep: h, size: g = S.size, variant: _ = S.variant, gap: v = S.gap, fadeWidth: y = S.fadeWidth, trigger: x = S.trigger, open: T, defaultOpen: E = S.defaultOpen, onOpen: j, onClose: M, disableClickAway: ee = S.disableClickAway, transitionDuration: te = S.transitionDuration, transitionEasing: ne = S.transitionEasing, classes: N, slots: P, slotProps: F, className: I, ...L } = r({
|
|
210
228
|
props: n,
|
|
211
229
|
name: "MuiCollageFab"
|
|
212
|
-
}), [
|
|
213
|
-
controlled:
|
|
214
|
-
default:
|
|
230
|
+
}), [R, z] = i({
|
|
231
|
+
controlled: T,
|
|
232
|
+
default: E,
|
|
215
233
|
name: "CollageFab",
|
|
216
234
|
state: "open"
|
|
217
|
-
}),
|
|
218
|
-
open:
|
|
235
|
+
}), B = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), V = B.length, H = {
|
|
236
|
+
open: R,
|
|
219
237
|
direction: u,
|
|
220
|
-
directions: e.useMemo(() =>
|
|
221
|
-
|
|
238
|
+
directions: e.useMemo(() => B.map((e, t) => f?.[t] ?? u), [
|
|
239
|
+
B,
|
|
222
240
|
f,
|
|
223
241
|
u
|
|
224
242
|
]),
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
243
|
+
spread: p,
|
|
244
|
+
radialStart: m,
|
|
245
|
+
radialStep: h ?? 360 / Math.max(V - 1, 1),
|
|
246
|
+
trigger: x,
|
|
247
|
+
size: d(g),
|
|
248
|
+
variant: _,
|
|
249
|
+
cornerRadius: C[_],
|
|
250
|
+
gap: v,
|
|
251
|
+
fadeWidth: y,
|
|
252
|
+
count: V,
|
|
253
|
+
transitionDuration: te,
|
|
254
|
+
transitionEasing: ne
|
|
255
|
+
}, U = D(R, N), W = e.useRef(null), G = e.useRef([]), K = e.useRef(!1), q = e.useRef("mouse"), J = e.useRef(!1), Y = a(W, s), X = e.useCallback((e, t) => {
|
|
256
|
+
e !== R && (z(e), e ? j?.(t) : M?.(t));
|
|
236
257
|
}, [
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
]),
|
|
242
|
-
|
|
243
|
-
}, X = (e) => {
|
|
244
|
-
_ === "hover" && e.pointerType === "mouse" && J(!1, e);
|
|
245
|
-
}, Z = (e) => {
|
|
246
|
-
_ !== "manual" && (G.current = e.pointerType, W.current = !1, e.pointerType === "mouse" || I || (W.current = !0, J(!0, e)));
|
|
247
|
-
}, ne = (e) => {
|
|
248
|
-
W.current && (W.current = !1, e.stopPropagation(), e.preventDefault());
|
|
249
|
-
}, re = (e) => {
|
|
250
|
-
_ !== "manual" && (_ === "click" ? J(!I, e) : I && G.current !== "mouse" && J(!1, e));
|
|
258
|
+
R,
|
|
259
|
+
z,
|
|
260
|
+
j,
|
|
261
|
+
M
|
|
262
|
+
]), re = (e) => {
|
|
263
|
+
x === "hover" && e.pointerType === "mouse" && X(!0, e);
|
|
251
264
|
}, ie = (e) => {
|
|
252
|
-
|
|
253
|
-
|
|
265
|
+
x === "hover" && e.pointerType === "mouse" && X(!1, e);
|
|
266
|
+
}, ae = (e) => {
|
|
267
|
+
x !== "manual" && (q.current = e.pointerType, K.current = !1, e.pointerType === "mouse" || R || (K.current = !0, X(!0, e)));
|
|
268
|
+
}, oe = (e) => {
|
|
269
|
+
K.current && (K.current = !1, e.stopPropagation(), e.preventDefault());
|
|
270
|
+
}, se = (e) => {
|
|
271
|
+
x !== "manual" && (x === "click" ? X(!R, e) : R && q.current !== "mouse" && X(!1, e));
|
|
272
|
+
}, ce = (e) => {
|
|
273
|
+
if (x !== "manual") {
|
|
274
|
+
if (R) {
|
|
254
275
|
if (e.key !== "Escape") return;
|
|
255
|
-
e.stopPropagation(),
|
|
256
|
-
} else (e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
276
|
+
e.stopPropagation(), X(!1, e), W.current?.focus();
|
|
277
|
+
} else (e.key === "Enter" || e.key === " ") && (e.preventDefault(), J.current = !0, X(!0, e));
|
|
257
278
|
}
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
}, Q =
|
|
279
|
+
}, Z = (e) => {
|
|
280
|
+
X(!1, e);
|
|
281
|
+
}, Q = P?.root ?? O, le = P?.item ?? k, ue = o({
|
|
261
282
|
elementType: Q,
|
|
262
|
-
externalForwardedProps:
|
|
263
|
-
externalSlotProps:
|
|
264
|
-
ownerState:
|
|
283
|
+
externalForwardedProps: L,
|
|
284
|
+
externalSlotProps: F?.root,
|
|
285
|
+
ownerState: H,
|
|
265
286
|
additionalProps: {
|
|
266
|
-
ref:
|
|
287
|
+
ref: Y,
|
|
267
288
|
role: "group",
|
|
268
|
-
tabIndex: !
|
|
269
|
-
onPointerEnter:
|
|
270
|
-
onPointerLeave:
|
|
271
|
-
onPointerDown:
|
|
272
|
-
onClick:
|
|
273
|
-
onClickCapture:
|
|
274
|
-
onKeyDown:
|
|
289
|
+
tabIndex: !R && x !== "manual" ? 0 : -1,
|
|
290
|
+
onPointerEnter: re,
|
|
291
|
+
onPointerLeave: ie,
|
|
292
|
+
onPointerDown: ae,
|
|
293
|
+
onClick: se,
|
|
294
|
+
onClickCapture: oe,
|
|
295
|
+
onKeyDown: ce
|
|
275
296
|
},
|
|
276
|
-
className: [
|
|
297
|
+
className: [U.root, I]
|
|
277
298
|
});
|
|
278
299
|
if (e.useEffect(() => {
|
|
279
|
-
if (!
|
|
280
|
-
|
|
281
|
-
let e =
|
|
282
|
-
e && (e.querySelector(
|
|
283
|
-
}, [
|
|
300
|
+
if (!R || !J.current) return;
|
|
301
|
+
J.current = !1;
|
|
302
|
+
let e = G.current[0];
|
|
303
|
+
e && (e.querySelector(w) ?? e).focus();
|
|
304
|
+
}, [R]), V === 0) return null;
|
|
284
305
|
let $ = /* @__PURE__ */ l(Q, {
|
|
285
|
-
...
|
|
286
|
-
children:
|
|
306
|
+
...ue,
|
|
307
|
+
children: B.map((e, t) => /* @__PURE__ */ l(A, {
|
|
287
308
|
index: t,
|
|
288
|
-
ownerState:
|
|
289
|
-
geometry:
|
|
290
|
-
className:
|
|
291
|
-
component:
|
|
292
|
-
inert: !
|
|
293
|
-
itemRefs:
|
|
294
|
-
slotProps:
|
|
309
|
+
ownerState: H,
|
|
310
|
+
geometry: b(t, H),
|
|
311
|
+
className: U.item,
|
|
312
|
+
component: le,
|
|
313
|
+
inert: !R && x !== "manual",
|
|
314
|
+
itemRefs: G,
|
|
315
|
+
slotProps: F?.item,
|
|
295
316
|
children: e
|
|
296
317
|
}, t))
|
|
297
318
|
});
|
|
298
|
-
return
|
|
299
|
-
onClickAway:
|
|
319
|
+
return ee || x === "manual" ? $ : /* @__PURE__ */ l(t, {
|
|
320
|
+
onClickAway: Z,
|
|
300
321
|
children: $
|
|
301
322
|
});
|
|
302
323
|
});
|
|
303
|
-
export {
|
|
324
|
+
export { j as CollageFab };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mui-collage-fab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
{
|
|
152
152
|
"name": "CJS build",
|
|
153
153
|
"path": "dist-lib/index.cjs",
|
|
154
|
-
"limit": "3.
|
|
154
|
+
"limit": "3.2 kB"
|
|
155
155
|
}
|
|
156
156
|
]
|
|
157
157
|
}
|