@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.
@@ -3060,18 +3060,119 @@ function Panel({
3060
3060
  }
3061
3061
  );
3062
3062
  }
3063
- var Table = React12.forwardRef(
3064
- ({ className, ...props }, ref) => (
3065
- // 둥근 테두리 상자(AgGridTable 과 같은 8px·같은 선). overflow-auto 라 내용이 라운드로 잘린다 (2026-10-17 이슈 47 4차)
3066
- /* @__PURE__ */ jsx("div", { className: "w-full overflow-auto rounded-medium border border-sys-divider-subtle", children: /* @__PURE__ */ jsx(
3067
- "table",
3068
- {
3069
- ref,
3070
- className: cn("w-full table-fixed border-collapse border-spacing-0 border-0", className),
3071
- ...props
3063
+
3064
+ // src/utils/columnWidths.ts
3065
+ var TEXT_COLUMN_GROW_LIMIT = 2;
3066
+ function distributeColumnWidths(cols, available) {
3067
+ const widths = cols.map((c) => c.content);
3068
+ let extra = available - widths.reduce((a, b) => a + b, 0);
3069
+ if (extra <= 0) return widths;
3070
+ const weight = (i) => Math.max(1, cols[i].content);
3071
+ const fill = (idx, cap) => {
3072
+ let active = idx.filter((i) => widths[i] < cap(i));
3073
+ while (extra > 0.01 && active.length > 0) {
3074
+ const total = active.reduce((s, i) => s + weight(i), 0);
3075
+ let used = 0;
3076
+ for (const i of active) {
3077
+ const give = Math.min(extra * weight(i) / total, cap(i) - widths[i]);
3078
+ widths[i] += give;
3079
+ used += give;
3072
3080
  }
3073
- ) })
3074
- )
3081
+ extra -= used;
3082
+ active = active.filter((i) => widths[i] < cap(i) - 0.01);
3083
+ }
3084
+ };
3085
+ const all = cols.map((_, i) => i);
3086
+ const grow = all.filter((i) => cols[i].grow);
3087
+ const maxOf = (i) => cols[i].max ?? Infinity;
3088
+ fill(grow, (i) => Math.min(maxOf(i), cols[i].content * TEXT_COLUMN_GROW_LIMIT));
3089
+ fill(all, maxOf);
3090
+ const last = grow.length > 0 ? grow : all;
3091
+ fill(last, () => Infinity);
3092
+ const rounded = widths.map((w) => Math.round(w));
3093
+ rounded[last[last.length - 1]] += Math.round(available) - rounded.reduce((a, b) => a + b, 0);
3094
+ return rounded;
3095
+ }
3096
+ var useIsoLayoutEffect = typeof window === "undefined" ? React12.useEffect : React12.useLayoutEffect;
3097
+ function measureColumnWidths(table) {
3098
+ const cells = Array.from(table.rows[0]?.cells ?? []);
3099
+ if (cells.length === 0 || cells.some((c) => c.colSpan > 1)) return null;
3100
+ const cols = Array.from(table.querySelectorAll(":scope > colgroup > col"));
3101
+ const saved = [table.style.width, table.style.tableLayout, ...cols.map((c) => c.style.width)];
3102
+ table.style.width = "max-content";
3103
+ table.style.tableLayout = "auto";
3104
+ cols.forEach((c) => c.style.width = "");
3105
+ const widths = cells.map((c) => c.getBoundingClientRect().width);
3106
+ table.style.width = saved[0];
3107
+ table.style.tableLayout = saved[1];
3108
+ cols.forEach((c, i) => c.style.width = saved[i + 2]);
3109
+ return widths.every((w) => w > 0) ? widths : null;
3110
+ }
3111
+ var sameWidths = (a, b) => a === b || !!a && !!b && a.length === b.length && a.every((w, i) => w === b[i]);
3112
+ var Table = React12.forwardRef(
3113
+ ({ className, children, ...props }, ref) => {
3114
+ const tableRef = React12.useRef(null);
3115
+ const setRef = React12.useCallback(
3116
+ (el) => {
3117
+ tableRef.current = el;
3118
+ if (typeof ref === "function") ref(el);
3119
+ else if (ref) ref.current = el;
3120
+ },
3121
+ [ref]
3122
+ );
3123
+ const [widths, setWidths] = React12.useState(null);
3124
+ const fit = !/(^|\s)table-fixed(\s|$)/.test(className ?? "");
3125
+ useIsoLayoutEffect(() => {
3126
+ const table = tableRef.current;
3127
+ const wrap = table?.parentElement;
3128
+ if (!fit || !table || !wrap) return;
3129
+ const update = () => {
3130
+ const content = measureColumnWidths(table);
3131
+ const available = wrap.clientWidth;
3132
+ let next = null;
3133
+ if (content && available > content.reduce((a, b) => a + b, 0)) {
3134
+ const firstIsNumber = table.rows[0].cells[0].dataset.align === "right";
3135
+ next = distributeColumnWidths(
3136
+ content.map((w, i) => ({ content: w, grow: i === 0 && !firstIsNumber })),
3137
+ available
3138
+ );
3139
+ }
3140
+ setWidths((prev) => sameWidths(prev, next) ? prev : next);
3141
+ };
3142
+ update();
3143
+ const ro = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
3144
+ ro?.observe(wrap);
3145
+ const mo = new MutationObserver(update);
3146
+ mo.observe(table, { childList: true, subtree: true, characterData: true });
3147
+ return () => {
3148
+ ro?.disconnect();
3149
+ mo.disconnect();
3150
+ };
3151
+ }, [fit]);
3152
+ return (
3153
+ // 둥근 테두리 상자(AgGridTable 과 같은 8px·같은 선). overflow-auto 라 내용이 라운드로 잘린다 (2026-10-17 이슈 47 4차)
3154
+ /* @__PURE__ */ jsx("div", { className: "w-full overflow-auto rounded-medium border border-sys-divider-subtle", children: /* @__PURE__ */ jsxs(
3155
+ "table",
3156
+ {
3157
+ ref: setRef,
3158
+ className: cn(
3159
+ "w-full border-collapse border-spacing-0 border-0",
3160
+ widths ? "table-fixed" : "table-auto",
3161
+ className
3162
+ ),
3163
+ ...props,
3164
+ children: [
3165
+ widths && /* @__PURE__ */ jsx("colgroup", { children: widths.map((w, i) => (
3166
+ // 열은 순서로만 구분된다(첫 행 셀 순서)
3167
+ // eslint-disable-next-line react/no-array-index-key
3168
+ /* @__PURE__ */ jsx("col", { style: { width: w } }, i)
3169
+ )) }),
3170
+ children
3171
+ ]
3172
+ }
3173
+ ) })
3174
+ );
3175
+ }
3075
3176
  );
3076
3177
  var tableHeaderVariant = cva(
3077
3178
  // 헤더: 아주 연한 바탕(sys-table-header-background = o10) + 아래 1px 선(행 선과 같은 토큰). 양끝 라운드는 바깥 상자가 맡는다.
@@ -3128,7 +3229,7 @@ var TableRow = React12.forwardRef(
3128
3229
  }
3129
3230
  )
3130
3231
  );
3131
- var NUMBER_COLUMN_CLASS = "w-[140px] whitespace-nowrap";
3232
+ var NUMBER_COLUMN_CLASS = "whitespace-nowrap";
3132
3233
  var tableHeadVariant = cva(null, {
3133
3234
  variants: {
3134
3235
  align: {
@@ -3146,6 +3247,7 @@ var TableHead = React12.forwardRef(
3146
3247
  "th",
3147
3248
  {
3148
3249
  ref,
3250
+ "data-align": alignFromClassName(align, className) ?? "left",
3149
3251
  className: cn(tableHeadVariant({ align: alignFromClassName(align, className) }), className),
3150
3252
  ...props
3151
3253
  }
@@ -3156,7 +3258,7 @@ var tableCellMasterVariant = cva("align-middle px-[12px]", {
3156
3258
  align: {
3157
3259
  left: "",
3158
3260
  center: "[&>_.c-wrap-main]:justify-center",
3159
- // 머리글 없는 표는 첫 행이 열 폭을 정하므로 셀에도 숫자 열 폭을 준다
3261
+ // 머리글 없는 표도 숫자 셀은 한 줄
3160
3262
  right: `[&>_.c-wrap-main]:justify-end ${NUMBER_COLUMN_CLASS}`
3161
3263
  }
3162
3264
  },
@@ -3176,6 +3278,7 @@ var TableCell = React12.forwardRef(
3176
3278
  "td",
3177
3279
  {
3178
3280
  ref,
3281
+ "data-align": alignFromClassName(align, className) ?? "left",
3179
3282
  className: cn(
3180
3283
  tableCellMasterVariant({ align: alignFromClassName(align, className) }),
3181
3284
  className
@@ -3976,6 +4079,8 @@ function AgGridContent() {
3976
4079
  columnTypes: userColumnTypes,
3977
4080
  onCellKeyDown,
3978
4081
  onRowClicked,
4082
+ onFirstDataRendered,
4083
+ fitColumnsToContent: fitToContent = true,
3979
4084
  ...restTableProps
3980
4085
  } = tableProps;
3981
4086
  const handleCellKeyDown = (e) => {
@@ -3986,6 +4091,14 @@ function AgGridContent() {
3986
4091
  if (!target?.matches(".ag-cell, .ag-full-width-row")) return;
3987
4092
  onRowClicked({ ...e, type: "rowClicked" });
3988
4093
  };
4094
+ const growIds = useMemo(
4095
+ () => growColumnIds(restTableProps.columnDefs),
4096
+ [restTableProps.columnDefs]
4097
+ );
4098
+ const handleFirstDataRendered = (e) => {
4099
+ onFirstDataRendered?.(e);
4100
+ if (fitToContent && !restTableProps.autoSizeStrategy) fitColumnsToContent(e.api, growIds);
4101
+ };
3989
4102
  const mergedDefaultColDef = {
3990
4103
  ...userDefaultColDef,
3991
4104
  cellStyle: {
@@ -4004,12 +4117,14 @@ function AgGridContent() {
4004
4117
  );
4005
4118
  const columnDefs = useMemo(
4006
4119
  () => withTypeClasses(
4007
- withHeaderMinWidth(
4008
- withSortIconOffset(
4009
- // 남는 폭 분배(2026-11-08 홀드아웃 21 뒤 결정 1): 글자 열이 하나뿐이면 ID·날짜 같은 넓은 고정 열도 flex 를 받는다 — 그 뒤 withFlexFill 이
4010
- // 상한 있는 flex 열만 남았는지 본다(분배된 열은 상한이 없으므로 글자 열의 maxWidth 는 살아남는다)
4011
- withExplicitSortIcons(
4012
- withFlexFill(withBalancedFill(withNumberColumnWidth(restTableProps.columnDefs)))
4120
+ withWidthFloor(
4121
+ withHeaderMinWidth(
4122
+ withSortIconOffset(
4123
+ // 남는 폭 분배(2026-11-08 홀드아웃 21 뒤 결정 1): 글자 열이 하나뿐이면 ID·날짜 같은 넓은 고정 열도 flex 를 받는다 — 그 뒤 withFlexFill 이
4124
+ // 상한 있는 flex 열만 남았는지 본다(분배된 열은 상한이 없으므로 글자 열의 maxWidth 는 살아남는다)
4125
+ withExplicitSortIcons(
4126
+ withFlexFill(withBalancedFill(withNumberColumnWidth(restTableProps.columnDefs)))
4127
+ )
4013
4128
  )
4014
4129
  )
4015
4130
  ),
@@ -4029,6 +4144,7 @@ function AgGridContent() {
4029
4144
  columnDefs,
4030
4145
  onRowClicked,
4031
4146
  onCellKeyDown: handleCellKeyDown,
4147
+ onFirstDataRendered: handleFirstDataRendered,
4032
4148
  theme,
4033
4149
  className,
4034
4150
  domLayout: "normal"
@@ -4049,6 +4165,7 @@ function AgGridContent() {
4049
4165
  columnDefs,
4050
4166
  onRowClicked,
4051
4167
  onCellKeyDown: handleCellKeyDown,
4168
+ onFirstDataRendered: handleFirstDataRendered,
4052
4169
  theme,
4053
4170
  className,
4054
4171
  rowClass: `${onRowClicked ? "ag-row-clickable" : ""} ${tableProps.rowClass || ""}`,
@@ -4279,6 +4396,82 @@ function withHeaderMinWidth(defs) {
4279
4396
  return { ...d, minWidth, ...raiseWidth ? { width: minWidth } : {} };
4280
4397
  });
4281
4398
  }
4399
+ function withWidthFloor(defs) {
4400
+ if (!Array.isArray(defs)) return defs;
4401
+ let changed = false;
4402
+ const out = defs.map((d) => {
4403
+ if (!d || typeof d !== "object") return d;
4404
+ if (Array.isArray(d.children)) {
4405
+ const children = withWidthFloor(d.children);
4406
+ if (children === d.children) return d;
4407
+ changed = true;
4408
+ return { ...d, children };
4409
+ }
4410
+ if (typeof d.width !== "number" || d.flex != null) return d;
4411
+ if (typeof d.minWidth === "number" && d.minWidth >= d.width) return d;
4412
+ changed = true;
4413
+ return { ...d, minWidth: d.width };
4414
+ });
4415
+ return changed ? out : defs;
4416
+ }
4417
+ function isFittable(col) {
4418
+ const def = col.getColDef();
4419
+ return col.isVisible() && !col.isPinned() && !col.getColId().startsWith("ag-Grid-") && !def.suppressAutoSize && !def.suppressSizeToFit;
4420
+ }
4421
+ function growColumnIds(defs) {
4422
+ const ids = /* @__PURE__ */ new Set();
4423
+ const walk = (list) => {
4424
+ if (!Array.isArray(list)) return;
4425
+ for (const d of list) {
4426
+ if (!d || typeof d !== "object") continue;
4427
+ if (Array.isArray(d.children)) {
4428
+ walk(d.children);
4429
+ continue;
4430
+ }
4431
+ const types = columnTypesOf(d);
4432
+ if (types.includes("number") || !isFlex(d) && !types.includes("primary")) continue;
4433
+ const id = d.colId ?? d.field;
4434
+ if (typeof id === "string" && id !== "") ids.add(id);
4435
+ }
4436
+ };
4437
+ walk(defs);
4438
+ return ids;
4439
+ }
4440
+ function fitColumnsToContent(api, grow = /* @__PURE__ */ new Set()) {
4441
+ const onAutosized = (e) => {
4442
+ if (e.source !== "autosizeColumns" || !e.finished) return;
4443
+ api.removeEventListener("columnResized", onAutosized);
4444
+ const all = api.getColumns() ?? [];
4445
+ const cols = all.filter(isFittable);
4446
+ if (cols.length === 0) return;
4447
+ let widths = cols.map((c) => c.getActualWidth());
4448
+ if (cols.some((c) => grow.has(c.getColId()))) {
4449
+ const range = api.getHorizontalPixelRange();
4450
+ const fixed = all.filter((c) => c.isVisible() && !c.isPinned() && !isFittable(c)).reduce((sum, c) => sum + c.getActualWidth(), 0);
4451
+ const available = range.right - range.left - fixed;
4452
+ if (available > 0)
4453
+ widths = distributeColumnWidths(
4454
+ cols.map((c, i) => ({
4455
+ content: widths[i],
4456
+ grow: grow.has(c.getColId()),
4457
+ max: c.getColDef().maxWidth ?? void 0
4458
+ })),
4459
+ available
4460
+ );
4461
+ }
4462
+ const state = cols.map((c, i) => ({
4463
+ colId: c.getColId(),
4464
+ flex: Math.max(1, Math.round(widths[i]))
4465
+ }));
4466
+ api.applyColumnState({ state });
4467
+ api.addEventListener("newColumnsLoaded", () => {
4468
+ const ids = new Set((api.getColumns() ?? []).map((c) => c.getColId()));
4469
+ api.applyColumnState({ state: state.filter((s) => ids.has(s.colId)) });
4470
+ });
4471
+ };
4472
+ api.addEventListener("columnResized", onAutosized);
4473
+ api.autoSizeAllColumns();
4474
+ }
4282
4475
  function getByPath(data, path) {
4283
4476
  return path.split(".").reduce((o, k) => o == null ? void 0 : o[k], data);
4284
4477
  }
@@ -4305,6 +4498,6 @@ function TwoLineCellRenderer(params) {
4305
4498
  ] });
4306
4499
  }
4307
4500
 
4308
- export { AG_GRID_LOCALE_KR, AgGridContext, AgGridTable, Alert, AlertActions, AlertDescription, AlertTitle, BADGE_OUTLINE_ACCENT, BALANCED_FILL_MIN_WIDTH, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardThumbnail, CardTitle, Checkbox, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyBoxIllustration, Form, FormControl, FormDescription, FormField, FormFooter, FormHeader, FormItem, FormLabel, FormMessage, FormSection, FormSectionLevelContext, FormValidMessage, HeaderCheckboxRenderer, IconButton, LucideIcon, NUMBER_COLUMN_CLASS, NUMBER_COLUMN_WIDTH, PageHeader, PageHeaderProvider, Pagination, PaginationContent, PaginationFirst, PaginationItem, PaginationLast, PaginationLink, PaginationNext, PaginationPrevious, PaginationWrapper, Panel, RowCheckboxRenderer, SORT_ICON_OFFSET_CLASS, Separator, Skeleton, SortIcon, Spinner, Stack, Table, TableBody, TableCell, TableHead, TableHeader, TablePagination, TableRow, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TwoLineCellRenderer, alignFromClassName, badgeVariants, buttonVariants, cn, estimateHeaderTextWidth, getPaginationRange, getSortedColumnState, sanitizeUserText, useFormControlContext, useFormField, usePageHeader, useRestoreFocusToOpener, withBalancedFill, withExplicitSortIcons, withFlexFill, withHeaderMinWidth, withNumberColumnWidth, withSortIconOffset, withTypeClasses };
4309
- //# sourceMappingURL=chunk-AIMWERAR.js.map
4310
- //# sourceMappingURL=chunk-AIMWERAR.js.map
4501
+ export { AG_GRID_LOCALE_KR, AgGridContext, AgGridTable, Alert, AlertActions, AlertDescription, AlertTitle, BADGE_OUTLINE_ACCENT, BALANCED_FILL_MIN_WIDTH, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardThumbnail, CardTitle, Checkbox, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyBoxIllustration, Form, FormControl, FormDescription, FormField, FormFooter, FormHeader, FormItem, FormLabel, FormMessage, FormSection, FormSectionLevelContext, FormValidMessage, HeaderCheckboxRenderer, IconButton, LucideIcon, NUMBER_COLUMN_CLASS, NUMBER_COLUMN_WIDTH, PageHeader, PageHeaderProvider, Pagination, PaginationContent, PaginationFirst, PaginationItem, PaginationLast, PaginationLink, PaginationNext, PaginationPrevious, PaginationWrapper, Panel, RowCheckboxRenderer, SORT_ICON_OFFSET_CLASS, Separator, Skeleton, SortIcon, Spinner, Stack, Table, TableBody, TableCell, TableHead, TableHeader, TablePagination, TableRow, TableSkeleton, Tabs, TabsContent, TabsList, TabsTrigger, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TwoLineCellRenderer, alignFromClassName, badgeVariants, buttonVariants, cn, estimateHeaderTextWidth, fitColumnsToContent, getPaginationRange, getSortedColumnState, growColumnIds, sanitizeUserText, useFormControlContext, useFormField, usePageHeader, useRestoreFocusToOpener, withBalancedFill, withExplicitSortIcons, withFlexFill, withHeaderMinWidth, withNumberColumnWidth, withSortIconOffset, withTypeClasses, withWidthFloor };
4502
+ //# sourceMappingURL=chunk-PDSWUEB2.js.map
4503
+ //# sourceMappingURL=chunk-PDSWUEB2.js.map