-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples. Table. Use table metadata instead of React contexts
- Loading branch information
Showing
11 changed files
with
56 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
.../tanstack-react-table/src/jsMain/kotlin/wrappers/example/table/selection/SelectionCell.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
package wrappers.example.table.selection | ||
|
||
import react.FC | ||
import react.Key | ||
import react.PropsWithValue | ||
|
||
internal val SelectionCell: FC<PropsWithValue<SelectedKeys>> = FC { props -> | ||
internal external interface SelectionCellProps : PropsWithValue<Set<Key>> { | ||
var metadata: TableMetadata | ||
} | ||
|
||
internal val SelectionCell: FC<SelectionCellProps> = FC { props -> | ||
val keys = props.value | ||
val metadata = props.metadata | ||
|
||
val changeHandler = useSelectionChangeHandler(keys) | ||
val checked = useIsChecked(keys, metadata) | ||
val changeHandler = useSelectionChangeHandler(keys, metadata) | ||
|
||
SelectionCheckbox { | ||
value = keys | ||
value = checked | ||
onChange = changeHandler | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
.../tanstack-react-table/src/jsMain/kotlin/wrappers/example/table/selection/TableMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package wrappers.example.table.selection | ||
|
||
import preact.signals.core.Signal | ||
import tanstack.table.core.RowData | ||
import tanstack.table.core.Table | ||
import tanstack.table.core.TableMeta | ||
import tanstack.table.core.TableOptionsResolved | ||
import wrappers.example.entities.User | ||
|
||
internal external interface TableMetadata : TableMeta<User> { | ||
var selection: Signal<SelectedKeys> | ||
} | ||
|
||
internal fun <T : RowData> Table<T>.getMeta(): TableMetadata = | ||
options.unsafeCast<TableOptionsResolved<T>>() | ||
.meta.unsafeCast<TableMetadata>() |
16 changes: 0 additions & 16 deletions
16
...ck-react-table/src/jsMain/kotlin/wrappers/example/table/selection/TableSelectionModule.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
...anstack-react-table/src/jsMain/kotlin/wrappers/example/table/selection/useSelectedKeys.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 6 additions & 9 deletions
15
...ack-react-table/src/jsMain/kotlin/wrappers/example/table/selection/useSelectionHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters