@atlaskit/pragmatic-drag-and-drop-react-drop-indicator
Version:
An optional Pragmatic drag and drop package containing react components that provide a visual indication about what the user will achieve when the drop (eg lines)
51 lines • 1.5 kB
JavaScript
import React from 'react';
import { DropIndicator as Border } from './border';
import { DropIndicator as Line } from './box';
function getElement(_ref) {
var instruction = _ref.instruction,
isBlocked = _ref.isBlocked;
var indent = "".concat(instruction.currentLevel * instruction.indentPerLevel, "px");
var appearance = isBlocked ? 'warning' : 'default';
if (instruction.type === 'reorder-above') {
return /*#__PURE__*/React.createElement(Line, {
edge: "top",
appearance: appearance,
indent: indent
});
}
if (instruction.type === 'reorder-below') {
return /*#__PURE__*/React.createElement(Line, {
edge: "bottom",
appearance: appearance,
indent: indent
});
}
if (instruction.type === 'make-child') {
return /*#__PURE__*/React.createElement(Border, {
appearance: appearance,
indent: indent
});
}
if (instruction.type === 'reparent') {
var reparentIndent = "".concat(instruction.desiredLevel * instruction.indentPerLevel, "px");
return /*#__PURE__*/React.createElement(Line, {
edge: "bottom",
appearance: appearance,
indent: reparentIndent
});
}
return null;
}
export function DropIndicator(_ref2) {
var instruction = _ref2.instruction;
if (instruction.type === 'instruction-blocked') {
return getElement({
instruction: instruction.desired,
isBlocked: true
});
}
return getElement({
instruction: instruction,
isBlocked: false
});
}