teachable-design-system 0.5.2 → 0.5.4

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.cjs.js CHANGED
@@ -1481,6 +1481,7 @@ const getCellBackgroundColor = (params) => {
1481
1481
  const TableOuterWrapper = styled.div `
1482
1482
  position: relative;
1483
1483
  display: inline-block;
1484
+ ${({ $width }) => $width && `width: ${$width};`}
1484
1485
  outline: none;
1485
1486
 
1486
1487
  &:focus {
@@ -2031,6 +2032,29 @@ function Table({ title, onTitleChange, onTitleDelete, columns, data, onCellEdit,
2031
2032
  const [titleValue, setTitleValue] = React.useState(title || '');
2032
2033
  // 실제 사용할 rowHeight (styleConfig 우선)
2033
2034
  const effectiveRowHeight = styleConfig?.bodyRowHeight || rowHeight || '30px';
2035
+ // 테이블 너비 계산 (컬럼 width 합계)
2036
+ const tableWidth = React.useMemo(() => {
2037
+ const hasAllWidths = columns.every(col => col.width);
2038
+ if (!hasAllWidths)
2039
+ return undefined; // width 미정의 컬럼이 있으면 auto
2040
+ let totalWidth = 0;
2041
+ for (const col of columns) {
2042
+ const w = col.width;
2043
+ if (typeof w === 'number') {
2044
+ totalWidth += w;
2045
+ }
2046
+ else if (typeof w === 'string') {
2047
+ const num = parseFloat(w);
2048
+ if (!isNaN(num)) {
2049
+ totalWidth += num;
2050
+ }
2051
+ else {
2052
+ return undefined; // %, auto 등은 계산 불가
2053
+ }
2054
+ }
2055
+ }
2056
+ return `${totalWidth}px`;
2057
+ }, [columns]);
2034
2058
  const sortedData = React.useMemo(() => {
2035
2059
  if (!sortColumn || !sortDirection)
2036
2060
  return data;
@@ -2369,7 +2393,7 @@ function Table({ title, onTitleChange, onTitleDelete, columns, data, onCellEdit,
2369
2393
  document.removeEventListener('keydown', handleKeyDown);
2370
2394
  };
2371
2395
  }, [isSelecting, handleCellMouseUp, handleKeyDown]);
2372
- return (jsxRuntime.jsxs(TableOuterWrapper, { ref: outerRef, className: className, tabIndex: 0, onContextMenu: handleContextMenu, children: [jsxRuntime.jsxs(TableWrapper, { "$borderColor": styleConfig?.borderColor, children: [(title !== undefined || onTitleChange) && (jsxRuntime.jsxs(TableTitle, { "$fontFamily": styleConfig?.fontFamily, children: [isEditingTitle ? (jsxRuntime.jsx(TableTitleInput, { value: titleValue, onChange: (e) => setTitleValue(e.target.value), onBlur: handleTitleSave, onKeyDown: handleTitleKeyDown, autoFocus: true })) : (jsxRuntime.jsx("span", { onDoubleClick: () => onTitleChange && setIsEditingTitle(true), children: title || '제목 없음' })), onTitleDelete && (jsxRuntime.jsx(TableTitleActions, { children: jsxRuntime.jsx("button", { onClick: onTitleDelete, style: {
2396
+ return (jsxRuntime.jsxs(TableOuterWrapper, { ref: outerRef, className: className, tabIndex: 0, onContextMenu: handleContextMenu, "$width": tableWidth, children: [jsxRuntime.jsxs(TableWrapper, { "$borderColor": styleConfig?.borderColor, children: [(title !== undefined || onTitleChange) && (jsxRuntime.jsxs(TableTitle, { "$fontFamily": styleConfig?.fontFamily, children: [isEditingTitle ? (jsxRuntime.jsx(TableTitleInput, { value: titleValue, onChange: (e) => setTitleValue(e.target.value), onBlur: handleTitleSave, onKeyDown: handleTitleKeyDown, autoFocus: true })) : (jsxRuntime.jsx("span", { onDoubleClick: () => onTitleChange && setIsEditingTitle(true), children: title || '제목 없음' })), onTitleDelete && (jsxRuntime.jsx(TableTitleActions, { children: jsxRuntime.jsx("button", { onClick: onTitleDelete, style: {
2373
2397
  background: 'transparent',
2374
2398
  border: 'none',
2375
2399
  cursor: 'pointer',