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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQAumujy5kXaOKurr6zgTP2krHrFVXi2kj8seRYrlvq2GssUjReh5MiVpQbLFQNy9HsmcasqpBNVsXytWTw0ZDjA=

Board

import { Board, Mosaic } from '@dxos/react-ui-mosaic';
import { Dnd } from '@dxos/react-ui-dnd';
Terminal window
npm install @dxos/react-ui-mosaic @dxos/react-ui-dnd @effect/atom-react

A board is a row of columns, each a stack of cards the user can drag. Cards move within a column and across columns, and columns move by the handle in their header.

The board reads a model of atoms.

Wrap your app in RegistryProvider from @effect/atom-react. This is best practice, because your app then controls the registry that the board reads. Without a provider, the board reads the library’s default registry.

Add the package’s strings from @dxos/react-ui-mosaic/translations to the resourceExtensions of Theme.Provider.

Part What it is
Board.Root The root, which reads a BoardModel. The model gives the columns, a column’s items, and an id for each
Board.Content The row of columns, drawn as a Tile each. Its eventHandler takes columns
Board.Column.Root A column, draggable by the element passed as dragHandle
Board.Column.Header The column’s header. Its dragHandleRef is the column’s handle
Board.Column.Body The column’s cards, drawn as a Tile each in a scroll area. Its eventHandler takes cards
Board.Column.Footer A toolbar under the column. It has an add button when it gets onAdd or the model has onItemCreate
Board.Item The default card
Board.Placeholder The gap a dropped card would land in
Board.Debug The state of the drag, for development

A BoardModel gives the board an atom for the columns and an atom for each column’s cards, so a change redraws only the columns it touches.

Example (Holding a board in one atom)

import {
const RegistryContext: React.Context<AtomRegistry>

Provides a React context that supplies the AtomRegistry used by Atom hooks and hydration helpers, defaulting to a standalone registry when no provider is present.

When to use

Use to supply an existing AtomRegistry through React context when hooks or hydration helpers need to share registry state that is managed outside RegistryProvider.

@see ― RegistryProvider for creating and providing a registry for a React subtree

@stability ― unstable

@category ― context

@since ― 4.0.0

RegistryContext
} from '@effect/atom-react/RegistryContext';
import * as
import Atom
Atom
from 'effect/reactivity/Atom';
import {
function useContext<T>(context: React.Context<T>): T

Accepts a context object (the value returned from React.createContext) and returns the current context value, as given by the nearest context provider for the given context.

useContext
,
function useMemo<T>(factory: () => T, deps: React.DependencyList): T

useMemo will only recompute the memoized value when one of the deps has changed.

@version ― 16.8.0

@see ― https://react.dev/reference/react/useMemo

useMemo
,
function useState<S>(initialState: S | (() => S)): [S, React.Dispatch<React.SetStateAction<S>>] (+1 overload)

Returns a stateful value, and a function to update it.

@version ― 16.8.0

@see ― https://react.dev/reference/react/useState

useState
} from 'react';
import { type
interface DndContainerHandler<TData = any, TObject = any>

Handler implemented by drop containers.

DndContainerHandler
, type
type DndData = DndTileData<any, any> | DndPlaceholderData<any> | DndContainerData
DndData
, type
type DndTileData<TData = any, TLocation = any> = {
type: "tile";
containerId: string;
id: string;
data: TData;
location: TLocation;
bounds?: DOMRect;
}

Draggable item. Tiles may contain arbitrary data (which may not be an ECHO object; e.g., search result).

DndTileData
} from '@dxos/react-ui-dnd';
import { type
interface BoardModel<TColumn = any, TItem = any>
BoardModel
} from '@dxos/react-ui-mosaic';
type
type Task = {
id: string;
title: string;
}
Task
= {
id: string
id
: string;
title: string
title
: string };
type
type Column = {
id: string;
name: string;
tasks: Task[];
}
Column
= {
id: string
id
: string;
name: string
name
: string;
tasks: Task[]
tasks
:
type Task = {
id: string;
title: string;
}
Task
[] };
const
const COLUMNS: Column[]
COLUMNS
:
type Column = {
id: string;
name: string;
tasks: Task[];
}
Column
[] = [
{
id: string
id
: 'todo',
name: string
name
: 'To do',
tasks: Task[]
tasks
: [
{
id: string
id
: '1',
title: string
title
: 'Write the blog post' },
{
id: string
id
: '2',
title: string
title
: 'Record the demo' },
],
},
{
id: string
id
: 'doing',
name: string
name
: 'Doing',
tasks: Task[]
tasks
: [
{
id: string
id
: '3',
title: string
title
: 'Update the docs' },
{
id: string
id
: '4',
title: string
title
: 'Fix the login bug' },
],
},
{
id: string
id
: 'done',
name: string
name
: 'Done',
tasks: Task[]
tasks
: [{
id: string
id
: '5',
title: string
title
: 'Ship the beta' }] },
];
const
const isColumn: (value: unknown) => value is Column
isColumn
= (
value: unknown
value
: unknown):
value: unknown
value
is
type Column = {
id: string;
name: string;
tasks: Task[];
}
Column
=>
typeof
value: unknown
value
=== 'object' &&
value: object | null
value
!== null && 'tasks' in
value: object
value
;
const
const isTask: (value: unknown) => value is Task
isTask
= (
value: unknown
value
: unknown):
value: unknown
value
is
type Task = {
id: string;
title: string;
}
Task
=>
typeof
value: unknown
value
=== 'object' &&
value: object | null
value
!== null &&
'title' in
value: object
value
&&
!('tasks' in
value: object & Record<"title", unknown>
value
);
/**
* `list` with the dragged item at the drop: after the tile it was dropped on, in the gap a placeholder names, or
* at the end when dropped on the container.
*/
const
const place: <T extends {
id: string;
}>(list: T[], source: DndTileData<T>, target?: DndData) => T[]

list with the dragged item at the drop: after the tile it was dropped on, in the gap a placeholder names, or at the end when dropped on the container.

place
= <
function (type parameter) T in <T extends {
id: string;
}>(list: T[], source: DndTileData<T>, target?: DndData): T[]
T
extends {
id: string
id
: string }>(
list: T[]
list
:
function (type parameter) T in <T extends {
id: string;
}>(list: T[], source: DndTileData<T>, target?: DndData): T[]
T
[],
source: DndTileData<T>
source
:
type DndTileData<TData = any, TLocation = any> = {
type: "tile";
containerId: string;
id: string;
data: TData;
location: TLocation;
bounds?: DOMRect;
}

Draggable item. Tiles may contain arbitrary data (which may not be an ECHO object; e.g., search result).

DndTileData
<
function (type parameter) T in <T extends {
id: string;
}>(list: T[], source: DndTileData<T>, target?: DndData): T[]
T
>,
target: DndData | undefined
target
?:
type DndData = DndTileData<any, any> | DndPlaceholderData<any> | DndContainerData
DndData
,
):
function (type parameter) T in <T extends {
id: string;
}>(list: T[], source: DndTileData<T>, target?: DndData): T[]
T
[] => {
const
const rest: T[]
rest
=
list: T[]
list
.
Array<T>.filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[] (+1 overload)

Returns the elements of an array that meet the condition specified in a callback function.

@param ― predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.

@param ― thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

filter
((
item: T extends { id: string; }
item
) =>
item: T extends { id: string; }
item
.
id: string
id
!==
source: DndTileData<T>
source
.
id: string
id
);
const
const index: number
index
=
target: DndData | undefined
target
?.
type: "tile" | "placeholder" | "container" | undefined
type
=== 'tile'
?
const rest: T[]
rest
.
Array<T>.findIndex(predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number

Returns the index of the first element in the array where predicate is true, and -1 otherwise.

@param ― predicate find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1.

@param ― thisArg If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

findIndex
((
item: T extends { id: string; }
item
) =>
item: T extends { id: string; }
item
.
id: string
id
===
target: DndTileData<any, any>
target
.
id: string
id
) + 1
:
target: DndPlaceholderData<any> | DndContainerData | undefined
target
?.
type: "placeholder" | "container" | undefined
type
=== 'placeholder'
?
var Math: Math

An intrinsic object that provides basic mathematics functionality and constants.

Math
.
Math.floor(x: number): number

Returns the greatest integer less than or equal to its numeric argument.

@param ― x A numeric expression.

floor
(
var Number: NumberConstructor
(value?: any) => number

An object that represents a number of any kind. All JavaScript numbers are 64-bit floating-point numbers.

Number
(
target: DndPlaceholderData<any>
target
.
location: any
location
))
:
const rest: T[]
rest
.
Array<T>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
;
const
const at: number
at
=
var Math: Math

An intrinsic object that provides basic mathematics functionality and constants.

Math
.
Math.min(...values: number[]): number

Returns the smaller of a set of supplied numeric expressions.

@param ― values Numeric expressions to be evaluated.

min
(
var Math: Math

An intrinsic object that provides basic mathematics functionality and constants.

Math
.
Math.max(...values: number[]): number

Returns the larger of a set of supplied numeric expressions.

@param ― values Numeric expressions to be evaluated.

max
(
const index: number
index
, 0),
const rest: T[]
rest
.
Array<T>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
);
return [...
const rest: T[]
rest
.
Array<T>.slice(start?: number, end?: number): T[]

Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.

@param ― start The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.

@param ― end The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array.

slice
(0,
const at: number
at
),
source: DndTileData<T>
source
.
data: T extends { id: string; }
data
, ...
const rest: T[]
rest
.
Array<T>.slice(start?: number, end?: number): T[]

Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.

@param ― start The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.

@param ― end The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array.

slice
(
const at: number
at
)];
};
/** The board reads its columns, and each column's cards, from one atom; a drop writes it and the board follows. */
const
const useTaskBoard: () => {
model: BoardModel<Column, Task>;
setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void;
columnHandler: DndContainerHandler<Column, any>;
}

The board reads its columns, and each column's cards, from one atom; a drop writes it and the board follows.

useTaskBoard
= () => {
const
const registry: AtomRegistry
registry
=
useContext<AtomRegistry>(context: React.Context<AtomRegistry>): AtomRegistry

Accepts a context object (the value returned from React.createContext) and returns the current context value, as given by the nearest context provider for the given context.

useContext
(
const RegistryContext: React.Context<AtomRegistry>

Provides a React context that supplies the AtomRegistry used by Atom hooks and hydration helpers, defaulting to a standalone registry when no provider is present.

When to use

Use to supply an existing AtomRegistry through React context when hooks or hydration helpers need to share registry state that is managed outside RegistryProvider.

@see ― RegistryProvider for creating and providing a registry for a React subtree

@stability ― unstable

@category ― context

@since ― 4.0.0

RegistryContext
);
const [
const columns: Atom.Writable<Column[], Column[]>
columns
] =
useState<Atom.Writable<Column[], Column[]>>(initialState: Atom.Writable<Column[], Column[]> | (() => Atom.Writable<Column[], Column[]>)): [Atom.Writable<Column[], Column[]>, React.Dispatch<React.SetStateAction<Atom.Writable<Column[], Column[]>>>] (+1 overload)

Returns a stateful value, and a function to update it.

@version ― 16.8.0

@see ― https://react.dev/reference/react/useState

useState
(() =>
import Atom
Atom
.
const make: <Column[]>(initialValue: Column[]) => Atom.Writable<Column[], Column[]> (+5 overloads)

Creates an atom from a synchronous value or read function, or from an Effect or Stream whose state is exposed as an AsyncResult; plain values create writable state atoms.

@stability ― unstable

@category ― constructors

@since ― 4.0.0

make
(
const COLUMNS: Column[]
COLUMNS
));
const
const model: BoardModel<Column, Task>
model
=
useMemo<BoardModel<Column, Task>>(factory: () => BoardModel<Column, Task>, deps: React.DependencyList): BoardModel<Column, Task>

useMemo will only recompute the memoized value when one of the deps has changed.

@version ― 16.8.0

@see ― https://react.dev/reference/react/useMemo

useMemo
<
interface BoardModel<TColumn = any, TItem = any>
BoardModel
<
type Column = {
id: string;
name: string;
tasks: Task[];
}
Column
,
type Task = {
id: string;
title: string;
}
Task
>>(() => {
const
const tasks: (arg: string) => Atom.Atom<Task[]>
tasks
=
import Atom
Atom
.
const family: <string, Atom.Atom<Task[]>>(f: (arg: string) => Atom.Atom<Task[]>) => (arg: string) => Atom.Atom<Task[]>

Creates a memoized atom factory that returns the same object for the same argument, using weak references for cached values when the platform supports them.

@stability ― unstable

@category ― constructors

@since ― 4.0.0

family
((
id: string
id
: string) =>
import Atom
Atom
.
const make: <Task[]>(create: (get: Atom.AtomContext) => Task[]) => Atom.Atom<Task[]> (+5 overloads)

Creates an atom from a synchronous value or read function, or from an Effect or Stream whose state is exposed as an AsyncResult; plain values create writable state atoms.

@stability ― unstable

@category ― constructors

@since ― 4.0.0

make
(
(
get: Atom.AtomContext
get
) =>
get: Atom.AtomContext
<Column[]>(atom: Atom.Atom<Column[]>) => Column[]
get
(
const columns: Atom.Writable<Column[], Column[]>
columns
).
Array<Column>.find(predicate: (value: Column, index: number, obj: Column[]) => unknown, thisArg?: any): Column | undefined (+1 overload)

Returns the value of the first element in the array where predicate is true, and undefined otherwise.

@param ― predicate find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.

@param ― thisArg If provided, it will be used as the this value for each invocation of predicate. If it is not provided, undefined is used instead.

find
((
column: Column
column
) =>
column: Column
column
.
id: string
id
===
id: string
id
)?.
tasks: Task[] | undefined
tasks
?? [],
),
);
return {
BoardModel<Column, Task>.getColumnId: GetId<Column>
getColumnId
: (
column: Column
column
) =>
column: Column
column
.
id: string
id
,
BoardModel<Column, Task>.getItemId: GetId<Task>
getItemId
: (
task: Task
task
) =>
task: Task
task
.
id: string
id
,
BoardModel<Column, Task>.isColumn: (obj: unknown) => obj is Column
isColumn
,
BoardModel<Column, Task>.isItem: (obj: unknown) => obj is Task
isItem
:
const isTask: (value: unknown) => value is Task
isTask
,
BoardModel<Column, Task>.columns: Atom.Atom<Column[] | readonly Column[]>
columns
,
BoardModel<Column, Task>.items: (column: Column) => Atom.Atom<Task[]>
items
: (
column: Column
column
) =>
const tasks: (arg: string) => Atom.Atom<Task[]>
tasks
(
column: Column
column
.
id: string
id
),
BoardModel<Column, Task>.getColumns: () => Column[]
getColumns
: () =>
const registry: AtomRegistry
registry
.
AtomRegistry.get: <Column[]>(atom: Atom.Atom<Column[]>) => Column[]
get
(
const columns: Atom.Writable<Column[], Column[]>
columns
),
BoardModel<Column, Task>.getItems: (column: Column) => Task[]
getItems
: (
column: Column
column
) =>
const registry: AtomRegistry
registry
.
AtomRegistry.get: <Task[]>(atom: Atom.Atom<Task[]>) => Task[]
get
(
const tasks: (arg: string) => Atom.Atom<Task[]>
tasks
(
column: Column
column
.
id: string
id
)),
};
}, [
const registry: AtomRegistry
registry
,
const columns: Atom.Writable<Column[], Column[]>
columns
]);
const
const setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void
setTasks
= (
id: string
id
: string,
update: (tasks: Task[]) => Task[]
update
: (
tasks: Task[]
tasks
:
type Task = {
id: string;
title: string;
}
Task
[]) =>
type Task = {
id: string;
title: string;
}
Task
[]) =>
const registry: AtomRegistry
registry
.
AtomRegistry.set: <Column[], Column[]>(atom: Atom.Writable<Column[], Column[]>, value: Column[]) => void
set
(
const columns: Atom.Writable<Column[], Column[]>
columns
,
const registry: AtomRegistry
registry
.
AtomRegistry.get: <Column[]>(atom: Atom.Atom<Column[]>) => Column[]
get
(
const columns: Atom.Writable<Column[], Column[]>
columns
)
.
Array<Column>.map<Column>(callbackfn: (value: Column, index: number, array: Column[]) => Column, thisArg?: any): Column[]

Calls a defined callback function on each element of an array, and returns an array that contains the results.

@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

map
((
column: Column
column
) =>
column: Column
column
.
id: string
id
===
id: string
id
? { ...
column: Column
column
,
tasks: Task[]
tasks
:
update: (tasks: Task[]) => Task[]
update
(
column: Column
column
.
tasks: Task[]
tasks
) }
:
column: Column
column
,
),
);
const
const columnHandler: DndContainerHandler<Column, any>
columnHandler
:
interface DndContainerHandler<TData = any, TObject = any>

Handler implemented by drop containers.

DndContainerHandler
<
type Column = {
id: string;
name: string;
tasks: Task[];
}
Column
> = {
DndContainerHandler<Column, any>.id: string

Container identifier. Must be unique per live container instance across the whole Dnd.Root (use useContainerId to append a discriminator when the same object may mount in multiple containers).

id
: 'columns',
DndContainerHandler<Column, any>.canDrop?: ((props: {
source: DndTileData<Column, any>;
}) => boolean) | undefined

Determine if the item can be dropped into this container. NOTE: This is continuously called while dragging (doesn't require mouse movement).

canDrop
: ({
source: DndTileData<Column, any>
source
}) =>
const isColumn: (value: unknown) => value is Column
isColumn
(
source: DndTileData<Column, any>
source
.
data: Column
data
),
DndContainerHandler<Column, any>.onDrop?: ((props: {
source: DndTileData<Column, any>;
target?: DndData;
}) => void) | undefined

Insert/rearrange the item at the given location.

onDrop
: ({
source: DndTileData<Column, any>
source
,
target: DndData | undefined
target
}) =>
const registry: AtomRegistry
registry
.
AtomRegistry.set: <Column[], Column[]>(atom: Atom.Writable<Column[], Column[]>, value: Column[]) => void
set
(
const columns: Atom.Writable<Column[], Column[]>
columns
,
const place: <Column>(list: Column[], source: DndTileData<Column>, target?: DndData) => Column[]

list with the dragged item at the drop: after the tile it was dropped on, in the gap a placeholder names, or at the end when dropped on the container.

place
(
const registry: AtomRegistry
registry
.
AtomRegistry.get: <Column[]>(atom: Atom.Atom<Column[]>) => Column[]
get
(
const columns: Atom.Writable<Column[], Column[]>
columns
),
source: DndTileData<Column, any>
source
,
target: DndData | undefined
target
)),
};
return {
model: BoardModel<Column, Task>
model
,
setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void
setTasks
,
columnHandler: DndContainerHandler<Column, any>
columnHandler
};
};

COLUMNS goes into one atom, which holds the columns in order, each with its cards in order. The model derives the atom for each column’s cards from it. place puts a dropped item where the drop landed:

  • If the user drops the item on a card, place puts it after that card.
  • If the user drops the item on a placeholder, place puts it in the gap between two cards.
  • If the user drops the item on the container, place puts it at the end.

A column’s body draws a Mosaic.Tile for each card. Each column’s eventHandler takes cards:

  • onDrop places a card in the column.
  • onTake runs on the column a card leaves, so that column can remove the card once the other column has it.

When the user drops a card in its own column, the column gets only onDrop, which reorders the card. Dnd.Root tracks the drag across the board.

Example (Dragging cards and columns)

import {
const useAtomValue: {
<A>(atom: Atom.Atom<A>): A;
<A, B>(atom: Atom.Atom<A>, f: (_: A) => B): B;
}

Subscribes to an atom in the current React registry and returns its current value, optionally mapped through a selector.

When to use

Use when a React component needs to render from an atom value without also returning a setter.

Details

When a selector is provided, the hook subscribes to the atom and applies the selector to its value from the current RegistryContext.

Gotchas

Late Suspense boundaries hydrate with the same atom snapshot as earlier readers, then update to the live value. The snapshot lasts until all readers unsubscribe. Changes before the first reader hydrates or after the last unsubscribes can still cause mismatches, as can a derived atom first read inside a late boundary.

@see ― useAtom for reading and updating a writable atom from one component

@see ― useAtomRef for reading an AtomRef directly

@stability ― unstable

@category ― hooks

@since ― 4.0.0

useAtomValue
} from '@effect/atom-react/Hooks';
import { type
(alias) interface CSSProperties
import CSSProperties
CSSProperties
,
function createContext<T>(defaultValue: T): React.Context<T>

Lets you create a

Context

that components can provide or read.

@param ― defaultValue The value you want the context to have when there is no matching Provider in the tree above the component reading the context. This is meant as a "last resort" fallback.

@see ― https://react.dev/reference/react/createContext#reference React Docs

@see ― https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet

@example

import { createContext } from 'react';
const ThemeContext = createContext('light');
function App() {
return (
<ThemeContext value="dark">
<Toolbar />
</ThemeContext>
);
}

createContext
,
function useContext<T>(context: React.Context<T>): T

Accepts a context object (the value returned from React.createContext) and returns the current context value, as given by the nearest context provider for the given context.

useContext
,
function useMemo<T>(factory: () => T, deps: React.DependencyList): T

useMemo will only recompute the memoized value when one of the deps has changed.

@version ― 16.8.0

@see ― https://react.dev/reference/react/useMemo

useMemo
,
function useState<S>(initialState: S | (() => S)): [S, React.Dispatch<React.SetStateAction<S>>] (+1 overload)

Returns a stateful value, and a function to update it.

@version ― 16.8.0

@see ― https://react.dev/reference/react/useState

useState
} from 'react';
import {
const Dnd: {
Root: {
({ children }: {
children?: React.ReactNode | undefined;
}): React.JSX.Element;
displayName: string;
};
}
Dnd
, type
interface DndContainerHandler<TData = any, TObject = any>

Handler implemented by drop containers.

DndContainerHandler
} from '@dxos/react-ui-dnd';
import {
const Board: {
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement;
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
};
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Placeholder: {
...;
};
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>;
}
Board
,
const Mosaic: {
Container: import("react").ForwardRefExoticComponent<Omit<MosaicContainerProps, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<import("react").HTMLAttributes<Element>, "children" | "role" | "style"> & import("react").RefAttributes<HTMLDivElement>>;
Tile: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").PropsWithChildren<{
className?: string;
dragHandle?: HTMLElement | null;
allowedEdges?: Edge[];
id: string;
data: any;
location: import("@dxos/react-ui-dnd").DndLocation;
draggable?: boolean;
nativeDragPreview?: boolean;
reorderOnEnter?: boolean;
current?: boolean;
selected?: boolean;
binding?: import("@dxos/react-ui/Focus").ItemBinding;
size?: import("@dxos/react-ui-dnd").Size;
onSizeChange?: (size: import("@dxos/react-ui-dnd").Size) => void;
minSize?: number;
maxSize?: number;
debug?: boolean;
}>, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
asChild?: boolean;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<import("react").HTMLAttributes<Element>, "children" | "role" | "style"> & import("react").RefAttributes<HTMLDivElement>>;
... 5 more ...;
VirtualStack: <TData = any>(props: import("node_modules/@dxos/react-ui-mosaic/dist/types/src/components/Mosaic/Stack").MosaicVirtualStackProps<TData> & {
ref?: import("react").Ref<HTMLDivElement>;
}) => import("react").ReactElement;
}
Mosaic
, type
type MosaicTileProps<TData = any, TLocation = DndLocation> = Omit<React.PropsWithChildren<{
className?: string;
dragHandle?: HTMLElement | null;
allowedEdges?: Edge[];
id: string;
data: TData;
location: TLocation;
draggable?: boolean;
nativeDragPreview?: boolean;
reorderOnEnter?: boolean;
current?: boolean;
selected?: boolean;
binding?: FocusItemBinding;
size?: Size;
onSizeChange?: (size: Size) => void;
minSize?: number;
maxSize?: number;
debug?: boolean;
}>, "className"> & {
classNames?: ClassNameValue;
}
MosaicTileProps
,
function useBoard<TColumn = any, TItem = any>(displayName?: string): BoardContextValue<TColumn, TItem>

Hook to read the board model from context (e.g. in custom column tiles). Pass TColumn and TItem for typed model.

useBoard
} from '@dxos/react-ui-mosaic';
import * as
import Card
Card
from '@dxos/react-ui/Card';
const
const TaskCard: ({ data: task, location, draggable, }: MosaicTileProps<Task>) => React.JSX.Element
TaskCard
= ({
data: Task
data
:
task: Task
task
,
location: DndLocation
location
,
draggable: boolean | undefined
draggable
,
}:
type MosaicTileProps<TData = any, TLocation = DndLocation> = Omit<React.PropsWithChildren<{
className?: string;
dragHandle?: HTMLElement | null;
allowedEdges?: Edge[];
id: string;
data: TData;
location: TLocation;
draggable?: boolean;
nativeDragPreview?: boolean;
reorderOnEnter?: boolean;
current?: boolean;
selected?: boolean;
binding?: FocusItemBinding;
size?: Size;
onSizeChange?: (size: Size) => void;
minSize?: number;
maxSize?: number;
debug?: boolean;
}>, "className"> & {
classNames?: ClassNameValue;
}
MosaicTileProps
<
type Task = {
id: string;
title: string;
}
Task
>) => (
<
const Mosaic: {
Container: import("react").ForwardRefExoticComponent<Omit<MosaicContainerProps, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<import("react").HTMLAttributes<Element>, "children" | "role" | "style"> & import("react").RefAttributes<HTMLDivElement>>;
Tile: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").PropsWithChildren<{
className?: string;
dragHandle?: HTMLElement | null;
allowedEdges?: Edge[];
id: string;
data: any;
location: import("@dxos/react-ui-dnd").DndLocation;
draggable?: boolean;
nativeDragPreview?: boolean;
reorderOnEnter?: boolean;
current?: boolean;
selected?: boolean;
binding?: import("@dxos/react-ui/Focus").ItemBinding;
size?: import("@dxos/react-ui-dnd").Size;
onSizeChange?: (size: import("@dxos/react-ui-dnd").Size) => void;
minSize?: number;
maxSize?: number;
debug?: boolean;
}>, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
asChild?: boolean;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<import("react").HTMLAttributes<Element>, "children" | "role" | "style"> & import("react").RefAttributes<HTMLDivElement>>;
... 5 more ...;
VirtualStack: <TData = any>(props: import("node_modules/@dxos/react-ui-mosaic/dist/types/src/components/Mosaic/Stack").MosaicVirtualStackProps<TData> & {
ref?: import("react").Ref<HTMLDivElement>;
}) => import("react").ReactElement;
}
Mosaic
.
type Tile: React.ForwardRefExoticComponent<Omit<Omit<React.PropsWithChildren<{
className?: string;
dragHandle?: HTMLElement | null;
allowedEdges?: Edge[];
id: string;
data: any;
location: import("@dxos/react-ui-dnd").DndLocation;
draggable?: boolean;
nativeDragPreview?: boolean;
reorderOnEnter?: boolean;
current?: boolean;
selected?: boolean;
binding?: import("@dxos/react-ui/Focus").ItemBinding;
size?: import("@dxos/react-ui-dnd").Size;
onSizeChange?: (size: import("@dxos/react-ui-dnd").Size) => void;
minSize?: number;
maxSize?: number;
debug?: boolean;
}>, "className"> & {
...;
} & {
...;
}, "className"> & {
...;
} & Pick<...> & React.RefAttributes<...>>
Tile
id: string
id
={
task: Task
task
.
id: string
id
}
data: any
data
={
task: Task
task
}
location: DndLocation
location
={
location: DndLocation
location
}
draggable?: boolean | undefined
draggable
={
draggable: boolean | undefined
draggable
}
>
<
import Card
Card
.
const Root: React.ForwardRefExoticComponent<Omit<Omit<Card.RootProps, "classNames">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
export Root

A card one level above its host (level='+1'), whose Header, Body and Footer share one content edge. With grid it is a rail Container (the child div wins the asChild merge, so the part keeps the card scope); without, a plain column that creates no grid. With onClick the card is a button (Enter and Space activate it); nested actions and menus stop their clicks reaching it.

Root
>
<
import Card
Card
.
const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>
export Header

A block row across the card's rails holding the Title: a Block or icon-only Button before the Title fills the start rail, and the last one after it the end rail, so the Title starts at the content edge.

Header
>
<
import Card
Card
.
const Title: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<TypographyProps, "lines" | "tone" | "truncate"> & React.RefAttributes<HTMLHeadingElement>>
export Title

An h3 on Typography, so it clamps (lines), truncates and takes a tone like any text.

Title
>{
task: Task
task
.
title: string
title
}</
import Card
Card
.
const Title: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<TypographyProps, "lines" | "tone" | "truncate"> & React.RefAttributes<HTMLHeadingElement>>
export Title

An h3 on Typography, so it clamps (lines), truncates and takes a tone like any text.

Title
>
</
import Card
Card
.
const Header: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>
export Header

A block row across the card's rails holding the Title: a Block or icon-only Button before the Title fills the start rail, and the last one after it the end rail, so the Title starts at the content edge.

Header
>
</
import Card
Card
.
const Root: React.ForwardRefExoticComponent<Omit<Omit<Card.RootProps, "classNames">, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
export Root

A card one level above its host (level='+1'), whose Header, Body and Footer share one content edge. With grid it is a rail Container (the child div wins the asChild merge, so the part keeps the card scope); without, a plain column that creates no grid. With onClick the card is a button (Enter and Space activate it); nested actions and menus stop their clicks reaching it.

Root
>
</
const Mosaic: {
Container: import("react").ForwardRefExoticComponent<Omit<MosaicContainerProps, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<import("react").HTMLAttributes<Element>, "children" | "role" | "style"> & import("react").RefAttributes<HTMLDivElement>>;
Tile: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").PropsWithChildren<{
className?: string;
dragHandle?: HTMLElement | null;
allowedEdges?: Edge[];
id: string;
data: any;
location: import("@dxos/react-ui-dnd").DndLocation;
draggable?: boolean;
nativeDragPreview?: boolean;
reorderOnEnter?: boolean;
current?: boolean;
selected?: boolean;
binding?: import("@dxos/react-ui/Focus").ItemBinding;
size?: import("@dxos/react-ui-dnd").Size;
onSizeChange?: (size: import("@dxos/react-ui-dnd").Size) => void;
minSize?: number;
maxSize?: number;
debug?: boolean;
}>, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
asChild?: boolean;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<import("react").HTMLAttributes<Element>, "children" | "role" | "style"> & import("react").RefAttributes<HTMLDivElement>>;
... 5 more ...;
VirtualStack: <TData = any>(props: import("node_modules/@dxos/react-ui-mosaic/dist/types/src/components/Mosaic/Stack").MosaicVirtualStackProps<TData> & {
ref?: import("react").Ref<HTMLDivElement>;
}) => import("react").ReactElement;
}
Mosaic
.
type Tile: React.ForwardRefExoticComponent<Omit<Omit<React.PropsWithChildren<{
className?: string;
dragHandle?: HTMLElement | null;
allowedEdges?: Edge[];
id: string;
data: any;
location: import("@dxos/react-ui-dnd").DndLocation;
draggable?: boolean;
nativeDragPreview?: boolean;
reorderOnEnter?: boolean;
current?: boolean;
selected?: boolean;
binding?: import("@dxos/react-ui/Focus").ItemBinding;
size?: import("@dxos/react-ui-dnd").Size;
onSizeChange?: (size: import("@dxos/react-ui-dnd").Size) => void;
minSize?: number;
maxSize?: number;
debug?: boolean;
}>, "className"> & {
...;
} & {
...;
}, "className"> & {
...;
} & Pick<...> & React.RefAttributes<...>>
Tile
>
);
/** Writes one column's cards; the board's columns read it from context. */
const
const SetTasksContext: React.Context<(id: string, update: (tasks: Task[]) => Task[]) => void>

Writes one column's cards; the board's columns read it from context.

SetTasksContext
=
createContext<(id: string, update: (tasks: Task[]) => Task[]) => void>(defaultValue: (id: string, update: (tasks: Task[]) => Task[]) => void): React.Context<(id: string, update: (tasks: Task[]) => Task[]) => void>

Lets you create a

Context

that components can provide or read.

@param ― defaultValue The value you want the context to have when there is no matching Provider in the tree above the component reading the context. This is meant as a "last resort" fallback.

@see ― https://react.dev/reference/react/createContext#reference React Docs

@see ― https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet

@example

import { createContext } from 'react';
const ThemeContext = createContext('light');
function App() {
return (
<ThemeContext value="dark">
<Toolbar />
</ThemeContext>
);
}

createContext
<
(
id: string
id
: string,
update: (tasks: Task[]) => Task[]
update
: (
tasks: Task[]
tasks
:
type Task = {
id: string;
title: string;
}
Task
[]) =>
type Task = {
id: string;
title: string;
}
Task
[]) => void
>(() => {});
/** A column moves by its header's handle; a card taken from another column leaves that one when it lands here. */
const
const TaskColumn: ({ data: column, location, draggable, }: MosaicTileProps<Column>) => React.JSX.Element

A column moves by its header's handle; a card taken from another column leaves that one when it lands here.

TaskColumn
= ({
data: Column
data
:
column: Column
column
,
location: DndLocation
location
,
draggable: boolean | undefined
draggable
,
}:
type MosaicTileProps<TData = any, TLocation = DndLocation> = Omit<React.PropsWithChildren<{
className?: string;
dragHandle?: HTMLElement | null;
allowedEdges?: Edge[];
id: string;
data: TData;
location: TLocation;
draggable?: boolean;
nativeDragPreview?: boolean;
reorderOnEnter?: boolean;
current?: boolean;
selected?: boolean;
binding?: FocusItemBinding;
size?: Size;
onSizeChange?: (size: Size) => void;
minSize?: number;
maxSize?: number;
debug?: boolean;
}>, "className"> & {
classNames?: ClassNameValue;
}
MosaicTileProps
<
type Column = {
id: string;
name: string;
tasks: Task[];
}
Column
>) => {
const {
const model: BoardModel<Column, Task>
model
} =
useBoard<Column, Task>(displayName?: string): BoardContextValue<Column, Task>

Hook to read the board model from context (e.g. in custom column tiles). Pass TColumn and TItem for typed model.

useBoard
<
type Column = {
id: string;
name: string;
tasks: Task[];
}
Column
,
type Task = {
id: string;
title: string;
}
Task
>();
const
const setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void
setTasks
=
useContext<(id: string, update: (tasks: Task[]) => Task[]) => void>(context: React.Context<(id: string, update: (tasks: Task[]) => Task[]) => void>): (id: string, update: (tasks: Task[]) => Task[]) => void

Accepts a context object (the value returned from React.createContext) and returns the current context value, as given by the nearest context provider for the given context.

useContext
(
const SetTasksContext: React.Context<(id: string, update: (tasks: Task[]) => Task[]) => void>

Writes one column's cards; the board's columns read it from context.

SetTasksContext
);
const
const count: number
count
=
useAtomValue<Task[]>(atom: Atom.Atom<Task[]>): Task[] (+1 overload)

Subscribes to an atom in the current React registry and returns its current value, optionally mapped through a selector.

When to use

Use when a React component needs to render from an atom value without also returning a setter.

Details

When a selector is provided, the hook subscribes to the atom and applies the selector to its value from the current RegistryContext.

Gotchas

Late Suspense boundaries hydrate with the same atom snapshot as earlier readers, then update to the live value. The snapshot lasts until all readers unsubscribe. Changes before the first reader hydrates or after the last unsubscribes can still cause mismatches, as can a derived atom first read inside a late boundary.

@see ― useAtom for reading and updating a writable atom from one component

@see ― useAtomRef for reading an AtomRef directly

@stability ― unstable

@category ― hooks

@since ― 4.0.0

useAtomValue
(
const model: BoardModel<Column, Task>
model
.
BoardModel<Column, Task>.items: (column: Column) => Atom.Atom<Task[]>
items
(
column: Column
column
)).
Array<Task>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
;
const [
const dragHandle: HTMLButtonElement | null
dragHandle
,
const setDragHandle: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>
setDragHandle
] =
useState<HTMLButtonElement | null>(initialState: HTMLButtonElement | (() => HTMLButtonElement | null) | null): [HTMLButtonElement | null, React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>] (+1 overload)

Returns a stateful value, and a function to update it.

@version ― 16.8.0

@see ― https://react.dev/reference/react/useState

useState
<
interface HTMLButtonElement

The HTMLButtonElement interface provides properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating elements.

MDN Reference

HTMLButtonElement
| null>(null);
const
const eventHandler: DndContainerHandler<Task, any>
eventHandler
=
useMemo<DndContainerHandler<Task, any>>(factory: () => DndContainerHandler<Task, any>, deps: React.DependencyList): DndContainerHandler<Task, any>

useMemo will only recompute the memoized value when one of the deps has changed.

@version ― 16.8.0

@see ― https://react.dev/reference/react/useMemo

useMemo
<
interface DndContainerHandler<TData = any, TObject = any>

Handler implemented by drop containers.

DndContainerHandler
<
type Task = {
id: string;
title: string;
}
Task
>>(
() => ({
DndContainerHandler<Task, any>.id: string

Container identifier. Must be unique per live container instance across the whole Dnd.Root (use useContainerId to append a discriminator when the same object may mount in multiple containers).

id
: `column-${
column: Column
column
.
id: string
id
}`,
DndContainerHandler<Task, any>.canDrop?: ((props: {
source: DndTileData<Task, any>;
}) => boolean) | undefined

Determine if the item can be dropped into this container. NOTE: This is continuously called while dragging (doesn't require mouse movement).

canDrop
: ({
source: DndTileData<Task, any>
source
}) =>
const isTask: (value: unknown) => value is Task
isTask
(
source: DndTileData<Task, any>
source
.
data: Task
data
),
DndContainerHandler<Task, any>.onTake?: ((props: {
source: DndTileData<Task, any>;
}, cb: (object: any) => Promise<boolean>) => void) | undefined

Request the object to be dropped. This allows the source container to clone/mutate/swap the object before it is dropped. If the callback returns true, then the callback may decide to remove the item from the source container, completing the transfer.

onTake
: ({
source: DndTileData<Task, any>
source
},
take: (object: any) => Promise<boolean>
take
) =>
void
take: (object: any) => Promise<boolean>
take
(
source: DndTileData<Task, any>
source
.
data: Task
data
).
Promise<boolean>.then<false | void, never>(onfulfilled?: ((value: boolean) => false | void | PromiseLike<false | void>) | null | undefined, onrejected?: ((reason: any) => PromiseLike<never>) | null | undefined): Promise<false | void>

Attaches callbacks for the resolution and/or rejection of the Promise.

@param ― onfulfilled The callback to execute when the Promise is resolved.

@param ― onrejected The callback to execute when the Promise is rejected.

@returns ― A Promise for the completion of which ever callback is executed.

then
(
(
taken: boolean
taken
) =>
taken: boolean
taken
&&
const setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void
setTasks
(
column: Column
column
.
id: string
id
, (
tasks: Task[]
tasks
) =>
tasks: Task[]
tasks
.
Array<Task>.filter(predicate: (value: Task, index: number, array: Task[]) => unknown, thisArg?: any): Task[] (+1 overload)

Returns the elements of an array that meet the condition specified in a callback function.

@param ― predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.

@param ― thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.

filter
((
task: Task
task
) =>
task: Task
task
.
id: string
id
!==
source: DndTileData<Task, any>
source
.
id: string
id
),
),
),
DndContainerHandler<Task, any>.onDrop?: ((props: {
source: DndTileData<Task, any>;
target?: DndData;
}) => void) | undefined

Insert/rearrange the item at the given location.

onDrop
: ({
source: DndTileData<Task, any>
source
,
target: DndData | undefined
target
}) =>
const setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void
setTasks
(
column: Column
column
.
id: string
id
, (
tasks: Task[]
tasks
) =>
const place: <Task>(list: Task[], source: DndTileData<Task>, target?: DndData) => Task[]

list with the dragged item at the drop: after the tile it was dropped on, in the gap a placeholder names, or at the end when dropped on the container.

place
(
tasks: Task[]
tasks
,
source: DndTileData<Task, any>
source
,
target: DndData | undefined
target
)),
}),
[
column: Column
column
.
id: string
id
,
const setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void
setTasks
],
);
return (
<
const Board: {
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement;
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
};
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Placeholder: {
...;
};
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>;
}
Board
.
type Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
}
Column
.
type Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement
Root
data: Column
data
={
column: Column
column
}
location: DndLocation
location
={
location: DndLocation
location
}
draggable?: boolean | undefined
draggable
={
draggable: boolean | undefined
draggable
}
dragHandle?: HTMLButtonElement | null | undefined
dragHandle
={
const dragHandle: HTMLButtonElement | null
dragHandle
}
classNames?: ClassNameValue
classNames
='grid grid-rows-[var(--dx-rail-action)_1fr]'
>
<
const Board: {
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement;
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
};
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Placeholder: {
...;
};
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>;
}
Board
.
type Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
}
Column
.
type Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Header
label: string
label
={`${
column: Column
column
.
name: string
name
} (${
const count: number
count
})`}
dragHandleRef?: React.Ref<HTMLButtonElement> | undefined
dragHandleRef
={
const setDragHandle: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>
setDragHandle
}
/>
<
const Board: {
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement;
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
};
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Placeholder: {
...;
};
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>;
}
Board
.
type Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
}
Column
.
type Body: <TItem = Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement
Body
data: any
data
={
column: Column
column
}
eventHandler?: DndContainerHandler<any, any> | undefined
eventHandler
={
const eventHandler: DndContainerHandler<Task, any>
eventHandler
}
Tile?: MosaicStackTileComponent<Task> | undefined
Tile
={
const TaskCard: ({ data: task, location, draggable, }: MosaicTileProps<Task>) => React.JSX.Element
TaskCard
}
/>
</
const Board: {
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement;
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
};
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Placeholder: {
...;
};
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>;
}
Board
.
type Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
}
Column
.
type Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement
Root
>
);
};
/** Narrower columns than the theme's card width, so three fit in a small frame. */
// `CSSProperties` has no key for a custom property.
const
const NARROW_COLUMNS: React.CSSProperties

Narrower columns than the theme's card width, so three fit in a small frame.

NARROW_COLUMNS
= {
'display': 'contents',
'--spacing-card-default-width': '9rem',
} as
(alias) interface CSSProperties
import CSSProperties
CSSProperties
;
/** Three columns of tasks: drag a card within or across columns, or drag a column by its handle. */
export const
const TaskBoard: () => React.JSX.Element

Three columns of tasks: drag a card within or across columns, or drag a column by its handle.

TaskBoard
= () => {
const {
const model: BoardModel<Column, Task>
model
,
const setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void
setTasks
,
const columnHandler: DndContainerHandler<Column, any>
columnHandler
} =
const useTaskBoard: () => {
model: BoardModel<Column, Task>;
setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void;
columnHandler: DndContainerHandler<Column, any>;
}

The board reads its columns, and each column's cards, from one atom; a drop writes it and the board follows.

useTaskBoard
();
return (
<
const SetTasksContext: React.Context<(id: string, update: (tasks: Task[]) => Task[]) => void>

Writes one column's cards; the board's columns read it from context.

SetTasksContext
.
Context<(id: string, update: (tasks: Task[]) => Task[]) => void>.Provider: React.Provider<(id: string, update: (tasks: Task[]) => Task[]) => void>
Provider
ProviderProps<(id: string, update: (tasks: Task[]) => Task[]) => void>.value: (id: string, update: (tasks: Task[]) => Task[]) => void
value
={
const setTasks: (id: string, update: (tasks: Task[]) => Task[]) => void
setTasks
}>
<
JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
HTMLAttributes<T>.style?: React.CSSProperties | undefined
style
={
const NARROW_COLUMNS: React.CSSProperties

Narrower columns than the theme's card width, so three fit in a small frame.

NARROW_COLUMNS
}>
<
const Dnd: {
Root: {
({ children }: {
children?: React.ReactNode | undefined;
}): React.JSX.Element;
displayName: string;
};
}
Dnd
.
type Root: {
({ children }: {
children?: React.ReactNode | undefined;
}): React.JSX.Element;
displayName: string;
}
Root
>
<
const Board: {
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement;
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
};
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Placeholder: {
...;
};
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>;
}
Board
.
type Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement
Root
model: BoardModel<Column, Task>
model
={
const model: BoardModel<Column, Task>
model
}>
<
const Board: {
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement;
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
};
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Placeholder: {
...;
};
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>;
}
Board
.
type Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement
Content
eventHandler?: DndContainerHandler<Column, any> | undefined
eventHandler
={
const columnHandler: DndContainerHandler<Column, any>
columnHandler
}
Tile?: MosaicStackTileComponent<Column> | undefined
Tile
={
const TaskColumn: ({ data: column, location, draggable, }: MosaicTileProps<Column>) => React.JSX.Element

A column moves by its header's handle; a card taken from another column leaves that one when it lands here.

TaskColumn
} />
</
const Board: {
Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement;
Content: <TColumn = any>(props: BoardContentProps<TColumn> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Column: {
Root: <TColumn = unknown>(props: (BoardColumnProps<TColumn> & {
children?: React.ReactNode | undefined;
} & {
dragHandle?: HTMLButtonElement | null;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Header: React.ForwardRefExoticComponent<Omit<{
label: string;
dragHandleRef?: React.Ref<HTMLButtonElement>;
}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;
Body: <TItem = import("@dxos/echo/Obj").Unknown>(props: (Pick<BoardColumnProps<any>, "data"> & Pick<import("@dxos/react-ui-mosaic").MosaicContainerProps, "debug" | "eventHandler"> & {
Tile?: import("@dxos/react-ui-mosaic").MosaicStackTileComponent<TItem> | undefined;
}) & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Footer: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & {
data?: any;
onAdd?: () => void;
} & React.RefAttributes<HTMLDivElement>>;
};
Item: <TItem extends import("@dxos/echo/Obj").Unknown = any>(props: BoardItemProps<TItem> & {
ref?: React.Ref<HTMLDivElement>;
}) => React.ReactElement;
Placeholder: {
...;
};
Debug: React.ForwardRefExoticComponent<Omit<{}, "className"> & {
classNames?: import("@dxos/ui-types").ClassNameValue;
} & React.RefAttributes<HTMLDivElement>>;
}
Board
.
type Root: <TColumn = any, TItem = any>(props: BoardRootProps<TColumn, TItem>) => React.ReactElement
Root
>
</
const Dnd: {
Root: {
({ children }: {
children?: React.ReactNode | undefined;
}): React.JSX.Element;
displayName: string;
};
}
Dnd
.
type Root: {
({ children }: {
children?: React.ReactNode | undefined;
}): React.JSX.Element;
displayName: string;
}
Root
>
</
JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
div
>
</
const SetTasksContext: React.Context<(id: string, update: (tasks: Task[]) => Task[]) => void>

Writes one column's cards; the board's columns read it from context.

SetTasksContext
.
Context<(id: string, update: (tasks: Task[]) => Task[]) => void>.Provider: React.Provider<(id: string, update: (tasks: Task[]) => Task[]) => void>
Provider
>
);
};

TaskColumn gives its eventHandler to the column’s body, and its canDrop takes only tasks. Board.Content gets columnHandler, which takes only columns. The header’s dragHandleRef sets the handle that drags the column.

The story at the top of this page runs this example.

Composer’s Kanban plugin uses Board over ECHO objects, where each column is a value of a field and a drop writes the field.