diff --git a/next-docs/public/examples/table/ExpandableCheckboxes.tsx b/next-docs/public/examples/table/ExpandableCheckboxes.tsx index d7c8223e05..02427dba2c 100644 --- a/next-docs/public/examples/table/ExpandableCheckboxes.tsx +++ b/next-docs/public/examples/table/ExpandableCheckboxes.tsx @@ -21,7 +21,7 @@ const Example = () => { const [selected, setSelected] = useState<{ [key: string]: boolean }>({}); const columnShift = (depth: number) => { - const shiftMap: { [key: number]: string } = [ + const shiftMap: { [key: number]: string } = [ 'ps-0', 'ps-6', 'ps-12', @@ -33,15 +33,15 @@ const Example = () => { const checkIfSelected = (id: string, canExpand: boolean, rowsById: { [key: string]: boolean }) => { return canExpand ? Object.keys(rowsById) - .filter((rowId) => rowId.indexOf(id) === 0 && rowId !== id) - .every((rowId) => selected[rowId] === true) + .filter((rowId) => rowId.indexOf(id) === 0 && rowId !== id) + .every((rowId) => selected[rowId] === true) : selected[id] === true; } const checkIfIndeterminate = (id: string, rowsById: { [key: string]: boolean }) => { - const matches = Object.keys(rowsById) + const matches = Object.keys(rowsById) .filter((rowId) => rowId.indexOf(id) === 0 && rowId !== id); - return !matches.every((rowId) => selected[rowId] === true) && matches.some((rowId) => selected[rowId] === true); + return !matches.every((rowId) => selected[rowId] === true) && matches.some((rowId) => selected[rowId] === true); } const columnsInitial = [ @@ -60,7 +60,7 @@ const Example = () => {
{ e.stopPropagation() }} @@ -72,28 +72,28 @@ const Example = () => {
), Cell: ({ row, rowsById }: any) => ( -
{ - if ((e.target as unknown as HTMLElement).tagName === 'SPAN') e.stopPropagation(); - }} - > -
- e.stopPropagation()} - /> -
- { row.canExpand ? ( - - {row.isExpanded ? '👇' : '👉'} - - ) : null } +
{ + if ((e.target as unknown as HTMLElement).tagName === 'SPAN') e.stopPropagation(); + }} + > +
+ e.stopPropagation()} + />
+ {row.canExpand ? ( + + {row.isExpanded ? '👇' : '👉'} + + ) : null} +
) }, ], @@ -304,10 +304,10 @@ const Example = () => { useCheckbox={true} expandedByDefault={true} getOnRowSelect={() => (rows) => { - setSelected(rows.reduce((acc: {[key: string]: boolean}, item) => { - acc[item.id] = true; - return acc; - }, {}) + setSelected(rows.reduce((acc: { [key: string]: boolean }, item) => { + acc[item.id] = true; + return acc; + }, {}) ); }} /> diff --git a/next-docs/public/examples/table/ExpandedWithModals.tsx b/next-docs/public/examples/table/ExpandedWithModals.tsx index df812f44a7..3ab8d4fb19 100644 --- a/next-docs/public/examples/table/ExpandedWithModals.tsx +++ b/next-docs/public/examples/table/ExpandedWithModals.tsx @@ -2,7 +2,6 @@ import React, { ReactNode, useState } from 'react'; import { Table } from '@heathmont/moon-table-tw'; import { Button, Chip, Modal, Tooltip } from '@heathmont/moon-core-tw'; import { OtherFrame } from '@heathmont/moon-icons-tw'; -import { number } from 'zod'; interface HeaderProps { isAllRowsExpanded: boolean; @@ -107,7 +106,8 @@ const Example = () => { onClick={() => { setTitle(modal.title); setPanel(modal.panel); - openModal(); }} + openModal(); + }} /> @@ -128,7 +128,7 @@ const Example = () => {
  • Activity: {Math.floor(index * 100)}
  • Actions: {Math.floor(index * 100)}
  • - ) + ) }; } diff --git a/workspaces/tables/src/components/Table.tsx b/workspaces/tables/src/components/Table.tsx index 9d5606eaef..314dedba9e 100644 --- a/workspaces/tables/src/components/Table.tsx +++ b/workspaces/tables/src/components/Table.tsx @@ -116,8 +116,8 @@ const Table = ({ setSelectedRows( rows?.length ? rows.filter((row: Row<{ isSelected?: boolean }>) => { - return row.original?.isSelected; - }) + return row.original?.isSelected; + }) : [] ); }, []); @@ -143,12 +143,12 @@ const Table = ({ stickySide={ // @ts-ignore (column.sticky === 'left' || column.parent?.sticky === 'left') && - scrollState.scrolledToRight + scrollState.scrolledToRight ? 'left' : // @ts-ignore column.sticky === 'right' || column.parent?.sticky === 'right' - ? 'right' - : '' + ? 'right' + : '' } isLastColumn={isLastColumn} rowSize={rowSize} @@ -199,8 +199,8 @@ const Table = ({ ? 'left' : // @ts-ignore column.sticky === 'right' && scrollState.scrolledToLeft - ? 'right' - : '' + ? 'right' + : '' } rowSize={rowSize} isCellBorder={isCellBorder} @@ -219,7 +219,7 @@ const Table = ({ ); }; - const setForceUpdateRowSelectedState = (callback: () => React.Dispatch>) => { + const setForceUpdateRowSelectedState = (callback: () => React.Dispatch>) => { updateRowSelectState = callback; } @@ -286,10 +286,10 @@ const Table = ({ const isAllRowsSelectedAtThisBranch = branchRowsAtSpecifiedDepth.every(Boolean); if (isAllRowsSelectedAtThisBranch) { - const isNodeRowAlreadyAffected = alreadySelectedRows.filter(({ id }) => id === mask).length; - if (!isNodeRowAlreadyAffected) { - alreadySelectedRows.push(rowsById[mask]); - } + const isNodeRowAlreadyAffected = alreadySelectedRows.filter(({ id }) => id === mask).length; + if (!isNodeRowAlreadyAffected) { + alreadySelectedRows.push(rowsById[mask]); + } } } depth--; @@ -369,37 +369,37 @@ const Table = ({ {variant === 'calendar' ? renderSpanRows({ - rows, - prepareRow, - getOnRowClickHandler, - evenRowBackgroundColor, - defaultRowBackgroundColor, - rowSpanHeaders, - selectable, - useCheckbox, - rowSize, - isCellBorder, - }) + rows, + prepareRow, + getOnRowClickHandler, + evenRowBackgroundColor, + defaultRowBackgroundColor, + rowSpanHeaders, + selectable, + useCheckbox, + rowSize, + isCellBorder, + }) : renderRows({ - rows, - prepareRow, - getOnRowClickHandler, - getOnRowSelectHandler: !selectable - ? undefined - : useCheckbox - ? (row) => selectCheckableRow - : (row) => selectCommonRow, + rows, + prepareRow, + getOnRowClickHandler, + getOnRowSelectHandler: !selectable + ? undefined + : useCheckbox + ? (row) => selectCheckableRow + : (row) => selectCommonRow, - evenRowBackgroundColor, - defaultRowBackgroundColor, - renderRowSubComponent, - setForceUpdateRowSelectedState, - selectable, - useCheckbox, - rowSize, - isCellBorder, - textClip, - })} + evenRowBackgroundColor, + defaultRowBackgroundColor, + renderRowSubComponent, + setForceUpdateRowSelectedState, + selectable, + useCheckbox, + rowSize, + isCellBorder, + textClip, + })} {withFooter && (