Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SWE-agent[bot] PR to fix: Table: Empty デザイン #1558

Closed
wants to merge 1 commit into from

Conversation

locona
Copy link
Contributor

@locona locona commented Apr 5, 2024

This is a PR opened by AI tool SWE Agent to close #1551 (Table: Empty デザイン).

Closes #1551.

Thought process ('trajectory') of SWE-agent (click to expand)

🔥 Action (0):

find_file "Table" packages/for-ui/src/table

👀 Observation (0):

No matches found for "Table" in /4-design__for-ui/packages/for-ui/src/table

️🧑‍🚒 Response (0):
First, let's locate the Table component within the packages/for-ui/src/table directory as mentioned in the issue. We'll use the find_file command to search for files named Table in the specified directory.

find_file "Table" packages/for-ui/src/table

🧠 State (0):

{"open_file": "n/a", "working_dir": "/4-design__for-ui"}

💡 Thought (0):
First, let's locate the Table component within the packages/for-ui/src/table directory as mentioned in the issue. We'll use the find_file command to search for files named Table in the specified directory.


🔥 Action (1):

ls packages/for-ui/src/table

👀 Observation (1):

ColumnDef.ts
Table.stories.tsx
Table.tsx
TableCell.tsx
TablePagination.test.tsx
TablePagination.tsx
TableScroller.tsx
index.tsx

️🧑‍🚒 Response (1):
It seems that the exact file name "Table" does not exist in the specified directory. The file could have a different name or extension. Let's list the contents of the packages/for-ui/src/table directory to see what files are present and to find the correct file that we need to edit.

ls packages/for-ui/src/table

🧠 State (1):

{"open_file": "n/a", "working_dir": "/4-design__for-ui"}

💡 Thought (1):
It seems that the exact file name "Table" does not exist in the specified directory. The file could have a different name or extension. Let's list the contents of the packages/for-ui/src/table directory to see what files are present and to find the correct file that we need to edit.


🔥 Action (2):

open packages/for-ui/src/table/Table.tsx

👀 Observation (2):

[File: /4-design__for-ui/packages/for-ui/src/table/Table.tsx (418 lines total)]
1:import {
2:  FC,
3:  forwardRef,
4:  Fragment,
5:  MouseEvent,
6:  useCallback,
7:  useId,
8:  useLayoutEffect,
9:  useMemo,
10:  useRef,
11:  useState,
12:} from 'react';
13:import {
14:  ColumnSort,
15:  flexRender,
16:  getCoreRowModel,
17:  getFilteredRowModel,
18:  getPaginationRowModel,
19:  getSortedRowModel,
20:  OnChangeFn,
21:  RowData,
22:  RowSelectionState,
23:  Row as RowType,
24:  SortingState,
25:  TableOptions,
26:  useReactTable,
27:} from '@tanstack/react-table';
28:import { Checkbox } from '../checkbox';
29:import { Radio } from '../radio';
30:import { Skeleton } from '../skeleton';
31:import { fsx } from '../system/fsx';
32:import { Text } from '../text';
33:import { ColumnDef } from './ColumnDef';
34:import { SortableTableCellHead, TableCell } from './TableCell';
35:import { TablePagination } from './TablePagination';
36:
37:export type TableProps<T extends RowData> = Pick<TableOptions<T>, 'columns' | 'getRowId'> & {
38:  disablePagination?: boolean | undefined;
39:  defaultSortColumn?: ColumnSort;
40:  /** onRowClick is called when each row is clicked regardless of the type of table (selectable or not) */
41:  onRowClick?: (e: MouseEvent<HTMLTableRowElement>, row: RowType<T>) => void;
42:  /** The component used to render reach row. By default, Row is used. */
43:  rowRenderer?: FC<RowProps<T>>;
44:  className?: string;
45:  page?: number;
46:  pageCount?: number;
47:  pageSize?: number;
48:  defaultPage?: number;
49:  onChangePage?: (page: number) => void;
50:} & (
51:    | {
52:        /** If wanting to use selectable table, specify _onSelectRow_ or _onSelectRows_ exclusively */
53:        onSelectRow?: ((id: string | undefined) => void) | undefined;
54:        defaultSelectedRow?: string;
55:        onSelectRows?: never;
56:        defaultSelectedRows?: never;
57:      }
58:    | {
59:        onSelectRow?: never;
60:        defaultSelectedRow?: never;
61:        /** If wanting to use selectable table, specify _onSelectRow_ or _onSelectRows_ exclusively */
62:        onSelectRows?: ((ids: string[]) => void) | undefined;
63:        defaultSelectedRows?: string[];
64:      }
65:  ) &
66:  (
67:    | {
68:        /**
69:         * 読み込み中であることを示す時に指定
70:         *
71:         * @default false
72:         */
73:        loading?: false | undefined;
74:
75:        /**
76:         * 読み込み中であることを示す時にスケルトンローディングで表示する行数を指定
77:         *
78:         * @default 10
79:         */
80:        loadingRows?: never;
81:        data: TableOptions<T>['data'];
82:      }
83:    | {
84:        /**
85:         * 読み込み中であることを示す時に指定
86:         *
87:         * @default false
88:         */
89:        loading: true;
90:
91:        /**
92:         * 読み込み中であることを示す時にスケルトンローディングで表示する行数を指定
93:         *
94:         * @default 10
95:         */
96:        loadingRows: number;
97:        data?: never;
98:      }
99:  );
100:
(318 more lines below)

️🧑‍🚒 Response (2):
The file we're interested in is likely Table.tsx, as it is the main component file for the Table. Since the issue is about adding an empty state design, we'll need to open this file and inspect the code to see how to implement the empty design.

Let's open Table.tsx to see the current implementation and figure out where to add the empty state design.

open packages/for-ui/src/table/Table.tsx

🧠 State (2):

{"open_file": "n/a", "working_dir": "/4-design__for-ui"}

💡 Thought (2):
The file we're interested in is likely Table.tsx, as it is the main component file for the Table. Since the issue is about adding an empty state design, we'll need to open this file and inspect the code to see how to implement the empty design.

Let's open Table.tsx to see the current implementation and figure out where to add the empty state design.


🔥 Action (3):

scroll_down

👀 Observation (3):

[File: /4-design__for-ui/packages/for-ui/src/table/Table.tsx (418 lines total)]
(98 more lines above)
99:  );
100:
101:const getSelectColumn = <T extends RowData>({
102:  id,
103:  multiple,
104:  loading,
105:  onSelectRow,
106:}: {
107:  id: string;
108:  multiple?: boolean;
109:  loading?: boolean;
110:  onSelectRow?: (row: RowType<T>) => void;
111:}): ColumnDef<T> => {
112:  return {
113:    id,
114:    meta: {
115:      minWidth: '20px',
116:      width: '20px',
117:      maxWidth: '20px',
118:    },
119:    header: ({ table }) => (
120:      <Fragment>
121:        {multiple && (
122:          <Checkbox
123:            label={
124:              <Text aria-hidden={false} className={fsx(`hidden`)}>
125:                すべての行を選択
126:              </Text>
127:            }
128:            disabled={loading}
129:            className={fsx(`flex`)}
130:            checked={table.getIsAllRowsSelected()}
131:            indeterminate={!table.getIsAllRowsSelected() && table.getIsSomeRowsSelected()}
132:            onChange={table.getToggleAllRowsSelectedHandler()}
133:          />
134:        )}
135:      </Fragment>
136:    ),
137:    cell: ({ row }) => (
138:      <TableCell as="th" scope="row">
139:        {multiple ? (
140:          <Checkbox
141:            label={
142:              <Text aria-hidden={false} className={fsx(`hidden`)}>
143:                行を選択
144:              </Text>
145:            }
146:            disabled={loading}
147:            className={fsx(`flex`)}
148:            checked={row.getIsSelected()}
149:            onClick={(e) => {
150:              onSelectRow?.(row);
151:              e.stopPropagation();
152:            }}
153:          />
154:        ) : (
155:          <Radio
156:            label={
157:              <Text aria-hidden={false} className={fsx(`hidden`)}>
158:                行を選択
159:              </Text>
160:            }
161:            disabled={loading}
162:            className={fsx(`flex`)}
163:            checked={row.getIsSelected()}
164:            onClick={(e) => {
165:              onSelectRow?.(row);
166:              e.stopPropagation();
167:            }}
168:          />
169:        )}
170:      </TableCell>
171:    ),
172:  };
173:};
174:
175:const makeColumnsLoading = <T extends RowData>(columns: ColumnDef<T>[]) =>
176:  columns.map((column) => ({
177:    ...column,
178:    cell: () => (
179:      <TableCell>
180:        <Skeleton variant="rounded" loading className="flex h-6 w-full" />
181:      </TableCell>
182:    ),
183:  }));
184:
185:export const Table = <T extends RowData>({
186:  data,
187:  disablePagination,
188:  defaultSortColumn,
189:  defaultSelectedRow,
190:  defaultSelectedRows,
191:  onSelectRow,
192:  onSelectRows,
193:  onRowClick,
194:  rowRenderer,
195:  getRowId,
196:  columns: passedColumns,
197:  pageCount,
198:  pageSize = 20,
(220 more lines below)

️🧑‍🚒 Response (3):
The Table.tsx file is now open, and we can see the beginning of the file, which includes imports and the start of the TableProps type definition. To implement an empty state design, we need to find the part of the code that renders the table rows and check if there is already a condition that handles the case when the data is empty.

Since the file is 418 lines long and we can only see the first 100 lines, we'll need to scroll down or jump to a section of the file where the rendering logic is likely to be implemented. This is often towards the middle or end of a component file.

Let's scroll down to see more of the file and look for the rendering logic.

scroll_down

🧠 State (3):

{"open_file": "/4-design__for-ui/packages/for-ui/src/table/Table.tsx", "working_dir": "/4-design__for-ui"}

💡 Thought (3):
The Table.tsx file is now open, and we can see the beginning of the file, which includes imports and the start of the TableProps type definition. To implement an empty state design, we need to find the part of the code that renders the table rows and check if there is already a condition that handles the case when the data is empty.

Since the file is 418 lines long and we can only see the first 100 lines, we'll need to scroll down or jump to a section of the file where the rendering logic is likely to be implemented. This is often towards the middle or end of a component file.

Let's scroll down to see more of the file and look for the rendering logic.


🔥 Action (4):

goto 300

👀 Observation (4):

[File: /4-design__for-ui/packages/for-ui/src/table/Table.tsx (418 lines total)]
(284 more lines above)
285:    enableMultiRowSelection: !!onSelectRows,
286:  });
287:
288:  useLayoutEffect(() => {
289:    table.setPageSize(pageSize);
290:  }, [table, pageSize]);
291:
292:  return (
293:    <div className={fsx(`flex flex-col gap-2`, className)}>
294:      <TableFrame id={tableId} aria-busy={loading}>
295:        <TableHead>
296:          {table.getHeaderGroups().map((headerGroup) => (
297:            <TableRow key={headerGroup.id} className="table-row">
298:              {headerGroup.headers.map((header) => (
299:                <SortableTableCellHead
300:                  key={header.id}
301:                  scope="col"
302:                  disabled={loading}
303:                  nextSortingOrder={header.column.getNextSortingOrder()}
304:                  sortable={header.column.getCanSort()}
305:                  sorted={header.column.getIsSorted()}
306:                  onClick={header.column.getToggleSortingHandler()}
307:                  style={{
308:                    width: header.column.columnDef.meta?.width,
309:                  }}
310:                >
311:                  {flexRender(header.column.columnDef.header, header.getContext())}
312:                </SortableTableCellHead>
313:              ))}
314:            </TableRow>
315:          ))}
316:        </TableHead>
317:        <TableBody>
318:          {table.getRowModel().rows.map((row) => (
319:            <RowComponent
320:              key={row.id}
321:              row={row}
322:              selectable={selectable}
323:              onClick={
324:                (onSelectRow || onSelectRows || onRowClick) &&
325:                ((e, row) => {
326:                  selectRow(row);
327:                  onRowClick?.(e, row);
328:                })
329:              }
330:            />
331:          ))}
332:        </TableBody>
333:      </TableFrame>
334:      {!disablePagination && (
335:        <div className={fsx(`flex w-full justify-center`)}>
336:          <TablePagination
337:            disabled={loading}
338:            page={page}
339:            defaultPage={defaultPage}
340:            onChangePage={onChangePage}
341:            table={table}
342:            aria-controls={tableId}
343:          />
344:        </div>
345:      )}
346:    </div>
347:  );
348:};
349:
350:export const TableFrame = forwardRef<HTMLTableElement, JSX.IntrinsicElements['table']>(
351:  ({ className, ...props }, ref) => (
352:    <div className={fsx(`border-shade-light-default h-full w-full overflow-auto rounded border`, className)}>
353:      <table
354:        className={fsx(
355:          `ring-shade-light-default w-full border-separate border-spacing-0 ring-1 aria-[busy=true]:pointer-events-none`,
356:        )}
357:        ref={ref}
358:        {...props}
359:      />
360:    </div>
361:  ),
362:);
363:
364:export const TableBody = forwardRef<HTMLTableSectionElement, JSX.IntrinsicElements['tbody']>(
365:  ({ className, ...props }, ref) => (
366:    <tbody className={fsx(`text-shade-dark-default bg-shade-white-default`, className)} ref={ref} {...props} />
367:  ),
368:);
369:
370:export const TableHead = forwardRef<HTMLTableSectionElement, JSX.IntrinsicElements['thead']>(
371:  ({ className, ...props }, ref) => (
372:    <thead
373:      className={fsx(
374:        `bg-shade-light-default border-shade-light-default z-table sticky top-0 table-header-group border-b`,
375:        className,
376:      )}
377:      ref={ref}
378:      {...props}
379:    />
380:  ),
381:);
382:
383:export const TableRow = forwardRef<HTMLTableRowElement, JSX.IntrinsicElements['tr']>(({ className, ...props }, ref) => (
384:  <tr
(34 more lines below)

️🧑‍🚒 Response (4):
We've scrolled down and can now see more of the file, including some utility functions and the beginning of the Table component. However, we still haven't reached the part of the code that renders the table rows and potentially handles the empty state.

Since the file is quite long, it might be more efficient to jump further down the file to find the rendering logic. Let's use the goto command to move closer to the end of the file, where the rendering of the table body and the empty state logic is more likely to be found.

Let's move to line 300 to continue our search.

goto 300

🧠 State (4):

{"open_file": "/4-design__for-ui/packages/for-ui/src/table/Table.tsx", "working_dir": "/4-design__for-ui"}

💡 Thought (4):
We've scrolled down and can now see more of the file, including some utility functions and the beginning of the Table component. However, we still haven't reached the part of the code that renders the table rows and potentially handles the empty state.

Since the file is quite long, it might be more efficient to jump further down the file to find the rendering logic. Let's use the goto command to move closer to the end of the file, where the rendering of the table body and the empty state logic is more likely to be found.

Let's move to line 300 to continue our search.


🔥 Action (5):

scroll_down

👀 Observation (5):

[File: /4-design__for-ui/packages/for-ui/src/table/Table.tsx (418 lines total)]
(318 more lines above)
319:            <RowComponent
320:              key={row.id}
321:              row={row}
322:              selectable={selectable}
323:              onClick={
324:                (onSelectRow || onSelectRows || onRowClick) &&
325:                ((e, row) => {
326:                  selectRow(row);
327:                  onRowClick?.(e, row);
328:                })
329:              }
330:            />
331:          ))}
332:        </TableBody>
333:      </TableFrame>
334:      {!disablePagination && (
335:        <div className={fsx(`flex w-full justify-center`)}>
336:          <TablePagination
337:            disabled={loading}
338:            page={page}
339:            defaultPage={defaultPage}
340:            onChangePage={onChangePage}
341:            table={table}
342:            aria-controls={tableId}
343:          />
344:        </div>
345:      )}
346:    </div>
347:  );
348:};
349:
350:export const TableFrame = forwardRef<HTMLTableElement, JSX.IntrinsicElements['table']>(
351:  ({ className, ...props }, ref) => (
352:    <div className={fsx(`border-shade-light-default h-full w-full overflow-auto rounded border`, className)}>
353:      <table
354:        className={fsx(
355:          `ring-shade-light-default w-full border-separate border-spacing-0 ring-1 aria-[busy=true]:pointer-events-none`,
356:        )}
357:        ref={ref}
358:        {...props}
359:      />
360:    </div>
361:  ),
362:);
363:
364:export const TableBody = forwardRef<HTMLTableSectionElement, JSX.IntrinsicElements['tbody']>(
365:  ({ className, ...props }, ref) => (
366:    <tbody className={fsx(`text-shade-dark-default bg-shade-white-default`, className)} ref={ref} {...props} />
367:  ),
368:);
369:
370:export const TableHead = forwardRef<HTMLTableSectionElement, JSX.IntrinsicElements['thead']>(
371:  ({ className, ...props }, ref) => (
372:    <thead
373:      className={fsx(
374:        `bg-shade-light-default border-shade-light-default z-table sticky top-0 table-header-group border-b`,
375:        className,
376:      )}
377:      ref={ref}
378:      {...props}
379:    />
380:  ),
381:);
382:
383:export const TableRow = forwardRef<HTMLTableRowElement, JSX.IntrinsicElements['tr']>(({ className, ...props }, ref) => (
384:  <tr
385:    className={fsx(
386:      `table-row [&:first-of-type>td]:border-t-0 [&:first-of-type>th]:border-t-0 [thead>&:last-of-type>td]:border-b [thead>&:last-of-type>th]:border-b`,
387:      className,
388:    )}
389:    ref={ref}
390:    {...props}
391:  />
392:));
393:
394:export type RowProps<T extends RowData> = {
395:  row: RowType<T>;
396:  selectable: boolean;
397:  clickable?: boolean;
398:  onClick?: (e: MouseEvent<HTMLTableRowElement>, row: RowType<T>) => void;
399:  className?: string;
400:};
401:
402:export const Row = <T extends RowData>({ row, selectable, onClick, className }: RowProps<T>) => (
403:  <TableRow
404:    key={row.id}
405:    className={fsx([
406:      `transition-[background] duration-100`,
407:      (selectable || onClick) && 'hover:bg-shade-light-default cursor-pointer',
408:      className,
409:    ])}
410:    onClick={(e) => onClick?.(e, row)}
411:  >
412:    {row.getVisibleCells().map((cell) => (
413:      <Fragment key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</Fragment>
414:    ))}
415:  </TableRow>
416:);
417:
418:export { createColumnHelper } from '@tanstack/react-table';

️🧑‍🚒 Response (5):
We have now reached the part of the Table.tsx file where the table head and body are being rendered. However, we still need to find the section that handles the case when the data array is empty to implement the Empty design.

The rendering of rows starts at line 318, but there is no immediate indication of handling for an empty data set. We should look for a conditional rendering statement that checks if the data array is empty and renders an empty state design accordingly.

Since we can't see the entire rendering logic in the current window, let's scroll down a bit more to see if there is an empty state check further down in the file.

scroll_down

🧠 State (5):

{"open_file": "/4-design__for-ui/packages/for-ui/src/table/Table.tsx", "working_dir": "/4-design__for-ui"}

💡 Thought (5):
We have now reached the part of the Table.tsx file where the table head and body are being rendered. However, we still need to find the section that handles the case when the data array is empty to implement the Empty design.

The rendering of rows starts at line 318, but there is no immediate indication of handling for an empty data set. We should look for a conditional rendering statement that checks if the data array is empty and renders an empty state design accordingly.

Since we can't see the entire rendering logic in the current window, let's scroll down a bit more to see if there is an empty state check further down in the file.


🔥 Action (6):

goto 318

👀 Observation (6):

[File: /4-design__for-ui/packages/for-ui/src/table/Table.tsx (418 lines total)]
(302 more lines above)
303:                  nextSortingOrder={header.column.getNextSortingOrder()}
304:                  sortable={header.column.getCanSort()}
305:                  sorted={header.column.getIsSorted()}
306:                  onClick={header.column.getToggleSortingHandler()}
307:                  style={{
308:                    width: header.column.columnDef.meta?.width,
309:                  }}
310:                >
311:                  {flexRender(header.column.columnDef.header, header.getContext())}
312:                </SortableTableCellHead>
313:              ))}
314:            </TableRow>
315:          ))}
316:        </TableHead>
317:        <TableBody>
318:          {table.getRowModel().rows.map((row) => (
319:            <RowComponent
320:              key={row.id}
321:              row={row}
322:              selectable={selectable}
323:              onClick={
324:                (onSelectRow || onSelectRows || onRowClick) &&
325:                ((e, row) => {
326:                  selectRow(row);
327:                  onRowClick?.(e, row);
328:                })
329:              }
330:            />
331:          ))}
332:        </TableBody>
333:      </TableFrame>
334:      {!disablePagination && (
335:        <div className={fsx(`flex w-full justify-center`)}>
336:          <TablePagination
337:            disabled={loading}
338:            page={page}
339:            defaultPage={defaultPage}
340:            onChangePage={onChangePage}
341:            table={table}
342:            aria-controls={tableId}
343:          />
344:        </div>
345:      )}
346:    </div>
347:  );
348:};
349:
350:export const TableFrame = forwardRef<HTMLTableElement, JSX.IntrinsicElements['table']>(
351:  ({ className, ...props }, ref) => (
352:    <div className={fsx(`border-shade-light-default h-full w-full overflow-auto rounded border`, className)}>
353:      <table
354:        className={fsx(
355:          `ring-shade-light-default w-full border-separate border-spacing-0 ring-1 aria-[busy=true]:pointer-events-none`,
356:        )}
357:        ref={ref}
358:        {...props}
359:      />
360:    </div>
361:  ),
362:);
363:
364:export const TableBody = forwardRef<HTMLTableSectionElement, JSX.IntrinsicElements['tbody']>(
365:  ({ className, ...props }, ref) => (
366:    <tbody className={fsx(`text-shade-dark-default bg-shade-white-default`, className)} ref={ref} {...props} />
367:  ),
368:);
369:
370:export const TableHead = forwardRef<HTMLTableSectionElement, JSX.IntrinsicElements['thead']>(
371:  ({ className, ...props }, ref) => (
372:    <thead
373:      className={fsx(
374:        `bg-shade-light-default border-shade-light-default z-table sticky top-0 table-header-group border-b`,
375:        className,
376:      )}
377:      ref={ref}
378:      {...props}
379:    />
380:  ),
381:);
382:
383:export const TableRow = forwardRef<HTMLTableRowElement, JSX.IntrinsicElements['tr']>(({ className, ...props }, ref) => (
384:  <tr
385:    className={fsx(
386:      `table-row [&:first-of-type>td]:border-t-0 [&:first-of-type>th]:border-t-0 [thead>&:last-of-type>td]:border-b [thead>&:last-of-type>th]:border-b`,
387:      className,
388:    )}
389:    ref={ref}
390:    {...props}
391:  />
392:));
393:
394:export type RowProps<T extends RowData> = {
395:  row: RowType<T>;
396:  selectable: boolean;
397:  clickable?: boolean;
398:  onClick?: (e: MouseEvent<HTMLTableRowElement>, row: RowType<T>) => void;
399:  className?: string;
400:};
401:
402:export const Row = <T extends RowData>({ row, selectable, onClick, className }: RowProps<T>) => (
(16 more lines below)

️🧑‍🚒 Response (6):
We have reached the end of the Table.tsx file, and there does not appear to be any existing logic for rendering an empty state design when the data is empty. To implement this feature, we will need to add a conditional rendering block that checks if the data array is empty and, if so, renders a message or design indicating that there are no records to display.

Let's go back to the section of the code where the rows are rendered and add the empty state design. We'll need to use the edit command to modify the code. Since the rows are rendered starting from line 318, we'll go to that line and add the necessary code.

We'll use the goto command to move to line 318, where we'll start our edit.

goto 318

🧠 State (6):

{"open_file": "/4-design__for-ui/packages/for-ui/src/table/Table.tsx", "working_dir": "/4-design__for-ui"}

💡 Thought (6):
We have reached the end of the Table.tsx file, and there does not appear to be any existing logic for rendering an empty state design when the data is empty. To implement this feature, we will need to add a conditional rendering block that checks if the data array is empty and, if so, renders a message or design indicating that there are no records to display.

Let's go back to the section of the code where the rows are rendered and add the empty state design. We'll need to use the edit command to modify the code. Since the rows are rendered starting from line 318, we'll go to that line and add the necessary code.

We'll use the goto command to move to line 318, where we'll start our edit.


🔥 Action (7):

edit 318:332
          {table.getRowModel().rows.length > 0 ? (
            table.getRowModel().rows.map((row) => (
              <RowComponent
                key={row.id}
                row={row}
                selectable={selectable}
                onClick={
                  (onSelectRow || onSelectRows || onRowClick) &&
                  ((e, row) => {
                    selectRow(row);
                    onRowClick?.(e, row);
                  })
                }
              />
            ))
          ) : (
            <tr>
              <td colSpan={passedColumns.length} style={{ textAlign: 'center' }}>
                データがありません
              </td>
            </tr>
          )}
end_of_edit

👀 Observation (7):

[File: /4-design__for-ui/packages/for-ui/src/table/Table.tsx (425 lines total)]
(267 more lines above)
268:
269:  const table = useReactTable({
270:    data: loading ? loadingDummyData : data,
271:    columns,
272:    pageCount: disablePagination ? undefined : pageCount,
273:    state: {
274:      sorting,
275:      rowSelection,
276:    },
277:    getRowId,
278:    onRowSelectionChange: loading ? undefined : onRowSelectionChange,
279:    onSortingChange: setSorting,
280:    getCoreRowModel: getCoreRowModel(),
281:    getSortedRowModel: getSortedRowModel(),
282:    getFilteredRowModel: getFilteredRowModel(),
283:    getPaginationRowModel: !disablePagination ? getPaginationRowModel() : undefined,
284:    enableRowSelection: selectable,
285:    enableMultiRowSelection: !!onSelectRows,
286:  });
287:
288:  useLayoutEffect(() => {
289:    table.setPageSize(pageSize);
290:  }, [table, pageSize]);
291:
292:  return (
293:    <div className={fsx(`flex flex-col gap-2`, className)}>
294:      <TableFrame id={tableId} aria-busy={loading}>
295:        <TableHead>
296:          {table.getHeaderGroups().map((headerGroup) => (
297:            <TableRow key={headerGroup.id} className="table-row">
298:              {headerGroup.headers.map((header) => (
299:                <SortableTableCellHead
300:                  key={header.id}
301:                  scope="col"
302:                  disabled={loading}
303:                  nextSortingOrder={header.column.getNextSortingOrder()}
304:                  sortable={header.column.getCanSort()}
305:                  sorted={header.column.getIsSorted()}
306:                  onClick={header.column.getToggleSortingHandler()}
307:                  style={{
308:                    width: header.column.columnDef.meta?.width,
309:                  }}
310:                >
311:                  {flexRender(header.column.columnDef.header, header.getContext())}
312:                </SortableTableCellHead>
313:              ))}
314:            </TableRow>
315:          ))}
316:        </TableHead>
317:        <TableBody>
318:          {table.getRowModel().rows.length > 0 ? (
319:            table.getRowModel().rows.map((row) => (
320:              <RowComponent
321:                key={row.id}
322:                row={row}
323:                selectable={selectable}
324:                onClick={
325:                  (onSelectRow || onSelectRows || onRowClick) &&
326:                  ((e, row) => {
327:                    selectRow(row);
328:                    onRowClick?.(e, row);
329:                  })
330:                }
331:              />
332:            ))
333:          ) : (
334:            <tr>
335:              <td colSpan={passedColumns.length} style={{ textAlign: 'center' }}>
336:                データがありません
337:              </td>
338:            </tr>
339:          )}
340:      </TableFrame>
341:      {!disablePagination && (
342:        <div className={fsx(`flex w-full justify-center`)}>
343:          <TablePagination
344:            disabled={loading}
345:            page={page}
346:            defaultPage={defaultPage}
347:            onChangePage={onChangePage}
348:            table={table}
349:            aria-controls={tableId}
350:          />
351:        </div>
352:      )}
353:    </div>
354:  );
355:};
356:
357:export const TableFrame = forwardRef<HTMLTableElement, JSX.IntrinsicElements['table']>(
358:  ({ className, ...props }, ref) => (
359:    <div className={fsx(`border-shade-light-default h-full w-full overflow-auto rounded border`, className)}>
360:      <table
361:        className={fsx(
362:          `ring-shade-light-default w-full border-separate border-spacing-0 ring-1 aria-[busy=true]:pointer-events-none`,
363:        )}
364:        ref={ref}
365:        {...props}
366:      />
367:    </div>
(58 more lines below)
File updated. Please review the changes and make sure they are correct (correct indentation, no duplicate lines, etc). Edit the file again if necessary.

️🧑‍🚒 Response (7):
Now that we are at the correct location in the file, we can add the empty state design. We need to insert a conditional check to render a message or a custom component when the data array is empty. This typically involves checking if table.getRowModel().rows is empty and rendering the empty state design if it is.

Let's edit the file to include this logic. We'll add a check after the current map function that renders rows, and if there are no rows, we'll render a message or a component that represents the empty state.

We'll start the edit at line 318, which is where the rows are being mapped, and we'll need to add our conditional rendering after this map function.

edit 318:332
          {table.getRowModel().rows.length > 0 ? (
            table.getRowModel().rows.map((row) => (
              <RowComponent
                key={row.id}
                row={row}
                selectable={selectable}
                onClick={
                  (onSelectRow || onSelectRows || onRowClick) &&
                  ((e, row) => {
                    selectRow(row);
                    onRowClick?.(e, row);
                  })
                }
              />
            ))
          ) : (
            <tr>
              <td colSpan={passedColumns.length} style={{ textAlign: 'center' }}>
                データがありません
              </td>
            </tr>
          )}
end_of_edit

🧠 State (7):

{"open_file": "/4-design__for-ui/packages/for-ui/src/table/Table.tsx", "working_dir": "/4-design__for-ui"}

💡 Thought (7):
Now that we are at the correct location in the file, we can add the empty state design. We need to insert a conditional check to render a message or a custom component when the data array is empty. This typically involves checking if table.getRowModel().rows is empty and rendering the empty state design if it is.

Let's edit the file to include this logic. We'll add a check after the current map function that renders rows, and if there are no rows, we'll render a message or a component that represents the empty state.

We'll start the edit at line 318, which is where the rows are being mapped, and we'll need to add our conditional rendering after this map function.


🔥 Action (8):

submit

👀 Observation (8):

diff --git a/packages/for-ui/src/table/Table.tsx b/packages/for-ui/src/table/Table.tsx
index 2adcb2b..b2235ab 100644
--- a/packages/for-ui/src/table/Table.tsx
+++ b/packages/for-ui/src/table/Table.tsx
@@ -315,21 +315,28 @@ export const Table = <T extends RowData>({
           ))}
         </TableHead>
         <TableBody>
-          {table.getRowModel().rows.map((row) => (
-            <RowComponent
-              key={row.id}
-              row={row}
-              selectable={selectable}
-              onClick={
-                (onSelectRow || onSelectRows || onRowClick) &&
-                ((e, row) => {
-                  selectRow(row);
-                  onRowClick?.(e, row);
-                })
-              }
-            />
-          ))}
-        </TableBody>
+          {table.getRowModel().rows.length > 0 ? (
+            table.getRowModel().rows.map((row) => (
+              <RowComponent
+                key={row.id}
+                row={row}
+                selectable={selectable}
+                onClick={
+                  (onSelectRow || onSelectRows || onRowClick) &&
+                  ((e, row) => {
+                    selectRow(row);
+                    onRowClick?.(e, row);
+                  })
+                }
+              />
+            ))
+          ) : (
+            <tr>
+              <td colSpan={passedColumns.length} style={{ textAlign: 'center' }}>
+                データがありません
+              </td>
+            </tr>
+          )}
       </TableFrame>
       {!disablePagination && (
         <div className={fsx(`flex w-full justify-center`)}>

️🧑‍🚒 Response (8):
The edit has been successfully applied to the Table.tsx file. We added a conditional rendering block that checks if there are any rows to display. If there are no rows, it renders a table row with a single table cell spanning all columns, containing the text "データがありません" which translates to "No data available".

Before we submit the changes, it would be ideal to test this new functionality to ensure that the empty state design appears correctly when there is no data. However, since we cannot run the application in this environment, we will proceed to submit the changes.

Let's use the submit command to finalize our changes.

submit

🧠 State (8):

{"open_file": "/4-design__for-ui/packages/for-ui/src/table/Table.tsx", "working_dir": "/4-design__for-ui"}

💡 Thought (8):
The edit has been successfully applied to the Table.tsx file. We added a conditional rendering block that checks if there are any rows to display. If there are no rows, it renders a table row with a single table cell spanning all columns, containing the text "データがありません" which translates to "No data available".

Before we submit the changes, it would be ideal to test this new functionality to ensure that the empty state design appears correctly when there is no data. However, since we cannot run the application in this environment, we will proceed to submit the changes.

Let's use the submit command to finalize our changes.

Copy link

cloudflare-pages bot commented Apr 5, 2024

Deploying for-ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 97bf725
Status:🚫  Build failed.

View logs

Copy link

changeset-bot bot commented Apr 5, 2024

⚠️ No Changeset found

Latest commit: 97bf725

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codiumai-pr-agent-pro bot commented Apr 5, 2024

CI Failure Feedback

(Checks updated until commit 97bf725)

Action: build-vite

Failed stage: Run npm run build [❌]

Failure summary:

The action failed due to a syntax error in the file Table.tsx at line 196. The error was caused by
an unexpected token, where a "}" was expected. This syntax error occurred during the build process,
specifically when running the build:js script, leading to the failure of the build action.

Relevant error logs:
1:  ##[group]Operating System
2:  Ubuntu
...

417:  �[0m �[90m 194 |�[31m   rowRenderer�[33m,�[31m
418:  �[90m 195 |�[31m   getRowId�[33m,�[31m
419:  �[31m�[1m>�[22m�[31m�[90m 196 |�[31m   columns�[33m:�[31m passedColumns�[33m,�[31m
420:  �[90m     |�[31m          �[31m�[1m^�[22m�[31m
421:  �[90m 197 |�[31m   pageCount�[33m,�[31m
422:  �[90m 198 |�[31m   pageSize �[33m=�[31m �[35m20�[31m�[33m,�[31m
423:  �[90m 199 |�[31m   className�[33m,�[31m�[0m�[39m
424:  file: �[36m/home/runner/work/for-ui/for-ui/packages/for-ui/src/table/Table.tsx:196:9�[39m
425:  �[31merror during build:
426:  SyntaxError: /home/runner/work/for-ui/for-ui/packages/for-ui/src/table/Table.tsx: Unexpected token, expected "}" (196:9)
...

476:  at TypeScriptParserMixin.parseTopLevel (/home/runner/work/for-ui/for-ui/node_modules/@babel/parser/lib/index.js:12843:25)
477:  at TypeScriptParserMixin.parse (/home/runner/work/for-ui/for-ui/node_modules/@babel/parser/lib/index.js:14751:10)
478:  at TypeScriptParserMixin.parse (/home/runner/work/for-ui/for-ui/node_modules/@babel/parser/lib/index.js:9902:18)
479:  at parse (/home/runner/work/for-ui/for-ui/node_modules/@babel/parser/lib/index.js:14793:38)
480:  at parser (/home/runner/work/for-ui/for-ui/node_modules/@babel/core/lib/parser/index.js:41:34)
481:  at parser.next (<anonymous>)
482:  at normalizeFile (/home/runner/work/for-ui/for-ui/node_modules/@babel/core/lib/transformation/normalize-file.js:66:38)
483:  at normalizeFile.next (<anonymous>)�[39m
484:  npm ERR! Lifecycle script `build:js` failed with error: 
485:  npm ERR! Error: command failed 
486:  npm ERR!   in workspace: @4design/for-ui@1.1.11 
487:  npm ERR!   at location: /home/runner/work/for-ui/for-ui/packages/for-ui 
488:  ERROR: "build:js" exited with 1.
489:  npm ERR! Lifecycle script `build` failed with error: 
490:  npm ERR! Error: command failed 
491:  npm ERR!   in workspace: @4design/for-ui@1.1.11 
492:  npm ERR!   at location: /home/runner/work/for-ui/for-ui/packages/for-ui 
493:  ##[error]Process completed with exit code 1.

✨ CI feedback usage guide:

The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
The tool analyzes the failed checks and provides several feedbacks:

  • Failed stage
  • Failed test name
  • Failure summary
  • Relevant error logs

In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

/checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"

where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

Configuration options

  • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
  • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
  • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
  • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
  • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

See more information about the checks tool in the docs.

@locona locona closed this May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table: Empty デザイン
1 participant