linkmore-design
Version:
π πlmη»δ»ΆεΊγπ
73 lines (69 loc) β’ 2.07 kB
JavaScript
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["children"];
import React, { forwardRef } from 'react';
import { useSortable } from '@dnd-kit/sortable';
// import { omit } from 'lodash'
import { CSS } from '@dnd-kit/utilities';
// interface ItemType {
// children: React.ReactNode
// }
// interface ItemInstance {}
// @ts-ignore
var Item = /*#__PURE__*/forwardRef(function (_ref, ref) {
var children = _ref.children,
props = _objectWithoutProperties(_ref, _excluded);
// const rProps = omit({ ...props, ...children.props }, [
// 'isSticky',
// 'colStart',
// 'colEnd',
// 'prefixCls',
// 'fixLeft',
// 'fixRight',
// 'lastFixLeft',
// 'firstFixRight',
// 'lastFixRight',
// 'firstFixLeft',
// 'isSticky',
// 'additionalProps',
// 'rowType',
// ])
return (
/*#__PURE__*/
// <th {...rProps} ref={ref as any} />
React.createElement("th", _extends({}, props, children.props, {
ref: ref
}))
// <th {...props} ref={ref as any}>
// {(children as any)?.props?.children || children}
// </th>
);
});
export default function SortableItem(props) {
var id = props.id;
var _useSortable = useSortable({
id: id
}),
attributes = _useSortable.attributes,
listeners = _useSortable.listeners,
setNodeRef = _useSortable.setNodeRef,
transform = _useSortable.transform,
transition = _useSortable.transition;
var style = {
position: 'relative',
transform: CSS.Translate.toString(transform ? _objectSpread(_objectSpread({}, transform), {}, {
y: 0
}) : transform),
transition: transition,
touchAction: 'none',
height: '40px',
cursor: 'move',
padding: '8px 10px',
fontSize: '12px'
};
return /*#__PURE__*/React.createElement(Item, _extends({
ref: setNodeRef,
style: style
}, attributes, listeners, props));
}