관망도 레이어 전체켜기 기능 추가
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/** SN 표시 순번 계산용 인자. pageIndex와 rowIndex는 0부터 시작한다. */
|
||||
type SnRowNumberParams = {
|
||||
/** 기존 호출부의 전체 건수는 페이지 계산에 사용하지 않는다. */
|
||||
total?: number;
|
||||
rowIndex: number;
|
||||
pageIndex?: number;
|
||||
pageSize?: number;
|
||||
};
|
||||
|
||||
/** 데이터 정렬·식별자는 유지하고 현재 조회 순서에 1부터 연속 순번을 붙인다. */
|
||||
export function getSnRowNumber({
|
||||
rowIndex,
|
||||
pageIndex = 0,
|
||||
pageSize = 0,
|
||||
}: SnRowNumberParams): number {
|
||||
return pageIndex * pageSize + rowIndex + 1;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
/** CSS 말줄임표 대상과 같은 범위를 사용하며 입력/액션/병합 셀의 툴팁은 건드리지 않는다. */
|
||||
const CELL_SELECTOR = 'body[data-sn-grid-ellipsis="true"] table:has(> thead) > tbody > tr > td:not([colspan]):not([rowspan]):not([data-sn-cell-wrap]):not(:has(input, textarea, select, button, [role="checkbox"], [role="switch"], [contenteditable="true"], table, img, svg))';
|
||||
|
||||
/** 동적 목록·포털에도 공통 적용하며 기존 title과 실제 데이터는 변경하지 않는다. */
|
||||
export function GridCellTooltip() {
|
||||
useEffect(() => {
|
||||
const generatedTitles = new WeakMap<HTMLTableCellElement, string>();
|
||||
const showFullText = (event: Event) => {
|
||||
if (!(event.target instanceof Element)) return;
|
||||
const cell = event.target.closest<HTMLTableCellElement>(CELL_SELECTOR);
|
||||
if (!cell) return;
|
||||
const previous = generatedTitles.get(cell);
|
||||
// 화면에서 이미 지정한 상세 툴팁을 우선한다.
|
||||
if ((cell.hasAttribute("title") && cell.title !== previous) || cell.querySelector("[title]")) return;
|
||||
const overflowed = [cell, ...cell.querySelectorAll<HTMLElement>("div, span, a, p")]
|
||||
.some((element) => element.scrollWidth > element.clientWidth + 1);
|
||||
if (overflowed) {
|
||||
const fullText = cell.textContent?.trim() ?? "";
|
||||
cell.title = fullText;
|
||||
generatedTitles.set(cell, fullText);
|
||||
} else if (previous !== undefined) {
|
||||
cell.removeAttribute("title");
|
||||
generatedTitles.delete(cell);
|
||||
}
|
||||
};
|
||||
document.addEventListener("pointerover", showFullText);
|
||||
document.addEventListener("focusin", showFullText);
|
||||
return () => {
|
||||
document.removeEventListener("pointerover", showFullText);
|
||||
document.removeEventListener("focusin", showFullText);
|
||||
};
|
||||
}, []);
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user