@bigtablet/design-system 3.27.0 → 3.28.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/dist/index.d.ts +4 -1
- package/dist/index.js +40 -1
- package/package.json +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -1718,7 +1718,10 @@ type TableProps<T extends object> = {
|
|
|
1718
1718
|
ariaLabel?: string;
|
|
1719
1719
|
/** 루트 wrapper에 추가할 className */
|
|
1720
1720
|
className?: string;
|
|
1721
|
-
/**
|
|
1721
|
+
/**
|
|
1722
|
+
* 행 클릭 콜백. 주면 행이 키보드로도 동작한다 - Enter/Space 로 열고 ↑↓ 로 행을 옮기며, 포커스가
|
|
1723
|
+
* 어디에도 없을 때 ↓ 는 화면의 첫 clickable 표 첫 행으로 들어간다.
|
|
1724
|
+
*/
|
|
1722
1725
|
onRowClick?: (item: T, index: number) => void;
|
|
1723
1726
|
/**
|
|
1724
1727
|
* clickable 행(onRowClick)의 동작 설명. 각 clickable 행에 `aria-describedby` 로 연결된다 (기본값: "클릭 가능한 행").
|
package/dist/index.js
CHANGED
|
@@ -3571,6 +3571,13 @@ var Checkbox = ({
|
|
|
3571
3571
|
] });
|
|
3572
3572
|
};
|
|
3573
3573
|
Checkbox.displayName = "Checkbox";
|
|
3574
|
+
var CELL_CONTROL = "a, button, input, select, textarea, label, [role='button'], [role='menuitem'], [role='checkbox'], [role='switch']";
|
|
3575
|
+
var isFromCellControl = (e) => {
|
|
3576
|
+
const target = e.target;
|
|
3577
|
+
if (!e.currentTarget.contains(target)) return true;
|
|
3578
|
+
const control = target.closest(CELL_CONTROL);
|
|
3579
|
+
return control !== null && e.currentTarget.contains(control);
|
|
3580
|
+
};
|
|
3574
3581
|
var Table = ({
|
|
3575
3582
|
columns,
|
|
3576
3583
|
data,
|
|
@@ -3634,6 +3641,33 @@ var Table = ({
|
|
|
3634
3641
|
mutationObserver?.disconnect();
|
|
3635
3642
|
};
|
|
3636
3643
|
}, []);
|
|
3644
|
+
const isRowClickable = Boolean(onRowClick);
|
|
3645
|
+
React20.useEffect(() => {
|
|
3646
|
+
if (!isRowClickable) return;
|
|
3647
|
+
const handleKeyDown2 = (e) => {
|
|
3648
|
+
if (e.key !== "ArrowDown" || e.defaultPrevented) return;
|
|
3649
|
+
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
|
|
3650
|
+
const active = document.activeElement;
|
|
3651
|
+
if (active && active !== document.body) return;
|
|
3652
|
+
const firstRows = document.querySelectorAll(
|
|
3653
|
+
".table_tbody > tr.table_row_clickable:first-child"
|
|
3654
|
+
);
|
|
3655
|
+
for (const row of firstRows) {
|
|
3656
|
+
row.focus();
|
|
3657
|
+
if (document.activeElement === row) {
|
|
3658
|
+
e.preventDefault();
|
|
3659
|
+
return;
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3662
|
+
};
|
|
3663
|
+
document.addEventListener("keydown", handleKeyDown2);
|
|
3664
|
+
return () => document.removeEventListener("keydown", handleKeyDown2);
|
|
3665
|
+
}, [isRowClickable]);
|
|
3666
|
+
const moveRowFocus = (e) => {
|
|
3667
|
+
e.preventDefault();
|
|
3668
|
+
const sibling = e.key === "ArrowDown" ? e.currentTarget.nextElementSibling : e.currentTarget.previousElementSibling;
|
|
3669
|
+
if (sibling instanceof HTMLTableRowElement && sibling.tabIndex >= 0) sibling.focus();
|
|
3670
|
+
};
|
|
3637
3671
|
const isEmpty = !isLoading && data.length === 0;
|
|
3638
3672
|
const getRowKey = (item, index) => rowKey?.(item) ?? String(index);
|
|
3639
3673
|
const allRowKeys = selectable ? data.map((item, index) => getRowKey(item, index)) : [];
|
|
@@ -3752,11 +3786,16 @@ var Table = ({
|
|
|
3752
3786
|
"aria-selected": selectable ? isSelected ? "true" : "false" : void 0,
|
|
3753
3787
|
"aria-describedby": onRowClick && rowClickHint ? rowClickHintId : void 0,
|
|
3754
3788
|
tabIndex: onRowClick ? 0 : void 0,
|
|
3755
|
-
onClick: onRowClick ? () =>
|
|
3789
|
+
onClick: onRowClick ? (e) => {
|
|
3790
|
+
if (!isFromCellControl(e)) onRowClick(item, rowIndex);
|
|
3791
|
+
} : void 0,
|
|
3756
3792
|
onKeyDown: onRowClick ? (e) => {
|
|
3793
|
+
if (e.target !== e.currentTarget) return;
|
|
3757
3794
|
if (e.key === "Enter" || e.key === " ") {
|
|
3758
3795
|
e.preventDefault();
|
|
3759
3796
|
onRowClick(item, rowIndex);
|
|
3797
|
+
} else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
3798
|
+
moveRowFocus(e);
|
|
3760
3799
|
}
|
|
3761
3800
|
} : void 0,
|
|
3762
3801
|
children: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigtablet/design-system",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.28.0",
|
|
4
4
|
"description": "Bigtablet Design System UI Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"test": "vitest run --project unit",
|
|
47
47
|
"test:watch": "vitest --project unit",
|
|
48
48
|
"test:coverage": "vitest run --project unit --coverage",
|
|
49
|
+
"coverage:docs": "vitest run --project unit --coverage --reporter=default --reporter=json --outputFile.json=coverage/test-results.json && python3 scripts/update-coverage-docs.py",
|
|
50
|
+
"coverage:docs:check": "vitest run --project unit --coverage --reporter=default --reporter=json --outputFile.json=coverage/test-results.json && python3 scripts/update-coverage-docs.py --check",
|
|
49
51
|
"test:storybook": "vitest run --project storybook",
|
|
50
52
|
"lint:css": "stylelint 'src/ui/**/*.scss' 'src/styles/**/*.scss' 'src/vanilla/**/*.scss'",
|
|
51
53
|
"check:css-vars": "scripts/check-css-vars.sh",
|