@t3q-ui/design-system 1.59.3 → 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,19 @@
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
+
3
17
  <!-- release: v1.59.3 -->
4
18
  ## 1.59.3 (2026-11-08)
5
19
 
@@ -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-auto 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
@@ -4019,9 +4122,13 @@ function AgGridContent() {
4019
4122
  if (!target?.matches(".ag-cell, .ag-full-width-row")) return;
4020
4123
  onRowClicked({ ...e, type: "rowClicked" });
4021
4124
  };
4125
+ const growIds = React12.useMemo(
4126
+ () => growColumnIds(restTableProps.columnDefs),
4127
+ [restTableProps.columnDefs]
4128
+ );
4022
4129
  const handleFirstDataRendered = (e) => {
4023
4130
  onFirstDataRendered?.(e);
4024
- if (fitToContent && !restTableProps.autoSizeStrategy) fitColumnsToContent(e.api);
4131
+ if (fitToContent && !restTableProps.autoSizeStrategy) fitColumnsToContent(e.api, growIds);
4025
4132
  };
4026
4133
  const mergedDefaultColDef = {
4027
4134
  ...userDefaultColDef,
@@ -4342,17 +4449,55 @@ function isFittable(col) {
4342
4449
  const def = col.getColDef();
4343
4450
  return col.isVisible() && !col.isPinned() && !col.getColId().startsWith("ag-Grid-") && !def.suppressAutoSize && !def.suppressSizeToFit;
4344
4451
  }
4345
- function fitColumnsToContent(api) {
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()) {
4346
4472
  const onAutosized = (e) => {
4347
4473
  if (e.source !== "autosizeColumns" || !e.finished) return;
4348
4474
  api.removeEventListener("columnResized", onAutosized);
4349
- const cols = (api.getColumns() ?? []).filter(isFittable);
4475
+ const all = api.getColumns() ?? [];
4476
+ const cols = all.filter(isFittable);
4350
4477
  if (cols.length === 0) return;
4351
- api.applyColumnState({
4352
- state: cols.map((c) => ({
4353
- colId: c.getColId(),
4354
- flex: Math.max(1, Math.round(c.getActualWidth()))
4355
- }))
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)) });
4356
4501
  });
4357
4502
  };
4358
4503
  api.addEventListener("columnResized", onAutosized);
@@ -4498,6 +4643,7 @@ exports.estimateHeaderTextWidth = estimateHeaderTextWidth;
4498
4643
  exports.fitColumnsToContent = fitColumnsToContent;
4499
4644
  exports.getPaginationRange = getPaginationRange;
4500
4645
  exports.getSortedColumnState = getSortedColumnState;
4646
+ exports.growColumnIds = growColumnIds;
4501
4647
  exports.sanitizeUserText = sanitizeUserText;
4502
4648
  exports.useFormControlContext = useFormControlContext;
4503
4649
  exports.useFormField = useFormField;
@@ -4511,5 +4657,5 @@ exports.withNumberColumnWidth = withNumberColumnWidth;
4511
4657
  exports.withSortIconOffset = withSortIconOffset;
4512
4658
  exports.withTypeClasses = withTypeClasses;
4513
4659
  exports.withWidthFloor = withWidthFloor;
4514
- //# sourceMappingURL=chunk-5O3JWQP3.cjs.map
4515
- //# sourceMappingURL=chunk-5O3JWQP3.cjs.map
4660
+ //# sourceMappingURL=chunk-FOVMRFMR.cjs.map
4661
+ //# sourceMappingURL=chunk-FOVMRFMR.cjs.map