MCPcopy Create free account
hub / github.com/adobe/react-spectrum / DragPreview

Function DragPreview

packages/@react-spectrum/s2/src/DragPreview.tsx:153–193  ·  view source on GitHub ↗
(props: DragPreviewProps)

Source from the content-addressed store, hash-verified

151 * contents, use Text with the "label" and "description" slots and/or a Icon for the leading icon.
152 */
153export function DragPreview(props: DragPreviewProps) {
154 let {items, overflowMode} = props;
155 let isDraggingMultiple = items.length > 1;
156 let itemLabel = items[0]?.['text/plain'] ?? '';
157 let scale = useScale();
158
159 return (
160 <div className={dragPreviewWrapper}>
161 {isDraggingMultiple && <div className={dragPreviewCardBack} />}
162 <div className={dragPreviewCard({scale})}>
163 <Provider
164 values={[
165 [
166 TextContext,
167 {
168 slots: {
169 [DEFAULT_SLOT]: {styles: label({overflowMode})},
170 label: {styles: label({overflowMode})},
171 description: {styles: description({overflowMode})}
172 }
173 }
174 ],
175 [
176 IconContext,
177 {
178 slots: {
179 icon: {
180 render: centerBaseline({slot: 'icon', styles: iconCenterWrapper}),
181 styles: icon
182 }
183 }
184 }
185 ]
186 ]}>
187 {props.children ?? <Text>{itemLabel}</Text>}
188 {isDraggingMultiple && <div className={dragPreviewBadge}>{items.length}</div>}
189 </Provider>
190 </div>
191 </div>
192 );
193}

Callers

nothing calls this directly

Calls 2

useScaleFunction · 0.90
centerBaselineFunction · 0.90

Tested by

no test coverage detected