@t3q-ui/design-system 1.59.2 → 1.60.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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ <!-- release: v1.60.0 -->
4
+ # 1.60.0 (2026-11-09)
5
+
6
+
7
+ ### Bug Fixes
8
+
9
+ * **listPage:** onRowClick 함수가 바뀌어도 열 정의를 다시 만들지 않는다 (f98a9df)
10
+
11
+
12
+ ### Features
13
+
14
+ * **agGridTable:** 짧은 열은 내용 폭, 남는 폭은 글자 열이 내용의 2배까지 받는다 (5f072fb)
15
+ * **table:** 열 내용 폭을 재서 목록과 같은 규칙으로 나눈다 — 숫자 열 140 고정 폭 제거 (2ba3d5d)
16
+
17
+ <!-- release: v1.59.3 -->
18
+ ## 1.59.3 (2026-11-08)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **agGridTable:** 열 폭을 내용에 맞춘 뒤 그 비율로 분배(fitColumnsToContent), 앱 width 는 하한 (홀드아웃 23 열 간격 7건, 사용자 결정 ③ A) (7aecb72)
24
+ * **listPage:** 페이지네이션 왼쪽 건수 라벨 제거 — 가운데 버튼만 (홀드아웃 23 "어디에도 붙어 있지 않다" 2건, 사용자 결정 ②) (3c6d0bb)
25
+ * **table:** 기본 table-auto — 폭 없는 열이 남는 폭을 내용 비율로 (홀드아웃 23 상세 단계 표 첫 열 과대 5건, 사용자 결정 ④ A) (82b30a1)
26
+ * **tokens:** Alert 배경 다섯 variant 를 새 단계 -o05(8%) 로 — 오류 배너 "무겁다" (홀드아웃 23 Opus 2건, 사용자 결정 ⑤) (846ed62), closes #ffe4e4 #fff2f2
27
+
3
28
  <!-- release: v1.59.2 -->
4
29
  ## 1.59.2 (2026-11-08)
5
30
 
@@ -3091,18 +3091,119 @@ function Panel({
3091
3091
  }
3092
3092
  );
3093
3093
  }
3094
- var Table = React12__namespace.forwardRef(
3095
- ({ className, ...props }, ref) => (
3096
- // 둥근 테두리 상자(AgGridTable 과 같은 8px·같은 선). overflow-auto 라 내용이 라운드로 잘린다 (2026-10-17 이슈 47 4차)
3097
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full overflow-auto rounded-medium border border-sys-divider-subtle", children: /* @__PURE__ */ jsxRuntime.jsx(
3098
- "table",
3099
- {
3100
- ref,
3101
- className: cn("w-full table-fixed border-collapse border-spacing-0 border-0", className),
3102
- ...props
3094
+
3095
+ // src/utils/columnWidths.ts
3096
+ var TEXT_COLUMN_GROW_LIMIT = 2;
3097
+ function distributeColumnWidths(cols, available) {
3098
+ const widths = cols.map((c) => c.content);
3099
+ let extra = available - widths.reduce((a, b) => a + b, 0);
3100
+ if (extra <= 0) return widths;
3101
+ const weight = (i) => Math.max(1, cols[i].content);
3102
+ const fill = (idx, cap) => {
3103
+ let active = idx.filter((i) => widths[i] < cap(i));
3104
+ while (extra > 0.01 && active.length > 0) {
3105
+ const total = active.reduce((s, i) => s + weight(i), 0);
3106
+ let used = 0;
3107
+ for (const i of active) {
3108
+ const give = Math.min(extra * weight(i) / total, cap(i) - widths[i]);
3109
+ widths[i] += give;
3110
+ used += give;
3103
3111
  }
3104
- ) })
3105
- )
3112
+ extra -= used;
3113
+ active = active.filter((i) => widths[i] < cap(i) - 0.01);
3114
+ }
3115
+ };
3116
+ const all = cols.map((_, i) => i);
3117
+ const grow = all.filter((i) => cols[i].grow);
3118
+ const maxOf = (i) => cols[i].max ?? Infinity;
3119
+ fill(grow, (i) => Math.min(maxOf(i), cols[i].content * TEXT_COLUMN_GROW_LIMIT));
3120
+ fill(all, maxOf);
3121
+ const last = grow.length > 0 ? grow : all;
3122
+ fill(last, () => Infinity);
3123
+ const rounded = widths.map((w) => Math.round(w));
3124
+ rounded[last[last.length - 1]] += Math.round(available) - rounded.reduce((a, b) => a + b, 0);
3125
+ return rounded;
3126
+ }
3127
+ var useIsoLayoutEffect = typeof window === "undefined" ? React12__namespace.useEffect : React12__namespace.useLayoutEffect;
3128
+ function measureColumnWidths(table) {
3129
+ const cells = Array.from(table.rows[0]?.cells ?? []);
3130
+ if (cells.length === 0 || cells.some((c) => c.colSpan > 1)) return null;
3131
+ const cols = Array.from(table.querySelectorAll(":scope > colgroup > col"));
3132
+ const saved = [table.style.width, table.style.tableLayout, ...cols.map((c) => c.style.width)];
3133
+ table.style.width = "max-content";
3134
+ table.style.tableLayout = "auto";
3135
+ cols.forEach((c) => c.style.width = "");
3136
+ const widths = cells.map((c) => c.getBoundingClientRect().width);
3137
+ table.style.width = saved[0];
3138
+ table.style.tableLayout = saved[1];
3139
+ cols.forEach((c, i) => c.style.width = saved[i + 2]);
3140
+ return widths.every((w) => w > 0) ? widths : null;
3141
+ }
3142
+ var sameWidths = (a, b) => a === b || !!a && !!b && a.length === b.length && a.every((w, i) => w === b[i]);
3143
+ var Table = React12__namespace.forwardRef(
3144
+ ({ className, children, ...props }, ref) => {
3145
+ const tableRef = React12__namespace.useRef(null);
3146
+ const setRef = React12__namespace.useCallback(
3147
+ (el) => {
3148
+ tableRef.current = el;
3149
+ if (typeof ref === "function") ref(el);
3150
+ else if (ref) ref.current = el;
3151
+ },
3152
+ [ref]
3153
+ );
3154
+ const [widths, setWidths] = React12__namespace.useState(null);
3155
+ const fit = !/(^|\s)table-fixed(\s|$)/.test(className ?? "");
3156
+ useIsoLayoutEffect(() => {
3157
+ const table = tableRef.current;
3158
+ const wrap = table?.parentElement;
3159
+ if (!fit || !table || !wrap) return;
3160
+ const update = () => {
3161
+ const content = measureColumnWidths(table);
3162
+ const available = wrap.clientWidth;
3163
+ let next = null;
3164
+ if (content && available > content.reduce((a, b) => a + b, 0)) {
3165
+ const firstIsNumber = table.rows[0].cells[0].dataset.align === "right";
3166
+ next = distributeColumnWidths(
3167
+ content.map((w, i) => ({ content: w, grow: i === 0 && !firstIsNumber })),
3168
+ available
3169
+ );
3170
+ }
3171
+ setWidths((prev) => sameWidths(prev, next) ? prev : next);
3172
+ };
3173
+ update();
3174
+ const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
3175
+ ro?.observe(wrap);
3176
+ const mo = new MutationObserver(update);
3177
+ mo.observe(table, { childList: true, subtree: true, characterData: true });
3178
+ return () => {
3179
+ ro?.disconnect();
3180
+ mo.disconnect();
3181
+ };
3182
+ }, [fit]);
3183
+ return (
3184
+ // 둥근 테두리 상자(AgGridTable 과 같은 8px·같은 선). overflow-auto 라 내용이 라운드로 잘린다 (2026-10-17 이슈 47 4차)
3185
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full overflow-auto rounded-medium border border-sys-divider-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs(
3186
+ "table",
3187
+ {
3188
+ ref: setRef,
3189
+ className: cn(
3190
+ "w-full border-collapse border-spacing-0 border-0",
3191
+ widths ? "table-fixed" : "table-auto",
3192
+ className
3193
+ ),
3194
+ ...props,
3195
+ children: [
3196
+ widths && /* @__PURE__ */ jsxRuntime.jsx("colgroup", { children: widths.map((w, i) => (
3197
+ // 열은 순서로만 구분된다(첫 행 셀 순서)
3198
+ // eslint-disable-next-line react/no-array-index-key
3199
+ /* @__PURE__ */ jsxRuntime.jsx("col", { style: { width: w } }, i)
3200
+ )) }),
3201
+ children
3202
+ ]
3203
+ }
3204
+ ) })
3205
+ );
3206
+ }
3106
3207
  );
3107
3208
  var tableHeaderVariant = classVarianceAuthority.cva(
3108
3209
  // 헤더: 아주 연한 바탕(sys-table-header-background = o10) + 아래 1px 선(행 선과 같은 토큰). 양끝 라운드는 바깥 상자가 맡는다.
@@ -3159,7 +3260,7 @@ var TableRow = React12__namespace.forwardRef(
3159
3260
  }
3160
3261
  )
3161
3262
  );
3162
- var NUMBER_COLUMN_CLASS = "w-[140px] whitespace-nowrap";
3263
+ var NUMBER_COLUMN_CLASS = "whitespace-nowrap";
3163
3264
  var tableHeadVariant = classVarianceAuthority.cva(null, {
3164
3265
  variants: {
3165
3266
  align: {
@@ -3177,6 +3278,7 @@ var TableHead = React12__namespace.forwardRef(
3177
3278
  "th",
3178
3279
  {
3179
3280
  ref,
3281
+ "data-align": alignFromClassName(align, className) ?? "left",
3180
3282
  className: cn(tableHeadVariant({ align: alignFromClassName(align, className) }), className),
3181
3283
  ...props
3182
3284
  }
@@ -3187,7 +3289,7 @@ var tableCellMasterVariant = classVarianceAuthority.cva("align-middle px-[12px]"
3187
3289
  align: {
3188
3290
  left: "",
3189
3291
  center: "[&>_.c-wrap-main]:justify-center",
3190
- // 머리글 없는 표는 첫 행이 열 폭을 정하므로 셀에도 숫자 열 폭을 준다
3292
+ // 머리글 없는 표도 숫자 셀은 한 줄
3191
3293
  right: `[&>_.c-wrap-main]:justify-end ${NUMBER_COLUMN_CLASS}`
3192
3294
  }
3193
3295
  },
@@ -3207,6 +3309,7 @@ var TableCell = React12__namespace.forwardRef(
3207
3309
  "td",
3208
3310
  {
3209
3311
  ref,
3312
+ "data-align": alignFromClassName(align, className) ?? "left",
3210
3313
  className: cn(
3211
3314
  tableCellMasterVariant({ align: alignFromClassName(align, className) }),
3212
3315
  className
@@ -4007,6 +4110,8 @@ function AgGridContent() {
4007
4110
  columnTypes: userColumnTypes,
4008
4111
  onCellKeyDown,
4009
4112
  onRowClicked,
4113
+ onFirstDataRendered,
4114
+ fitColumnsToContent: fitToContent = true,
4010
4115
  ...restTableProps
4011
4116
  } = tableProps;
4012
4117
  const handleCellKeyDown = (e) => {
@@ -4017,6 +4122,14 @@ function AgGridContent() {
4017
4122
  if (!target?.matches(".ag-cell, .ag-full-width-row")) return;
4018
4123
  onRowClicked({ ...e, type: "rowClicked" });
4019
4124
  };
4125
+ const growIds = React12.useMemo(
4126
+ () => growColumnIds(restTableProps.columnDefs),
4127
+ [restTableProps.columnDefs]
4128
+ );
4129
+ const handleFirstDataRendered = (e) => {
4130
+ onFirstDataRendered?.(e);
4131
+ if (fitToContent && !restTableProps.autoSizeStrategy) fitColumnsToContent(e.api, growIds);
4132
+ };
4020
4133
  const mergedDefaultColDef = {
4021
4134
  ...userDefaultColDef,
4022
4135
  cellStyle: {
@@ -4035,12 +4148,14 @@ function AgGridContent() {
4035
4148
  );
4036
4149
  const columnDefs = React12.useMemo(
4037
4150
  () => withTypeClasses(
4038
- withHeaderMinWidth(
4039
- withSortIconOffset(
4040
- // 남는 폭 분배(2026-11-08 홀드아웃 21 뒤 결정 1): 글자 열이 하나뿐이면 ID·날짜 같은 넓은 고정 열도 flex 를 받는다 — 그 뒤 withFlexFill 이
4041
- // 상한 있는 flex 열만 남았는지 본다(분배된 열은 상한이 없으므로 글자 열의 maxWidth 는 살아남는다)
4042
- withExplicitSortIcons(
4043
- withFlexFill(withBalancedFill(withNumberColumnWidth(restTableProps.columnDefs)))
4151
+ withWidthFloor(
4152
+ withHeaderMinWidth(
4153
+ withSortIconOffset(
4154
+ // 남는 폭 분배(2026-11-08 홀드아웃 21 뒤 결정 1): 글자 열이 하나뿐이면 ID·날짜 같은 넓은 고정 열도 flex 를 받는다 — 그 뒤 withFlexFill 이
4155
+ // 상한 있는 flex 열만 남았는지 본다(분배된 열은 상한이 없으므로 글자 열의 maxWidth 는 살아남는다)
4156
+ withExplicitSortIcons(
4157
+ withFlexFill(withBalancedFill(withNumberColumnWidth(restTableProps.columnDefs)))
4158
+ )
4044
4159
  )
4045
4160
  )
4046
4161
  ),
@@ -4060,6 +4175,7 @@ function AgGridContent() {
4060
4175
  columnDefs,
4061
4176
  onRowClicked,
4062
4177
  onCellKeyDown: handleCellKeyDown,
4178
+ onFirstDataRendered: handleFirstDataRendered,
4063
4179
  theme,
4064
4180
  className,
4065
4181
  domLayout: "normal"
@@ -4080,6 +4196,7 @@ function AgGridContent() {
4080
4196
  columnDefs,
4081
4197
  onRowClicked,
4082
4198
  onCellKeyDown: handleCellKeyDown,
4199
+ onFirstDataRendered: handleFirstDataRendered,
4083
4200
  theme,
4084
4201
  className,
4085
4202
  rowClass: `${onRowClicked ? "ag-row-clickable" : ""} ${tableProps.rowClass || ""}`,
@@ -4310,6 +4427,82 @@ function withHeaderMinWidth(defs) {
4310
4427
  return { ...d, minWidth, ...raiseWidth ? { width: minWidth } : {} };
4311
4428
  });
4312
4429
  }
4430
+ function withWidthFloor(defs) {
4431
+ if (!Array.isArray(defs)) return defs;
4432
+ let changed = false;
4433
+ const out = defs.map((d) => {
4434
+ if (!d || typeof d !== "object") return d;
4435
+ if (Array.isArray(d.children)) {
4436
+ const children = withWidthFloor(d.children);
4437
+ if (children === d.children) return d;
4438
+ changed = true;
4439
+ return { ...d, children };
4440
+ }
4441
+ if (typeof d.width !== "number" || d.flex != null) return d;
4442
+ if (typeof d.minWidth === "number" && d.minWidth >= d.width) return d;
4443
+ changed = true;
4444
+ return { ...d, minWidth: d.width };
4445
+ });
4446
+ return changed ? out : defs;
4447
+ }
4448
+ function isFittable(col) {
4449
+ const def = col.getColDef();
4450
+ return col.isVisible() && !col.isPinned() && !col.getColId().startsWith("ag-Grid-") && !def.suppressAutoSize && !def.suppressSizeToFit;
4451
+ }
4452
+ function growColumnIds(defs) {
4453
+ const ids = /* @__PURE__ */ new Set();
4454
+ const walk = (list) => {
4455
+ if (!Array.isArray(list)) return;
4456
+ for (const d of list) {
4457
+ if (!d || typeof d !== "object") continue;
4458
+ if (Array.isArray(d.children)) {
4459
+ walk(d.children);
4460
+ continue;
4461
+ }
4462
+ const types = columnTypesOf(d);
4463
+ if (types.includes("number") || !isFlex(d) && !types.includes("primary")) continue;
4464
+ const id = d.colId ?? d.field;
4465
+ if (typeof id === "string" && id !== "") ids.add(id);
4466
+ }
4467
+ };
4468
+ walk(defs);
4469
+ return ids;
4470
+ }
4471
+ function fitColumnsToContent(api, grow = /* @__PURE__ */ new Set()) {
4472
+ const onAutosized = (e) => {
4473
+ if (e.source !== "autosizeColumns" || !e.finished) return;
4474
+ api.removeEventListener("columnResized", onAutosized);
4475
+ const all = api.getColumns() ?? [];
4476
+ const cols = all.filter(isFittable);
4477
+ if (cols.length === 0) return;
4478
+ let widths = cols.map((c) => c.getActualWidth());
4479
+ if (cols.some((c) => grow.has(c.getColId()))) {
4480
+ const range = api.getHorizontalPixelRange();
4481
+ const fixed = all.filter((c) => c.isVisible() && !c.isPinned() && !isFittable(c)).reduce((sum, c) => sum + c.getActualWidth(), 0);
4482
+ const available = range.right - range.left - fixed;
4483
+ if (available > 0)
4484
+ widths = distributeColumnWidths(
4485
+ cols.map((c, i) => ({
4486
+ content: widths[i],
4487
+ grow: grow.has(c.getColId()),
4488
+ max: c.getColDef().maxWidth ?? void 0
4489
+ })),
4490
+ available
4491
+ );
4492
+ }
4493
+ const state = cols.map((c, i) => ({
4494
+ colId: c.getColId(),
4495
+ flex: Math.max(1, Math.round(widths[i]))
4496
+ }));
4497
+ api.applyColumnState({ state });
4498
+ api.addEventListener("newColumnsLoaded", () => {
4499
+ const ids = new Set((api.getColumns() ?? []).map((c) => c.getColId()));
4500
+ api.applyColumnState({ state: state.filter((s) => ids.has(s.colId)) });
4501
+ });
4502
+ };
4503
+ api.addEventListener("columnResized", onAutosized);
4504
+ api.autoSizeAllColumns();
4505
+ }
4313
4506
  function getByPath(data, path) {
4314
4507
  return path.split(".").reduce((o, k) => o == null ? void 0 : o[k], data);
4315
4508
  }
@@ -4447,8 +4640,10 @@ exports.badgeVariants = badgeVariants;
4447
4640
  exports.buttonVariants = buttonVariants;
4448
4641
  exports.cn = cn;
4449
4642
  exports.estimateHeaderTextWidth = estimateHeaderTextWidth;
4643
+ exports.fitColumnsToContent = fitColumnsToContent;
4450
4644
  exports.getPaginationRange = getPaginationRange;
4451
4645
  exports.getSortedColumnState = getSortedColumnState;
4646
+ exports.growColumnIds = growColumnIds;
4452
4647
  exports.sanitizeUserText = sanitizeUserText;
4453
4648
  exports.useFormControlContext = useFormControlContext;
4454
4649
  exports.useFormField = useFormField;
@@ -4461,5 +4656,6 @@ exports.withHeaderMinWidth = withHeaderMinWidth;
4461
4656
  exports.withNumberColumnWidth = withNumberColumnWidth;
4462
4657
  exports.withSortIconOffset = withSortIconOffset;
4463
4658
  exports.withTypeClasses = withTypeClasses;
4464
- //# sourceMappingURL=chunk-24IZHXNG.cjs.map
4465
- //# sourceMappingURL=chunk-24IZHXNG.cjs.map
4659
+ exports.withWidthFloor = withWidthFloor;
4660
+ //# sourceMappingURL=chunk-FOVMRFMR.cjs.map
4661
+ //# sourceMappingURL=chunk-FOVMRFMR.cjs.map