UNPKG

@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)

58 lines (57 loc) 1.78 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.DropIndicator = DropIndicator; var _react = _interopRequireDefault(require("react")); var _border = require("./border"); var _box = require("./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.default.createElement(_box.DropIndicator, { edge: "top", appearance: appearance, indent: indent }); } if (instruction.type === 'reorder-below') { return /*#__PURE__*/_react.default.createElement(_box.DropIndicator, { edge: "bottom", appearance: appearance, indent: indent }); } if (instruction.type === 'make-child') { return /*#__PURE__*/_react.default.createElement(_border.DropIndicator, { appearance: appearance, indent: indent }); } if (instruction.type === 'reparent') { var reparentIndent = "".concat(instruction.desiredLevel * instruction.indentPerLevel, "px"); return /*#__PURE__*/_react.default.createElement(_box.DropIndicator, { edge: "bottom", appearance: appearance, indent: reparentIndent }); } return null; } 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 }); }