@ihabdevteam/core 0.382.0 → 0.384.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/dist/components.cjs.js +173 -173
- package/dist/components.esm.css +1 -1
- package/dist/hooks.cjs.js +1 -1
- package/dist/i18n.cjs.js +1 -1
- package/dist/ihabdevteam-core.cjs.js +178 -178
- package/dist/ihabdevteam-core.d.ts +25 -2
- package/dist/packages/core/src/components/Table.css +27 -1
- package/dist/packages/core/src/components/Table.d.ts +7 -0
- package/dist/packages/core/src/components/Table.js +63 -29
- package/dist/packages/core/src/components/Word/WordTableBlock.js +4 -0
- package/dist/packages/core/src/components/WordTable.d.ts +17 -1
- package/dist/packages/core/src/components/WordTable.js +24 -10
- package/dist/packages/core/src/components/tableFitWidths.d.ts +46 -0
- package/dist/packages/core/src/components/tableFitWidths.js +55 -0
- package/dist/packages/core/src/components/tableSpanMeasure.d.ts +48 -0
- package/dist/packages/core/src/components/tableSpanMeasure.js +74 -0
- package/dist/packages/core/src/utils/headProbeStatus.d.ts +1 -1
- package/dist/packages/core/src/utils/headProbeStatus.js +1 -1
- package/dist/packages/core/src/version.d.ts +1 -1
- package/dist/packages/core/src/version.js +1 -1
- package/dist/utils.cjs.js +1 -1
- package/package.json +1 -1
|
@@ -1787,7 +1787,7 @@ export declare function copyText(text: string): Promise<boolean>;
|
|
|
1787
1787
|
*
|
|
1788
1788
|
* 값은 손으로 적고 `test/coreVersion.test.ts` 가 package.json 과 어긋나면 운다.
|
|
1789
1789
|
*/
|
|
1790
|
-
export declare const CORE_VERSION = "0.
|
|
1790
|
+
export declare const CORE_VERSION = "0.384.0";
|
|
1791
1791
|
|
|
1792
1792
|
/** @public */
|
|
1793
1793
|
declare const coreDefault: Record<string, unknown>;
|
|
@@ -8015,11 +8015,18 @@ export declare type TableProps<T extends {
|
|
|
8015
8015
|
*
|
|
8016
8016
|
* 안 주면 전과 같다 — 줄이 `tabIndex` 와 설명으로만 눌린다((가) 그대로).
|
|
8017
8017
|
*/
|
|
8018
|
+
/**
|
|
8019
|
+
* 줄 하나를 칸들로. `span` 을 주면 그 칸이 **여러 열을 덮는다**(말귀 청 (215), 2026-10-28) —
|
|
8020
|
+
* 코어가 `grid-column: span N` 과 `aria-colspan` 을 붙이고, **'칸 너비 초기화' 가 재는
|
|
8021
|
+
* 자리도 그 수를 센다.** `style` 에 `gridColumn` 을 손으로 적어도 격자는 서지만 재는 쪽이
|
|
8022
|
+
* 모르므로, 덮는 칸은 `span` 으로 알려 줘야 한다.
|
|
8023
|
+
*/
|
|
8018
8024
|
renderRow: (item: T) => Array<{
|
|
8019
8025
|
content: ReactNode;
|
|
8020
8026
|
className?: string;
|
|
8021
8027
|
style?: CSSProperties;
|
|
8022
8028
|
rowLabel?: string;
|
|
8029
|
+
span?: number;
|
|
8023
8030
|
}>;
|
|
8024
8031
|
onRowClick?: (item: T) => void;
|
|
8025
8032
|
/**
|
|
@@ -11523,7 +11530,7 @@ export declare interface WordSearchResultWord {
|
|
|
11523
11530
|
* 표시(items)·편집(editCells) 두 모드를 지원한다.
|
|
11524
11531
|
* @public
|
|
11525
11532
|
*/
|
|
11526
|
-
export declare function WordTable({ title, titleIcon, disc, className, orientation, contentTypes, baseItem, baseContentTypes, cutLine, showOutline, showDivLine, items, editCells, count, activeCell, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd, addableCount, contentRef, buttonSize, brand, code, pageNumber, pageNumberPosition, fitHeight, scoring, marks, onMarkClick, scoreIndexOffset, }: WordTableProps): JSX.Element;
|
|
11533
|
+
export declare function WordTable({ title, titleIcon, disc, className, orientation, contentTypes, baseItem, baseContentTypes, cutLine, showOutline, showDivLine, items, editCells, count, activeCell, onActivateCell, onRemoveCell, onRemoveItem, onReorder, indexOffset, totalCount, renderCellAction, showFillerAdd, addableCount, contentRef, buttonSize, brand, code, pageNumber, pageNumberPosition, fitHeight, scoring, marks, onMarkClick, scoreIndexOffset, }: WordTableProps): JSX.Element;
|
|
11527
11534
|
|
|
11528
11535
|
export declare function WordTableBlock({ title, titleIcon, disc, filterTitle, filterCollapsible, filterDefaultCollapsed, filterCollapsed, onFilterCollapsedChange, filterHeaderSummary, brand, code, baseItem, baseContentTypes, cellCapacity, maxItemsPerPage, items, onSaveComplete, onLoad, onRemoveItem, onReset, resetLabel, saveButtonLabel, secondarySaveButtonLabel, onReorder, showCellCount, onAddItem, className, renderSavePopup, renderWordSearch, hideControls, saveOnly, tableName, nameValue, onNameChange, descriptionValue, onDescriptionChange, namePlaceholder, descriptionPlaceholder, existingNames, editingName, onCancel, initialItemsPerPage, renderCellAction, actionsLeftExtra }: WordTableBlockProps): JSX.Element;
|
|
11529
11536
|
|
|
@@ -11952,6 +11959,22 @@ export declare interface WordTableProps {
|
|
|
11952
11959
|
* 키보드로 옮기면 초점이 그 칸을 따라가고 바뀐 자리를 `role="status"` 로 알린다.
|
|
11953
11960
|
*/
|
|
11954
11961
|
onReorder?: (fromIndex: number, toIndex: number) => void;
|
|
11962
|
+
/**
|
|
11963
|
+
* 이 표의 첫 칸이 **전체 목록에서 몇 번째**인가 — 쪽으로 나뉜 표에서 `WordTableBlock` 이 준다
|
|
11964
|
+
* (말귀 청 (338), 2026-10-28).
|
|
11965
|
+
*
|
|
11966
|
+
* 쪽마다 `WordTable` 이 따로 서면 `index` 는 **쪽 안의 번호**다. 그래서 `Alt`+`→` 가 쪽의
|
|
11967
|
+
* 마지막 칸에서, `Alt`+`←` 가 쪽의 첫 칸에서 **돌아섰다** — 활용표는 스무 칸이 두 쪽이라
|
|
11968
|
+
* 쪽 경계가 늘 가운데에 있고, 거기 선 칸은 영영 못 옮겼다(말귀 실측: 눌러도 아무 칸도
|
|
11969
|
+
* 안 움직인다).
|
|
11970
|
+
*
|
|
11971
|
+
* `onReorder` 로 올라가는 번호는 **그대로 쪽 안의 번호**다(쪽을 넘을 때는 `-1` 이나
|
|
11972
|
+
* `count` 가 된다) — 부르는 쪽이 이미 `+ 쪽번호 × 쪽당` 을 얹으므로 그 합이 곧 전체
|
|
11973
|
+
* 번호가 된다. 부르는 쪽은 고칠 것이 없다.
|
|
11974
|
+
*/
|
|
11975
|
+
indexOffset?: number;
|
|
11976
|
+
/** 전체 칸 수 — 쪽으로 나뉜 표에서 양 끝을 전체 기준으로 가른다(`indexOffset` 과 한 짝) */
|
|
11977
|
+
totalCount?: number;
|
|
11955
11978
|
/** 표시 모드에서 `count` 안의 빈칸(항목 수 뒤 ~ count)에 '추가' 버튼 노출. count 가 항목 수와 같으면 그런 칸이 없다. `onActivateCell` 필요. */
|
|
11956
11979
|
showFillerAdd?: boolean;
|
|
11957
11980
|
/**
|
|
@@ -79,7 +79,9 @@
|
|
|
79
79
|
/* 필드 라벨 행 — 정렬 클릭 가능한 컬럼 헤더. 높이는 size 스케일을 따름 */
|
|
80
80
|
/* 되돌리기 단추를 얹을 겉. **`.table-fields` 안에 넣으면 안 된다** — 그 자식은
|
|
81
81
|
곧 열이라 칸이 하나 늘어 몸통 줄과 어긋난다. 겉에서 자리를 안 차지하게 얹는다. */
|
|
82
|
-
.table-fields-strip { position: relative; }
|
|
82
|
+
.table-fields-strip { position: relative; display: flex; align-items: stretch; }
|
|
83
|
+
/* 격자는 **줄어들지 않는다** — `min-width: 0` 을 주면 열 폭 합보다 좁아져 넘침이 사라진다 */
|
|
84
|
+
.table-fields-strip > .table-fields { flex: 1 0 auto; }
|
|
83
85
|
|
|
84
86
|
/* 단추가 설 자리를 비운다. **머리와 몸통에 똑같이** 줘야 한다 — 한쪽만 주면
|
|
85
87
|
그쪽 격자만 좁아져 열이 어긋난다.
|
|
@@ -92,14 +94,38 @@
|
|
|
92
94
|
.table-wrap--resizable .table-fields,
|
|
93
95
|
.table-wrap--resizable .table-row { padding-right: var(--table-reset-gutter, 40px); }
|
|
94
96
|
|
|
97
|
+
/* **단추 받침 — 보이는 오른쪽 끝에 붙박인다**(말귀 청 (216), 2026-10-28).
|
|
98
|
+
|
|
99
|
+
단추가 띠의 `right: 0` 에 그냥 얹혀 있던 때는, 열이 넘쳐 안쪽 상자가 열 폭만큼
|
|
100
|
+
넓어지면 그 자리가 **스크롤 끝**이었다 — 오른쪽 끝까지 밀어야 단추가 나왔고,
|
|
101
|
+
칸이 넘치는 그때가 바로 누르고 싶은 때였다(말귀 실측: 단추는 `visible`,
|
|
102
|
+
스크롤러는 `.table-wrap` 의 `overflow-x: auto`).
|
|
103
|
+
|
|
104
|
+
`sticky right: 0` 이 스크롤러의 **보이는** 오른쪽 끝에 붙여 둔다. 폭을 0 으로 두어
|
|
105
|
+
열 셈에는 아무것도 더하지 않는다(빈자리는 `--table-reset-gutter` 가 따로 비운다). */
|
|
106
|
+
.table-fields__reset-dock {
|
|
107
|
+
position: sticky;
|
|
108
|
+
right: 0;
|
|
109
|
+
flex: 0 0 0;
|
|
110
|
+
width: 0;
|
|
111
|
+
align-self: center;
|
|
112
|
+
/* 받침은 폭이 0 이라 단추가 밖으로 나와야 보인다 */
|
|
113
|
+
overflow: visible;
|
|
114
|
+
}
|
|
115
|
+
|
|
95
116
|
.table-fields__reset {
|
|
96
117
|
position: absolute;
|
|
97
118
|
/* **빈자리(40px)에 딱 맞춘다** — `right: 2px` 이던 때는 40px 단추가 42px 을 차지해 마지막
|
|
98
119
|
머리의 안쪽 여백을 2px 물고 있었다(2026-10-26 실측: 단추 1482~1522, 마지막 머리 끝 1484).
|
|
99
120
|
눈에는 안 띄는 겹침이지만 머리·본문에 비운 자리와 수가 어긋난다. */
|
|
121
|
+
/* 받침의 오른쪽 끝에서 왼쪽으로 — 받침이 폭 0 이므로 단추 전체가 왼쪽에 걸린다 */
|
|
100
122
|
right: 0;
|
|
101
123
|
top: 50%;
|
|
102
124
|
transform: translateY(-50%);
|
|
125
|
+
/* 넘쳐서 열 위에 겹쳐 설 때 **글자가 비쳐 읽히지 않게** 바탕을 깐다 —
|
|
126
|
+
붙박이가 된 뒤에 생긴 일이다(전에는 빈자리에만 섰다). */
|
|
127
|
+
background: var(--color-white);
|
|
128
|
+
border-radius: var(--radius-card);
|
|
103
129
|
}
|
|
104
130
|
|
|
105
131
|
.table-fields {
|
|
@@ -127,11 +127,18 @@ export type TableProps<T extends {
|
|
|
127
127
|
*
|
|
128
128
|
* 안 주면 전과 같다 — 줄이 `tabIndex` 와 설명으로만 눌린다((가) 그대로).
|
|
129
129
|
*/
|
|
130
|
+
/**
|
|
131
|
+
* 줄 하나를 칸들로. `span` 을 주면 그 칸이 **여러 열을 덮는다**(말귀 청 (215), 2026-10-28) —
|
|
132
|
+
* 코어가 `grid-column: span N` 과 `aria-colspan` 을 붙이고, **'칸 너비 초기화' 가 재는
|
|
133
|
+
* 자리도 그 수를 센다.** `style` 에 `gridColumn` 을 손으로 적어도 격자는 서지만 재는 쪽이
|
|
134
|
+
* 모르므로, 덮는 칸은 `span` 으로 알려 줘야 한다.
|
|
135
|
+
*/
|
|
130
136
|
renderRow: (item: T) => Array<{
|
|
131
137
|
content: ReactNode;
|
|
132
138
|
className?: string;
|
|
133
139
|
style?: CSSProperties;
|
|
134
140
|
rowLabel?: string;
|
|
141
|
+
span?: number;
|
|
135
142
|
}>;
|
|
136
143
|
onRowClick?: (item: T) => void;
|
|
137
144
|
/**
|
|
@@ -12,6 +12,8 @@ import { compareCellBlankLast } from '../utils/textSort';
|
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
import './Table.css';
|
|
14
14
|
import './TableCell.css';
|
|
15
|
+
import { widestPerColumn, spanFromGridStyle } from './tableSpanMeasure';
|
|
16
|
+
import { fitFluidWidths, columnFloors } from './tableFitWidths';
|
|
15
17
|
import './TableField.css';
|
|
16
18
|
import { useState, useRef, useCallback, useEffect, useId, useMemo } from 'react';
|
|
17
19
|
import ChevronUp from 'lucide-react/dist/esm/icons/chevron-up.mjs';
|
|
@@ -23,8 +25,14 @@ import useMediaQuery from '../hooks/useMediaQuery';
|
|
|
23
25
|
/* 칸 하나 — `role="cell"` 이라야 낭독기가 **낱낱으로** 읽는다(말귀 요청 (56), 2026-10-02).
|
|
24
26
|
역할이 없던 때는 줄 전체가 한 덩어리 글로 읽혀 `홍길동 010-1234-5678 2026-09-30 활성`
|
|
25
27
|
이 한 호흡에 나갔다 — 어디까지가 이름이고 어디부터 전화인지 소리로는 알 수 없었다. */
|
|
26
|
-
function TableCell({ children, className, style, rowLabel, onRowClick }) {
|
|
27
|
-
|
|
28
|
+
function TableCell({ children, className, style, span, rowLabel, onRowClick }) {
|
|
29
|
+
/* 부르는 쪽이 `style` 에 적은 `gridColumn` 은 그대로 둔다 — `span` 을 줬을 때만 코어가 짓는다.
|
|
30
|
+
둘 다 주면 부르는 쪽 것이 이긴다(뒤에 놓인다): 격자는 그쪽 뜻대로 서고, 재는 자리는
|
|
31
|
+
`span` 을 보니 둘이 어긋나면 그것은 부르는 쪽이 고를 일이다. */
|
|
32
|
+
const cellStyle = span && span > 1
|
|
33
|
+
? { gridColumn: `span ${span}`, ...style }
|
|
34
|
+
: style;
|
|
35
|
+
return (_jsx("div", { role: "cell", className: className ? `table-cell ${className}` : 'table-cell', style: cellStyle, "aria-colspan": span && span > 1 ? span : undefined, children: rowLabel && onRowClick
|
|
28
36
|
/* **진짜 `<button>` 이라 Enter·Space 는 브라우저가 처리한다** — 손으로 키를 붙이지
|
|
29
37
|
않는다(`TableField` 의 머리 단추와 같은 본). 클릭은 줄로 올라가 `onRowClick` 이
|
|
30
38
|
한 번 불린다. 겉모양은 CSS 가 지운다(`.table-cell__row-button`). */
|
|
@@ -527,13 +535,40 @@ export default function Table({ fields: rawFields = [], sort: sortBinding, sorta
|
|
|
527
535
|
이때는 열이 어긋나 보이지만, 같은 함수 안에서 되돌리므로 화면에는 안 나온다. */
|
|
528
536
|
const rows = Array.from(wrap.querySelectorAll('.table-row'))
|
|
529
537
|
.filter(r => !r.classList.contains('table-row--loading') && !r.classList.contains('table-row--empty'));
|
|
538
|
+
/* **열마다 가장 넓은 값** — 자식 번호가 아니라 **격자 번호**로 센다(말귀 청 (215)).
|
|
539
|
+
규칙은 `tableSpanMeasure.ts` 가 든다(그 머리말에 까닭과 실측이 있다). 여기서는 DOM 에서
|
|
540
|
+
폭과 덮는 수를 읽어 넘기기만 한다 — 머리 줄도 한 줄로 함께 넣는다. */
|
|
541
|
+
const cellsOf = (row) => Array.from(row.children).map(c => {
|
|
542
|
+
const cs = window.getComputedStyle(c);
|
|
543
|
+
return { width: c.getBoundingClientRect().width, span: spanFromGridStyle(cs.gridColumnStart, cs.gridColumnEnd) };
|
|
544
|
+
});
|
|
545
|
+
const columnGap = parseFloat(window.getComputedStyle(el).columnGap) || 0;
|
|
546
|
+
const bodyCells = rows.map(cellsOf);
|
|
547
|
+
const headCells = cellsOf(el);
|
|
548
|
+
const widest = widestPerColumn([headCells, ...bodyCells], fields.length, columnGap);
|
|
549
|
+
/**
|
|
550
|
+
* **머리글자가 드는 폭은 바닥이다**(말귀 청 (217), 2026-10-28,
|
|
551
|
+
* 사장님 *"value 길이만 계산하고 있는건가? tablefield의 이름 길이도 고려할 수 있나?"*).
|
|
552
|
+
*
|
|
553
|
+
* 머리 칸은 **재고 있었다** — 위 `headCells` 가 그것이다. **잰 뒤 줄일 때 잊었다.**
|
|
554
|
+
* 비율로 줄이는 자리의 바닥이 `declaredMinWidth` 뿐이라, 그 칸에 `minmax(…px,…)` 가
|
|
555
|
+
* 없으면 `MIN_COL_W`(48px) 한 값으로 떨어졌다. 그래서 `성별` 이 `성ᅧ` 로 잘렸다
|
|
556
|
+
* (말귀 실측: 단추 칸 머리는 118px 이 드는데 70px 로 줄었다).
|
|
557
|
+
*
|
|
558
|
+
* **화살표 자리를 정렬 가능한 칸 모두에 얹는다.** 화살표는 *지금 고른* 칸에만 서므로
|
|
559
|
+
* (실측: 고른 칸 16px, 나머지 0), 지금 폭만 보고 바닥을 잡으면 **다른 칸을 고르는
|
|
560
|
+
* 순간 그 칸만 잘린다.**
|
|
561
|
+
*/
|
|
562
|
+
const floors = columnFloors(fields.map((f, i) => ({
|
|
563
|
+
declaredMin: minWidthRef.current(i),
|
|
564
|
+
headWidth: headCells[i]?.width ?? 0,
|
|
565
|
+
sortable: f.sortDir !== undefined || !!f.onClick,
|
|
566
|
+
sorted: !!f.sortDir,
|
|
567
|
+
})));
|
|
568
|
+
/** 줄일 때의 바닥 — 선언된 밑값과 머리글자가 드는 폭 가운데 넓은 쪽 */
|
|
569
|
+
const floorOf = (i) => floors[i] ?? minWidthRef.current(i);
|
|
530
570
|
const measured = fields.map((_, i) => {
|
|
531
|
-
|
|
532
|
-
for (const row of rows) {
|
|
533
|
-
const c = row.children[i];
|
|
534
|
-
if (c)
|
|
535
|
-
w = Math.max(w, c.getBoundingClientRect().width);
|
|
536
|
-
}
|
|
571
|
+
const w = widest[i];
|
|
537
572
|
/* 고정 px 열은 정해 둔 값 그대로 — 최소 폭(MIN_COL_W)으로 올린 값을 고정 합에 넣으면 격자에는 원래 값(40px)으로 나가
|
|
538
573
|
그만큼(8px) 표 오른쪽이 비었다(말귀 어드민 버그 탭·쿠폰) */
|
|
539
574
|
const fixedWidth = isFixedPxRef.current(i) ? parseFloat(defaultColsRef.current[i]) : NaN;
|
|
@@ -568,25 +603,12 @@ export default function Table({ fields: rawFields = [], sort: sortBinding, sorta
|
|
|
568
603
|
|
|
569
604
|
`fit` 은 이 값이 fr 가중치가 되어 어차피 비율로 채우지만, 저장되는 숫자도
|
|
570
605
|
같은 뜻이 되게 함께 맞춘다. */
|
|
571
|
-
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
finalWidths = measured.map((w, i) => (isFixedPxRef.current(i) ? w : Math.max(minWidthRef.current(i), Math.round(w * ratio))));
|
|
578
|
-
/* 반올림으로 남은 몇 px 은 가장 넓은 유동 열에 얹는다 — 안 그러면 늘 몇 px 이
|
|
579
|
-
비거나 넘친다. 최소 폭에 걸린 열이 있으면 넘칠 수 있는데, 그건 담을 수
|
|
580
|
-
없을 만큼 좁다는 뜻이라 가로 스크롤로 두는 편이 맞다. */
|
|
581
|
-
const diff = Math.round(available - finalWidths.reduce((a, w, i) => a + (isFixedPxRef.current(i) ? 0 : w), 0));
|
|
582
|
-
if (diff !== 0) {
|
|
583
|
-
let widestIndex = -1;
|
|
584
|
-
finalWidths.forEach((w, i) => { if (!isFixedPxRef.current(i) && (widestIndex < 0 || w > finalWidths[widestIndex]))
|
|
585
|
-
widestIndex = i; });
|
|
586
|
-
if (widestIndex >= 0)
|
|
587
|
-
finalWidths[widestIndex] = Math.max(minWidthRef.current(widestIndex), finalWidths[widestIndex] + diff);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
606
|
+
/* 규칙은 `tableFitWidths.ts` 가 든다 — 줄일 때의 **바닥**이 그 머리말의 핵이다(청 (217)). */
|
|
607
|
+
const finalWidths = fitFluidWidths(measured, {
|
|
608
|
+
isFixed: i => isFixedPxRef.current(i),
|
|
609
|
+
floorOf,
|
|
610
|
+
containerWidth,
|
|
611
|
+
});
|
|
590
612
|
/* **쓰지도 저장하지도 않는다 — 잰 값을 돌려줄 뿐이다.** 자동 모드에서는 저장하면
|
|
591
613
|
안 된다(저장소에 값이 있으면 손 모드이므로, 저장하는 순간 자동으로 돌아갈 길이
|
|
592
614
|
사라진다). 쓰는 것은 부르는 쪽이 한다. */
|
|
@@ -867,7 +889,19 @@ export default function Table({ fields: rawFields = [], sort: sortBinding, sorta
|
|
|
867
889
|
손잡이를 두지 않는다 — 두면 그 컬럼만 grow처럼 넓어져 표가 밀린다. */
|
|
868
890
|
onResizeStart: canResize && i < fields.length - 1 && f.resizable !== false
|
|
869
891
|
&& (resizeMode !== 'fit' || fields.some((g, j) => j > i && g.resizable !== false))
|
|
870
|
-
? (e) => startResize(i, e) : undefined, children: f.label }, i))) }), canResize && (
|
|
892
|
+
? (e) => startResize(i, e) : undefined, children: f.label }, i))) }), canResize && (
|
|
893
|
+
/* **보이는 오른쪽 끝에 붙박는다**(말귀 청 (216), 2026-10-28,
|
|
894
|
+
사장님 *"칸 너비 초기화 버튼이 사라지면 안되지"*).
|
|
895
|
+
|
|
896
|
+
전에는 단추가 이 띠의 `right: 0` 에 그냥 얹혀 있었다. 띠는 `.table-wrap`
|
|
897
|
+
(= 가로 스크롤러) 안이고, 열이 넘칠 때는 안쪽 상자가 **열 폭만큼** 넓어지므로
|
|
898
|
+
(`measureOverflow`) 그 `right: 0` 은 **스크롤 끝**이다 — 오른쪽 끝까지 밀어야
|
|
899
|
+
단추가 나왔다. **칸이 넘치는 그때가 바로 누르고 싶은 때**인데 그때 손이 안 닿았다.
|
|
900
|
+
|
|
901
|
+
그래서 자리를 안 차지하는 `sticky` 받침에 담는다. 넘치지 않을 때는 띠 끝의
|
|
902
|
+
빈자리(`--table-reset-gutter`)에 그대로 서고, 넘칠 때는 보이는 오른쪽 끝에
|
|
903
|
+
붙어 선다. 받침이 폭 0 이라 열 셈에는 아무것도 더하지 않는다. */
|
|
904
|
+
_jsx("div", { className: "table-fields__reset-dock", children: _jsx(Button, { htmlType: "button", size: 40, type: "dot", variant: "transparent-gray", useBorder: false, icon: "chevrons-left-right-ellipsis", ariaLabel: t('table.resetColumns', '칸 너비 초기화'), showTooltipInfo: t('table.resetColumns', '칸 너비 초기화'), className: "table-fields__reset", onClick: resetColumns }) }))] }), _jsx("div", { role: "rowgroup", className: "table-body", children: loading ? (_jsx(TableRow, { variant: "loading", colSpan: fields.length || undefined })) : items.length === 0 && empty ? (_jsx(TableRow, { variant: "empty", colSpan: fields.length || undefined, children: empty })) : items.map((item, idx) => {
|
|
871
905
|
const isDragging = draggingId != null && item.id === draggingId;
|
|
872
906
|
const clickable = !!onRowClick && (isRowClickable ? isRowClickable(item) : true);
|
|
873
907
|
/* 글자로 견준다 — URL·폼에서 온 '5' 와 자료의 5 가 같은 줄인데 `===` 로는 안 펴졌다 */
|
|
@@ -887,6 +921,6 @@ export default function Table({ fields: rawFields = [], sort: sortBinding, sorta
|
|
|
887
921
|
rowHasButton: renderRow(item).some(c => !!c.rowLabel), describedBy: rowHintId, onMouseEnter: onRowMouseEnter ? (e) => onRowMouseEnter(item, e) : undefined, onMouseLeave: onRowMouseLeave ? (e) => onRowMouseLeave(item, e) : undefined, onDragStart: onRowDragStart ? (e) => onRowDragStart(item, e) : undefined, onDragEnd: onRowDragEnd ? (e) => onRowDragEnd(item, e) : undefined, expandedContent: isExpanded && renderExpandedRow ? renderExpandedRow(item) : undefined, children: renderRow(item).map((cell, i) => (
|
|
888
922
|
/* 열 맞춤(`fields[i].align`)은 **머리와 본문에 함께** 걸린다 —
|
|
889
923
|
한쪽만 걸면 숫자 열의 머리와 값이 서로 다른 쪽으로 붙는다 */
|
|
890
|
-
_jsx(TableCell, { className: cx(cell.className, alignClass(fields[i]?.align)), style: cell.style, rowLabel: clickable ? cell.rowLabel : undefined, onRowClick: clickable ? () => onRowClick(item) : undefined, children: cell.content }, i))) }, item.id != null ? `${typeof item.id}:${item.id}` : `__idx:${idx}`));
|
|
924
|
+
_jsx(TableCell, { className: cx(cell.className, alignClass(fields[i]?.align)), style: cell.style, span: cell.span, rowLabel: clickable ? cell.rowLabel : undefined, onRowClick: clickable ? () => onRowClick(item) : undefined, children: cell.content }, i))) }, item.id != null ? `${typeof item.id}:${item.id}` : `__idx:${idx}`));
|
|
891
925
|
}) })] }))] })] }));
|
|
892
926
|
}
|
|
@@ -386,6 +386,10 @@ export default function WordTableBlock({ title, titleIcon, disc, filterTitle, fi
|
|
|
386
386
|
/* 쪽이 나뉘면 끌어 옮기기가 통째로 꺼졌다(말귀 단어 찾기: 9개부터). 쪽 안의 자리를 전체 자리로 옮겨 넘긴다 —
|
|
387
387
|
쪽을 넘는 이동은 하지 않는다. */
|
|
388
388
|
onReorder: onReorder && ((from, to) => onReorder(from + i * itemsPerPage, to + i * itemsPerPage)),
|
|
389
|
+
/* 쪽 경계에 선 칸도 옮길 수 있게 — 양 끝을 **전체 기준**으로 가르고, 옮긴 칸에
|
|
390
|
+
초점이 옆 쪽까지 따라간다(말귀 청 (338)). 위 `onReorder` 의 셈은 그대로다:
|
|
391
|
+
쪽을 넘을 때 안쪽 표가 주는 `-1`·`쪽당` 에 이 쪽의 몫이 얹혀 전체 번호가 된다. */
|
|
392
|
+
indexOffset: i * itemsPerPage, totalCount: items?.length ?? 0,
|
|
389
393
|
/* 안쪽 표는 제 쪽 안의 번호를 준다 — 부르는 쪽에는 **표 전체 기준**으로 넘긴다
|
|
390
394
|
(위 `onReorder` 와 같은 셈이다. 쪽이 몇으로 나뉘었는지는 부르는 쪽 일이 아니다). */
|
|
391
395
|
renderCellAction: renderCellAction && ((n, item) => renderCellAction(n + i * itemsPerPage, item)),
|
|
@@ -50,6 +50,22 @@ export interface WordTableProps {
|
|
|
50
50
|
* 키보드로 옮기면 초점이 그 칸을 따라가고 바뀐 자리를 `role="status"` 로 알린다.
|
|
51
51
|
*/
|
|
52
52
|
onReorder?: (fromIndex: number, toIndex: number) => void;
|
|
53
|
+
/**
|
|
54
|
+
* 이 표의 첫 칸이 **전체 목록에서 몇 번째**인가 — 쪽으로 나뉜 표에서 `WordTableBlock` 이 준다
|
|
55
|
+
* (말귀 청 (338), 2026-10-28).
|
|
56
|
+
*
|
|
57
|
+
* 쪽마다 `WordTable` 이 따로 서면 `index` 는 **쪽 안의 번호**다. 그래서 `Alt`+`→` 가 쪽의
|
|
58
|
+
* 마지막 칸에서, `Alt`+`←` 가 쪽의 첫 칸에서 **돌아섰다** — 활용표는 스무 칸이 두 쪽이라
|
|
59
|
+
* 쪽 경계가 늘 가운데에 있고, 거기 선 칸은 영영 못 옮겼다(말귀 실측: 눌러도 아무 칸도
|
|
60
|
+
* 안 움직인다).
|
|
61
|
+
*
|
|
62
|
+
* `onReorder` 로 올라가는 번호는 **그대로 쪽 안의 번호**다(쪽을 넘을 때는 `-1` 이나
|
|
63
|
+
* `count` 가 된다) — 부르는 쪽이 이미 `+ 쪽번호 × 쪽당` 을 얹으므로 그 합이 곧 전체
|
|
64
|
+
* 번호가 된다. 부르는 쪽은 고칠 것이 없다.
|
|
65
|
+
*/
|
|
66
|
+
indexOffset?: number;
|
|
67
|
+
/** 전체 칸 수 — 쪽으로 나뉜 표에서 양 끝을 전체 기준으로 가른다(`indexOffset` 과 한 짝) */
|
|
68
|
+
totalCount?: number;
|
|
53
69
|
/** 표시 모드에서 `count` 안의 빈칸(항목 수 뒤 ~ count)에 '추가' 버튼 노출. count 가 항목 수와 같으면 그런 칸이 없다. `onActivateCell` 필요. */
|
|
54
70
|
showFillerAdd?: boolean;
|
|
55
71
|
/**
|
|
@@ -211,4 +227,4 @@ export interface WordTableProps {
|
|
|
211
227
|
* 표시(items)·편집(editCells) 두 모드를 지원한다.
|
|
212
228
|
* @public
|
|
213
229
|
*/
|
|
214
|
-
export default function WordTable({ title, titleIcon, disc, className, orientation, contentTypes, baseItem, baseContentTypes, cutLine, showOutline, showDivLine, items, editCells, count, activeCell, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd, addableCount, contentRef, buttonSize, brand, code, pageNumber, pageNumberPosition, fitHeight, scoring, marks, onMarkClick, scoreIndexOffset, }: WordTableProps): import("react").JSX.Element;
|
|
230
|
+
export default function WordTable({ title, titleIcon, disc, className, orientation, contentTypes, baseItem, baseContentTypes, cutLine, showOutline, showDivLine, items, editCells, count, activeCell, onActivateCell, onRemoveCell, onRemoveItem, onReorder, indexOffset, totalCount, renderCellAction, showFillerAdd, addableCount, contentRef, buttonSize, brand, code, pageNumber, pageNumberPosition, fitHeight, scoring, marks, onMarkClick, scoreIndexOffset, }: WordTableProps): import("react").JSX.Element;
|
|
@@ -277,7 +277,7 @@ function WordCell({ label, subLabel, colloquialLabel, captionLabel, captionBadge
|
|
|
277
277
|
* 표시(items)·편집(editCells) 두 모드를 지원한다.
|
|
278
278
|
* @public
|
|
279
279
|
*/
|
|
280
|
-
export default function WordTable({ title, titleIcon, disc, className, orientation = 'landscape', contentTypes = ['image', 'word', 'standardPron'], baseItem, baseContentTypes, cutLine = 'show', showOutline = true, showDivLine = true, items, editCells, count, activeCell = null, onActivateCell, onRemoveCell, onRemoveItem, onReorder, renderCellAction, showFillerAdd = false, addableCount, contentRef, buttonSize = 40, brand, code, pageNumber, pageNumberPosition = 'right', fitHeight = false, scoring = false, marks, onMarkClick, scoreIndexOffset = 0, }) {
|
|
280
|
+
export default function WordTable({ title, titleIcon, disc, className, orientation = 'landscape', contentTypes = ['image', 'word', 'standardPron'], baseItem, baseContentTypes, cutLine = 'show', showOutline = true, showDivLine = true, items, editCells, count, activeCell = null, onActivateCell, onRemoveCell, onRemoveItem, onReorder, indexOffset = 0, totalCount, renderCellAction, showFillerAdd = false, addableCount, contentRef, buttonSize = 40, brand, code, pageNumber, pageNumberPosition = 'right', fitHeight = false, scoring = false, marks, onMarkClick, scoreIndexOffset = 0, }) {
|
|
281
281
|
const clickMark = useCallback((cellIndex, clicked) => {
|
|
282
282
|
onMarkClick?.(scoreIndexOffset + cellIndex, clicked);
|
|
283
283
|
}, [onMarkClick, scoreIndexOffset]);
|
|
@@ -326,6 +326,8 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
326
326
|
굴러가지도 않아 손가락으로도 못 바꿨다. 표를 만드는 화면의 핵심 조작인데
|
|
327
327
|
마우스 있는 사람만 쓸 수 있었다. 마우스 끌기는 그대로 두고 두 길을 더한다. */
|
|
328
328
|
const wordCount = items?.length ?? 0;
|
|
329
|
+
/* 쪽으로 나뉜 표에서는 **전체** 칸 수로 양 끝을 가른다(청 (338)) — 안 주면 이 표가 전부다 */
|
|
330
|
+
const reorderTotal = totalCount ?? wordCount;
|
|
329
331
|
/** 지금 손가락에 끌려가는 칸 */
|
|
330
332
|
const [dragging, setDragging] = useState(null);
|
|
331
333
|
/** 낭독기에 바뀐 자리를 알리는 글. 처음에는 비워 둔다 — 열자마자 뜬금없이 읽지 않게. */
|
|
@@ -347,12 +349,16 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
347
349
|
contentRef.current = el;
|
|
348
350
|
}, [contentRef]);
|
|
349
351
|
const move = useCallback((from, to) => {
|
|
350
|
-
|
|
352
|
+
/* **초점 갈 곳은 전체 번호로 둔다** — 쪽을 넘는 이동에서는 그 칸이 **옆 쪽의 표**에
|
|
353
|
+
서므로, 이 표 안의 번호로는 찾을 수 없다(청 (338)). */
|
|
354
|
+
focusTarget.current = indexOffset + to;
|
|
351
355
|
onReorder?.(from, to);
|
|
356
|
+
/* 낭독기에 이르는 수도 전체 기준이다 — 쪽 안의 번호를 읽으면 "20칸 가운데 1번째" 가
|
|
357
|
+
두 번 나와 어디로 갔는지 알 수 없다 */
|
|
352
358
|
setMoveAnnounce(t('wordTable.reorder.moved', {
|
|
353
|
-
n: to + 1, total:
|
|
359
|
+
n: indexOffset + to + 1, total: reorderTotal, defaultValue: '{{total}}칸 가운데 {{n}}번째로 옮김',
|
|
354
360
|
}));
|
|
355
|
-
}, [onReorder, t,
|
|
361
|
+
}, [onReorder, t, reorderTotal, indexOffset]);
|
|
356
362
|
/* 옮긴 칸을 초점이 따라간다. 자리를 잃으면 다음 Alt+화살표가 엉뚱한 칸을 민다 —
|
|
357
363
|
아예 문서 처음으로 튀어 어디였는지도 알 수 없다. 의존성 배열 없이 매 렌더 뒤에
|
|
358
364
|
보되 `초점갈곳` 이 비어 있으면 곧바로 돌아온다(거의 언제나 그렇다). */
|
|
@@ -361,8 +367,12 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
361
367
|
if (to == null)
|
|
362
368
|
return;
|
|
363
369
|
focusTarget.current = null;
|
|
364
|
-
|
|
365
|
-
|
|
370
|
+
/* **쪽을 넘어 찾는다**(청 (338)). 쪽으로 나뉜 표는 쪽마다 `WordTable` 이 따로 서므로,
|
|
371
|
+
옆 쪽으로 옮긴 칸은 **이 표 안에 없다.** 쪽들을 담은 상자까지 올라가 전체 번호로 찾는다
|
|
372
|
+
— 그 상자가 없으면(쪽이 안 나뉜 표) 이 표 안에서만 찾는다. 상자까지 올라가는 것이
|
|
373
|
+
`document` 전체를 뒤지는 것보다 좁다: 한 화면에 표가 둘이면 번호가 겹친다. */
|
|
374
|
+
const scope = gridRef.current?.closest('.word-table-block__pages') ?? gridRef.current;
|
|
375
|
+
scope?.querySelector(`[data-wordtable-index="${to}"] .word-table__card-handle button`)?.focus();
|
|
366
376
|
});
|
|
367
377
|
/* 떠날 때 걸어 둔 것을 푼다 — 길게 누르는 중에 팝업이 닫히면 window 리스너와
|
|
368
378
|
타이머가 남아 사라진 화면의 상태를 건드린다(표의 폭 조절에서 겪은 것과 같다). */
|
|
@@ -383,10 +393,14 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
383
393
|
return;
|
|
384
394
|
e.preventDefault();
|
|
385
395
|
const to = index + (forward ? 1 : -1);
|
|
386
|
-
|
|
387
|
-
|
|
396
|
+
/* **전체 기준으로 가른다**(청 (338)). 쪽 안의 번호로 가르면 쪽의 첫 칸(`to = -1`)과
|
|
397
|
+
마지막 칸(`to = 쪽당`)에서 돌아서, 쪽 경계에 선 칸을 영영 못 옮긴다. 넘기는 번호는
|
|
398
|
+
그대로 쪽 안의 것이라(`-1`·`count`) 부르는 쪽이 얹는 쪽 몫과 합쳐 전체 번호가 된다. */
|
|
399
|
+
const globalTo = indexOffset + to;
|
|
400
|
+
if (globalTo < 0 || globalTo >= reorderTotal)
|
|
401
|
+
return; // 전체의 양 끝 — 아무 일도 하지 않는다
|
|
388
402
|
move(index, to);
|
|
389
|
-
}, [onReorder,
|
|
403
|
+
}, [onReorder, reorderTotal, indexOffset, move]);
|
|
390
404
|
/**
|
|
391
405
|
* **손가락으로 옮긴다** — 길게 누르면(400ms) 끌기가 시작되고 손가락 밑의 칸으로 떨어진다.
|
|
392
406
|
*
|
|
@@ -616,7 +630,7 @@ export default function WordTable({ title, titleIcon, disc, className, orientati
|
|
|
616
630
|
gridRow: `1 / span ${half.rows}`,
|
|
617
631
|
/* 머리 칸과 나머지 절반을 가르는 점선 — 가로면 오른쪽, 세로면 아래쪽 */
|
|
618
632
|
...dotDashStyle(0, orientation === 'landscape' ? 2 : 1, orientation === 'landscape' ? 1 : 2, cutLine),
|
|
619
|
-
}, children: (baseItem.words ?? []).map((w, wi) => (_jsxs(Fragment, { children: [wi > 0 && _jsx("div", { className: withLegacy("word-table__pair-divider") }), _jsx(WordCell, { outerScale: scale, label: w.label, subLabel: w.subLabel, colloquialLabel: w.colloquialLabel, captionLabel: w.captionLabel, captionBadge: w.captionBadge, homonum: w.homonum, showWord: baseShow.word, showImage: baseShow.image, showPronunciation: baseShow.pron, showColloquial: baseShow.colloq, showCaption: baseShow.caption, buttonSize: buttonSize, wordInfo: (w.grade || w.syllables != null || w.pos || w.wordType) ? { grade: w.grade, syllables: w.syllables, pos: w.pos, wordType: w.wordType } : undefined })] }, wi))) })), (items ?? []).map((item, index) => (_jsxs("div", { "data-wordtable-cell": onReorder ? index : undefined, className: withLegacy(`word-table__card${onReorder ? ' word-table__card--draggable' : ''}${dragOver === index ? ' word-table__card--drag-over' : ''}${dragging === index ? ' word-table__card--dragging' : ''}`), style: dotDashStyle(index, itemCols, itemRows, cutLine), draggable: !!onReorder, onPointerDown: onReorder ? (e) => longPressDrag(e, index) : undefined, onKeyDown: onReorder ? (e) => moveByKey(e, index) : undefined, onDragStart: onReorder ? () => { dragIndex.current = index; } : undefined, onDragOver: onReorder ? (e) => { e.preventDefault(); setDragOver(index); } : undefined, onDragLeave: onReorder ? () => setDragOver(null) : undefined, onDrop: onReorder ? (e) => { e.preventDefault(); if (dragIndex.current !== null && dragIndex.current !== index) {
|
|
633
|
+
}, children: (baseItem.words ?? []).map((w, wi) => (_jsxs(Fragment, { children: [wi > 0 && _jsx("div", { className: withLegacy("word-table__pair-divider") }), _jsx(WordCell, { outerScale: scale, label: w.label, subLabel: w.subLabel, colloquialLabel: w.colloquialLabel, captionLabel: w.captionLabel, captionBadge: w.captionBadge, homonum: w.homonum, showWord: baseShow.word, showImage: baseShow.image, showPronunciation: baseShow.pron, showColloquial: baseShow.colloq, showCaption: baseShow.caption, buttonSize: buttonSize, wordInfo: (w.grade || w.syllables != null || w.pos || w.wordType) ? { grade: w.grade, syllables: w.syllables, pos: w.pos, wordType: w.wordType } : undefined })] }, wi))) })), (items ?? []).map((item, index) => (_jsxs("div", { "data-wordtable-cell": onReorder ? index : undefined, "data-wordtable-index": onReorder ? indexOffset + index : undefined, className: withLegacy(`word-table__card${onReorder ? ' word-table__card--draggable' : ''}${dragOver === index ? ' word-table__card--drag-over' : ''}${dragging === index ? ' word-table__card--dragging' : ''}`), style: dotDashStyle(index, itemCols, itemRows, cutLine), draggable: !!onReorder, onPointerDown: onReorder ? (e) => longPressDrag(e, index) : undefined, onKeyDown: onReorder ? (e) => moveByKey(e, index) : undefined, onDragStart: onReorder ? () => { dragIndex.current = index; } : undefined, onDragOver: onReorder ? (e) => { e.preventDefault(); setDragOver(index); } : undefined, onDragLeave: onReorder ? () => setDragOver(null) : undefined, onDrop: onReorder ? (e) => { e.preventDefault(); if (dragIndex.current !== null && dragIndex.current !== index) {
|
|
620
634
|
onReorder(dragIndex.current, index);
|
|
621
635
|
} ; dragIndex.current = null; setDragOver(null); } : undefined, onDragEnd: onReorder ? () => { dragIndex.current = null; setDragOver(null); } : undefined, children: [(item.words ?? []).map((w, i) => (_jsxs(Fragment, { children: [i > 0 && _jsx("div", { className: withLegacy("word-table__pair-divider") }), _jsx(WordCell, { outerScale: scale, label: w.label, subLabel: w.subLabel, colloquialLabel: w.colloquialLabel, captionLabel: w.captionLabel, captionBadge: w.captionBadge, homonum: w.homonum, showWord: show.word, showImage: show.image, showPronunciation: show.pron, showColloquial: show.colloq, showCaption: show.caption, buttonSize: buttonSize, wordInfo: (w.grade || w.syllables != null || w.pos || w.wordType) ? { grade: w.grade, syllables: w.syllables, pos: w.pos, wordType: w.wordType } : undefined })] }, i))), scoring && renderScore(index, (item.words ?? []).map(w => w.label).join(' / ')), (renderCellAction || onRemoveItem || onReorder) && (
|
|
622
636
|
/* **오른쪽 기둥** — 빼기 → 부르는 쪽이 얹은 것 → 옮기기 손잡이 차례로 쌓인다
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **잰 열 폭을 그릇에 맞춘다** — 남는 자리는 비율대로 나누고, 좁으면 비율대로 줄인다.
|
|
3
|
+
*
|
|
4
|
+
* 잰 값을 그대로 쓰면 칸이 제 글자만큼만 차지해 표 오른쪽에 빈 자리가 남는다(다 왼쪽에
|
|
5
|
+
* 붙어 보인다). 그래서 고정 px 열을 뺀 나머지를 **잰 크기의 비율대로** 늘리거나 줄여 그릇을
|
|
6
|
+
* 꽉 채운다 — 좁으면 줄고 넓으면 는다. 한 식으로 둘 다 된다.
|
|
7
|
+
*
|
|
8
|
+
* **줄일 때의 바닥이 이 함수의 핵이다**(말귀 청 (217), 2026-10-28). 바닥이 선언된 밑값
|
|
9
|
+
* 하나뿐이던 때는, 그 칸에 `minmax(…px,…)` 가 없으면 `MIN_COL_W`(48px) 한 값으로 떨어져
|
|
10
|
+
* **머리글자가 잘렸다** — 사장님이 화면에서 `성별` 이 `성ᅧ` 로 잘린 것을 짚으셨다(말귀 실측:
|
|
11
|
+
* 단추 칸 머리는 118px 이 드는데 70px 로 줄었다). 머리 폭은 이미 재고 있었고 **줄일 때만
|
|
12
|
+
* 잊었다.** 그래서 바닥을 부르는 쪽이 넘긴다 — 선언된 밑값과 머리글자가 드는 폭 가운데
|
|
13
|
+
* 넓은 쪽이다.
|
|
14
|
+
*
|
|
15
|
+
* 바닥에 걸린 열이 있으면 합이 그릇을 넘을 수 있다. 그것은 **담을 수 없을 만큼 좁다는 뜻**
|
|
16
|
+
* 이라 가로 스크롤로 두는 편이 맞다 — 잘려 안 보이는 것보다 밀어서 보는 편이 낫다.
|
|
17
|
+
*/
|
|
18
|
+
export interface FitWidthsOptions {
|
|
19
|
+
/** 이 열이 고정 px 인가 — 고정 열은 비율에 안 든다(정해 둔 크기를 잃지 않게) */
|
|
20
|
+
isFixed: (index: number) => boolean;
|
|
21
|
+
/** 이 열이 줄어들 수 있는 바닥 */
|
|
22
|
+
floorOf: (index: number) => number;
|
|
23
|
+
/** 열들이 채울 그릇의 안쪽 폭 */
|
|
24
|
+
containerWidth: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function fitFluidWidths(measured: readonly number[], opts: FitWidthsOptions): number[];
|
|
27
|
+
/** 정렬 화살표가 드는 폭 — `SortArrow` 의 `size={16}` 과 같아야 한다(어긋나면 머리가 잘린다) */
|
|
28
|
+
export declare const SORT_ARROW_W = 16;
|
|
29
|
+
export interface ColumnFloorInput {
|
|
30
|
+
/** 선언된 밑값 — `minmax(…px,…)` 의 밑값, 없으면 `MIN_COL_W` */
|
|
31
|
+
declaredMin: number;
|
|
32
|
+
/** 그 칸 **머리글자**가 드는 폭(`max-content` 로 재 둔 값) */
|
|
33
|
+
headWidth: number;
|
|
34
|
+
/** 이 칸을 눌러 정렬할 수 있나 */
|
|
35
|
+
sortable: boolean;
|
|
36
|
+
/** 지금 이 칸으로 정렬돼 있나 — 그때만 화살표가 서 있다 */
|
|
37
|
+
sorted: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* **열이 줄어들 수 있는 바닥** — 선언된 밑값과 머리글자가 드는 폭 가운데 넓은 쪽(청 (217)).
|
|
41
|
+
*
|
|
42
|
+
* **화살표 자리를 정렬 가능한 칸 모두에 얹는다.** 화살표는 *지금 고른* 칸에만 서므로
|
|
43
|
+
* (말귀 실측: 고른 칸 16px, 나머지 0), 지금 폭만 보고 바닥을 잡으면 **다른 칸을 고르는
|
|
44
|
+
* 순간 그 칸만 잘린다.** 이미 선 칸에는 그 16px 이 `headWidth` 에 들어 있으니 또 얹지 않는다.
|
|
45
|
+
*/
|
|
46
|
+
export declare function columnFloors(cols: readonly ColumnFloorInput[], arrowWidth?: number): number[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **잰 열 폭을 그릇에 맞춘다** — 남는 자리는 비율대로 나누고, 좁으면 비율대로 줄인다.
|
|
3
|
+
*
|
|
4
|
+
* 잰 값을 그대로 쓰면 칸이 제 글자만큼만 차지해 표 오른쪽에 빈 자리가 남는다(다 왼쪽에
|
|
5
|
+
* 붙어 보인다). 그래서 고정 px 열을 뺀 나머지를 **잰 크기의 비율대로** 늘리거나 줄여 그릇을
|
|
6
|
+
* 꽉 채운다 — 좁으면 줄고 넓으면 는다. 한 식으로 둘 다 된다.
|
|
7
|
+
*
|
|
8
|
+
* **줄일 때의 바닥이 이 함수의 핵이다**(말귀 청 (217), 2026-10-28). 바닥이 선언된 밑값
|
|
9
|
+
* 하나뿐이던 때는, 그 칸에 `minmax(…px,…)` 가 없으면 `MIN_COL_W`(48px) 한 값으로 떨어져
|
|
10
|
+
* **머리글자가 잘렸다** — 사장님이 화면에서 `성별` 이 `성ᅧ` 로 잘린 것을 짚으셨다(말귀 실측:
|
|
11
|
+
* 단추 칸 머리는 118px 이 드는데 70px 로 줄었다). 머리 폭은 이미 재고 있었고 **줄일 때만
|
|
12
|
+
* 잊었다.** 그래서 바닥을 부르는 쪽이 넘긴다 — 선언된 밑값과 머리글자가 드는 폭 가운데
|
|
13
|
+
* 넓은 쪽이다.
|
|
14
|
+
*
|
|
15
|
+
* 바닥에 걸린 열이 있으면 합이 그릇을 넘을 수 있다. 그것은 **담을 수 없을 만큼 좁다는 뜻**
|
|
16
|
+
* 이라 가로 스크롤로 두는 편이 맞다 — 잘려 안 보이는 것보다 밀어서 보는 편이 낫다.
|
|
17
|
+
*/
|
|
18
|
+
export function fitFluidWidths(measured, opts) {
|
|
19
|
+
const { isFixed, floorOf, containerWidth } = opts;
|
|
20
|
+
const fixedTotal = measured.reduce((a, w, i) => a + (isFixed(i) ? w : 0), 0);
|
|
21
|
+
const fluidTotal = measured.reduce((a, w, i) => a + (isFixed(i) ? 0 : w), 0);
|
|
22
|
+
const available = containerWidth - fixedTotal;
|
|
23
|
+
/* 맞출 수 없는 자리에서는 **잰 값을 그대로 둔다** — 그릇을 아직 모르거나(0), 유동 열이
|
|
24
|
+
없거나, 고정 열만으로 이미 그릇을 넘었을 때다. */
|
|
25
|
+
if (!(containerWidth > 0 && fluidTotal > 0 && available > 0))
|
|
26
|
+
return [...measured];
|
|
27
|
+
const ratio = available / fluidTotal;
|
|
28
|
+
const out = measured.map((w, i) => (isFixed(i) ? w : Math.max(floorOf(i), Math.round(w * ratio))));
|
|
29
|
+
/* 반올림으로 남은 몇 px 은 **가장 넓은 유동 열**에 얹는다 — 안 그러면 늘 몇 px 이 비거나
|
|
30
|
+
넘친다. 바닥에 걸린 열이 있으면 넘칠 수 있는데, 위 머리말에 적은 그 자리다. */
|
|
31
|
+
const diff = Math.round(available - out.reduce((a, w, i) => a + (isFixed(i) ? 0 : w), 0));
|
|
32
|
+
if (diff !== 0) {
|
|
33
|
+
let widestIndex = -1;
|
|
34
|
+
out.forEach((w, i) => { if (!isFixed(i) && (widestIndex < 0 || w > out[widestIndex]))
|
|
35
|
+
widestIndex = i; });
|
|
36
|
+
if (widestIndex >= 0)
|
|
37
|
+
out[widestIndex] = Math.max(floorOf(widestIndex), out[widestIndex] + diff);
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
/** 정렬 화살표가 드는 폭 — `SortArrow` 의 `size={16}` 과 같아야 한다(어긋나면 머리가 잘린다) */
|
|
42
|
+
export const SORT_ARROW_W = 16;
|
|
43
|
+
/**
|
|
44
|
+
* **열이 줄어들 수 있는 바닥** — 선언된 밑값과 머리글자가 드는 폭 가운데 넓은 쪽(청 (217)).
|
|
45
|
+
*
|
|
46
|
+
* **화살표 자리를 정렬 가능한 칸 모두에 얹는다.** 화살표는 *지금 고른* 칸에만 서므로
|
|
47
|
+
* (말귀 실측: 고른 칸 16px, 나머지 0), 지금 폭만 보고 바닥을 잡으면 **다른 칸을 고르는
|
|
48
|
+
* 순간 그 칸만 잘린다.** 이미 선 칸에는 그 16px 이 `headWidth` 에 들어 있으니 또 얹지 않는다.
|
|
49
|
+
*/
|
|
50
|
+
export function columnFloors(cols, arrowWidth = SORT_ARROW_W) {
|
|
51
|
+
return cols.map(c => {
|
|
52
|
+
const needsArrowRoom = c.sortable && !c.sorted;
|
|
53
|
+
return Math.max(c.declaredMin, Math.ceil(c.headWidth + (needsArrowRoom ? arrowWidth : 0)));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **줄 하나의 칸들을 열마다 가장 넓은 값으로** — 자식 번호가 아니라 **격자 번호**로 센다
|
|
3
|
+
* (말귀 청 (215), 2026-10-28).
|
|
4
|
+
*
|
|
5
|
+
* `row.children[i]` 를 그 열의 칸으로 보던 자였다. 그것은 *몇 번째 자식*이지 *몇 번째 열*이
|
|
6
|
+
* 아니다 — 여러 열을 덮는 칸(`span`)이 하나라도 있으면 둘이 갈라진다. 말귀 실측: 칸
|
|
7
|
+
* 여섯짜리 고객 표에 초대 줄(자식 넷, 첫 칸이 앞 셋을 덮음)을 하나 넣고 '칸 너비 초기화' 를
|
|
8
|
+
* 누르니 **첫 열이 94px → 254px(2.7배)** 로 부풀고, 부푼 만큼을 남은 유동 열들이 비율대로
|
|
9
|
+
* 토해 냈다 — **한 줄이 표 전체의 열 폭을 다시 짰다.**
|
|
10
|
+
*
|
|
11
|
+
* 여기 둔 것은 **재는 규칙만**이다. DOM 에서 폭과 덮는 수를 읽는 일은 `Table` 이 하고, 이
|
|
12
|
+
* 함수는 숫자만 받는다 — 그래야 격자를 못 세우는 자리에서도 규칙을 그대로 셀 수 있다.
|
|
13
|
+
*/
|
|
14
|
+
/** 줄 안의 칸 하나 — 잰 폭과 덮는 열 수 */
|
|
15
|
+
export interface MeasuredCell {
|
|
16
|
+
width: number;
|
|
17
|
+
/** 몇 열을 덮나. 1 이거나 없으면 한 열 */
|
|
18
|
+
span?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 줄들을 훑어 **열마다 가장 넓은 값**을 낸다.
|
|
22
|
+
*
|
|
23
|
+
* 덮는 칸의 폭은 **덮은 열들에 나눠 넣는다** — 안 넣으면 그 줄만 있는 표에서 열이 최소
|
|
24
|
+
* 폭으로 가라앉는다. 나눌 때 **열 사이 틈**을 먼저 뺀다(안 빼면 덮은 열마다 틈만큼 넓게
|
|
25
|
+
* 잡힌다). 나눈 값이 그 열의 제 글자보다 좁으면 넓은 쪽이 남으므로, **좁은 덮는 칸이 열을
|
|
26
|
+
* 줄이는 일은 없다.**
|
|
27
|
+
*
|
|
28
|
+
* 칸이 열보다 많으면 넘는 칸은 버린다 — 줄 하나가 표의 열 수를 바꾸지는 못한다. 덮는 수가
|
|
29
|
+
* 남은 열을 넘으면 **남은 열로 조인다**(브라우저가 그렇게 세우므로, 적힌 수로 나누면 열마다
|
|
30
|
+
* 받는 몫이 모자라게 잡힌다).
|
|
31
|
+
*
|
|
32
|
+
* @param rows 줄마다 칸 목록. 머리 줄도 한 줄로 넣는다.
|
|
33
|
+
* @param columnCount 표의 열 수
|
|
34
|
+
* @param columnGap 열 사이 틈(px). 없으면 0
|
|
35
|
+
*/
|
|
36
|
+
export declare function widestPerColumn(rows: readonly (readonly MeasuredCell[])[], columnCount: number, columnGap?: number): number[];
|
|
37
|
+
/** 덮는 수를 믿을 수 있는 정수로 — 없거나 이상한 값은 1 */
|
|
38
|
+
export declare function normalizeSpan(span: unknown): number;
|
|
39
|
+
/**
|
|
40
|
+
* 선 격자에서 덮는 수를 읽는다 — `getComputedStyle(cell)` 의 `gridColumnStart`/`End` 꼴을 받는다.
|
|
41
|
+
*
|
|
42
|
+
* **`aria-colspan` 만 믿지 않는다.** 그것은 코어가 `span` 프롭을 받아 지을 때만 붙으므로,
|
|
43
|
+
* 부르는 쪽이 `style={{ gridColumn: 'span 3' }}` 로 손수 적은 줄은 못 본다. 격자는 둘 다
|
|
44
|
+
* 똑같이 서므로 **선 격자**를 읽는 쪽이 둘을 다 본다.
|
|
45
|
+
*
|
|
46
|
+
* 브라우저에 따라 `span 3` · `span 3 / auto` · `auto / span 3` 으로 나오므로 양쪽을 다 본다.
|
|
47
|
+
*/
|
|
48
|
+
export declare function spanFromGridStyle(start?: string | null, end?: string | null): number;
|