@antv/s2-react-components
Version:
React components for S2
22 lines • 1.82 kB
JavaScript
import cx from 'classnames';
import { isEmpty } from 'lodash';
import React from 'react';
import { Draggable } from 'react-beautiful-dnd';
import { getSwitcherClassName } from '../util';
import './index.less';
import { SingleItem } from './single-item';
export const DimensionItem = React.memo(({ fieldType, item: { id, displayName, checked = true, children = [] }, expandable, expandChildren, isDragDisabled, selectable, index, draggingItemId, onVisibleItemChange, }) => (React.createElement(Draggable, { draggableId: id, index: index, isDragDisabled: isDragDisabled }, (provided, snapshot) => (React.createElement("div", Object.assign({}, provided.draggableProps, { ref: provided.innerRef, className: cx(getSwitcherClassName(selectable ? 'checkable-list' : 'normal-list'), {
dragging: snapshot.isDragging,
'disable-dragging': isDragDisabled,
}) }),
React.createElement(SingleItem, { dragHandleProps: provided.dragHandleProps, fieldType: fieldType, id: id, displayName: displayName, checked: checked, onVisibleItemChange: onVisibleItemChange, selectable: selectable, className: cx(selectable ? 'checkable-item' : 'normal-item', {
'item-collapse': !expandChildren,
}) }),
expandable &&
expandChildren &&
!isEmpty(children) &&
draggingItemId !== id && (React.createElement("div", { className: cx('child-items', {
'item-hidden': !expandChildren,
}) }, children.map((item) => (React.createElement(SingleItem, { key: item.id, id: item.id, fieldType: fieldType, displayName: item.displayName, disabled: !checked, checked: item.checked, parentId: id, selectable: selectable, onVisibleItemChange: onVisibleItemChange, className: "checkable-item" }))))))))));
DimensionItem.displayName = 'DimensionItem';
//# sourceMappingURL=index.js.map