| 48 | }); |
| 49 | |
| 50 | export function InsertionIndicator({target}: {target: ItemDropTarget}) { |
| 51 | let {dropState} = useContext(DragAndDropContext) ?? {}; |
| 52 | let level = 0; |
| 53 | if (target.type === 'item' && dropState?.collection) { |
| 54 | level = dropState.collection.getItem(target.key)?.level ?? 0; |
| 55 | } |
| 56 | return ( |
| 57 | <DropIndicator className="" target={target}> |
| 58 | {({isDropTarget}) => ( |
| 59 | <div |
| 60 | className={insertionIndicatorWrapper({isDropTarget, isRoot: level === 0})} |
| 61 | style={level > 0 ? ({'--drop-level': level} as React.CSSProperties) : undefined}> |
| 62 | <svg aria-hidden width="100%" height="12"> |
| 63 | <line x1="0" y1="6" x2="100%" y2="6" strokeWidth="2" stroke="currentColor" /> |
| 64 | <circle |
| 65 | cx="6" |
| 66 | cy="6" |
| 67 | r="5" |
| 68 | strokeWidth="2" |
| 69 | stroke="currentColor" |
| 70 | style={{fill: 'var(--indicator-circle-bg)'}} |
| 71 | /> |
| 72 | <circle |
| 73 | cx="100%" |
| 74 | cy="6" |
| 75 | r="5" |
| 76 | strokeWidth="2" |
| 77 | stroke="currentColor" |
| 78 | style={{fill: 'var(--indicator-circle-bg)'}} |
| 79 | transform="translate(-6, 0)" |
| 80 | /> |
| 81 | </svg> |
| 82 | </div> |
| 83 | )} |
| 84 | </DropIndicator> |
| 85 | ); |
| 86 | } |
| 87 | |
| 88 | let dragButton = style({ |
| 89 | color: 'inherit', |