@ceed/ads 1.5.6 → 1.5.7-next.1

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 CHANGED
@@ -3051,7 +3051,9 @@ var StyledTh = (0, import_joy33.styled)(import_framer_motion21.motion.th)(({ the
3051
3051
  }));
3052
3052
  var StyledTd = (0, import_joy33.styled)("td")(({ theme }) => ({
3053
3053
  transition: `box-shadow 0.3s`,
3054
- boxShadow: "1px 0 var(--TableCell-borderColor)",
3054
+ "&:not(.is-last-left):not(.is-last-right)": {
3055
+ boxShadow: "1px 0 var(--TableCell-borderColor)"
3056
+ },
3055
3057
  ".ScrollableRight &": {
3056
3058
  "&.is-last-left": {
3057
3059
  boxShadow: `1px 0 var(--TableCell-borderColor), ${theme.shadow.md}`
@@ -3386,6 +3388,7 @@ var BodyCell = (props) => {
3386
3388
  () => noWrap && type === "longText",
3387
3389
  [noWrap, type]
3388
3390
  );
3391
+ const isBoundary = props.isLastStartPinnedColumn || props.isLastEndPinnedColumn;
3389
3392
  (0, import_react25.useEffect)(() => {
3390
3393
  setValue(row[field]);
3391
3394
  }, [row, field]);
@@ -3401,7 +3404,7 @@ var BodyCell = (props) => {
3401
3404
  position: isPinned ? "sticky" : void 0,
3402
3405
  left: isPinned ? pinnedStartPosition : void 0,
3403
3406
  right: isPinned ? pinnedEndPosition : void 0,
3404
- zIndex: isPinned ? `calc(${theme.getCssVar("zIndex-table")} + 2)` : void 0,
3407
+ zIndex: isPinned ? `calc(${theme.getCssVar("zIndex-table")} + ${isBoundary ? 2 : 3})` : void 0,
3405
3408
  "--TableCell-dataBackground": isPinned ? `var(--TableCell-headBackground)` : void 0
3406
3409
  },
3407
3410
  className: isLastStartPinnedColumn && "is-last-left" || isLastEndPinnedColumn && "is-last-right" || ""
@@ -3448,6 +3451,37 @@ var BodyRow = (0, import_react25.memo)(
3448
3451
  )));
3449
3452
  }
3450
3453
  );
3454
+ function useColumnWidths(columnsByField) {
3455
+ const [widths, setWidths] = (0, import_react25.useState)({});
3456
+ const roRef = (0, import_react25.useRef)();
3457
+ (0, import_react25.useLayoutEffect)(() => {
3458
+ if (roRef.current) roRef.current.disconnect();
3459
+ roRef.current = new ResizeObserver((entries) => {
3460
+ let changed = false;
3461
+ setWidths((prev) => {
3462
+ const next = { ...prev };
3463
+ entries.forEach((entry) => {
3464
+ const field = entry.target.dataset.field;
3465
+ const w = Math.round(entry.contentRect.width);
3466
+ if (next[field] !== w) {
3467
+ next[field] = w;
3468
+ changed = true;
3469
+ }
3470
+ });
3471
+ return changed ? next : prev;
3472
+ });
3473
+ });
3474
+ Object.entries(columnsByField).forEach(([field, def]) => {
3475
+ const el = def.headerRef.current;
3476
+ if (el) {
3477
+ el.dataset.field = field;
3478
+ roRef.current.observe(el);
3479
+ }
3480
+ });
3481
+ return () => roRef.current?.disconnect();
3482
+ }, [columnsByField]);
3483
+ return widths;
3484
+ }
3451
3485
  function useDataTableRenderer({
3452
3486
  rows: _rows,
3453
3487
  columns: columnsProp,
@@ -3550,6 +3584,12 @@ function useDataTableRenderer({
3550
3584
  () => _isTotalSelected ?? (rowCount > 0 && (selectionModel?.length || 0) === rowCount),
3551
3585
  [_isTotalSelected, selectionModel, rowCount]
3552
3586
  );
3587
+ const columnWidths = useColumnWidths(columnsByField);
3588
+ const getWidth = (0, import_react25.useCallback)(
3589
+ (f) => (columnWidths[f] ?? columnsByField[f].width ?? // Column prop 으로 지정된 width
3590
+ columnsByField[f].minWidth ?? 0) + columnsProp.length,
3591
+ [columnWidths, columnsByField, columnsProp.length]
3592
+ );
3553
3593
  const columns = (0, import_react25.useMemo)(() => {
3554
3594
  const baseColumns = columnsProp || // fallback
3555
3595
  Object.keys(rows[0] || {}).map((key) => ({
@@ -3571,32 +3611,27 @@ function useDataTableRenderer({
3571
3611
  sortOrder: columnsByField[column.field]?.sortOrder || sortOrder,
3572
3612
  isPinned,
3573
3613
  isLastStartPinnedColumn: isLeftPinned && [...pinnedColumns?.left || []].pop() === column.field,
3574
- isLastEndPinnedColumn: isRightPinned && [...pinnedColumns?.right || []].pop() === column.field,
3614
+ isLastEndPinnedColumn: isRightPinned && (pinnedColumns?.right?.[0] ?? null) === column.field,
3615
+ // pinned 관련 계산부
3575
3616
  pinnedStartPosition: pinnedColumns?.left?.slice(
3576
3617
  0,
3577
- isLeftPinned ? pinnedColumns?.left?.indexOf(column.field) : pinnedColumns.left.length
3578
- ).reduce(
3579
- (acc, curr) => acc + (columnsByField[curr]?.headerRef.current?.clientWidth || 0),
3580
- 0
3581
- ),
3618
+ isLeftPinned ? pinnedColumns.left.indexOf(column.field) : pinnedColumns.left.length
3619
+ ).reduce((acc, curr) => acc + getWidth(curr), 0),
3582
3620
  pinnedEndPosition: pinnedColumns?.right?.slice(
3583
- 0,
3584
- isRightPinned ? pinnedColumns.right.indexOf(column.field) : pinnedColumns.right.length
3585
- ).reduceRight(
3586
- (acc, curr) => acc + (columnsByField[curr]?.headerRef.current?.clientWidth || 0),
3587
- 0
3588
- )
3621
+ isRightPinned ? pinnedColumns.right.indexOf(column.field) + 1 : 0
3622
+ ).reduce((acc, curr) => acc + getWidth(curr), 0)
3589
3623
  };
3590
3624
  });
3591
3625
  }, [
3592
3626
  columnsProp,
3593
3627
  rows,
3628
+ pinnedColumns?.left,
3629
+ pinnedColumns?.right,
3630
+ columnsByField,
3594
3631
  editMode,
3595
3632
  sortModel,
3596
- columnsByField,
3597
3633
  sortOrder,
3598
- pinnedColumns?.left,
3599
- pinnedColumns?.right
3634
+ getWidth
3600
3635
  ]);
3601
3636
  const handlePageChange = (0, import_react25.useCallback)(
3602
3637
  (newPage) => {
package/dist/index.js CHANGED
@@ -2025,7 +2025,8 @@ import React23, {
2025
2025
  forwardRef as forwardRef7,
2026
2026
  useImperativeHandle as useImperativeHandle2,
2027
2027
  createElement,
2028
- memo
2028
+ memo,
2029
+ useLayoutEffect
2029
2030
  } from "react";
2030
2031
  import { useVirtualizer as useVirtualizer2 } from "@tanstack/react-virtual";
2031
2032
  import {
@@ -3008,7 +3009,9 @@ var StyledTh = styled12(motion21.th)(({ theme }) => ({
3008
3009
  }));
3009
3010
  var StyledTd = styled12("td")(({ theme }) => ({
3010
3011
  transition: `box-shadow 0.3s`,
3011
- boxShadow: "1px 0 var(--TableCell-borderColor)",
3012
+ "&:not(.is-last-left):not(.is-last-right)": {
3013
+ boxShadow: "1px 0 var(--TableCell-borderColor)"
3014
+ },
3012
3015
  ".ScrollableRight &": {
3013
3016
  "&.is-last-left": {
3014
3017
  boxShadow: `1px 0 var(--TableCell-borderColor), ${theme.shadow.md}`
@@ -3343,6 +3346,7 @@ var BodyCell = (props) => {
3343
3346
  () => noWrap && type === "longText",
3344
3347
  [noWrap, type]
3345
3348
  );
3349
+ const isBoundary = props.isLastStartPinnedColumn || props.isLastEndPinnedColumn;
3346
3350
  useEffect5(() => {
3347
3351
  setValue(row[field]);
3348
3352
  }, [row, field]);
@@ -3358,7 +3362,7 @@ var BodyCell = (props) => {
3358
3362
  position: isPinned ? "sticky" : void 0,
3359
3363
  left: isPinned ? pinnedStartPosition : void 0,
3360
3364
  right: isPinned ? pinnedEndPosition : void 0,
3361
- zIndex: isPinned ? `calc(${theme.getCssVar("zIndex-table")} + 2)` : void 0,
3365
+ zIndex: isPinned ? `calc(${theme.getCssVar("zIndex-table")} + ${isBoundary ? 2 : 3})` : void 0,
3362
3366
  "--TableCell-dataBackground": isPinned ? `var(--TableCell-headBackground)` : void 0
3363
3367
  },
3364
3368
  className: isLastStartPinnedColumn && "is-last-left" || isLastEndPinnedColumn && "is-last-right" || ""
@@ -3405,6 +3409,37 @@ var BodyRow = memo(
3405
3409
  )));
3406
3410
  }
3407
3411
  );
3412
+ function useColumnWidths(columnsByField) {
3413
+ const [widths, setWidths] = useState6({});
3414
+ const roRef = useRef4();
3415
+ useLayoutEffect(() => {
3416
+ if (roRef.current) roRef.current.disconnect();
3417
+ roRef.current = new ResizeObserver((entries) => {
3418
+ let changed = false;
3419
+ setWidths((prev) => {
3420
+ const next = { ...prev };
3421
+ entries.forEach((entry) => {
3422
+ const field = entry.target.dataset.field;
3423
+ const w = Math.round(entry.contentRect.width);
3424
+ if (next[field] !== w) {
3425
+ next[field] = w;
3426
+ changed = true;
3427
+ }
3428
+ });
3429
+ return changed ? next : prev;
3430
+ });
3431
+ });
3432
+ Object.entries(columnsByField).forEach(([field, def]) => {
3433
+ const el = def.headerRef.current;
3434
+ if (el) {
3435
+ el.dataset.field = field;
3436
+ roRef.current.observe(el);
3437
+ }
3438
+ });
3439
+ return () => roRef.current?.disconnect();
3440
+ }, [columnsByField]);
3441
+ return widths;
3442
+ }
3408
3443
  function useDataTableRenderer({
3409
3444
  rows: _rows,
3410
3445
  columns: columnsProp,
@@ -3507,6 +3542,12 @@ function useDataTableRenderer({
3507
3542
  () => _isTotalSelected ?? (rowCount > 0 && (selectionModel?.length || 0) === rowCount),
3508
3543
  [_isTotalSelected, selectionModel, rowCount]
3509
3544
  );
3545
+ const columnWidths = useColumnWidths(columnsByField);
3546
+ const getWidth = useCallback9(
3547
+ (f) => (columnWidths[f] ?? columnsByField[f].width ?? // Column prop 으로 지정된 width
3548
+ columnsByField[f].minWidth ?? 0) + columnsProp.length,
3549
+ [columnWidths, columnsByField, columnsProp.length]
3550
+ );
3510
3551
  const columns = useMemo8(() => {
3511
3552
  const baseColumns = columnsProp || // fallback
3512
3553
  Object.keys(rows[0] || {}).map((key) => ({
@@ -3528,32 +3569,27 @@ function useDataTableRenderer({
3528
3569
  sortOrder: columnsByField[column.field]?.sortOrder || sortOrder,
3529
3570
  isPinned,
3530
3571
  isLastStartPinnedColumn: isLeftPinned && [...pinnedColumns?.left || []].pop() === column.field,
3531
- isLastEndPinnedColumn: isRightPinned && [...pinnedColumns?.right || []].pop() === column.field,
3572
+ isLastEndPinnedColumn: isRightPinned && (pinnedColumns?.right?.[0] ?? null) === column.field,
3573
+ // pinned 관련 계산부
3532
3574
  pinnedStartPosition: pinnedColumns?.left?.slice(
3533
3575
  0,
3534
- isLeftPinned ? pinnedColumns?.left?.indexOf(column.field) : pinnedColumns.left.length
3535
- ).reduce(
3536
- (acc, curr) => acc + (columnsByField[curr]?.headerRef.current?.clientWidth || 0),
3537
- 0
3538
- ),
3576
+ isLeftPinned ? pinnedColumns.left.indexOf(column.field) : pinnedColumns.left.length
3577
+ ).reduce((acc, curr) => acc + getWidth(curr), 0),
3539
3578
  pinnedEndPosition: pinnedColumns?.right?.slice(
3540
- 0,
3541
- isRightPinned ? pinnedColumns.right.indexOf(column.field) : pinnedColumns.right.length
3542
- ).reduceRight(
3543
- (acc, curr) => acc + (columnsByField[curr]?.headerRef.current?.clientWidth || 0),
3544
- 0
3545
- )
3579
+ isRightPinned ? pinnedColumns.right.indexOf(column.field) + 1 : 0
3580
+ ).reduce((acc, curr) => acc + getWidth(curr), 0)
3546
3581
  };
3547
3582
  });
3548
3583
  }, [
3549
3584
  columnsProp,
3550
3585
  rows,
3586
+ pinnedColumns?.left,
3587
+ pinnedColumns?.right,
3588
+ columnsByField,
3551
3589
  editMode,
3552
3590
  sortModel,
3553
- columnsByField,
3554
3591
  sortOrder,
3555
- pinnedColumns?.left,
3556
- pinnedColumns?.right
3592
+ getWidth
3557
3593
  ]);
3558
3594
  const handlePageChange = useCallback9(
3559
3595
  (newPage) => {