mui-collage-fab 0.2.0 → 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 +3 -2
- 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 +116 -96
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,8 +73,9 @@ const [open, setOpen] = useState(false);
|
|
|
73
73
|
|
|
74
74
|
| Prop | Type | Default | Description |
|
|
75
75
|
| -------------------- | ------------------------------------------ | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
76
|
-
| `children` | `React.ReactNode` | — | The buttons to stack. Every valid element is wrapped in a masked slot shaped by `variant`. Order matters: index 0 is the anchor, the rest fan out along `direction`.
|
|
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
|
+
| `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`. |
|
|
78
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. |
|
|
79
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. |
|
|
80
81
|
| `gap` | `number` | `16` | Main-axis gap in pixels between two buttons when expanded. |
|
|
@@ -108,7 +109,7 @@ const [open, setOpen] = useState(false);
|
|
|
108
109
|
|
|
109
110
|
<!-- api:owner-state:start -->
|
|
110
111
|
|
|
111
|
-
`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`.
|
|
112
113
|
<!-- api:owner-state:end -->
|
|
113
114
|
|
|
114
115
|
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={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){let n=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={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
|
@@ -37,33 +37,42 @@ function p({ x: e, y: t }, n) {
|
|
|
37
37
|
return e !== 0 && t !== 0 ? `translate(${e}px, ${t}px)` : n ? `translateX(${e}px)` : `translateY(${t}px)`;
|
|
38
38
|
}
|
|
39
39
|
function m(e, t) {
|
|
40
|
-
|
|
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;
|
|
41
46
|
return {
|
|
42
|
-
x:
|
|
43
|
-
y:
|
|
47
|
+
x: r.x * o,
|
|
48
|
+
y: r.y * o
|
|
44
49
|
};
|
|
45
50
|
}
|
|
46
|
-
function h(e) {
|
|
47
|
-
return e.every((e) => e <= 0) && e.some((e) => e < 0) ? "end" : "start";
|
|
48
|
-
}
|
|
49
51
|
function g(e) {
|
|
50
|
-
let
|
|
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
|
+
};
|
|
51
60
|
return {
|
|
52
61
|
extent: {
|
|
53
|
-
width:
|
|
54
|
-
height:
|
|
62
|
+
width: o(i),
|
|
63
|
+
height: o(a)
|
|
55
64
|
},
|
|
56
65
|
align: {
|
|
57
|
-
x:
|
|
58
|
-
y:
|
|
66
|
+
x: g(i),
|
|
67
|
+
y: g(a)
|
|
59
68
|
}
|
|
60
69
|
};
|
|
61
70
|
}
|
|
62
|
-
function
|
|
63
|
-
let { count: n, size: r, gap: i, fadeWidth: a, open: o
|
|
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) : {
|
|
64
73
|
x: 0,
|
|
65
74
|
y: 0
|
|
66
|
-
}, _ = e === 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 ? {
|
|
67
76
|
x: y,
|
|
68
77
|
y: 0
|
|
69
78
|
} : {
|
|
@@ -72,16 +81,16 @@ function _(e, t) {
|
|
|
72
81
|
}, x = {
|
|
73
82
|
x: b.x - g.x,
|
|
74
83
|
y: b.y - g.y
|
|
75
|
-
}, S =
|
|
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`;
|
|
76
85
|
return {
|
|
77
|
-
translate: p(g,
|
|
78
|
-
maskImage: n > 1 ? `linear-gradient(${
|
|
79
|
-
maskSize:
|
|
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`,
|
|
80
89
|
maskPosition: `${x.x}px ${x.y}px`
|
|
81
90
|
};
|
|
82
91
|
}
|
|
83
92
|
// src/components/collageFabDefaults.ts
|
|
84
|
-
var
|
|
93
|
+
var y = {
|
|
85
94
|
direction: "left",
|
|
86
95
|
size: "large",
|
|
87
96
|
variant: "circular",
|
|
@@ -92,26 +101,26 @@ var v = {
|
|
|
92
101
|
disableClickAway: !1,
|
|
93
102
|
transitionDuration: 400,
|
|
94
103
|
transitionEasing: "cubic-bezier(0.4, 0, 0.2, 1)"
|
|
95
|
-
},
|
|
104
|
+
}, b = {
|
|
96
105
|
circular: "50%",
|
|
97
106
|
rounded: "25%",
|
|
98
107
|
square: 0
|
|
99
|
-
},
|
|
100
|
-
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) {
|
|
101
110
|
return `${e}ms ${t}`;
|
|
102
111
|
}
|
|
103
|
-
function
|
|
112
|
+
function C(e) {
|
|
104
113
|
return c("MuiCollageFab", e);
|
|
105
114
|
}
|
|
106
|
-
var
|
|
115
|
+
var w = (e, t) => s({
|
|
107
116
|
root: ["root", e ? "expanded" : "collapsed"],
|
|
108
117
|
item: ["item"]
|
|
109
|
-
},
|
|
118
|
+
}, C, t), T = n("div", {
|
|
110
119
|
name: "MuiCollageFab",
|
|
111
120
|
slot: "root",
|
|
112
121
|
overridesResolver: (e, t) => t.root
|
|
113
122
|
})(({ ownerState: e }) => {
|
|
114
|
-
let { open: t, size: n, transitionDuration: r, transitionEasing: i } = e, { extent: a } =
|
|
123
|
+
let { open: t, size: n, transitionDuration: r, transitionEasing: i } = e, { extent: a } = _(e), o = S(r, i);
|
|
115
124
|
return {
|
|
116
125
|
position: "relative",
|
|
117
126
|
width: t ? a.width : n,
|
|
@@ -121,15 +130,21 @@ var C = (e, t) => s({
|
|
|
121
130
|
cursor: t ? "default" : "pointer",
|
|
122
131
|
WebkitTapHighlightColor: "transparent"
|
|
123
132
|
};
|
|
124
|
-
}),
|
|
133
|
+
}), ee = n("div", {
|
|
125
134
|
name: "MuiCollageFab",
|
|
126
135
|
slot: "item",
|
|
127
136
|
overridesResolver: (e, t) => t.item
|
|
128
137
|
})(({ ownerState: e }) => {
|
|
129
|
-
let { size: t, index: n, geometry: r, cornerRadius: i, transitionDuration: a, transitionEasing: o } = e, { align: s } =
|
|
130
|
-
...s.x === "end" ? { right: 0 } :
|
|
131
|
-
|
|
132
|
-
|
|
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);
|
|
133
148
|
return {
|
|
134
149
|
position: "absolute",
|
|
135
150
|
...c,
|
|
@@ -160,7 +175,7 @@ var C = (e, t) => s({
|
|
|
160
175
|
}
|
|
161
176
|
};
|
|
162
177
|
});
|
|
163
|
-
function
|
|
178
|
+
function te(t) {
|
|
164
179
|
let { index: n, ownerState: r, geometry: i, className: s, component: c, inert: u, itemRefs: d, slotProps: f, children: p } = t, m = e.useMemo(() => ({
|
|
165
180
|
...r,
|
|
166
181
|
index: n,
|
|
@@ -190,94 +205,99 @@ function E(t) {
|
|
|
190
205
|
});
|
|
191
206
|
return /* @__PURE__ */ l(c, { ...v });
|
|
192
207
|
}
|
|
193
|
-
var
|
|
194
|
-
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({
|
|
195
210
|
props: n,
|
|
196
211
|
name: "MuiCollageFab"
|
|
197
|
-
}), [
|
|
198
|
-
controlled:
|
|
199
|
-
default:
|
|
212
|
+
}), [I, L] = i({
|
|
213
|
+
controlled: S,
|
|
214
|
+
default: C,
|
|
200
215
|
name: "CollageFab",
|
|
201
216
|
state: "open"
|
|
202
|
-
}),
|
|
203
|
-
open:
|
|
217
|
+
}), R = e.useMemo(() => e.Children.toArray(c).filter((t) => e.isValidElement(t)), [c]), z = R.length, B = {
|
|
218
|
+
open: I,
|
|
204
219
|
direction: u,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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));
|
|
216
236
|
}, [
|
|
217
|
-
F,
|
|
218
237
|
I,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
g === "hover" && e.pointerType === "mouse" && q(!1, e);
|
|
238
|
+
L,
|
|
239
|
+
E,
|
|
240
|
+
D
|
|
241
|
+
]), Y = (e) => {
|
|
242
|
+
_ === "hover" && e.pointerType === "mouse" && J(!0, e);
|
|
225
243
|
}, X = (e) => {
|
|
226
|
-
|
|
244
|
+
_ === "hover" && e.pointerType === "mouse" && J(!1, e);
|
|
227
245
|
}, Z = (e) => {
|
|
228
|
-
|
|
246
|
+
_ !== "manual" && (G.current = e.pointerType, W.current = !1, e.pointerType === "mouse" || I || (W.current = !0, J(!0, e)));
|
|
229
247
|
}, ne = (e) => {
|
|
230
|
-
|
|
248
|
+
W.current && (W.current = !1, e.stopPropagation(), e.preventDefault());
|
|
231
249
|
}, re = (e) => {
|
|
232
|
-
|
|
233
|
-
|
|
250
|
+
_ !== "manual" && (_ === "click" ? J(!I, e) : I && G.current !== "mouse" && J(!1, e));
|
|
251
|
+
}, ie = (e) => {
|
|
252
|
+
if (_ !== "manual") {
|
|
253
|
+
if (I) {
|
|
234
254
|
if (e.key !== "Escape") return;
|
|
235
|
-
e.stopPropagation(),
|
|
236
|
-
} 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));
|
|
237
257
|
}
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
}, Q =
|
|
258
|
+
}, ae = (e) => {
|
|
259
|
+
J(!1, e);
|
|
260
|
+
}, Q = M?.root ?? T, oe = M?.item ?? ee, se = o({
|
|
241
261
|
elementType: Q,
|
|
242
|
-
externalForwardedProps:
|
|
243
|
-
externalSlotProps:
|
|
244
|
-
ownerState:
|
|
262
|
+
externalForwardedProps: F,
|
|
263
|
+
externalSlotProps: N?.root,
|
|
264
|
+
ownerState: B,
|
|
245
265
|
additionalProps: {
|
|
246
|
-
ref:
|
|
266
|
+
ref: q,
|
|
247
267
|
role: "group",
|
|
248
|
-
tabIndex: !
|
|
249
|
-
onPointerEnter:
|
|
250
|
-
onPointerLeave:
|
|
251
|
-
onPointerDown:
|
|
252
|
-
onClick:
|
|
253
|
-
onClickCapture:
|
|
254
|
-
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
|
|
255
275
|
},
|
|
256
|
-
className: [
|
|
276
|
+
className: [V.root, P]
|
|
257
277
|
});
|
|
258
278
|
if (e.useEffect(() => {
|
|
259
|
-
if (!
|
|
260
|
-
|
|
261
|
-
let e =
|
|
262
|
-
e && (e.querySelector(
|
|
263
|
-
}, [
|
|
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;
|
|
264
284
|
let $ = /* @__PURE__ */ l(Q, {
|
|
265
|
-
...
|
|
266
|
-
children:
|
|
285
|
+
...se,
|
|
286
|
+
children: R.map((e, t) => /* @__PURE__ */ l(te, {
|
|
267
287
|
index: t,
|
|
268
|
-
ownerState:
|
|
269
|
-
geometry:
|
|
270
|
-
className:
|
|
271
|
-
component:
|
|
272
|
-
inert: !
|
|
273
|
-
itemRefs:
|
|
274
|
-
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,
|
|
275
295
|
children: e
|
|
276
296
|
}, t))
|
|
277
297
|
});
|
|
278
|
-
return
|
|
279
|
-
onClickAway:
|
|
298
|
+
return O || _ === "manual" ? $ : /* @__PURE__ */ l(t, {
|
|
299
|
+
onClickAway: ae,
|
|
280
300
|
children: $
|
|
281
301
|
});
|
|
282
302
|
});
|
|
283
|
-
export {
|
|
303
|
+
export { E as CollageFab };
|
package/package.json
CHANGED