@bigtablet/design-system 3.27.0 → 3.29.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 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 로 열고 ↑↓ · PageUp/PageDown · Home/End 로 행을 옮기며, 포커스가
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,14 @@ var Checkbox = ({
3571
3571
  ] });
3572
3572
  };
3573
3573
  Checkbox.displayName = "Checkbox";
3574
+ var ROW_MOVE_KEYS = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "PageDown", "PageUp", "Home", "End"]);
3575
+ var CELL_CONTROL = "a, button, input, select, textarea, label, [role='button'], [role='menuitem'], [role='checkbox'], [role='switch']";
3576
+ var isFromCellControl = (e) => {
3577
+ const target = e.target;
3578
+ if (!e.currentTarget.contains(target)) return true;
3579
+ const control = target.closest(CELL_CONTROL);
3580
+ return control !== null && e.currentTarget.contains(control);
3581
+ };
3574
3582
  var Table = ({
3575
3583
  columns,
3576
3584
  data,
@@ -3634,6 +3642,49 @@ var Table = ({
3634
3642
  mutationObserver?.disconnect();
3635
3643
  };
3636
3644
  }, []);
3645
+ const isRowClickable = Boolean(onRowClick);
3646
+ React20.useEffect(() => {
3647
+ if (!isRowClickable) return;
3648
+ const handleKeyDown2 = (e) => {
3649
+ if (e.key !== "ArrowDown" || e.defaultPrevented) return;
3650
+ if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
3651
+ const active = document.activeElement;
3652
+ if (active && active !== document.body) return;
3653
+ const firstRows = document.querySelectorAll(
3654
+ ".table_tbody > tr.table_row_clickable:first-child"
3655
+ );
3656
+ for (const row of firstRows) {
3657
+ row.focus();
3658
+ if (document.activeElement === row) {
3659
+ e.preventDefault();
3660
+ return;
3661
+ }
3662
+ }
3663
+ };
3664
+ document.addEventListener("keydown", handleKeyDown2);
3665
+ return () => document.removeEventListener("keydown", handleKeyDown2);
3666
+ }, [isRowClickable]);
3667
+ const moveRowFocus = (e) => {
3668
+ e.preventDefault();
3669
+ const row = e.currentTarget;
3670
+ const rows = Array.from(row.parentElement?.children ?? []).filter(
3671
+ (el) => el instanceof HTMLTableRowElement && el.tabIndex >= 0
3672
+ );
3673
+ const current = rows.indexOf(row);
3674
+ const wrapper = wrapperRef.current;
3675
+ const viewHeight = wrapper && wrapper.scrollHeight > wrapper.clientHeight ? wrapper.clientHeight : window.innerHeight;
3676
+ const pageStep = Math.max(1, Math.floor(viewHeight / Math.max(1, row.offsetHeight)) - 1);
3677
+ const steps = {
3678
+ ArrowDown: 1,
3679
+ ArrowUp: -1,
3680
+ PageDown: pageStep,
3681
+ PageUp: -pageStep,
3682
+ Home: -rows.length,
3683
+ End: rows.length
3684
+ };
3685
+ const target = rows[Math.min(rows.length - 1, Math.max(0, current + (steps[e.key] ?? 0)))];
3686
+ target?.focus();
3687
+ };
3637
3688
  const isEmpty = !isLoading && data.length === 0;
3638
3689
  const getRowKey = (item, index) => rowKey?.(item) ?? String(index);
3639
3690
  const allRowKeys = selectable ? data.map((item, index) => getRowKey(item, index)) : [];
@@ -3752,11 +3803,17 @@ var Table = ({
3752
3803
  "aria-selected": selectable ? isSelected ? "true" : "false" : void 0,
3753
3804
  "aria-describedby": onRowClick && rowClickHint ? rowClickHintId : void 0,
3754
3805
  tabIndex: onRowClick ? 0 : void 0,
3755
- onClick: onRowClick ? () => onRowClick(item, rowIndex) : void 0,
3806
+ onClick: onRowClick ? (e) => {
3807
+ if (!isFromCellControl(e)) onRowClick(item, rowIndex);
3808
+ } : void 0,
3756
3809
  onKeyDown: onRowClick ? (e) => {
3810
+ if (e.target !== e.currentTarget) return;
3811
+ if (e.altKey || e.ctrlKey || e.metaKey) return;
3757
3812
  if (e.key === "Enter" || e.key === " ") {
3758
3813
  e.preventDefault();
3759
3814
  onRowClick(item, rowIndex);
3815
+ } else if (ROW_MOVE_KEYS.has(e.key)) {
3816
+ moveRowFocus(e);
3760
3817
  }
3761
3818
  } : void 0,
3762
3819
  children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigtablet/design-system",
3
- "version": "3.27.0",
3
+ "version": "3.29.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",