- Begin to integrate DND with trello
- Resolve all ESLint issues in DND Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -3,8 +3,6 @@ import React, { forwardRef } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import InstanceRenderMgr from "../../utils/instanceRenderMgr";
|
import InstanceRenderMgr from "../../utils/instanceRenderMgr";
|
||||||
|
|
||||||
//To be used as a form element only.
|
|
||||||
const { Option } = Select;
|
|
||||||
const BillLineSearchSelect = ({ options, disabled, allowRemoved, ...restProps }, ref) => {
|
const BillLineSearchSelect = ({ options, disabled, allowRemoved, ...restProps }, ref) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ export function ProductionBoardKanbanComponent({
|
|||||||
|
|
||||||
const handleDragEnd = async (cardId, sourceLaneId, targetLaneId, position, cardDetails) => {
|
const handleDragEnd = async (cardId, sourceLaneId, targetLaneId, position, cardDetails) => {
|
||||||
logImEXEvent("kanban_drag_end");
|
logImEXEvent("kanban_drag_end");
|
||||||
|
|
||||||
setIsMoving(true);
|
setIsMoving(true);
|
||||||
|
|
||||||
const sameColumnTransfer = sourceLaneId === targetLaneId;
|
const sameColumnTransfer = sourceLaneId === targetLaneId;
|
||||||
@@ -152,6 +151,11 @@ export function ProductionBoardKanbanComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onDragEnd = ({ draggableId, type, source, reason, mode, destination, combine }) => {
|
||||||
|
if (!type || type !== "lane") return;
|
||||||
|
console.log("onDragEnd", { draggableId, type, source, reason, mode, destination, combine });
|
||||||
|
};
|
||||||
|
|
||||||
const totalHrs = data
|
const totalHrs = data
|
||||||
.reduce(
|
.reduce(
|
||||||
(acc, val) => acc + (val.labhrs?.aggregate?.sum?.mod_lb_hrs || 0) + (val.larhrs?.aggregate?.sum?.mod_lb_hrs || 0),
|
(acc, val) => acc + (val.labhrs?.aggregate?.sum?.mod_lb_hrs || 0) + (val.larhrs?.aggregate?.sum?.mod_lb_hrs || 0),
|
||||||
@@ -260,7 +264,7 @@ export function ProductionBoardKanbanComponent({
|
|||||||
<StickyContainer>
|
<StickyContainer>
|
||||||
<Board
|
<Board
|
||||||
data={boardLanes}
|
data={boardLanes}
|
||||||
handleDragEnd={handleDragEnd}
|
onDragEnd={onDragEnd}
|
||||||
style={{ height: "100%", backgroundColor: "transparent", overflowY: "auto" }}
|
style={{ height: "100%", backgroundColor: "transparent", overflowY: "auto" }}
|
||||||
components={components}
|
components={components}
|
||||||
orientation={orientation}
|
orientation={orientation}
|
||||||
@@ -272,7 +276,7 @@ export function ProductionBoardKanbanComponent({
|
|||||||
<div>
|
<div>
|
||||||
<Board
|
<Board
|
||||||
data={boardLanes}
|
data={boardLanes}
|
||||||
handleDragEnd={handleDragEnd}
|
onDragEnd={onDragEnd}
|
||||||
style={{ backgroundColor: "transparent", overflowY: "auto" }}
|
style={{ backgroundColor: "transparent", overflowY: "auto" }}
|
||||||
components={components}
|
components={components}
|
||||||
collapsibleLanes
|
collapsibleLanes
|
||||||
|
|||||||
@@ -14,14 +14,13 @@ const LaneHeaderComponent = ({
|
|||||||
label,
|
label,
|
||||||
title,
|
title,
|
||||||
titleStyle,
|
titleStyle,
|
||||||
labelStyle,
|
labelStyle
|
||||||
laneDraggable
|
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LaneHeader onDoubleClick={onDoubleClick} editLaneTitle={editLaneTitle}>
|
<LaneHeader onDoubleClick={onDoubleClick} editLaneTitle={editLaneTitle}>
|
||||||
<Title draggable={laneDraggable} style={titleStyle}>
|
<Title style={titleStyle}>
|
||||||
{editLaneTitle ? (
|
{editLaneTitle ? (
|
||||||
<InlineInput
|
<InlineInput
|
||||||
value={title}
|
value={title}
|
||||||
@@ -48,7 +47,6 @@ LaneHeaderComponent.propTypes = {
|
|||||||
updateTitle: PropTypes.func,
|
updateTitle: PropTypes.func,
|
||||||
editLaneTitle: PropTypes.bool,
|
editLaneTitle: PropTypes.bool,
|
||||||
canAddLanes: PropTypes.bool,
|
canAddLanes: PropTypes.bool,
|
||||||
laneDraggable: PropTypes.bool,
|
|
||||||
label: PropTypes.string,
|
label: PropTypes.string,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
onDelete: PropTypes.func,
|
onDelete: PropTypes.func,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from "react-redux";
|
|||||||
// import Container from "../dnd/Container";
|
// import Container from "../dnd/Container";
|
||||||
// import Draggable from "../dnd/Draggable";
|
// import Draggable from "../dnd/Draggable";
|
||||||
|
|
||||||
import { DragDropContext } from "../dnd/lib";
|
import { DragDropContext, Droppable } from "../dnd/lib";
|
||||||
|
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import pick from "lodash/pick";
|
import pick from "lodash/pick";
|
||||||
@@ -23,9 +23,6 @@ import * as actions from "../../../redux/trello/trello.actions.js";
|
|||||||
* @param {Object} props.components - Custom components to use in the board
|
* @param {Object} props.components - Custom components to use in the board
|
||||||
* @param {Object} props.data - The initial data for the board
|
* @param {Object} props.data - The initial data for the board
|
||||||
* @param {boolean} props.draggable - Whether the board is draggable
|
* @param {boolean} props.draggable - Whether the board is draggable
|
||||||
* @param {boolean} props.laneDraggable - Whether the lanes in the board are draggable
|
|
||||||
* @param {string} props.laneDragClass - The CSS class to apply when a lane is being dragged
|
|
||||||
* @param {string} props.laneDropClass - The CSS class to apply when a lane is dropped
|
|
||||||
* @param {Object} props.style - The CSS styles to apply to the board
|
* @param {Object} props.style - The CSS styles to apply to the board
|
||||||
* @param {Function} props.onDataChange - Callback function when the board data changes
|
* @param {Function} props.onDataChange - Callback function when the board data changes
|
||||||
* @param {Function} props.onCardAdd - Callback function when a card is added
|
* @param {Function} props.onCardAdd - Callback function when a card is added
|
||||||
@@ -38,14 +35,13 @@ import * as actions from "../../../redux/trello/trello.actions.js";
|
|||||||
* @param {Function} props.onLaneAdd - Callback function when a lane is added
|
* @param {Function} props.onLaneAdd - Callback function when a lane is added
|
||||||
* @param {Function} props.onLaneDelete - Callback function when a lane is deleted
|
* @param {Function} props.onLaneDelete - Callback function when a lane is deleted
|
||||||
* @param {Function} props.onLaneUpdate - Callback function when a lane is updated
|
* @param {Function} props.onLaneUpdate - Callback function when a lane is updated
|
||||||
|
* @param {Function} props.onDragEnd - Callback function when a drag ends
|
||||||
* @param {boolean} props.editable - Whether the board is editable
|
* @param {boolean} props.editable - Whether the board is editable
|
||||||
* @param {boolean} props.canAddLanes - Whether lanes can be added to the board
|
* @param {boolean} props.canAddLanes - Whether lanes can be added to the board
|
||||||
* @param {Object} props.laneStyle - The CSS styles to apply to the lanes
|
* @param {Object} props.laneStyle - The CSS styles to apply to the lanes
|
||||||
* @param {Function} props.onCardMoveAcrossLanes - Callback function when a card is moved across lanes
|
* @param {Function} props.onCardMoveAcrossLanes - Callback function when a card is moved across lanes
|
||||||
* @param {string} props.orientation - The orientation of the board ("horizontal" or "vertical")
|
* @param {string} props.orientation - The orientation of the board ("horizontal" or "vertical")
|
||||||
* @param {Function} props.eventBusHandle - Function to handle events from the event bus
|
* @param {Function} props.eventBusHandle - Function to handle events from the event bus
|
||||||
* @param {Function} props.handleLaneDragStart - Callback function when a lane drag starts
|
|
||||||
* @param {Function} props.handleLaneDragEnd - Callback function when a lane drag ends
|
|
||||||
* @param {Object} props.reducerData - The initial data for the Redux reducer
|
* @param {Object} props.reducerData - The initial data for the Redux reducer
|
||||||
* @param {Object} props.cardStyle - The CSS styles to apply to the cards
|
* @param {Object} props.cardStyle - The CSS styles to apply to the cards
|
||||||
* @param {Object} props.otherProps - Any other props to pass to the board
|
* @param {Object} props.otherProps - Any other props to pass to the board
|
||||||
@@ -56,9 +52,6 @@ const BoardContainer = ({
|
|||||||
components,
|
components,
|
||||||
data,
|
data,
|
||||||
draggable = false,
|
draggable = false,
|
||||||
laneDraggable = true,
|
|
||||||
laneDragClass = "react_trello_dragLaneClass",
|
|
||||||
laneDropClass = "react_trello_dragLaneDropClass",
|
|
||||||
style,
|
style,
|
||||||
onDataChange = () => {},
|
onDataChange = () => {},
|
||||||
onCardAdd = () => {},
|
onCardAdd = () => {},
|
||||||
@@ -71,14 +64,13 @@ const BoardContainer = ({
|
|||||||
onLaneAdd = () => {},
|
onLaneAdd = () => {},
|
||||||
onLaneDelete = () => {},
|
onLaneDelete = () => {},
|
||||||
onLaneUpdate = () => {},
|
onLaneUpdate = () => {},
|
||||||
|
onDragEnd = () => {},
|
||||||
editable = false,
|
editable = false,
|
||||||
canAddLanes = false,
|
canAddLanes = false,
|
||||||
laneStyle,
|
laneStyle,
|
||||||
onCardMoveAcrossLanes = () => {},
|
onCardMoveAcrossLanes = () => {},
|
||||||
orientation = "horizontal",
|
orientation = "horizontal",
|
||||||
eventBusHandle,
|
eventBusHandle,
|
||||||
handleLaneDragStart = () => {},
|
|
||||||
handleLaneDragEnd = () => {},
|
|
||||||
reducerData,
|
reducerData,
|
||||||
cardStyle,
|
cardStyle,
|
||||||
...otherProps
|
...otherProps
|
||||||
@@ -138,26 +130,38 @@ const BoardContainer = ({
|
|||||||
}
|
}
|
||||||
}, [currentReducerData, reducerData, onDataChange]);
|
}, [currentReducerData, reducerData, onDataChange]);
|
||||||
|
|
||||||
const onDragStart = useCallback(
|
/**
|
||||||
({ payload }) => {
|
* onDragUpdate
|
||||||
handleLaneDragStart(payload.id);
|
* @param draggableId
|
||||||
},
|
* @param type
|
||||||
[handleLaneDragStart]
|
* @param source
|
||||||
);
|
* @param mode
|
||||||
|
* @param combine
|
||||||
|
* @param destination
|
||||||
|
*/
|
||||||
|
const onDragUpdate = ({ draggableId, type, source, mode, combine, destination }) => {};
|
||||||
|
|
||||||
const onLaneDrop = useCallback(
|
/**
|
||||||
({ removedIndex, addedIndex, payload }) => {
|
* onDragStart
|
||||||
if (removedIndex !== addedIndex) {
|
* @type {(function({draggableId: *, type: *, source: *, mode: *}): void)|*}
|
||||||
dispatch(actions.moveLane({ oldIndex: removedIndex, newIndex: addedIndex }));
|
*/
|
||||||
handleLaneDragEnd(removedIndex, addedIndex, payload);
|
const onDragStart = useCallback(({ draggableId, type, source, mode }) => {}, []);
|
||||||
}
|
|
||||||
},
|
|
||||||
[dispatch, handleLaneDragEnd]
|
|
||||||
);
|
|
||||||
|
|
||||||
const onDragEnd = (...params) => {
|
/**
|
||||||
console.dir(params);
|
* onBeforeDragStart
|
||||||
};
|
* @param draggableId
|
||||||
|
* @param type
|
||||||
|
* @param source
|
||||||
|
* @param mode
|
||||||
|
*/
|
||||||
|
const onBeforeDragStart = ({ draggableId, type, source, mode }) => {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* onBeforeCapture
|
||||||
|
* @param draggableId
|
||||||
|
* @param mode
|
||||||
|
*/
|
||||||
|
const onBeforeCapture = ({ draggableId, mode }) => {};
|
||||||
|
|
||||||
const getCardDetails = useCallback(
|
const getCardDetails = useCallback(
|
||||||
(laneId, cardIndex) => {
|
(laneId, cardIndex) => {
|
||||||
@@ -166,13 +170,6 @@ const BoardContainer = ({
|
|||||||
[currentReducerData]
|
[currentReducerData]
|
||||||
);
|
);
|
||||||
|
|
||||||
const getLaneDetails = useCallback(
|
|
||||||
(index) => {
|
|
||||||
return currentReducerData.lanes[index];
|
|
||||||
},
|
|
||||||
[currentReducerData]
|
|
||||||
);
|
|
||||||
|
|
||||||
const hideEditableLane = () => {
|
const hideEditableLane = () => {
|
||||||
setAddLaneMode(false);
|
setAddLaneMode(false);
|
||||||
};
|
};
|
||||||
@@ -193,9 +190,6 @@ const BoardContainer = ({
|
|||||||
components,
|
components,
|
||||||
data,
|
data,
|
||||||
draggable,
|
draggable,
|
||||||
laneDraggable,
|
|
||||||
laneDragClass,
|
|
||||||
laneDropClass,
|
|
||||||
style,
|
style,
|
||||||
onDataChange,
|
onDataChange,
|
||||||
onCardAdd,
|
onCardAdd,
|
||||||
@@ -214,8 +208,6 @@ const BoardContainer = ({
|
|||||||
onCardMoveAcrossLanes,
|
onCardMoveAcrossLanes,
|
||||||
orientation,
|
orientation,
|
||||||
eventBusHandle,
|
eventBusHandle,
|
||||||
handleLaneDragStart,
|
|
||||||
handleLaneDragEnd,
|
|
||||||
reducerData,
|
reducerData,
|
||||||
cardStyle,
|
cardStyle,
|
||||||
...otherProps
|
...otherProps
|
||||||
@@ -233,7 +225,6 @@ const BoardContainer = ({
|
|||||||
"onLaneClick",
|
"onLaneClick",
|
||||||
"laneSortFunction",
|
"laneSortFunction",
|
||||||
"draggable",
|
"draggable",
|
||||||
"laneDraggable",
|
|
||||||
"cardDraggable",
|
"cardDraggable",
|
||||||
"collapsibleLanes",
|
"collapsibleLanes",
|
||||||
"canAddLanes",
|
"canAddLanes",
|
||||||
@@ -254,14 +245,12 @@ const BoardContainer = ({
|
|||||||
<PopoverWrapper>
|
<PopoverWrapper>
|
||||||
<DragDropContext
|
<DragDropContext
|
||||||
onDragEnd={onDragEnd}
|
onDragEnd={onDragEnd}
|
||||||
// orientation={orientation === "vertical" ? "vertical" : "horizontal"}
|
onDragUpdate={onDragUpdate}
|
||||||
// onDragStart={onDragStart}
|
onDragStart={onDragStart}
|
||||||
// dragClass={laneDragClass}
|
onBeforeDragStart={onBeforeDragStart}
|
||||||
// dropClass={laneDropClass}
|
onBeforeCapture={onBeforeCapture}
|
||||||
// onDrop={onLaneDrop}
|
contextId={groupName}
|
||||||
// lockAxis={orientation === "vertical" ? "y" : "x"}
|
|
||||||
// getChildPayload={(index) => getLaneDetails(index)}
|
// getChildPayload={(index) => getLaneDetails(index)}
|
||||||
// groupName={groupName}
|
|
||||||
>
|
>
|
||||||
{currentReducerData.lanes.map((lane, index) => {
|
{currentReducerData.lanes.map((lane, index) => {
|
||||||
const { id, droppable, ...laneOtherProps } = lane;
|
const { id, droppable, ...laneOtherProps } = lane;
|
||||||
@@ -284,17 +273,17 @@ const BoardContainer = ({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{canAddLanes && (
|
||||||
|
<Droppable type="placeholder" direction={orientation === "horizontal" ? "vertical" : "grid"}>
|
||||||
|
{editable && !addLaneMode ? (
|
||||||
|
<components.NewLaneSection onClick={showEditableLane} />
|
||||||
|
) : (
|
||||||
|
addLaneMode && <components.NewLaneForm onCancel={hideEditableLane} onAdd={addNewLane} />
|
||||||
|
)}
|
||||||
|
</Droppable>
|
||||||
|
)}
|
||||||
</DragDropContext>
|
</DragDropContext>
|
||||||
</PopoverWrapper>
|
</PopoverWrapper>
|
||||||
{/*{canAddLanes && (*/}
|
|
||||||
{/* <Container orientation={orientation === "vertical" ? "vertical" : "horizontal"}>*/}
|
|
||||||
{/* {editable && !addLaneMode ? (*/}
|
|
||||||
{/* <components.NewLaneSection onClick={showEditableLane} />*/}
|
|
||||||
{/* ) : (*/}
|
|
||||||
{/* addLaneMode && <components.NewLaneForm onCancel={hideEditableLane} onAdd={addNewLane} />*/}
|
|
||||||
{/* )}*/}
|
|
||||||
{/* </Container>*/}
|
|
||||||
{/*)}*/}
|
|
||||||
</components.BoardWrapper>
|
</components.BoardWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -325,15 +314,10 @@ BoardContainer.propTypes = {
|
|||||||
hideCardDeleteIcon: PropTypes.bool,
|
hideCardDeleteIcon: PropTypes.bool,
|
||||||
handleDragStart: PropTypes.func,
|
handleDragStart: PropTypes.func,
|
||||||
handleDragEnd: PropTypes.func,
|
handleDragEnd: PropTypes.func,
|
||||||
handleLaneDragStart: PropTypes.func,
|
|
||||||
handleLaneDragEnd: PropTypes.func,
|
|
||||||
style: PropTypes.object,
|
style: PropTypes.object,
|
||||||
tagStyle: PropTypes.object,
|
tagStyle: PropTypes.object,
|
||||||
laneDraggable: PropTypes.bool,
|
|
||||||
cardDraggable: PropTypes.bool,
|
cardDraggable: PropTypes.bool,
|
||||||
cardDragClass: PropTypes.string,
|
cardDragClass: PropTypes.string,
|
||||||
laneDragClass: PropTypes.string,
|
|
||||||
laneDropClass: PropTypes.string,
|
|
||||||
onCardMoveAcrossLanes: PropTypes.func,
|
onCardMoveAcrossLanes: PropTypes.func,
|
||||||
orientation: PropTypes.string,
|
orientation: PropTypes.string,
|
||||||
cardStyle: PropTypes.object
|
cardStyle: PropTypes.object
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import { Droppable, Draggable } from "../dnd/lib/index.js";
|
|||||||
* @param {Function} props.onLaneClick - Callback function when a lane is clicked
|
* @param {Function} props.onLaneClick - Callback function when a lane is clicked
|
||||||
* @param {Function} props.onLaneScroll - Callback function when a lane is scrolled
|
* @param {Function} props.onLaneScroll - Callback function when a lane is scrolled
|
||||||
* @param {boolean} props.editable - Whether the lane is editable
|
* @param {boolean} props.editable - Whether the lane is editable
|
||||||
* @param {boolean} props.laneDraggable - Whether the lane is draggable
|
|
||||||
* @param {boolean} props.cardDraggable - Whether the cards are draggable
|
* @param {boolean} props.cardDraggable - Whether the cards are draggable
|
||||||
* @param {string} props.cardDragClass - The CSS class to apply when a card is being dragged
|
* @param {string} props.cardDragClass - The CSS class to apply when a card is being dragged
|
||||||
* @param {string} props.cardDropClass - The CSS class to apply when a card is dropped
|
* @param {string} props.cardDropClass - The CSS class to apply when a card is dropped
|
||||||
@@ -87,7 +86,6 @@ function Lane({
|
|||||||
onLaneClick = () => {},
|
onLaneClick = () => {},
|
||||||
onLaneScroll = () => {},
|
onLaneScroll = () => {},
|
||||||
editable = false,
|
editable = false,
|
||||||
laneDraggable = false,
|
|
||||||
cardDraggable = true,
|
cardDraggable = true,
|
||||||
cardDragClass,
|
cardDragClass,
|
||||||
cardDropClass,
|
cardDropClass,
|
||||||
@@ -178,7 +176,6 @@ function Lane({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCardClick = (e, card) => {
|
const handleCardClick = (e, card) => {
|
||||||
console.log("hit");
|
|
||||||
onCardClick && onCardClick(card.id, card.metadata, card.laneId);
|
onCardClick && onCardClick(card.id, card.metadata, card.laneId);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
};
|
};
|
||||||
@@ -300,6 +297,7 @@ function Lane({
|
|||||||
<Droppable
|
<Droppable
|
||||||
direction={orientation === "horizontal" ? "vertical" : "grid"}
|
direction={orientation === "horizontal" ? "vertical" : "grid"}
|
||||||
droppableId={`lane-${index}`}
|
droppableId={`lane-${index}`}
|
||||||
|
type="lane"
|
||||||
// dragClass={cardDragClass}
|
// dragClass={cardDragClass}
|
||||||
// dropClass={cardDropClass}
|
// dropClass={cardDropClass}
|
||||||
// onDragStart={onDragStart}
|
// onDragStart={onDragStart}
|
||||||
@@ -360,7 +358,6 @@ function Lane({
|
|||||||
collapsibleLanes,
|
collapsibleLanes,
|
||||||
droppable,
|
droppable,
|
||||||
editable,
|
editable,
|
||||||
laneDraggable,
|
|
||||||
cardDraggable,
|
cardDraggable,
|
||||||
cardDragClass,
|
cardDragClass,
|
||||||
cardDropClass,
|
cardDropClass,
|
||||||
@@ -422,7 +419,6 @@ Lane.propTypes = {
|
|||||||
onLaneClick: PropTypes.func,
|
onLaneClick: PropTypes.func,
|
||||||
onLaneScroll: PropTypes.func,
|
onLaneScroll: PropTypes.func,
|
||||||
editable: PropTypes.bool,
|
editable: PropTypes.bool,
|
||||||
laneDraggable: PropTypes.bool,
|
|
||||||
cardDraggable: PropTypes.bool,
|
cardDraggable: PropTypes.bool,
|
||||||
cardDragClass: PropTypes.string,
|
cardDragClass: PropTypes.string,
|
||||||
cardDropClass: PropTypes.string,
|
cardDropClass: PropTypes.string,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const forceEnable = () => {
|
|||||||
export const start = (key) => {
|
export const start = (key) => {
|
||||||
// we want to strip all the code out for production builds
|
// we want to strip all the code out for production builds
|
||||||
// draw back: can only do timings in dev env (which seems to be fine for now)
|
// draw back: can only do timings in dev env (which seems to be fine for now)
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (import.meta.env.DEV) {
|
||||||
if (!isTimingsEnabled()) {
|
if (!isTimingsEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ export const start = (key) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const finish = (key) => {
|
export const finish = (key) => {
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (import.meta.env.DEV) {
|
||||||
if (!isTimingsEnabled()) {
|
if (!isTimingsEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const isProduction = process.env.NODE_ENV === "production";
|
const isProduction = import.meta.env.PROD;
|
||||||
|
|
||||||
// not replacing newlines (which \s does)
|
// not replacing newlines (which \s does)
|
||||||
const spacesAndTabs = /[ \t]{2,}/g;
|
const spacesAndTabs = /[ \t]{2,}/g;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable no-restricted-syntax */
|
/* eslint-disable no-restricted-syntax */
|
||||||
const isProduction = process.env.NODE_ENV === "production";
|
const isProduction = import.meta.env.PROD;
|
||||||
const prefix = "Invariant failed";
|
const prefix = "Invariant failed";
|
||||||
|
|
||||||
// Want to use this:
|
// Want to use this:
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const getScrollableDroppableOver = (target, droppables) => {
|
|||||||
});
|
});
|
||||||
return maybe;
|
return maybe;
|
||||||
};
|
};
|
||||||
export default ({ center, destination, droppables }) => {
|
const getBestScrollableDroppable = ({ center, destination, droppables }) => {
|
||||||
// We need to scroll the best droppable frame we can so that the
|
// We need to scroll the best droppable frame we can so that the
|
||||||
// placeholder buffer logic works correctly
|
// placeholder buffer logic works correctly
|
||||||
|
|
||||||
@@ -41,3 +41,5 @@ export default ({ center, destination, droppables }) => {
|
|||||||
const dimension = getScrollableDroppableOver(center, droppables);
|
const dimension = getScrollableDroppableOver(center, droppables);
|
||||||
return dimension;
|
return dimension;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getBestScrollableDroppable;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import getScroll from "./get-scroll";
|
import getScroll from "./get-scroll";
|
||||||
import { canScrollDroppable } from "../can-scroll";
|
import { canScrollDroppable } from "../can-scroll";
|
||||||
|
|
||||||
export default ({ droppable, subject, center, dragStartTime, shouldUseTimeDampening }) => {
|
const getDroppableScrollChange = ({ droppable, subject, center, dragStartTime, shouldUseTimeDampening }) => {
|
||||||
// We know this has a closestScrollable
|
// We know this has a closestScrollable
|
||||||
const frame = droppable.frame;
|
const frame = droppable.frame;
|
||||||
|
|
||||||
@@ -18,3 +18,5 @@ export default ({ droppable, subject, center, dragStartTime, shouldUseTimeDampen
|
|||||||
});
|
});
|
||||||
return scroll && canScrollDroppable(droppable, scroll) ? scroll : null;
|
return scroll && canScrollDroppable(droppable, scroll) ? scroll : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getDroppableScrollChange;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { warning } from "../../../dev-warning";
|
import { warning } from "../../../dev-warning";
|
||||||
|
|
||||||
export default ({ startOfRange, endOfRange, current }) => {
|
const getPercentage = ({ startOfRange, endOfRange, current }) => {
|
||||||
const range = endOfRange - startOfRange;
|
const range = endOfRange - startOfRange;
|
||||||
if (range === 0) {
|
if (range === 0) {
|
||||||
warning(`
|
warning(`
|
||||||
@@ -11,6 +11,8 @@ export default ({ startOfRange, endOfRange, current }) => {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
const currentInRange = current - startOfRange;
|
const currentInRange = current - startOfRange;
|
||||||
const percentage = currentInRange / range;
|
|
||||||
return percentage;
|
return currentInRange / range;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getPercentage;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default ({ container, subject, proposedScroll }) => {
|
const adjustForSizeLimits = ({ container, subject, proposedScroll }) => {
|
||||||
const isTooBigVertically = subject.height > container.height;
|
const isTooBigVertically = subject.height > container.height;
|
||||||
const isTooBigHorizontally = subject.width > container.width;
|
const isTooBigHorizontally = subject.width > container.width;
|
||||||
|
|
||||||
@@ -19,3 +19,5 @@ export default ({ container, subject, proposedScroll }) => {
|
|||||||
y: isTooBigVertically ? 0 : proposedScroll.y
|
y: isTooBigVertically ? 0 : proposedScroll.y
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default adjustForSizeLimits;
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import minScroll from "./min-scroll";
|
|||||||
|
|
||||||
const accelerateAt = config.durationDampening.accelerateAt;
|
const accelerateAt = config.durationDampening.accelerateAt;
|
||||||
const stopAt = config.durationDampening.stopDampeningAt;
|
const stopAt = config.durationDampening.stopDampeningAt;
|
||||||
export default (proposedScroll, dragStartTime) => {
|
|
||||||
|
const dampenValueByTime = (proposedScroll, dragStartTime) => {
|
||||||
const startOfRange = dragStartTime;
|
const startOfRange = dragStartTime;
|
||||||
const endOfRange = stopAt;
|
const endOfRange = stopAt;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
@@ -29,3 +30,5 @@ export default (proposedScroll, dragStartTime) => {
|
|||||||
const scroll = proposedScroll * config.ease(betweenAccelerateAtAndStopAtPercentage);
|
const scroll = proposedScroll * config.ease(betweenAccelerateAtAndStopAtPercentage);
|
||||||
return Math.ceil(scroll);
|
return Math.ceil(scroll);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default dampenValueByTime;
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
import config from "../../config";
|
import config from "../../config";
|
||||||
|
|
||||||
|
const getDistanceThresholds = (container, axis) => {
|
||||||
|
const startScrollingFrom = container[axis.size] * config.startFromPercentage;
|
||||||
|
const maxScrollValueAt = container[axis.size] * config.maxScrollAtPercentage;
|
||||||
|
return {
|
||||||
|
startScrollingFrom,
|
||||||
|
maxScrollValueAt
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// all in pixels
|
// all in pixels
|
||||||
|
|
||||||
// converts the percentages in the config into actual pixel values
|
// converts the percentages in the config into actual pixel values
|
||||||
export default (container, axis) => {
|
export default getDistanceThresholds;
|
||||||
const startScrollingFrom = container[axis.size] * config.startFromPercentage;
|
|
||||||
const maxScrollValueAt = container[axis.size] * config.maxScrollAtPercentage;
|
|
||||||
const thresholds = {
|
|
||||||
startScrollingFrom,
|
|
||||||
maxScrollValueAt
|
|
||||||
};
|
|
||||||
return thresholds;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import getPercentage from "../../get-percentage";
|
|||||||
import config from "../../config";
|
import config from "../../config";
|
||||||
import minScroll from "./min-scroll";
|
import minScroll from "./min-scroll";
|
||||||
|
|
||||||
export default (distanceToEdge, thresholds) => {
|
const getValueFromDistance = (distanceToEdge, thresholds) => {
|
||||||
/*
|
/*
|
||||||
// This function only looks at the distance to one edge
|
// This function only looks at the distance to one edge
|
||||||
// Example: looking at bottom edge
|
// Example: looking at bottom edge
|
||||||
@@ -50,3 +50,5 @@ export default (distanceToEdge, thresholds) => {
|
|||||||
// scroll will always be a positive integer
|
// scroll will always be a positive integer
|
||||||
return Math.ceil(scroll);
|
return Math.ceil(scroll);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getValueFromDistance;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import getValueFromDistance from "./get-value-from-distance";
|
|||||||
import dampenValueByTime from "./dampen-value-by-time";
|
import dampenValueByTime from "./dampen-value-by-time";
|
||||||
import minScroll from "./min-scroll";
|
import minScroll from "./min-scroll";
|
||||||
|
|
||||||
export default ({ distanceToEdge, thresholds, dragStartTime, shouldUseTimeDampening }) => {
|
const getValue = ({ distanceToEdge, thresholds, dragStartTime, shouldUseTimeDampening }) => {
|
||||||
const scroll = getValueFromDistance(distanceToEdge, thresholds);
|
const scroll = getValueFromDistance(distanceToEdge, thresholds);
|
||||||
|
|
||||||
// not enough distance to trigger a minimum scroll
|
// not enough distance to trigger a minimum scroll
|
||||||
@@ -23,3 +23,5 @@ export default ({ distanceToEdge, thresholds, dragStartTime, shouldUseTimeDampen
|
|||||||
|
|
||||||
return Math.max(dampenValueByTime(scroll, dragStartTime), minScroll);
|
return Math.max(dampenValueByTime(scroll, dragStartTime), minScroll);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getValue;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import getDistanceThresholds from "./get-distance-thresholds";
|
import getDistanceThresholds from "./get-distance-thresholds";
|
||||||
import getValue from "./get-value";
|
import getValue from "./get-value";
|
||||||
|
|
||||||
export default ({ container, distanceToEdges, dragStartTime, axis, shouldUseTimeDampening }) => {
|
const getScrollOnAxis = ({ container, distanceToEdges, dragStartTime, axis, shouldUseTimeDampening }) => {
|
||||||
const thresholds = getDistanceThresholds(container, axis);
|
const thresholds = getDistanceThresholds(container, axis);
|
||||||
const isCloserToEnd = distanceToEdges[axis.end] < distanceToEdges[axis.start];
|
const isCloserToEnd = distanceToEdges[axis.end] < distanceToEdges[axis.start];
|
||||||
if (isCloserToEnd) {
|
if (isCloserToEnd) {
|
||||||
@@ -22,3 +22,5 @@ export default ({ container, distanceToEdges, dragStartTime, axis, shouldUseTime
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getScrollOnAxis;
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
// A scroll event will only be triggered when there is a value of at least 1px change
|
// A scroll event will only be triggered when there is a value of at least 1px change
|
||||||
export default 1;
|
const minScroll = 1;
|
||||||
|
|
||||||
|
export default minScroll;
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import { horizontal, vertical } from "../../../axis";
|
|||||||
|
|
||||||
// will replace -0 and replace with +0
|
// will replace -0 and replace with +0
|
||||||
const clean = apply((value) => (value === 0 ? 0 : value));
|
const clean = apply((value) => (value === 0 ? 0 : value));
|
||||||
export default ({ dragStartTime, container, subject, center, shouldUseTimeDampening }) => {
|
|
||||||
|
const getScroll = ({ dragStartTime, container, subject, center, shouldUseTimeDampening }) => {
|
||||||
// get distance to each edge
|
// get distance to each edge
|
||||||
const distanceToEdges = {
|
const distanceToEdges = {
|
||||||
top: center.y - container.top,
|
top: center.y - container.top,
|
||||||
@@ -57,3 +58,5 @@ export default ({ dragStartTime, container, subject, center, shouldUseTimeDampen
|
|||||||
}
|
}
|
||||||
return isEqual(limited, origin) ? null : limited;
|
return isEqual(limited, origin) ? null : limited;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getScroll;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import getScroll from "./get-scroll";
|
import getScroll from "./get-scroll";
|
||||||
import { canScrollWindow } from "../can-scroll";
|
import { canScrollWindow } from "../can-scroll";
|
||||||
|
|
||||||
export default ({ viewport, subject, center, dragStartTime, shouldUseTimeDampening }) => {
|
const getWindowScrollChange = ({ viewport, subject, center, dragStartTime, shouldUseTimeDampening }) => {
|
||||||
const scroll = getScroll({
|
const scroll = getScroll({
|
||||||
dragStartTime,
|
dragStartTime,
|
||||||
container: viewport.frame,
|
container: viewport.frame,
|
||||||
@@ -11,3 +11,5 @@ export default ({ viewport, subject, center, dragStartTime, shouldUseTimeDampeni
|
|||||||
});
|
});
|
||||||
return scroll && canScrollWindow(viewport, scroll) ? scroll : null;
|
return scroll && canScrollWindow(viewport, scroll) ? scroll : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getWindowScrollChange;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import scroll from "./scroll";
|
|||||||
import { invariant } from "../../../invariant";
|
import { invariant } from "../../../invariant";
|
||||||
import * as timings from "../../../debug/timings";
|
import * as timings from "../../../debug/timings";
|
||||||
|
|
||||||
export default ({ scrollWindow, scrollDroppable }) => {
|
const fluidScroller = ({ scrollWindow, scrollDroppable }) => {
|
||||||
const scheduleWindowScroll = rafSchd(scrollWindow);
|
const scheduleWindowScroll = rafSchd(scrollWindow);
|
||||||
const scheduleDroppableScroll = rafSchd(scrollDroppable);
|
const scheduleDroppableScroll = rafSchd(scrollDroppable);
|
||||||
let dragging = null;
|
let dragging = null;
|
||||||
@@ -59,3 +59,5 @@ export default ({ scrollWindow, scrollDroppable }) => {
|
|||||||
scroll: tryScroll
|
scroll: tryScroll
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default fluidScroller;
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import getBestScrollableDroppable from "./get-best-scrollable-droppable";
|
|||||||
import whatIsDraggedOver from "../../droppable/what-is-dragged-over";
|
import whatIsDraggedOver from "../../droppable/what-is-dragged-over";
|
||||||
import getWindowScrollChange from "./get-window-scroll-change";
|
import getWindowScrollChange from "./get-window-scroll-change";
|
||||||
import getDroppableScrollChange from "./get-droppable-scroll-change";
|
import getDroppableScrollChange from "./get-droppable-scroll-change";
|
||||||
|
const scroll = ({ state, dragStartTime, shouldUseTimeDampening, scrollWindow, scrollDroppable }) => {
|
||||||
export default ({ state, dragStartTime, shouldUseTimeDampening, scrollWindow, scrollDroppable }) => {
|
|
||||||
const center = state.current.page.borderBoxCenter;
|
const center = state.current.page.borderBoxCenter;
|
||||||
const draggable = state.dimensions.draggables[state.critical.draggable.id];
|
const draggable = state.dimensions.draggables[state.critical.draggable.id];
|
||||||
const subject = draggable.page.marginBox;
|
const subject = draggable.page.marginBox;
|
||||||
@@ -41,3 +40,5 @@ export default ({ state, dragStartTime, shouldUseTimeDampening, scrollWindow, sc
|
|||||||
scrollDroppable(droppable.descriptor.id, change);
|
scrollDroppable(droppable.descriptor.id, change);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default scroll;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import createFluidScroller from "./fluid-scroller";
|
import createFluidScroller from "./fluid-scroller";
|
||||||
import createJumpScroller from "./jump-scroller";
|
import createJumpScroller from "./jump-scroller";
|
||||||
|
|
||||||
export default ({ scrollDroppable, scrollWindow, move }) => {
|
const autoScroller = ({ scrollDroppable, scrollWindow, move }) => {
|
||||||
const fluidScroller = createFluidScroller({
|
const fluidScroller = createFluidScroller({
|
||||||
scrollWindow,
|
scrollWindow,
|
||||||
scrollDroppable
|
scrollDroppable
|
||||||
@@ -32,3 +32,5 @@ export default ({ scrollDroppable, scrollWindow, move }) => {
|
|||||||
};
|
};
|
||||||
return scroller;
|
return scroller;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default autoScroller;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { add, subtract } from "../position";
|
|||||||
import { canScrollWindow, canScrollDroppable, getWindowOverlap, getDroppableOverlap } from "./can-scroll";
|
import { canScrollWindow, canScrollDroppable, getWindowOverlap, getDroppableOverlap } from "./can-scroll";
|
||||||
import whatIsDraggedOver from "../droppable/what-is-dragged-over";
|
import whatIsDraggedOver from "../droppable/what-is-dragged-over";
|
||||||
|
|
||||||
export default ({ move, scrollDroppable, scrollWindow }) => {
|
const jumpScroller = ({ move, scrollDroppable, scrollWindow }) => {
|
||||||
const moveByOffset = (state, offset) => {
|
const moveByOffset = (state, offset) => {
|
||||||
const client = add(state.current.client.selection, offset);
|
const client = add(state.current.client.selection, offset);
|
||||||
move({
|
move({
|
||||||
@@ -82,3 +82,5 @@ export default ({ move, scrollDroppable, scrollWindow }) => {
|
|||||||
};
|
};
|
||||||
return jumpScroller;
|
return jumpScroller;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default jumpScroller;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default (state, id) => {
|
const canStartDrag = (state, id) => {
|
||||||
// Ready to go!
|
// Ready to go!
|
||||||
if (state.phase === "IDLE") {
|
if (state.phase === "IDLE") {
|
||||||
return true;
|
return true;
|
||||||
@@ -24,3 +24,5 @@ export default (state, id) => {
|
|||||||
// if cancelling - disallow lifting
|
// if cancelling - disallow lifting
|
||||||
return state.completed.result.reason === "DROP";
|
return state.completed.result.reason === "DROP";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default canStartDrag;
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ import pendingDrop from "./middleware/pending-drop";
|
|||||||
// This is needed for universal apps that render the component server side.
|
// This is needed for universal apps that render the component server side.
|
||||||
// Details: https://github.com/zalmoxisus/redux-devtools-extension#12-advanced-store-setup
|
// Details: https://github.com/zalmoxisus/redux-devtools-extension#12-advanced-store-setup
|
||||||
const composeEnhancers =
|
const composeEnhancers =
|
||||||
process.env.NODE_ENV !== "production" && typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
import.meta.env.DEV && typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||||
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
|
||||||
name: "react-beautiful-dnd"
|
name: "react-beautiful-dnd"
|
||||||
})
|
})
|
||||||
: compose;
|
: compose;
|
||||||
export default ({ dimensionMarshal, focusMarshal, styleMarshal, getResponders, announce, autoScroller }) =>
|
|
||||||
|
const createBoardStore = ({ dimensionMarshal, focusMarshal, styleMarshal, getResponders, announce, autoScroller }) =>
|
||||||
createStore(
|
createStore(
|
||||||
reducer,
|
reducer,
|
||||||
composeEnhancers(
|
composeEnhancers(
|
||||||
@@ -68,3 +69,5 @@ export default ({ dimensionMarshal, focusMarshal, styleMarshal, getResponders, a
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export default createBoardStore;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ function shouldPublishUpdate(registry, dragging, entry) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (registry, callbacks) => {
|
const dimensionMarashal = (registry, callbacks) => {
|
||||||
let collection = null;
|
let collection = null;
|
||||||
const publisher = createPublisher({
|
const publisher = createPublisher({
|
||||||
callbacks: {
|
callbacks: {
|
||||||
@@ -149,3 +149,5 @@ export default (registry, callbacks) => {
|
|||||||
};
|
};
|
||||||
return marshal;
|
return marshal;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default dimensionMarashal;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as timings from "../../debug/timings";
|
|||||||
import { toDraggableMap, toDroppableMap } from "../dimension-structures";
|
import { toDraggableMap, toDroppableMap } from "../dimension-structures";
|
||||||
import getViewport from "../../view/window/get-viewport";
|
import getViewport from "../../view/window/get-viewport";
|
||||||
|
|
||||||
export default ({ critical, scrollOptions, registry }) => {
|
const getInitialPublish = ({ critical, scrollOptions, registry }) => {
|
||||||
const timingKey = "Initial collection from DOM";
|
const timingKey = "Initial collection from DOM";
|
||||||
timings.start(timingKey);
|
timings.start(timingKey);
|
||||||
const viewport = getViewport();
|
const viewport = getViewport();
|
||||||
@@ -26,3 +26,5 @@ export default ({ critical, scrollOptions, registry }) => {
|
|||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getInitialPublish;
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
export default (draggable, destination) => draggable.descriptor.droppableId === destination.descriptor.id;
|
const isHomeOf = (draggable, destination) => draggable.descriptor.droppableId === destination.descriptor.id;
|
||||||
|
|
||||||
|
export default isHomeOf;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { invariant } from "../../invariant";
|
|||||||
import { negate, subtract } from "../position";
|
import { negate, subtract } from "../position";
|
||||||
import getSubject from "./util/get-subject";
|
import getSubject from "./util/get-subject";
|
||||||
|
|
||||||
export default (droppable, newScroll) => {
|
const scrollDroppable = (droppable, newScroll) => {
|
||||||
invariant(droppable.frame);
|
invariant(droppable.frame);
|
||||||
const scrollable = droppable.frame;
|
const scrollable = droppable.frame;
|
||||||
const scrollDiff = subtract(newScroll, scrollable.scroll.initial);
|
const scrollDiff = subtract(newScroll, scrollable.scroll.initial);
|
||||||
@@ -39,3 +39,5 @@ export default (droppable, newScroll) => {
|
|||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default scrollDroppable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { getRect } from "css-box-model";
|
import { getRect } from "css-box-model";
|
||||||
|
|
||||||
export default (frame, subject) => {
|
const clip = (frame, subject) => {
|
||||||
const result = getRect({
|
const result = getRect({
|
||||||
top: Math.max(subject.top, frame.top),
|
top: Math.max(subject.top, frame.top),
|
||||||
right: Math.min(subject.right, frame.right),
|
right: Math.min(subject.right, frame.right),
|
||||||
@@ -12,3 +12,5 @@ export default (frame, subject) => {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default clip;
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ const clip = (target, frame) => {
|
|||||||
}
|
}
|
||||||
return getRect(target);
|
return getRect(target);
|
||||||
};
|
};
|
||||||
export default ({ page, withPlaceholder, axis, frame }) => {
|
|
||||||
|
const getSubject = ({ page, withPlaceholder, axis, frame }) => {
|
||||||
const scrolled = scroll(page.marginBox, frame);
|
const scrolled = scroll(page.marginBox, frame);
|
||||||
const increased = increase(scrolled, axis, withPlaceholder);
|
const increased = increase(scrolled, axis, withPlaceholder);
|
||||||
const clipped = clip(increased, frame);
|
const clipped = clip(increased, frame);
|
||||||
@@ -33,3 +34,5 @@ export default ({ page, withPlaceholder, axis, frame }) => {
|
|||||||
active: clipped
|
active: clipped
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getSubject;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default (result) => {
|
const whatIsDraggedOverFromResult = (result) => {
|
||||||
const { combine, destination } = result;
|
const { combine, destination } = result;
|
||||||
if (destination) {
|
if (destination) {
|
||||||
return destination.droppableId;
|
return destination.droppableId;
|
||||||
@@ -8,3 +8,5 @@ export default (result) => {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default whatIsDraggedOverFromResult;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default (impact) => {
|
const whatIsDraggedOver = (impact) => {
|
||||||
const at = impact.at;
|
const at = impact.at;
|
||||||
if (!at) {
|
if (!at) {
|
||||||
return null;
|
return null;
|
||||||
@@ -8,3 +8,5 @@ export default (impact) => {
|
|||||||
}
|
}
|
||||||
return at.combine.droppableId;
|
return at.combine.droppableId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default whatIsDraggedOver;
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { add, subtract } from "../../position";
|
import { add, subtract } from "../../position";
|
||||||
import withViewportDisplacement from "../../with-scroll-change/with-viewport-displacement";
|
import withViewportDisplacement from "../../with-scroll-change/with-viewport-displacement";
|
||||||
|
|
||||||
export default ({ pageBorderBoxCenter, draggable, viewport }) => {
|
const getClientRectFromPageBorderBoxCenter = ({ pageBorderBoxCenter, draggable, viewport }) => {
|
||||||
const withoutPageScrollChange = withViewportDisplacement(viewport, pageBorderBoxCenter);
|
const withoutPageScrollChange = withViewportDisplacement(viewport, pageBorderBoxCenter);
|
||||||
const offset = subtract(withoutPageScrollChange, draggable.page.borderBox.center);
|
const offset = subtract(withoutPageScrollChange, draggable.page.borderBox.center);
|
||||||
return add(draggable.client.borderBox.center, offset);
|
return add(draggable.client.borderBox.center, offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getClientRectFromPageBorderBoxCenter;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import getPageBorderBoxCenterFromImpact from "../get-page-border-box-center";
|
import getPageBorderBoxCenterFromImpact from "../get-page-border-box-center";
|
||||||
import getClientFromPageBorderBoxCenter from "./get-client-from-page-border-box-center";
|
import getClientFromPageBorderBoxCenter from "./get-client-from-page-border-box-center";
|
||||||
|
|
||||||
export default ({ impact, draggable, droppable, draggables, viewport, afterCritical }) => {
|
const getClientBorderBoxCenter = ({ impact, draggable, droppable, draggables, viewport, afterCritical }) => {
|
||||||
const pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
|
const pageBorderBoxCenter = getPageBorderBoxCenterFromImpact({
|
||||||
impact,
|
impact,
|
||||||
draggable,
|
draggable,
|
||||||
@@ -15,3 +15,5 @@ export default ({ impact, draggable, droppable, draggables, viewport, afterCriti
|
|||||||
viewport
|
viewport
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getClientBorderBoxCenter;
|
||||||
|
|||||||
@@ -26,9 +26,12 @@ const getResultWithoutDroppableDisplacement = ({ impact, draggable, droppable, d
|
|||||||
afterCritical
|
afterCritical
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
export default (args) => {
|
|
||||||
|
const getPageBorderBoxCenter = (args) => {
|
||||||
const withoutDisplacement = getResultWithoutDroppableDisplacement(args);
|
const withoutDisplacement = getResultWithoutDroppableDisplacement(args);
|
||||||
const droppable = args.droppable;
|
const droppable = args.droppable;
|
||||||
const withDisplacement = droppable ? withDroppableDisplacement(droppable, withoutDisplacement) : withoutDisplacement;
|
|
||||||
return withDisplacement;
|
return droppable ? withDroppableDisplacement(droppable, withoutDisplacement) : withoutDisplacement;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getPageBorderBoxCenter;
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ import { invariant } from "../../../invariant";
|
|||||||
import { add } from "../../position";
|
import { add } from "../../position";
|
||||||
import getCombinedItemDisplacement from "../../get-combined-item-displacement";
|
import getCombinedItemDisplacement from "../../get-combined-item-displacement";
|
||||||
import { tryGetCombine } from "../../get-impact-location";
|
import { tryGetCombine } from "../../get-impact-location";
|
||||||
// Returns the client offset required to move an item from its
|
|
||||||
// original client position to its final resting position
|
const whenCombining = ({ afterCritical, impact, draggables }) => {
|
||||||
export default ({ afterCritical, impact, draggables }) => {
|
|
||||||
const combine = tryGetCombine(impact);
|
const combine = tryGetCombine(impact);
|
||||||
invariant(combine);
|
invariant(combine);
|
||||||
const combineWith = combine.draggableId;
|
const combineWith = combine.draggableId;
|
||||||
@@ -17,3 +16,7 @@ export default ({ afterCritical, impact, draggables }) => {
|
|||||||
});
|
});
|
||||||
return add(center, displaceBy);
|
return add(center, displaceBy);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Returns the client offset required to move an item from its
|
||||||
|
// original client position to its final resting position
|
||||||
|
export default whenCombining;
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ import { goBefore, goAfter, goIntoStart } from "../move-relative-to";
|
|||||||
import getDraggablesInsideDroppable from "../../get-draggables-inside-droppable";
|
import getDraggablesInsideDroppable from "../../get-draggables-inside-droppable";
|
||||||
import { negate } from "../../position";
|
import { negate } from "../../position";
|
||||||
import didStartAfterCritical from "../../did-start-after-critical";
|
import didStartAfterCritical from "../../did-start-after-critical";
|
||||||
// Returns the client offset required to move an item from its
|
|
||||||
// original client position to its final resting position
|
const whenReordering = ({ impact, draggable, draggables, droppable, afterCritical }) => {
|
||||||
export default ({ impact, draggable, draggables, droppable, afterCritical }) => {
|
|
||||||
const insideDestination = getDraggablesInsideDroppable(droppable.descriptor.id, draggables);
|
const insideDestination = getDraggablesInsideDroppable(droppable.descriptor.id, draggables);
|
||||||
const draggablePage = draggable.page;
|
const draggablePage = draggable.page;
|
||||||
const axis = droppable.axis;
|
const axis = droppable.axis;
|
||||||
@@ -74,3 +73,7 @@ export default ({ impact, draggable, draggables, droppable, afterCritical }) =>
|
|||||||
isMoving: draggablePage
|
isMoving: draggablePage
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Returns the client offset required to move an item from its
|
||||||
|
// original client position to its final resting position
|
||||||
|
export default whenReordering;
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { negate, origin } from "./position";
|
import { negate, origin } from "./position";
|
||||||
import didStartAfterCritical from "./did-start-after-critical";
|
import didStartAfterCritical from "./did-start-after-critical";
|
||||||
|
|
||||||
export default ({ displaced, afterCritical, combineWith, displacedBy }) => {
|
const getCombinedItemDisplacement = ({ displaced, afterCritical, combineWith, displacedBy }) => {
|
||||||
const isDisplaced = Boolean(displaced.visible[combineWith] || displaced.invisible[combineWith]);
|
const isDisplaced = Boolean(displaced.visible[combineWith] || displaced.invisible[combineWith]);
|
||||||
if (didStartAfterCritical(combineWith, afterCritical)) {
|
if (didStartAfterCritical(combineWith, afterCritical)) {
|
||||||
return isDisplaced ? origin : negate(displacedBy.point);
|
return isDisplaced ? origin : negate(displacedBy.point);
|
||||||
}
|
}
|
||||||
return isDisplaced ? displacedBy.point : origin;
|
return isDisplaced ? displacedBy.point : origin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getCombinedItemDisplacement;
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import getIsDisplaced from "../get-is-displaced";
|
|||||||
import removeDraggableFromList from "../remove-draggable-from-list";
|
import removeDraggableFromList from "../remove-draggable-from-list";
|
||||||
// exported for testing
|
// exported for testing
|
||||||
export const combineThresholdDivisor = 4;
|
export const combineThresholdDivisor = 4;
|
||||||
export default ({
|
|
||||||
|
const getCombineImpact = ({
|
||||||
draggable,
|
draggable,
|
||||||
pageBorderBoxWithDroppableScroll: targetRect,
|
pageBorderBoxWithDroppableScroll: targetRect,
|
||||||
previousImpact,
|
previousImpact,
|
||||||
@@ -64,10 +65,12 @@ export default ({
|
|||||||
// is in resting position - being moved backwards on to
|
// is in resting position - being moved backwards on to
|
||||||
return targetStart > childRect[axis.start] + threshold && targetStart < childRect[axis.end] - threshold;
|
return targetStart > childRect[axis.start] + threshold && targetStart < childRect[axis.end] - threshold;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!combineWith) {
|
if (!combineWith) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const impact = {
|
|
||||||
|
return {
|
||||||
// no change to displacement when combining
|
// no change to displacement when combining
|
||||||
displacedBy,
|
displacedBy,
|
||||||
displaced: previousImpact.displaced,
|
displaced: previousImpact.displaced,
|
||||||
@@ -79,5 +82,6 @@ export default ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return impact;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getCombineImpact;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function atIndex({ draggable, closest, inHomeList }) {
|
|||||||
return closest.descriptor.index;
|
return closest.descriptor.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ({
|
const getReorderImpact = ({
|
||||||
pageBorderBoxWithDroppableScroll: targetRect,
|
pageBorderBoxWithDroppableScroll: targetRect,
|
||||||
draggable,
|
draggable,
|
||||||
destination,
|
destination,
|
||||||
@@ -100,3 +100,5 @@ export default ({
|
|||||||
index: newIndex
|
index: newIndex
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getReorderImpact;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import getCombineImpact from "./get-combine-impact";
|
|||||||
import noImpact from "../no-impact";
|
import noImpact from "../no-impact";
|
||||||
import { offsetRectByPosition } from "../rect";
|
import { offsetRectByPosition } from "../rect";
|
||||||
|
|
||||||
export default ({ pageOffset, draggable, draggables, droppables, previousImpact, viewport, afterCritical }) => {
|
const getDragImpact = ({ pageOffset, draggable, draggables, droppables, previousImpact, viewport, afterCritical }) => {
|
||||||
const pageBorderBox = offsetRectByPosition(draggable.page.borderBox, pageOffset);
|
const pageBorderBox = offsetRectByPosition(draggable.page.borderBox, pageOffset);
|
||||||
const destinationId = getDroppableOver({
|
const destinationId = getDroppableOver({
|
||||||
pageBorderBox,
|
pageBorderBox,
|
||||||
@@ -49,3 +49,5 @@ export default ({ pageOffset, draggable, draggables, droppables, previousImpact,
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getDragImpact;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { invariant } from "../invariant";
|
import { invariant } from "../invariant";
|
||||||
|
|
||||||
export default (droppable) => {
|
const getFrame = (droppable) => {
|
||||||
const frame = droppable.frame;
|
const frame = droppable.frame;
|
||||||
invariant(frame, "Expected Droppable to have a frame");
|
invariant(frame, "Expected Droppable to have a frame");
|
||||||
return frame;
|
return frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getFrame;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
export default (descriptor) => ({
|
const getHomeLocation = (descriptor) => ({
|
||||||
index: descriptor.index,
|
index: descriptor.index,
|
||||||
droppableId: descriptor.droppableId
|
droppableId: descriptor.droppableId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default getHomeLocation;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import getDraggablesInsideDroppable from "./get-draggables-inside-droppable";
|
|||||||
import getDisplacedBy from "./get-displaced-by";
|
import getDisplacedBy from "./get-displaced-by";
|
||||||
import getDisplacementGroups from "./get-displacement-groups";
|
import getDisplacementGroups from "./get-displacement-groups";
|
||||||
|
|
||||||
export default ({ draggable, home, draggables, viewport }) => {
|
const getLiftEffect = ({ draggable, home, draggables, viewport }) => {
|
||||||
const displacedBy = getDisplacedBy(home.axis, draggable.displaceBy);
|
const displacedBy = getDisplacedBy(home.axis, draggable.displaceBy);
|
||||||
const insideHome = getDraggablesInsideDroppable(home.descriptor.id, draggables);
|
const insideHome = getDraggablesInsideDroppable(home.descriptor.id, draggables);
|
||||||
|
|
||||||
@@ -46,3 +46,5 @@ export default ({ draggable, home, draggables, viewport }) => {
|
|||||||
afterCritical
|
afterCritical
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getLiftEffect;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { subtract } from "./position";
|
import { subtract } from "./position";
|
||||||
|
|
||||||
export default ({ scrollHeight, scrollWidth, height, width }) => {
|
const getMaxScroll = ({ scrollHeight, scrollWidth, height, width }) => {
|
||||||
const maxScroll = subtract(
|
const maxScroll = subtract(
|
||||||
// full size
|
// full size
|
||||||
{
|
{
|
||||||
@@ -19,3 +19,5 @@ export default ({ scrollHeight, scrollWidth, height, width }) => {
|
|||||||
};
|
};
|
||||||
return adjustedMaxScroll;
|
return adjustedMaxScroll;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getMaxScroll;
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
|
const isWithin = (lowerBound, upperBound) => (value) => lowerBound <= value && value <= upperBound;
|
||||||
|
|
||||||
// is a value between two other values
|
// is a value between two other values
|
||||||
export default (lowerBound, upperBound) => (value) => lowerBound <= value && value <= upperBound;
|
export default isWithin;
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { invariant } from "../../invariant";
|
|||||||
|
|
||||||
const shouldStop = (action) =>
|
const shouldStop = (action) =>
|
||||||
action.type === "DROP_COMPLETE" || action.type === "DROP_ANIMATE" || action.type === "FLUSH";
|
action.type === "DROP_COMPLETE" || action.type === "DROP_ANIMATE" || action.type === "FLUSH";
|
||||||
export default (autoScroller) => (store) => (next) => (action) => {
|
|
||||||
|
const autoScroll = (autoScroller) => (store) => (next) => (action) => {
|
||||||
if (shouldStop(action)) {
|
if (shouldStop(action)) {
|
||||||
autoScroller.stop();
|
autoScroller.stop();
|
||||||
next(action);
|
next(action);
|
||||||
@@ -22,3 +23,5 @@ export default (autoScroller) => (store) => (next) => (action) => {
|
|||||||
next(action);
|
next(action);
|
||||||
autoScroller.scroll(store.getState());
|
autoScroller.scroll(store.getState());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default autoScroll;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default (marshal) => () => (next) => (action) => {
|
const dimensionMarshalStopper = (marshal) => () => (next) => (action) => {
|
||||||
// Not stopping a collection on a 'DROP' as we want a collection to continue
|
// Not stopping a collection on a 'DROP' as we want a collection to continue
|
||||||
if (
|
if (
|
||||||
// drag is finished
|
// drag is finished
|
||||||
@@ -11,3 +11,5 @@ export default (marshal) => () => (next) => (action) => {
|
|||||||
}
|
}
|
||||||
next(action);
|
next(action);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default dimensionMarshalStopper;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { invariant } from "../../../invariant";
|
import { invariant } from "../../../invariant";
|
||||||
import { completeDrop } from "../../action-creators";
|
import { completeDrop } from "../../action-creators";
|
||||||
|
|
||||||
export default (store) => (next) => (action) => {
|
const dropAnimiationFinishMiddleware = (store) => (next) => (action) => {
|
||||||
if (action.type !== "DROP_ANIMATION_FINISHED") {
|
if (action.type !== "DROP_ANIMATION_FINISHED") {
|
||||||
next(action);
|
next(action);
|
||||||
return;
|
return;
|
||||||
@@ -14,3 +14,5 @@ export default (store) => (next) => (action) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default dropAnimiationFinishMiddleware;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { dropAnimationFinished } from "../../action-creators";
|
import { dropAnimationFinished } from "../../action-creators";
|
||||||
import bindEvents from "../../../view/event-bindings/bind-events";
|
import bindEvents from "../../../view/event-bindings/bind-events";
|
||||||
|
|
||||||
export default (store) => {
|
const dropAnimationFlushOnScrollMiddleware = (store) => {
|
||||||
let unbind = null;
|
let unbind = null;
|
||||||
let frameId = null;
|
let frameId = null;
|
||||||
|
|
||||||
@@ -53,3 +53,5 @@ export default (store) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default dropAnimationFlushOnScrollMiddleware;
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import getNewHomeClientOffset from "./get-new-home-client-offset";
|
|||||||
import getDropImpact from "./get-drop-impact";
|
import getDropImpact from "./get-drop-impact";
|
||||||
import { tryGetCombine, tryGetDestination } from "../../get-impact-location";
|
import { tryGetCombine, tryGetDestination } from "../../get-impact-location";
|
||||||
|
|
||||||
export default ({ getState, dispatch }) =>
|
const dropMiddleware =
|
||||||
|
({ getState, dispatch }) =>
|
||||||
(next) =>
|
(next) =>
|
||||||
(action) => {
|
(action) => {
|
||||||
if (action.type !== "DROP") {
|
if (action.type !== "DROP") {
|
||||||
@@ -110,3 +111,5 @@ export default ({ getState, dispatch }) =>
|
|||||||
};
|
};
|
||||||
dispatch(animateDrop(args));
|
dispatch(animateDrop(args));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default dropMiddleware;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const dropTimeRange = maxDropTime - minDropTime;
|
|||||||
const maxDropTimeAtDistance = 1500;
|
const maxDropTimeAtDistance = 1500;
|
||||||
// will bring a time lower - which makes it faster
|
// will bring a time lower - which makes it faster
|
||||||
const cancelDropModifier = 0.6;
|
const cancelDropModifier = 0.6;
|
||||||
export default ({ current, destination, reason }) => {
|
const getDropDuration = ({ current, destination, reason }) => {
|
||||||
const distance = getDistance(current, destination);
|
const distance = getDistance(current, destination);
|
||||||
// even if there is no distance to travel, we might still need to animate opacity
|
// even if there is no distance to travel, we might still need to animate opacity
|
||||||
if (distance <= 0) {
|
if (distance <= 0) {
|
||||||
@@ -28,3 +28,5 @@ export default ({ current, destination, reason }) => {
|
|||||||
// To two decimal points by converting to string and back
|
// To two decimal points by converting to string and back
|
||||||
return Number(withDuration.toFixed(2));
|
return Number(withDuration.toFixed(2));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getDropDuration;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import recompute from "../../update-displacement-visibility/recompute";
|
import recompute from "../../update-displacement-visibility/recompute";
|
||||||
import { emptyGroups } from "../../no-impact";
|
import { emptyGroups } from "../../no-impact";
|
||||||
|
|
||||||
export default ({ draggables, reason, lastImpact, home, viewport, onLiftImpact }) => {
|
const getDropImpact = ({ draggables, reason, lastImpact, home, viewport, onLiftImpact }) => {
|
||||||
if (!lastImpact.at || reason !== "DROP") {
|
if (!lastImpact.at || reason !== "DROP") {
|
||||||
// Dropping outside of a list or the drag was cancelled
|
// Dropping outside of a list or the drag was cancelled
|
||||||
|
|
||||||
@@ -42,3 +42,5 @@ export default ({ draggables, reason, lastImpact, home, viewport, onLiftImpact }
|
|||||||
didDropInsideDroppable: true
|
didDropInsideDroppable: true
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getDropImpact;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import whatIsDraggedOver from "../../droppable/what-is-dragged-over";
|
|||||||
import { subtract } from "../../position";
|
import { subtract } from "../../position";
|
||||||
import getClientBorderBoxCenter from "../../get-center-from-impact/get-client-border-box-center";
|
import getClientBorderBoxCenter from "../../get-center-from-impact/get-client-border-box-center";
|
||||||
|
|
||||||
export default ({ impact, draggable, dimensions, viewport, afterCritical }) => {
|
const getNewHomeClientOffset = ({ impact, draggable, dimensions, viewport, afterCritical }) => {
|
||||||
const { draggables, droppables } = dimensions;
|
const { draggables, droppables } = dimensions;
|
||||||
const droppableId = whatIsDraggedOver(impact);
|
const droppableId = whatIsDraggedOver(impact);
|
||||||
const destination = droppableId ? droppables[droppableId] : null;
|
const destination = droppableId ? droppables[droppableId] : null;
|
||||||
@@ -19,3 +19,5 @@ export default ({ impact, draggable, dimensions, viewport, afterCritical }) => {
|
|||||||
const offset = subtract(newClientCenter, draggable.client.borderBox.center);
|
const offset = subtract(newClientCenter, draggable.client.borderBox.center);
|
||||||
return offset;
|
return offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getNewHomeClientOffset;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default (marshal) => {
|
const focus = (marshal) => {
|
||||||
let isWatching = false;
|
let isWatching = false;
|
||||||
return () => (next) => (action) => {
|
return () => (next) => (action) => {
|
||||||
if (action.type === "INITIAL_PUBLISH") {
|
if (action.type === "INITIAL_PUBLISH") {
|
||||||
@@ -29,3 +29,5 @@ export default (marshal) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default focus;
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { invariant } from "../../invariant";
|
|||||||
import { beforeInitialCapture, completeDrop, flush, initialPublish } from "../action-creators";
|
import { beforeInitialCapture, completeDrop, flush, initialPublish } from "../action-creators";
|
||||||
import validateDimensions from "./util/validate-dimensions";
|
import validateDimensions from "./util/validate-dimensions";
|
||||||
|
|
||||||
export default (marshal) =>
|
const lift =
|
||||||
|
(marshal) =>
|
||||||
({ getState, dispatch }) =>
|
({ getState, dispatch }) =>
|
||||||
(next) =>
|
(next) =>
|
||||||
(action) => {
|
(action) => {
|
||||||
@@ -62,3 +63,5 @@ export default (marshal) =>
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default lift;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { drop } from "../action-creators";
|
import { drop } from "../action-creators";
|
||||||
|
|
||||||
export default (store) => (next) => (action) => {
|
const pendingDrop = (store) => (next) => (action) => {
|
||||||
// Always let the action go through first
|
// Always let the action go through first
|
||||||
next(action);
|
next(action);
|
||||||
if (action.type !== "PUBLISH_WHILE_DRAGGING") {
|
if (action.type !== "PUBLISH_WHILE_DRAGGING") {
|
||||||
@@ -28,3 +28,5 @@ export default (store) => (next) => (action) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default pendingDrop;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { invariant } from "../../../invariant";
|
import { invariant } from "../../../invariant";
|
||||||
import { findIndex } from "../../../native-with-fallback";
|
import { findIndex } from "../../../native-with-fallback";
|
||||||
|
|
||||||
export default () => {
|
const asyncMarshal = () => {
|
||||||
const entries = [];
|
const entries = [];
|
||||||
const execute = (timerId) => {
|
const execute = (timerId) => {
|
||||||
const index = findIndex(entries, (item) => item.timerId === timerId);
|
const index = findIndex(entries, (item) => item.timerId === timerId);
|
||||||
@@ -36,3 +36,5 @@ export default () => {
|
|||||||
flush
|
flush
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default asyncMarshal;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { warning } from "../../../dev-warning";
|
import { warning } from "../../../dev-warning";
|
||||||
|
|
||||||
export default (announce) => {
|
const expiringAnnounce = (announce) => {
|
||||||
let wasCalled = false;
|
let wasCalled = false;
|
||||||
let isExpired = false;
|
let isExpired = false;
|
||||||
|
|
||||||
@@ -31,3 +31,5 @@ export default (announce) => {
|
|||||||
result.wasCalled = () => wasCalled;
|
result.wasCalled = () => wasCalled;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default expiringAnnounce;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ const execute = (responder, data, announce, getDefaultMessage) => {
|
|||||||
announce(getDefaultMessage(data));
|
announce(getDefaultMessage(data));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export default (getResponders, announce) => {
|
const publisher = (getResponders, announce) => {
|
||||||
const asyncMarshal = getAsyncMarshal();
|
const asyncMarshal = getAsyncMarshal();
|
||||||
let dragging = null;
|
let dragging = null;
|
||||||
const beforeCapture = (draggableId, mode) => {
|
const beforeCapture = (draggableId, mode) => {
|
||||||
@@ -152,3 +152,5 @@ export default (getResponders, announce) => {
|
|||||||
abort
|
abort
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default publisher;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import getPublisher from "./publisher";
|
import getPublisher from "./publisher";
|
||||||
|
|
||||||
export default (getResponders, announce) => {
|
const respondersMiddleware = (getResponders, announce) => {
|
||||||
const publisher = getPublisher(getResponders, announce);
|
const publisher = getPublisher(getResponders, announce);
|
||||||
return (store) => (next) => (action) => {
|
return (store) => (next) => (action) => {
|
||||||
if (action.type === "BEFORE_INITIAL_CAPTURE") {
|
if (action.type === "BEFORE_INITIAL_CAPTURE") {
|
||||||
@@ -46,3 +46,5 @@ export default (getResponders, announce) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default respondersMiddleware;
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import getScrollListener from "../../view/scroll-listener";
|
|||||||
// TODO: this is taken from auto-scroll. Let's make it a util
|
// TODO: this is taken from auto-scroll. Let's make it a util
|
||||||
const shouldEnd = (action) =>
|
const shouldEnd = (action) =>
|
||||||
action.type === "DROP_COMPLETE" || action.type === "DROP_ANIMATE" || action.type === "FLUSH";
|
action.type === "DROP_COMPLETE" || action.type === "DROP_ANIMATE" || action.type === "FLUSH";
|
||||||
export default (store) => {
|
|
||||||
|
const scrollListener = (store) => {
|
||||||
const listener = getScrollListener({
|
const listener = getScrollListener({
|
||||||
onWindowScroll: (newScroll) => {
|
onWindowScroll: (newScroll) => {
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
@@ -24,3 +25,5 @@ export default (store) => {
|
|||||||
next(action);
|
next(action);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default scrollListener;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default (marshal) => () => (next) => (action) => {
|
const style = (marshal) => () => (next) => (action) => {
|
||||||
if (action.type === "INITIAL_PUBLISH") {
|
if (action.type === "INITIAL_PUBLISH") {
|
||||||
marshal.dragging();
|
marshal.dragging();
|
||||||
}
|
}
|
||||||
@@ -12,3 +12,5 @@ export default (marshal) => () => (next) => (action) => {
|
|||||||
}
|
}
|
||||||
next(action);
|
next(action);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default style;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ function checkIndexes(insideDestination) {
|
|||||||
|
|
||||||
export default function validateDimensions(critical, dimensions) {
|
export default function validateDimensions(critical, dimensions) {
|
||||||
// wrapping entire block for better minification
|
// wrapping entire block for better minification
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (import.meta.env.DEV) {
|
||||||
const insideDestination = getDraggablesInsideDroppable(critical.droppable.id, dimensions.draggables);
|
const insideDestination = getDraggablesInsideDroppable(critical.droppable.id, dimensions.draggables);
|
||||||
checkIndexes(insideDestination);
|
checkIndexes(insideDestination);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const getDroppableOver = (impact, droppables) => {
|
|||||||
const id = whatIsDraggedOver(impact);
|
const id = whatIsDraggedOver(impact);
|
||||||
return id ? droppables[id] : null;
|
return id ? droppables[id] : null;
|
||||||
};
|
};
|
||||||
export default ({ state, type }) => {
|
const moveInDirection = ({ state, type }) => {
|
||||||
const isActuallyOver = getDroppableOver(state.impact, state.dimensions.droppables);
|
const isActuallyOver = getDroppableOver(state.impact, state.dimensions.droppables);
|
||||||
const isMainAxisMovementAllowed = Boolean(isActuallyOver);
|
const isMainAxisMovementAllowed = Boolean(isActuallyOver);
|
||||||
const home = state.dimensions.droppables[state.critical.droppable.id];
|
const home = state.dimensions.droppables[state.critical.droppable.id];
|
||||||
@@ -48,3 +48,5 @@ export default ({ state, type }) => {
|
|||||||
afterCritical: state.afterCritical
|
afterCritical: state.afterCritical
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default moveInDirection;
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ const getKnownActive = (droppable) => {
|
|||||||
invariant(rect, "Cannot get clipped area from droppable");
|
invariant(rect, "Cannot get clipped area from droppable");
|
||||||
return rect;
|
return rect;
|
||||||
};
|
};
|
||||||
export default ({ isMovingForward, pageBorderBoxCenter, source, droppables, viewport }) => {
|
|
||||||
|
const getBestCrossAxisDroppable = ({ isMovingForward, pageBorderBoxCenter, source, droppables, viewport }) => {
|
||||||
const active = source.subject.active;
|
const active = source.subject.active;
|
||||||
if (!active) {
|
if (!active) {
|
||||||
return null;
|
return null;
|
||||||
@@ -107,3 +108,5 @@ export default ({ isMovingForward, pageBorderBoxCenter, source, droppables, view
|
|||||||
return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
|
return getKnownActive(a)[axis.start] - getKnownActive(b)[axis.start];
|
||||||
})[0];
|
})[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getBestCrossAxisDroppable;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { isTotallyVisible } from "../../visibility/is-visible";
|
|||||||
import withDroppableDisplacement from "../../with-scroll-change/with-droppable-displacement";
|
import withDroppableDisplacement from "../../with-scroll-change/with-droppable-displacement";
|
||||||
import { getCurrentPageBorderBox, getCurrentPageBorderBoxCenter } from "./without-starting-displacement";
|
import { getCurrentPageBorderBox, getCurrentPageBorderBoxCenter } from "./without-starting-displacement";
|
||||||
|
|
||||||
export default ({ pageBorderBoxCenter, viewport, destination, insideDestination, afterCritical }) => {
|
const getClosestDraggable = ({ pageBorderBoxCenter, viewport, destination, insideDestination, afterCritical }) => {
|
||||||
const sorted = insideDestination
|
const sorted = insideDestination
|
||||||
.filter((draggable) =>
|
.filter((draggable) =>
|
||||||
// Allowing movement to draggables that are not visible in the viewport
|
// Allowing movement to draggables that are not visible in the viewport
|
||||||
@@ -43,3 +43,5 @@ export default ({ pageBorderBoxCenter, viewport, destination, insideDestination,
|
|||||||
});
|
});
|
||||||
return sorted[0] || null;
|
return sorted[0] || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getClosestDraggable;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import getClientFromPageBorderBoxCenter from "../../get-center-from-impact/get-c
|
|||||||
import getPageBorderBoxCenter from "../../get-center-from-impact/get-page-border-box-center";
|
import getPageBorderBoxCenter from "../../get-center-from-impact/get-page-border-box-center";
|
||||||
import moveToNewDroppable from "./move-to-new-droppable";
|
import moveToNewDroppable from "./move-to-new-droppable";
|
||||||
|
|
||||||
export default ({
|
const moveCrossAxis = ({
|
||||||
isMovingForward,
|
isMovingForward,
|
||||||
previousPageBorderBoxCenter,
|
previousPageBorderBoxCenter,
|
||||||
draggable,
|
draggable,
|
||||||
@@ -69,3 +69,5 @@ export default ({
|
|||||||
scrollJumpRequest: null
|
scrollJumpRequest: null
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default moveCrossAxis;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { addPlaceholder } from "../../droppable/with-placeholder";
|
|||||||
import isHomeOf from "../../droppable/is-home-of";
|
import isHomeOf from "../../droppable/is-home-of";
|
||||||
import calculateReorderImpact from "../../calculate-drag-impact/calculate-reorder-impact";
|
import calculateReorderImpact from "../../calculate-drag-impact/calculate-reorder-impact";
|
||||||
|
|
||||||
export default ({
|
const moveToNewDroppable = ({
|
||||||
previousPageBorderBoxCenter,
|
previousPageBorderBoxCenter,
|
||||||
moveRelativeTo,
|
moveRelativeTo,
|
||||||
insideDestination,
|
insideDestination,
|
||||||
@@ -84,3 +84,5 @@ export default ({
|
|||||||
index: proposedIndex
|
index: proposedIndex
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default moveToNewDroppable;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import getClientFromPageBorderBoxCenter from "../../get-center-from-impact/get-c
|
|||||||
import { subtract } from "../../position";
|
import { subtract } from "../../position";
|
||||||
import isTotallyVisibleInNewLocation from "./is-totally-visible-in-new-location";
|
import isTotallyVisibleInNewLocation from "./is-totally-visible-in-new-location";
|
||||||
|
|
||||||
export default ({
|
const moveToNextPlace = ({
|
||||||
isMovingForward,
|
isMovingForward,
|
||||||
draggable,
|
draggable,
|
||||||
destination,
|
destination,
|
||||||
@@ -92,3 +92,5 @@ export default ({
|
|||||||
scrollJumpRequest: distance
|
scrollJumpRequest: distance
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default moveToNextPlace;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { subtract } from "../../position";
|
|||||||
import { offsetByPosition } from "../../spacing";
|
import { offsetByPosition } from "../../spacing";
|
||||||
import { isTotallyVisible, isTotallyVisibleOnAxis } from "../../visibility/is-visible";
|
import { isTotallyVisible, isTotallyVisibleOnAxis } from "../../visibility/is-visible";
|
||||||
|
|
||||||
export default ({
|
const isTotallyVisibleInNewLocation = ({
|
||||||
draggable,
|
draggable,
|
||||||
destination,
|
destination,
|
||||||
newPageBorderBoxCenter,
|
newPageBorderBoxCenter,
|
||||||
@@ -26,3 +26,5 @@ export default ({
|
|||||||
};
|
};
|
||||||
return onlyOnMainAxis ? isTotallyVisibleOnAxis(args) : isTotallyVisible(args);
|
return onlyOnMainAxis ? isTotallyVisibleOnAxis(args) : isTotallyVisible(args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default isTotallyVisibleInNewLocation;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { tryGetDestination } from "../../../get-impact-location";
|
|||||||
import { findIndex } from "../../../../native-with-fallback";
|
import { findIndex } from "../../../../native-with-fallback";
|
||||||
import removeDraggableFromList from "../../../remove-draggable-from-list";
|
import removeDraggableFromList from "../../../remove-draggable-from-list";
|
||||||
|
|
||||||
export default ({ isMovingForward, draggable, destination, insideDestination, previousImpact }) => {
|
const moveToNextCombine = ({ isMovingForward, draggable, destination, insideDestination, previousImpact }) => {
|
||||||
if (!destination.isCombineEnabled) {
|
if (!destination.isCombineEnabled) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -59,3 +59,5 @@ export default ({ isMovingForward, draggable, destination, insideDestination, pr
|
|||||||
const before = withoutDraggable[proposedIndex];
|
const before = withoutDraggable[proposedIndex];
|
||||||
return getImpact(before.descriptor.id);
|
return getImpact(before.descriptor.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default moveToNextCombine;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import didStartAfterCritical from "../../../did-start-after-critical";
|
import didStartAfterCritical from "../../../did-start-after-critical";
|
||||||
|
|
||||||
export default ({ isMovingForward, destination, draggables, combine, afterCritical }) => {
|
const fromCombine = ({ isMovingForward, destination, draggables, combine, afterCritical }) => {
|
||||||
if (!destination.isCombineEnabled) {
|
if (!destination.isCombineEnabled) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -19,3 +19,5 @@ export default ({ isMovingForward, destination, draggables, combine, afterCritic
|
|||||||
}
|
}
|
||||||
return combineWithIndex;
|
return combineWithIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default fromCombine;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default ({ isMovingForward, isInHomeList, insideDestination, location }) => {
|
const fromReorder = ({ isMovingForward, isInHomeList, insideDestination, location }) => {
|
||||||
// cannot move in the list
|
// cannot move in the list
|
||||||
if (!insideDestination.length) {
|
if (!insideDestination.length) {
|
||||||
return null;
|
return null;
|
||||||
@@ -20,3 +20,5 @@ export default ({ isMovingForward, isInHomeList, insideDestination, location })
|
|||||||
}
|
}
|
||||||
return proposedIndex;
|
return proposedIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default fromReorder;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import calculateReorderImpact from "../../../calculate-drag-impact/calculate-reo
|
|||||||
import fromCombine from "./from-combine";
|
import fromCombine from "./from-combine";
|
||||||
import fromReorder from "./from-reorder";
|
import fromReorder from "./from-reorder";
|
||||||
|
|
||||||
export default ({
|
const moveToNextIndex = ({
|
||||||
isMovingForward,
|
isMovingForward,
|
||||||
isInHomeList,
|
isInHomeList,
|
||||||
draggable,
|
draggable,
|
||||||
@@ -60,3 +60,5 @@ export default ({
|
|||||||
index: newIndex
|
index: newIndex
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default moveToNextIndex;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import patchDroppableMap from "./patch-droppable-map";
|
import patchDroppableMap from "./patch-droppable-map";
|
||||||
|
|
||||||
export default (dimensions, updated) => ({
|
const patchDimensionMap = (dimensions, updated) => ({
|
||||||
draggables: dimensions.draggables,
|
draggables: dimensions.draggables,
|
||||||
droppables: patchDroppableMap(dimensions.droppables, updated)
|
droppables: patchDroppableMap(dimensions.droppables, updated)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default patchDimensionMap;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
export default (droppables, updated) => ({
|
const patchDroppableMap = (droppables, updated) => ({
|
||||||
...droppables,
|
...droppables,
|
||||||
[updated.descriptor.id]: updated
|
[updated.descriptor.id]: updated
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default patchDroppableMap;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import recomputeDisplacementVisibility from "../../update-displacement-visibilit
|
|||||||
import getClientBorderBoxCenter from "../../get-center-from-impact/get-client-border-box-center";
|
import getClientBorderBoxCenter from "../../get-center-from-impact/get-client-border-box-center";
|
||||||
import update from "./update";
|
import update from "./update";
|
||||||
|
|
||||||
export default ({ state, dimensions: forcedDimensions, viewport: forcedViewport }) => {
|
const refreshSnap = ({ state, dimensions: forcedDimensions, viewport: forcedViewport }) => {
|
||||||
invariant(state.movementMode === "SNAP");
|
invariant(state.movementMode === "SNAP");
|
||||||
const needsVisibilityCheck = state.impact;
|
const needsVisibilityCheck = state.impact;
|
||||||
const viewport = forcedViewport || state.viewport;
|
const viewport = forcedViewport || state.viewport;
|
||||||
@@ -38,3 +38,5 @@ export default ({ state, dimensions: forcedDimensions, viewport: forcedViewport
|
|||||||
viewport
|
viewport
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default refreshSnap;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import getDragImpact from "../../get-drag-impact";
|
|||||||
import { add, subtract } from "../../position";
|
import { add, subtract } from "../../position";
|
||||||
import recomputePlaceholders from "../../recompute-placeholders";
|
import recomputePlaceholders from "../../recompute-placeholders";
|
||||||
|
|
||||||
export default ({
|
const update = ({
|
||||||
state,
|
state,
|
||||||
clientSelection: forcedClientSelection,
|
clientSelection: forcedClientSelection,
|
||||||
dimensions: forcedDimensions,
|
dimensions: forcedDimensions,
|
||||||
@@ -80,3 +80,5 @@ export default ({
|
|||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default update;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { add } from "../position";
|
|||||||
import offsetDraggable from "./offset-draggable";
|
import offsetDraggable from "./offset-draggable";
|
||||||
import getFrame from "../get-frame";
|
import getFrame from "../get-frame";
|
||||||
|
|
||||||
export default ({ additions, updatedDroppables, viewport }) => {
|
const adjustAdditionsForScrollChanges = ({ additions, updatedDroppables, viewport }) => {
|
||||||
// We need to adjust collected draggables so that they
|
// We need to adjust collected draggables so that they
|
||||||
// match the model we had when the drag started.
|
// match the model we had when the drag started.
|
||||||
// When a draggable is dynamically collected it does not have
|
// When a draggable is dynamically collected it does not have
|
||||||
@@ -30,3 +30,5 @@ export default ({ additions, updatedDroppables, viewport }) => {
|
|||||||
return moved;
|
return moved;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default adjustAdditionsForScrollChanges;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import scrollDroppable from "../droppable/scroll-droppable";
|
|||||||
import whatIsDraggedOver from "../droppable/what-is-dragged-over";
|
import whatIsDraggedOver from "../droppable/what-is-dragged-over";
|
||||||
|
|
||||||
const timingsKey = "Processing dynamic changes";
|
const timingsKey = "Processing dynamic changes";
|
||||||
export default ({ state, published }) => {
|
const publishWhileDraggingInVirtual = ({ state, published }) => {
|
||||||
timings.start(timingsKey);
|
timings.start(timingsKey);
|
||||||
|
|
||||||
// TODO: update window scroll (needs to be a part of the published object)
|
// TODO: update window scroll (needs to be a part of the published object)
|
||||||
@@ -107,3 +107,5 @@ export default ({ state, published }) => {
|
|||||||
};
|
};
|
||||||
return dropPending;
|
return dropPending;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default publishWhileDraggingInVirtual;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { offset as offsetBox, withScroll } from "css-box-model";
|
import { offset as offsetBox, withScroll } from "css-box-model";
|
||||||
|
|
||||||
export default ({ draggable, offset, initialWindowScroll }) => {
|
const offsetDraggable = ({ draggable, offset, initialWindowScroll }) => {
|
||||||
const client = offsetBox(draggable.client, offset);
|
const client = offsetBox(draggable.client, offset);
|
||||||
const page = withScroll(client, initialWindowScroll);
|
const page = withScroll(client, initialWindowScroll);
|
||||||
const moved = {
|
const moved = {
|
||||||
@@ -14,3 +14,5 @@ export default ({ draggable, offset, initialWindowScroll }) => {
|
|||||||
};
|
};
|
||||||
return moved;
|
return moved;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default offsetDraggable;
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ const clearUnusedPlaceholder = ({ previousImpact, impact, droppables }) => {
|
|||||||
const updated = removePlaceholder(lastDroppable);
|
const updated = removePlaceholder(lastDroppable);
|
||||||
return patchDroppableMap(droppables, updated);
|
return patchDroppableMap(droppables, updated);
|
||||||
};
|
};
|
||||||
export default ({ draggable, draggables, droppables, previousImpact, impact }) => {
|
|
||||||
|
const recomputePlaceholders = ({ draggable, draggables, droppables, previousImpact, impact }) => {
|
||||||
const cleaned = clearUnusedPlaceholder({
|
const cleaned = clearUnusedPlaceholder({
|
||||||
previousImpact,
|
previousImpact,
|
||||||
impact,
|
impact,
|
||||||
@@ -49,3 +50,5 @@ export default ({ draggable, draggables, droppables, previousImpact, impact }) =
|
|||||||
const patched = addPlaceholder(droppable, draggable, draggables);
|
const patched = addPlaceholder(droppable, draggable, draggables);
|
||||||
return patchDroppableMap(cleaned, patched);
|
return patchDroppableMap(cleaned, patched);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default recomputePlaceholders;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const idle = {
|
|||||||
completed: null,
|
completed: null,
|
||||||
shouldFlush: false
|
shouldFlush: false
|
||||||
};
|
};
|
||||||
export default (state = idle, action) => {
|
const reducer = (state = idle, action) => {
|
||||||
if (action.type === "FLUSH") {
|
if (action.type === "FLUSH") {
|
||||||
return {
|
return {
|
||||||
...idle,
|
...idle,
|
||||||
@@ -330,3 +330,5 @@ export default (state = idle, action) => {
|
|||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default reducer;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getRect } from "css-box-model";
|
import { getRect } from "css-box-model";
|
||||||
import { subtract, negate } from "./position";
|
import { subtract, negate } from "./position";
|
||||||
|
|
||||||
export default (viewport, newScroll) => {
|
const scrollViewport = (viewport, newScroll) => {
|
||||||
const diff = subtract(newScroll, viewport.scroll.initial);
|
const diff = subtract(newScroll, viewport.scroll.initial);
|
||||||
const displacement = negate(diff);
|
const displacement = negate(diff);
|
||||||
|
|
||||||
@@ -27,3 +27,5 @@ export default (viewport, newScroll) => {
|
|||||||
};
|
};
|
||||||
return updated;
|
return updated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default scrollViewport;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ function getDraggables(ids, draggables) {
|
|||||||
return ids.map((id) => draggables[id]);
|
return ids.map((id) => draggables[id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ({ impact, viewport, draggables, destination, forceShouldAnimate }) => {
|
const recompute = ({ impact, viewport, draggables, destination, forceShouldAnimate }) => {
|
||||||
const last = impact.displaced;
|
const last = impact.displaced;
|
||||||
const afterDragging = getDraggables(last.all, draggables);
|
const afterDragging = getDraggables(last.all, draggables);
|
||||||
const displaced = getDisplacementGroups({
|
const displaced = getDisplacementGroups({
|
||||||
@@ -20,3 +20,5 @@ export default ({ impact, viewport, draggables, destination, forceShouldAnimate
|
|||||||
displaced
|
displaced
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default recompute;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function tryGetVisible(id, groups) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ({ impact, viewport, destination, draggables, maxScrollChange }) => {
|
const speculativelyIncrease = ({ impact, viewport, destination, draggables, maxScrollChange }) => {
|
||||||
const scrolledViewport = scrollViewport(viewport, add(viewport.scroll.current, maxScrollChange));
|
const scrolledViewport = scrollViewport(viewport, add(viewport.scroll.current, maxScrollChange));
|
||||||
const scrolledDroppable = destination.frame
|
const scrolledDroppable = destination.frame
|
||||||
? scrollDroppable(destination, add(destination.frame.scroll.current, maxScrollChange))
|
? scrollDroppable(destination, add(destination.frame.scroll.current, maxScrollChange))
|
||||||
@@ -57,7 +57,8 @@ export default ({ impact, viewport, destination, draggables, maxScrollChange })
|
|||||||
}
|
}
|
||||||
invisible[id] = true;
|
invisible[id] = true;
|
||||||
});
|
});
|
||||||
const newImpact = {
|
|
||||||
|
return {
|
||||||
...impact,
|
...impact,
|
||||||
displaced: {
|
displaced: {
|
||||||
all: last.all,
|
all: last.all,
|
||||||
@@ -65,5 +66,6 @@ export default ({ impact, viewport, destination, draggables, maxScrollChange })
|
|||||||
visible
|
visible
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return newImpact;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default speculativelyIncrease;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import isWithin from "../is-within";
|
import isWithin from "../is-within";
|
||||||
|
|
||||||
export default (frame) => {
|
const isPartiallyVisibleThroughFrame = (frame) => {
|
||||||
const isWithinVertical = isWithin(frame.top, frame.bottom);
|
const isWithinVertical = isWithin(frame.top, frame.bottom);
|
||||||
const isWithinHorizontal = isWithin(frame.left, frame.right);
|
const isWithinHorizontal = isWithin(frame.left, frame.right);
|
||||||
return (subject) => {
|
return (subject) => {
|
||||||
@@ -42,3 +42,5 @@ export default (frame) => {
|
|||||||
return isTargetBiggerOnOneAxis;
|
return isTargetBiggerOnOneAxis;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default isPartiallyVisibleThroughFrame;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import isWithin from "../is-within";
|
import isWithin from "../is-within";
|
||||||
import { vertical } from "../axis";
|
import { vertical } from "../axis";
|
||||||
|
|
||||||
export default (axis) => (frame) => {
|
const isTotallyVisibleThroughFrameOnAxis = (axis) => (frame) => {
|
||||||
const isWithinVertical = isWithin(frame.top, frame.bottom);
|
const isWithinVertical = isWithin(frame.top, frame.bottom);
|
||||||
const isWithinHorizontal = isWithin(frame.left, frame.right);
|
const isWithinHorizontal = isWithin(frame.left, frame.right);
|
||||||
return (subject) => {
|
return (subject) => {
|
||||||
@@ -11,3 +11,5 @@ export default (axis) => (frame) => {
|
|||||||
return isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
|
return isWithinHorizontal(subject.left) && isWithinHorizontal(subject.right);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default isTotallyVisibleThroughFrameOnAxis;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import isWithin from "../is-within";
|
import isWithin from "../is-within";
|
||||||
|
|
||||||
export default (frame) => {
|
const isTotallyVisibleThroughFrame = (frame) => {
|
||||||
const isWithinVertical = isWithin(frame.top, frame.bottom);
|
const isWithinVertical = isWithin(frame.top, frame.bottom);
|
||||||
const isWithinHorizontal = isWithin(frame.left, frame.right);
|
const isWithinHorizontal = isWithin(frame.left, frame.right);
|
||||||
return (subject) => {
|
return (subject) => {
|
||||||
@@ -12,3 +12,5 @@ export default (frame) => {
|
|||||||
return isContained;
|
return isContained;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default isTotallyVisibleThroughFrame;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { add } from "../position";
|
import { add } from "../position";
|
||||||
|
|
||||||
export default (droppable, point) => {
|
const withDroppableDisplacement = (droppable, point) => {
|
||||||
const frame = droppable.frame;
|
const frame = droppable.frame;
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
return add(point, frame.scroll.diff.displacement);
|
return add(point, frame.scroll.diff.displacement);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default withDroppableDisplacement;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { offsetRectByPosition } from "../rect";
|
import { offsetRectByPosition } from "../rect";
|
||||||
|
|
||||||
export default (droppable, area) => {
|
const withDroppableScroll = (droppable, area) => {
|
||||||
const frame = droppable.frame;
|
const frame = droppable.frame;
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
return area;
|
return area;
|
||||||
}
|
}
|
||||||
return offsetRectByPosition(area, frame.scroll.diff.value);
|
return offsetRectByPosition(area, frame.scroll.diff.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default withDroppableScroll;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
import { add } from "../position";
|
import { add } from "../position";
|
||||||
|
|
||||||
export default (viewport, point) => add(viewport.scroll.diff.displacement, point);
|
const withViewportDisplacement = (viewport, point) => add(viewport.scroll.diff.displacement, point);
|
||||||
|
|
||||||
|
export default withViewportDisplacement;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export default function App(props) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Checking for unexpected store changes
|
// Checking for unexpected store changes
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (import.meta.env.DEV) {
|
||||||
if (lazyStoreRef.current && lazyStoreRef.current !== store) {
|
if (lazyStoreRef.current && lazyStoreRef.current !== store) {
|
||||||
warning("unexpected store change");
|
warning("unexpected store change");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const suffix = `
|
|||||||
|
|
||||||
More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/doctype.md
|
More information: https://github.com/atlassian/react-beautiful-dnd/blob/master/docs/guides/doctype.md
|
||||||
`;
|
`;
|
||||||
export default (doc) => {
|
const checkDocType = (doc) => {
|
||||||
const doctype = doc.doctype;
|
const doctype = doc.doctype;
|
||||||
if (!doctype) {
|
if (!doctype) {
|
||||||
warning(`
|
warning(`
|
||||||
@@ -32,3 +32,5 @@ export default (doc) => {
|
|||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default checkDocType;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default class ErrorBoundary extends React.Component {
|
|||||||
|
|
||||||
componentDidCatch(err) {
|
componentDidCatch(err) {
|
||||||
if (err instanceof RbdInvariant) {
|
if (err instanceof RbdInvariant) {
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (import.meta.env.DEV) {
|
||||||
error(err.message);
|
error(err.message);
|
||||||
}
|
}
|
||||||
this.setState({});
|
this.setState({});
|
||||||
@@ -51,7 +51,7 @@ export default class ErrorBoundary extends React.Component {
|
|||||||
// Marking the event as dealt with.
|
// Marking the event as dealt with.
|
||||||
// This will prevent any 'uncaught' error warnings in the console
|
// This will prevent any 'uncaught' error warnings in the console
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (import.meta.env.DEV) {
|
||||||
error(err.message);
|
error(err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import ConnectedDraggable from "./connected-draggable";
|
|||||||
import useRequiredContext from "../use-required-context";
|
import useRequiredContext from "../use-required-context";
|
||||||
import DroppableContext from "../context/droppable-context"; // We can use this to render a draggable with more control
|
import DroppableContext from "../context/droppable-context"; // We can use this to render a draggable with more control
|
||||||
|
|
||||||
|
/* eslint-disable no-func-assign */
|
||||||
function _extends() {
|
function _extends() {
|
||||||
return (
|
return (
|
||||||
(_extends = Object.assign
|
(_extends = Object.assign
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { invariant } from "../invariant";
|
import { invariant } from "../invariant";
|
||||||
|
|
||||||
export default () => {
|
const getBodyElements = () => {
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
invariant(body, "Cannot find document.body");
|
invariant(body, "Cannot find document.body");
|
||||||
return body;
|
return body;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default getBodyElements;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user