linkmore-design
Version:
π πlmη»δ»ΆεΊγπ
39 lines β’ 1.37 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["data-row-key", "children", "className", "virtual"];
import React, { memo } from 'react';
import { useSortable } from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
import { VirtualRow } from "./virtual";
var SortableItem = function SortableItem(props) {
var key = props['data-row-key'],
children = props.children,
className = props.className,
virtual = props.virtual,
resetField = _objectWithoutProperties(props, _excluded);
var _useSortable = useSortable({
id: key
}),
attributes = _useSortable.attributes,
setNodeRef = _useSortable.setNodeRef,
transform = _useSortable.transform,
transition = _useSortable.transition;
var style = {
transform: CSS.Transform.toString(transform),
transition: transition
};
if (!virtual) {
return /*#__PURE__*/React.createElement("tr", _extends({}, resetField, {
ref: setNodeRef,
key: key,
style: style
}, attributes), children);
}
return /*#__PURE__*/React.createElement(VirtualRow, _extends({}, resetField, {
ref: setNodeRef,
pref: setNodeRef,
key: key,
style: style
}, attributes), children);
};
export default /*#__PURE__*/memo(SortableItem);