Skip to content

Commit 9f65809

Browse files
committed
Remove "external active column"
1 parent a0c9dd4 commit 9f65809

5 files changed

Lines changed: 12 additions & 35 deletions

File tree

src/table/Cell.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface CellProps {
1111
value: unknown
1212
setValue?: (value: unknown) => void
1313
onEdit?: (pos: number) => void
14-
extActive?: boolean
1514
}
1615

1716
export interface CellInputProps {
@@ -31,20 +30,16 @@ export function Cell(props: CellProps) {
3130
const [value, setValue] = createSignal(props.value)
3231
createEffect(() => props.value !== undefined && setValue(props.value))
3332

34-
const isNull = () => value() === null
35-
3633
return (
37-
<div ref={containerEl} class="cell" data-ext-active={props.extActive} tabIndex={-1}>
38-
<Show when={!isNull()} fallback={<span class="null">NULL</span>}>
39-
<Dynamic
40-
component={props.component}
41-
value={value()}
42-
setValue={props.setValue}
43-
onEdit={props.onEdit}
44-
editable={props.editable}
45-
format={props.format}
46-
/>
47-
</Show>
34+
<div ref={containerEl} class="cell" tabIndex={-1}>
35+
<Dynamic
36+
component={props.component}
37+
value={value()}
38+
setValue={props.setValue}
39+
onEdit={props.onEdit}
40+
editable={props.editable}
41+
format={props.format}
42+
/>
4843
</div>
4944
)
5045
}

src/table/Table.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@
148148
outline: none;
149149
/* text-sm */
150150

151-
.null {
151+
/* .null {
152152
width: 100%;
153153
text-align: center;
154154
font-style: italic;
155155
color: oklch(87.2% 0.01 258.338); /* gray-300 */
156-
}
156+
} */
157157
}
158158

159159
.cell-input-container {

src/table/Table.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ export interface TableProps<K = string> {
4141
activeRange: ActiveRange
4242
/** Sets the state of the selected cell or cells in the table. */
4343
setActiveRange?: (range: ActiveRange) => void
44-
/** The ID of the column that is being edited by another (external) UI. */
45-
extActiveColumn?: K
4644
/** Gets the value in a cell. */
4745
getCellValue(row: number, column: Column<K>): unknown
4846
/** Sets the value of the given cell. */
@@ -182,15 +180,6 @@ export default function Table<K = string>(props: TableProps<K>) {
182180
}
183181
})
184182

185-
// Scroll to the externally active column
186-
const extActiveColumnIdx = createMemo(() =>
187-
props.columns.findIndex(c => c.id === props.extActiveColumn),
188-
)
189-
createEffect(() => {
190-
const colIndex = extActiveColumnIdx()
191-
if (colIndex >= 0) scrollToCell(undefined, colIndex)
192-
})
193-
194183
// Watch scroll position
195184
const viewport = watchViewport(() => tableEl!)
196185

@@ -576,7 +565,6 @@ export default function Table<K = string>(props: TableProps<K>) {
576565
1,
577566
)
578567
}
579-
extActiveColumn={props.extActiveColumn}
580568
/>
581569
{/* Add column button */}
582570
<Show when={props.columnsEditable}>
@@ -647,7 +635,6 @@ export default function Table<K = string>(props: TableProps<K>) {
647635
onMouseContextDown={onCellContextDown}
648636
onContextMenu={onContextMenu}
649637
onEditCell={editCell}
650-
extActiveColumn={props.extActiveColumn}
651638
/>
652639
)}
653640
</For>

src/table/TableHeader.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface TableHeaderProps<K> {
1111
onResizeColumn?: (colId: K, width: number | null) => void
1212
setColumnName?: (colId: K, name: string) => void
1313
removeColumn(colId: K): void
14-
extActiveColumn?: K
1514
}
1615

1716
export function TableHeader<K>(props: TableHeaderProps<K>) {
@@ -25,7 +24,6 @@ export function TableHeader<K>(props: TableHeaderProps<K>) {
2524
columnsEditable={props.columnsEditable}
2625
setColumnName={props.setColumnName}
2726
removeColumn={props.removeColumn}
28-
extActive={col.id === props.extActiveColumn}
2927
/>
3028
<ResizeBar
3129
class="resize-bar"
@@ -53,7 +51,6 @@ interface ColumnHeaderProps<K> {
5351
columnsEditable?: boolean
5452
setColumnName?: (id: K, name: string) => void
5553
removeColumn(id: K): void
56-
extActive?: boolean
5754
}
5855

5956
function ColumnHeader<K>(props: ColumnHeaderProps<K>) {
@@ -94,7 +91,7 @@ function ColumnHeader<K>(props: ColumnHeaderProps<K>) {
9491
}}
9592
onContextMenu={handleContextMenu}
9693
>
97-
<div data-ext-active={props.extActive}>
94+
<div>
9895
<Renameable
9996
class="renameable"
10097
value={props.column.name}

src/table/TableRow.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export interface TableRowProps<K> {
1515
onMouseContextDown?: (ev: MouseEvent, i: number, j: number) => void
1616
onContextMenu?: (ev: MouseEvent, i: number, j: number) => void
1717
onEditCell?: (pos: number) => void
18-
extActiveColumn?: K
1918
}
2019

2120
export function TableRow<K>(props: TableRowProps<K>) {
@@ -43,7 +42,6 @@ export function TableRow<K>(props: TableRowProps<K>) {
4342
value={props.getCellValue(props.rowIdx, col)}
4443
setValue={value => props.setCellValue?.(props.rowIdx, col.id, value)}
4544
onEdit={props.onEditCell}
46-
extActive={col.id === props.extActiveColumn}
4745
/>
4846
</div>
4947
)}

0 commit comments

Comments
 (0)