mui-collage-fab 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -54
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/index.d.cts +216 -0
- package/dist-lib/index.d.ts +216 -0
- package/dist-lib/index.js +222 -265
- package/package.json +81 -14
- package/dist-lib/.nojekyll +0 -0
- package/dist-lib/types/components/CollageFab.d.ts +0 -134
- 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
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { CreateSlotsAndSlotProps, SlotProps } from '@mui/material/utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The axis the buttons fan out on, starting from the anchor child.
|
|
7
|
+
*/
|
|
8
|
+
type CollageFabDirection = 'left' | 'right' | 'up' | 'down';
|
|
9
|
+
/**
|
|
10
|
+
* How the group reacts to pointers.
|
|
11
|
+
*/
|
|
12
|
+
type CollageFabTrigger = 'hover' | 'click' | 'manual';
|
|
13
|
+
/**
|
|
14
|
+
* Diameter of every button. Named sizes resolve to small 40px, medium 48px and
|
|
15
|
+
* large 56px; numeric values are used verbatim.
|
|
16
|
+
*/
|
|
17
|
+
type CollageFabSize = 'small' | 'medium' | 'large' | number;
|
|
18
|
+
/**
|
|
19
|
+
* The shape of every button: a circle, a rounded square or a sharp-cornered
|
|
20
|
+
* square.
|
|
21
|
+
*/
|
|
22
|
+
type CollageFabVariant = 'circular' | 'rounded' | 'square';
|
|
23
|
+
/**
|
|
24
|
+
* Class names the component applies, and the accepted keys for `classes`.
|
|
25
|
+
*/
|
|
26
|
+
interface CollageFabClasses {
|
|
27
|
+
/** The animated container that holds every slice. */
|
|
28
|
+
root: string;
|
|
29
|
+
/** One masked wrapper per child. */
|
|
30
|
+
item: string;
|
|
31
|
+
/** Applied to the root while the group is expanded. */
|
|
32
|
+
expanded: string;
|
|
33
|
+
/** Applied to the root while the group is collapsed. */
|
|
34
|
+
collapsed: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Every key accepted by `classes`.
|
|
38
|
+
*/
|
|
39
|
+
type CollageFabClassKey = keyof CollageFabClasses;
|
|
40
|
+
/**
|
|
41
|
+
* Slot props accepted by a custom `root` slot component.
|
|
42
|
+
*/
|
|
43
|
+
interface CollageFabRootSlotPropsOverrides {
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Slot props accepted by a custom `item` slot component.
|
|
47
|
+
*/
|
|
48
|
+
interface CollageFabItemSlotPropsOverrides {
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* State shared by the root slot and the item slots while styling.
|
|
52
|
+
*/
|
|
53
|
+
interface CollageFabOwnerState {
|
|
54
|
+
/** Whether the group is currently expanded. */
|
|
55
|
+
open: boolean;
|
|
56
|
+
/** The resolved fan-out direction. */
|
|
57
|
+
direction: CollageFabDirection;
|
|
58
|
+
/** The resolved pointer trigger mode. */
|
|
59
|
+
trigger: CollageFabTrigger;
|
|
60
|
+
/** The button diameter in pixels, after resolving the named size. */
|
|
61
|
+
size: number;
|
|
62
|
+
/** The resolved shape of every button. */
|
|
63
|
+
variant: CollageFabVariant;
|
|
64
|
+
/** The corner radius resolved from `variant`, inherited by every child. */
|
|
65
|
+
cornerRadius: number | string;
|
|
66
|
+
/** The main-axis gap in pixels. */
|
|
67
|
+
gap: number;
|
|
68
|
+
/** The fade width in pixels. */
|
|
69
|
+
fadeWidth: number;
|
|
70
|
+
/** The number of valid children currently rendered. */
|
|
71
|
+
count: number;
|
|
72
|
+
/** The morph duration in milliseconds. */
|
|
73
|
+
transitionDuration: number;
|
|
74
|
+
/** The morph easing. */
|
|
75
|
+
transitionEasing: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The per-slice CSS computed for one child.
|
|
79
|
+
*/
|
|
80
|
+
interface CollageFabItemGeometry {
|
|
81
|
+
/** The translate that moves the slice along the main axis. */
|
|
82
|
+
translate: string;
|
|
83
|
+
/** The gradient that cuts the slice out of the container. */
|
|
84
|
+
maskImage: string;
|
|
85
|
+
/** The size of that gradient, wide enough to cover the expanded row. */
|
|
86
|
+
maskSize: string;
|
|
87
|
+
/** The offset that pins the cut line in container space. */
|
|
88
|
+
maskPosition: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* State handed to the item slot. It extends the shared state with the position
|
|
92
|
+
* of the child, so an item can be styled individually.
|
|
93
|
+
*/
|
|
94
|
+
interface CollageFabItemOwnerState extends CollageFabOwnerState {
|
|
95
|
+
/** The position of the child in the stack. 0 is the anchor. */
|
|
96
|
+
index: number;
|
|
97
|
+
/** True for the anchor child (index 0). */
|
|
98
|
+
isAnchor: boolean;
|
|
99
|
+
/** The computed translate, mask image, mask size and mask position for this slice. */
|
|
100
|
+
geometry: CollageFabItemGeometry;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Replaceable internal components.
|
|
104
|
+
*/
|
|
105
|
+
interface CollageFabSlots {
|
|
106
|
+
/** The animated container. A replacement must forward `ref`, which `ClickAwayListener` needs. */
|
|
107
|
+
root?: React.ElementType;
|
|
108
|
+
/** One masked wrapper per child, shaped by `variant`. */
|
|
109
|
+
item?: React.ElementType;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The `slots` and `slotProps` props, typed per slot.
|
|
113
|
+
*/
|
|
114
|
+
type CollageFabSlotsAndSlotProps = CreateSlotsAndSlotProps<CollageFabSlots, {
|
|
115
|
+
/** Props for the root slot, or a resolver that receives the shared ownerState. */
|
|
116
|
+
root: SlotProps<'div', CollageFabRootSlotPropsOverrides, CollageFabOwnerState>;
|
|
117
|
+
/** Props for the item slot, or a resolver that receives the item ownerState. */
|
|
118
|
+
item: SlotProps<'div', CollageFabItemSlotPropsOverrides, CollageFabItemOwnerState>;
|
|
119
|
+
}>;
|
|
120
|
+
/**
|
|
121
|
+
* Props for the CollageFab component.
|
|
122
|
+
*/
|
|
123
|
+
interface CollageFabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
124
|
+
/**
|
|
125
|
+
* The buttons to stack. Every valid element is wrapped in a masked slot shaped
|
|
126
|
+
* by `variant`. Order matters: index 0 is the anchor, the rest fan out along
|
|
127
|
+
* `direction`.
|
|
128
|
+
*/
|
|
129
|
+
children?: React.ReactNode;
|
|
130
|
+
/**
|
|
131
|
+
* The axis the buttons fan out on, starting from the anchor child. `left`
|
|
132
|
+
* matches the original right-anchored behaviour.
|
|
133
|
+
*/
|
|
134
|
+
direction?: CollageFabDirection;
|
|
135
|
+
/**
|
|
136
|
+
* Diameter of every button. Named sizes resolve to small 40px, medium 48px,
|
|
137
|
+
* large 56px; numeric values are used verbatim.
|
|
138
|
+
*/
|
|
139
|
+
size?: CollageFabSize;
|
|
140
|
+
/**
|
|
141
|
+
* The shape of every button. `'circular'` clips each slice to a circle,
|
|
142
|
+
* `'rounded'` to a rounded square and `'square'` to a sharp-cornered square.
|
|
143
|
+
* The mask still slices the silhouette along the main axis, so the stack reads
|
|
144
|
+
* as one shape when collapsed and as separate shapes when expanded.
|
|
145
|
+
*/
|
|
146
|
+
variant?: CollageFabVariant;
|
|
147
|
+
/**
|
|
148
|
+
* Main-axis gap in pixels between two buttons when expanded.
|
|
149
|
+
*/
|
|
150
|
+
gap?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Width in pixels of the soft cut line between two slices.
|
|
153
|
+
*/
|
|
154
|
+
fadeWidth?: number;
|
|
155
|
+
/**
|
|
156
|
+
* How the group reacts to pointers. `'hover'` opens on mouse enter, closes on
|
|
157
|
+
* mouse leave and toggles on touch or pen tap; `'click'` toggles on any click;
|
|
158
|
+
* `'manual'` disables all built-in pointer interaction.
|
|
159
|
+
*/
|
|
160
|
+
trigger?: CollageFabTrigger;
|
|
161
|
+
/**
|
|
162
|
+
* If `true`, the group is expanded. Use it to control the component.
|
|
163
|
+
*/
|
|
164
|
+
open?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* If `true`, the group is expanded by default (uncontrolled).
|
|
167
|
+
*/
|
|
168
|
+
defaultOpen?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Callback fired when the group is expanded.
|
|
171
|
+
*/
|
|
172
|
+
onOpen?: (event: React.SyntheticEvent) => void;
|
|
173
|
+
/**
|
|
174
|
+
* Callback fired when the group is collapsed.
|
|
175
|
+
*/
|
|
176
|
+
onClose?: (event: React.SyntheticEvent) => void;
|
|
177
|
+
/**
|
|
178
|
+
* If `true`, the group does not collapse when the user clicks away from it.
|
|
179
|
+
*/
|
|
180
|
+
disableClickAway?: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Duration of the morph, in milliseconds.
|
|
183
|
+
*/
|
|
184
|
+
transitionDuration?: number;
|
|
185
|
+
/**
|
|
186
|
+
* Easing of the morph.
|
|
187
|
+
*/
|
|
188
|
+
transitionEasing?: string;
|
|
189
|
+
/**
|
|
190
|
+
* System prop that defines system overrides as well as additional CSS styles.
|
|
191
|
+
*/
|
|
192
|
+
sx?: SxProps<Theme>;
|
|
193
|
+
/**
|
|
194
|
+
* Override or extend the styles applied to the component.
|
|
195
|
+
*/
|
|
196
|
+
classes?: Partial<CollageFabClasses>;
|
|
197
|
+
/**
|
|
198
|
+
* Custom components for the `root` and `item` slots.
|
|
199
|
+
*/
|
|
200
|
+
slots?: CollageFabSlotsAndSlotProps['slots'];
|
|
201
|
+
/**
|
|
202
|
+
* Props for each slot. `slotProps.item` accepts either a props object or an
|
|
203
|
+
* `(ownerState) => props` callback, which is the per-child escape hatch.
|
|
204
|
+
*/
|
|
205
|
+
slotProps?: CollageFabSlotsAndSlotProps['slotProps'];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* A floating action button that stacks several children into a single shape and
|
|
209
|
+
* unfolds them along a configurable direction on interaction. The root animates
|
|
210
|
+
* its own main-axis extent and applies one shared drop shadow, while each child
|
|
211
|
+
* is clipped by a moving gradient mask.
|
|
212
|
+
*/
|
|
213
|
+
declare const CollageFab: React.ForwardRefExoticComponent<CollageFabProps & React.RefAttributes<HTMLDivElement>>;
|
|
214
|
+
|
|
215
|
+
export { CollageFab };
|
|
216
|
+
export type { CollageFabClassKey, CollageFabClasses, CollageFabDirection, CollageFabItemGeometry, CollageFabItemOwnerState, CollageFabItemSlotPropsOverrides, CollageFabOwnerState, CollageFabProps, CollageFabRootSlotPropsOverrides, CollageFabSize, CollageFabSlots, CollageFabSlotsAndSlotProps, CollageFabTrigger, CollageFabVariant };
|