({
tabId,
active,
showDivider,
isDragging,
isReordering,
hoverResetVersion,
onSelect,
onClose,
onRename,
onDragStart,
onDragOver,
onDrop,
onDragEnd,
onHoverChanged,
}: VTabWrapperProps)
| 103 | } |
| 104 | |
| 105 | function VTabWrapper({ |
| 106 | tabId, |
| 107 | active, |
| 108 | showDivider, |
| 109 | isDragging, |
| 110 | isReordering, |
| 111 | hoverResetVersion, |
| 112 | onSelect, |
| 113 | onClose, |
| 114 | onRename, |
| 115 | onDragStart, |
| 116 | onDragOver, |
| 117 | onDrop, |
| 118 | onDragEnd, |
| 119 | onHoverChanged, |
| 120 | }: VTabWrapperProps) { |
| 121 | const env = useWaveEnv<VTabBarEnv>(); |
| 122 | const [tabData] = env.wos.useWaveObjectValue<Tab>(makeORef("tab", tabId)); |
| 123 | const badges = useAtomValue(getTabBadgeAtom(tabId, env)); |
| 124 | const renameRef = useRef<(() => void) | null>(null); |
| 125 | const tabModel = getTabModelByTabId(tabId, env); |
| 126 | |
| 127 | useEffect(() => { |
| 128 | const cb = () => renameRef.current?.(); |
| 129 | tabModel.startRenameCallback = cb; |
| 130 | return () => { |
| 131 | if (tabModel.startRenameCallback === cb) { |
| 132 | tabModel.startRenameCallback = null; |
| 133 | } |
| 134 | }; |
| 135 | }, [tabModel]); |
| 136 | |
| 137 | const rawFlagColor = tabData?.meta?.["tab:flagcolor"]; |
| 138 | let flagColor: string | null = null; |
| 139 | if (rawFlagColor) { |
| 140 | try { |
| 141 | validateCssColor(rawFlagColor); |
| 142 | flagColor = rawFlagColor; |
| 143 | } catch { |
| 144 | flagColor = null; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | const tab: VTabItem = { |
| 149 | id: tabId, |
| 150 | name: tabData?.name ?? "", |
| 151 | badges, |
| 152 | flagColor, |
| 153 | }; |
| 154 | |
| 155 | const handleContextMenu = useCallback( |
| 156 | (e: React.MouseEvent<HTMLDivElement>) => { |
| 157 | e.preventDefault(); |
| 158 | e.stopPropagation(); |
| 159 | const menu = buildTabContextMenu(tabId, renameRef, () => onClose(), env); |
| 160 | env.showContextMenu(menu, e); |
| 161 | }, |
| 162 | [tabId, onClose, env] |
nothing calls this directly
no test coverage detected