MCPcopy
hub / github.com/hello-pangea/dnd / selector

Function selector

src/view/droppable/connected-droppable.ts:172–258  ·  view source on GitHub ↗
(state: State, ownProps: InternalOwnProps)

Source from the content-addressed store, hash-verified

170 );
171
172 const selector = (state: State, ownProps: InternalOwnProps): MapProps => {
173 // not checking if item is disabled as we need the home list to display a placeholder
174
175 const ownPropsWithDefaultProps = attachDefaultPropsToOwnProps(ownProps);
176 const id: DroppableId = ownPropsWithDefaultProps.droppableId;
177 const type: TypeId = ownPropsWithDefaultProps.type;
178 const isEnabled = !ownPropsWithDefaultProps.isDropDisabled;
179 const renderClone: DraggableChildrenFn | null =
180 ownPropsWithDefaultProps.renderClone;
181
182 if (isDragging(state)) {
183 const critical: Critical = state.critical;
184 if (!isMatchingType(type, critical)) {
185 return idleWithoutAnimation;
186 }
187
188 const dragging: DraggableDimension = getDraggable(
189 critical,
190 state.dimensions,
191 );
192 const isDraggingOver: boolean = whatIsDraggedOver(state.impact) === id;
193
194 return getMapProps(
195 id,
196 isEnabled,
197 isDraggingOver,
198 isDraggingOver,
199 dragging,
200 renderClone,
201 );
202 }
203
204 if (state.phase === 'DROP_ANIMATING') {
205 const completed: CompletedDrag = state.completed;
206 if (!isMatchingType(type, completed.critical)) {
207 return idleWithoutAnimation;
208 }
209
210 const dragging: DraggableDimension = getDraggable(
211 completed.critical,
212 state.dimensions,
213 );
214
215 // Snapshot based on result and not impact
216 // The result might be null (cancel) but the impact is populated
217 // to move everything back
218 return getMapProps(
219 id,
220 isEnabled,
221 whatIsDraggedOverFromResult(completed.result) === id,
222 whatIsDraggedOver(completed.impact) === id,
223 dragging,
224 renderClone,
225 );
226 }
227
228 if (state.phase === 'IDLE' && state.completed && !state.shouldFlush) {
229 const completed: CompletedDrag = state.completed;

Calls 4

isMatchingTypeFunction · 0.85
getDraggableFunction · 0.85
isDraggingFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…