### Install main package with yarn Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.2-quick-start-guide Install the @caldwell619/react-kanban package using yarn. ```bash yarn add @caldwell619/react-kanban ``` -------------------------------- ### Install main package with npm or yarn Source: https://deepwiki.com/christopher-caldwell/react-kanban/2-getting-started Install the core library using either npm or yarn. The command is the first step in setting up the library. ```bash npm install @caldwell619/react-kanban # or yarn add @caldwell619/react-kanban ``` -------------------------------- ### Basic import test Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.1-installation Verify the installation by importing the Board components and styles, then logging a success message. ```typescript // test-installation.ts import { Board, UncontrolledBoard, ControlledBoard } from '@caldwell619/react-kanban'; import '@caldwell619/react-kanban/dist/styles.css'; console.log('React Kanban installed successfully'); ``` -------------------------------- ### Install with npm Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.1-installation Install the @caldwell619/react-kanban package using npm. ```bash npm install @caldwell619/react-kanban ``` -------------------------------- ### Install peer dependencies with npm or yarn Source: https://deepwiki.com/christopher-caldwell/react-kanban/2-getting-started Install the required peer dependencies: react, react-dom, and @hello-pangea/dnd. These must be installed alongside the main package. ```bash npm install react react-dom @hello-pangea/dnd # or yarn add react react-dom @hello-pangea/dnd ``` -------------------------------- ### Install with pnpm Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.1-installation Install the @caldwell619/react-kanban package using pnpm. ```bash pnpm add @caldwell619/react-kanban ``` -------------------------------- ### Basic import setup for @caldwell619/react-kanban Source: https://deepwiki.com/christopher-caldwell/react-kanban/2-getting-started Import the UncontrolledBoard component and KanbanBoard type, along with the library's CSS. Required before using any board components. ```javascript import { UncontrolledBoard, KanbanBoard } from '@caldwell619/react-kanban' import '@caldwell619/react-kanban/dist/styles.css' ``` -------------------------------- ### Clone and install dependencies Source: https://deepwiki.com/christopher-caldwell/react-kanban/5-development-guide Sets up the development environment by cloning the repository and installing dependencies with Yarn. Requires Node.js 14.x or 16.x and peer dependencies react, react-dom, and @hello-pangea/dnd. ```bash git clone https://github.com/christopher-caldwell/react-kanban cd react-kanban yarn install ``` -------------------------------- ### Peer dependency check in package.json Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.1-installation Verify all peer dependencies are correctly installed by checking that your package.json dependencies section includes these entries. ```json { "dependencies": { "@caldwell619/react-kanban": "^0.0.12", "@hello-pangea/dnd": "^16.0.0", "react": "^16.0.0", "react-dom": "^16.0.0" } } ``` -------------------------------- ### TypeScript support verification Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.1-installation Verify TypeScript types are working by creating a KanbanBoard and Card object. ```typescript import { KanbanBoard, Card } from '@caldwell619/react-kanban'; const testBoard: KanbanBoard = { columns: [] }; const testCard: Card = { id: 1, title: 'Test Card' }; ``` -------------------------------- ### Import CSS in JavaScript/TypeScript entry point Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.1-installation Alternatively, import the styles in your JavaScript or TypeScript entry point. ```javascript import '@caldwell619/react-kanban/dist/styles.css'; ``` -------------------------------- ### UncontrolledBoard example with drag handler Source: https://deepwiki.com/christopher-caldwell/react-kanban/2-getting-started Renders a board with self-managed state. The onCardDragEnd callback logs card movement details (card, source, destination). ```javascript import { UncontrolledBoard, KanbanBoard } from '@caldwell619/react-kanban' import '@caldwell619/react-kanban/dist/styles.css' const MyKanbanApp = () => { return ( { console.log('Card moved:', { card, source, destination }) }} /> ) } ``` -------------------------------- ### Import CSS in main CSS file Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.1-installation Add this import to your application's main CSS file to include the pre-built styles. ```css @import '@caldwell619/react-kanban/dist/styles.css'; ``` -------------------------------- ### Import default CSS styles Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.2-quick-start-guide Import the default CSS styles for the library in your application. ```javascript import '@caldwell619/react-kanban/dist/styles.css' ``` -------------------------------- ### Remix Vite configuration for SSR Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.1-installation Add this to your vite.config.ts to prevent Vite from externalizing the react-kanban package during server-side rendering, avoiding compatibility issues. ```typescript export default defineConfig({ // existing configuration ssr: { noExternal: ["@caldwell619/react-kanban"] }, }); ``` -------------------------------- ### Basic UncontrolledBoard Implementation Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.2-uncontrolledboard Shows the minimal setup for using UncontrolledBoard with an initial board and an onCardDragEnd callback. Imports UncontrolledBoard and KanbanBoard from '@caldwell619/react-kanban'. ```jsx import { UncontrolledBoard, KanbanBoard } from '@caldwell619/react-kanban' const initialBoard: KanbanBoard = { columns: [/* column definitions */] } { console.log('Card moved:', { card, source, destination }) }} /> ``` -------------------------------- ### Define board data structure with KanbanBoard type Source: https://deepwiki.com/christopher-caldwell/react-kanban/2-getting-started Structure for a Kanban board with columns and cards. Each column has an id, title, and cards array; each card has id, title, and description. ```typescript const board: KanbanBoard = { columns: [ { id: 1, title: 'Backlog', cards: [ { id: 1, title: 'Add card', description: 'Add capability to add a card in a column' } ] } ] } ``` -------------------------------- ### GitHub Actions Cache Step for Yarn Source: https://deepwiki.com/christopher-caldwell/react-kanban/5.2-testing Caches the Yarn dependency directory to speed up installation in CI. Uses actions/cache@v2 with a key based on the runner OS and hash of yarn.lock. ```yaml - uses: actions/cache@v2 with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} ``` -------------------------------- ### ControlledBoard with moveCard helper Source: https://deepwiki.com/christopher-caldwell/react-kanban/2-getting-started Use ControlledBoard when external state management is required. The moveCard helper updates the board state on card drag end. ```typescript import { useState } from 'react' import { ControlledBoard, moveCard, KanbanBoard, OnDragEndNotification, Card } from '@caldwell619/react-kanban' const MyControlledBoard = () => { const [board, setBoard] = useState(initialBoard) const handleCardMove: OnDragEndNotification = (_card, source, destination) => { setBoard(currentBoard => { return moveCard(currentBoard, source, destination) }) } return ( {board} ) } ``` -------------------------------- ### CustomCard interface extending Card Source: https://deepwiki.com/christopher-caldwell/react-kanban/2.2-quick-start-guide Shows how to extend the base Card interface with custom fields for your own data, such as assigneeId, storyPoints, and ticketType. ```typescript interface CustomCard extends Card { assigneeId: number storyPoints: number ticketType: 'bug' | 'feature' | 'enhancement' } ``` -------------------------------- ### Run automated release script with yarn publish:version Source: https://deepwiki.com/christopher-caldwell/react-kanban/5.4-release-process Executes the release pipeline via scripts/publish.sh. Requires a clean working directory, npm publish permissions, conventional commits, and passing tests. Halts on any quality gate failure. ```bash yarn publish:version ``` -------------------------------- ### Basic Controlled Board with moveCard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Shows a minimal controlled board using useState and moveCard to handle card drag events. Requires initialBoard and imports from '@caldwell619/react-kanban'. ```tsx import { ControlledBoard, moveCard, KanbanBoard, OnDragEndNotification, Card } from '@caldwell619/react-kanban' const MyBoard = () => { const [board, setBoard] = useState(initialBoard) const handleCardMove: OnDragEndNotification = (_card, source, destination) => { setBoard((currentBoard) => { return moveCard(currentBoard, source, destination) }) } return {board} } ``` -------------------------------- ### Compile SCSS to CSS with sass Source: https://deepwiki.com/christopher-caldwell/react-kanban/5.1-build-system Compiles src/styles.scss into dist/styles.css without source maps to reduce bundle size. Produces a production-ready CSS file for distribution. ```bash yarn sass src/styles.scss dist/styles.css --no-source-map ``` -------------------------------- ### UncontrolledBoard with Custom Rendering Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.2-uncontrolledboard Demonstrates customizing card and column header rendering via renderCard and renderColumnHeader props. The render props receive handlers like removeCard, dragging, renameColumn, and addCard. ```jsx ( )} renderColumnHeader={(column, { renameColumn, addCard }) => ( )} /> ``` -------------------------------- ### ControlledBoard Basic Usage Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Basic usage of ControlledBoard with moveCard and onCardDragEnd callback. ```APIDOC ## ControlledBoard Basic Usage ### Description Basic usage of ControlledBoard with moveCard and onCardDragEnd callback. ### Example ```typescript import { ControlledBoard, moveCard, KanbanBoard, OnDragEndNotification, Card } from '@caldwell619/react-kanban' const MyBoard = () => { const [board, setBoard] = useState(initialBoard) const handleCardMove: OnDragEndNotification = (_card, source, destination) => { setBoard((currentBoard) => { return moveCard(currentBoard, source, destination) }) } return {board} } ``` ``` -------------------------------- ### Board Component Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.1-board-component The Board component is the primary entry point for the react-kanban library. It automatically delegates to either UncontrolledBoard or ControlledBoard based on the props provided, supporting both controlled and uncontrolled usage patterns. ```APIDOC ## Board Component ### Description The Board component serves as the primary entry point and unified interface for the react-kanban library. It acts as an abstraction layer that automatically delegates to either `UncontrolledBoard` or `ControlledBoard` based on the props provided, allowing developers to use a single component regardless of their state management approach. ### Props #### Shared Props (SharedProps) | Prop | Type | Default | Description | | --- | --- | --- | --- | | `onCardDragEnd` | function | - | Card drag completion callback | | `onColumnDragEnd` | function | - | Column drag completion callback | | `onCardRemove` | function | - | Card removal callback | | `onColumnRemove` | function | - | Column removal callback | | `onColumnRename` | function | - | Column rename callback | | `onCardNew` | function | - | New card creation callback | | `onColumnNew` | function | - | New column creation callback | | `onNewCardConfirm` | function | - | Async card creation validator | | `onNewColumnConfirm` | function | - | Async column creation validator | | `disableCardDrag` | boolean | `false` | Disable card dragging | | `disableColumnDrag` | boolean | `false` | Disable column dragging | | `allowAddCard` | boolean | `true` | Enable card addition | | `allowRemoveCard` | boolean | `true` | Enable card removal | | `allowRemoveColumn` | boolean | `true` | Enable column removal | | `allowRenameColumn` | boolean | `true` | Enable column renaming | | `allowAddColumn` | boolean | `true` | Enable column addition | | `renderCard` | function | - | Custom card renderer | #### UncontrolledBoardProps - `initialBoard` (Board) - Required - The initial board state - Cannot have `children` #### ControlledBoardProps - `children` (ReactNode) - Required - The controlled board children - Cannot have `initialBoard` ### Usage Patterns 1. **Uncontrolled with initialBoard**: Provide `initialBoard` prop to use the uncontrolled board. 2. **Controlled with children**: Provide `children` prop to use the controlled board. 3. **Legacy unified interface**: Automatically determines implementation based on props. ### Error Handling - **Missing Props**: Throws error when neither `initialBoard` nor `children` is provided. Error message: `'Must provide either "children" or "initialBoard" props'` - **Type Safety**: TypeScript prevents invalid prop combinations at compile time. - **Runtime Validation**: Performs runtime checks to ensure proper delegation. ``` -------------------------------- ### Render Prop Bag Interfaces (ColumnHeaderBag, ColumnAdderBag) Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.2-uncontrolledboard Defines the helper function signatures passed to render props for column header and column adder customizations. ColumnHeaderBag includes removeColumn, renameColumn, and addCard; ColumnAdderBag includes addColumn returning a Promise. ```typescript interface ColumnHeaderBag { removeColumn: () => void renameColumn: (title: string) => void addCard: (card: TCard, options?: Position) => void } interface ColumnAdderBag { addColumn: (newColumn: Column) => Promise } ``` -------------------------------- ### ControlledBoard Props Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard The ControlledBoard component accepts a comprehensive set of props for customization and event handling. This documentation covers required, event handler, customization, and feature control props. ```APIDOC ## ControlledBoard Props ### Description The `ControlledBoard` component accepts a comprehensive set of props for customization and event handling. ### Required Props | Prop | Type | Description | | --- | --- | --- | | `children` | `KanbanBoard` | The board state to render | ### Event Handler Props | Prop | Type | Description | | --- | --- | --- | | `onCardDragEnd` | `OnDragEndNotification` | Called when card drag operation completes | | `onColumnDragEnd` | `OnDragEndNotification>` | Called when column drag operation completes | | `onNewColumnConfirm` | `(column: Omit, 'id'>) => void` | Called when new column is confirmed | | `onColumnRemove` | `(args: {board, column}) => void` | Called when column is removed | | `onColumnRename` | `(args: {board, column}) => void` | Called when column is renamed | | `onCardRemove` | `(args: {board, column, card}) => void` | Called when card is removed | ### Customization Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `renderCard` | `(card: TCard, options: {dragging: boolean}) => JSX.Element` | `DefaultCard` | Custom card renderer | | `renderColumnHeader` | `(column: Column) => JSX.Element` | `DefaultColumn` | Custom column header renderer | | `renderColumnAdder` | `() => JSX.Element` | `ColumnAdder` | Custom column adder renderer | ### Feature Control Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `allowAddColumn` | `boolean` | `true` | Enable column addition | | `allowRemoveColumn` | `boolean` | `true` | Enable column removal | | `allowRenameColumn` | `boolean` | `true` | Enable column renaming | | `allowRemoveCard` | `boolean` | `true` | Enable card removal | | `allowAddCard` | `boolean` | `true` | Enable card addition | | `disableCardDrag` | `boolean` | `false` | Disable card drag operations | | `disableColumnDrag` | `boolean` | `false` | Disable column drag operations | ``` -------------------------------- ### Custom Card Rendering with ControlledBoard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Renders custom card components via the renderCard prop. Uses a generic ControlledBoard and passes dragging state to the custom component. ```tsx const CustomBoard = () => { return ( renderCard={(card, { dragging }) => ( )} onCardDragEnd={handleCardMove} > {board} ) } ``` -------------------------------- ### ControlledBoard Custom Card Rendering Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Usage of ControlledBoard with custom card rendering via renderCard prop. ```APIDOC ## ControlledBoard Custom Card Rendering ### Description Usage of ControlledBoard with custom card rendering via renderCard prop. ### Example ```typescript const CustomBoard = () => { return ( renderCard={(card, { dragging }) => ( )} onCardDragEnd={handleCardMove} > {board} ) } ``` ``` -------------------------------- ### Helper Functions Source: https://deepwiki.com/christopher-caldwell/react-kanban/4.3-custom-rendering Helper functions provided by the library for state management in custom components. Availability varies based on whether the board is controlled or uncontrolled. ```APIDOC ## Helper Functions ### Description Helper functions for state management in custom components. Availability varies based on whether the board is controlled or uncontrolled. ### Function Availability Matrix | Function | Controlled Board | Uncontrolled Board | | --- | --- | --- | | `removeCard` | ❌ | ✅ | | `removeColumn` | ❌ | ✅ | | `renameColumn` | ❌ | ✅ | | `addCard` | ❌ | ✅ | | `addColumn` | ❌ | ✅ | | `dragging` (cards) | ✅ | ✅ | ### Controlled vs Uncontrolled Considerations - In controlled boards, state mutations must be handled externally through callback props like `onCardDragEnd` and `onColumnDragEnd`, combined with helper functions from the API reference. - In uncontrolled boards, the render prop helper functions provide direct mutation capabilities, allowing immediate state changes within the custom components. ``` -------------------------------- ### SCSS @extend inheritance for card styling Source: https://deepwiki.com/christopher-caldwell/react-kanban/5.3-code-quality Used in src/styles.scss to inherit base card skeleton styles. Demonstrates BEM-style naming and Prettier formatting. ```scss .react-kanban-card { @extend .react-kanban-card-skeleton; // Additional styles } ``` -------------------------------- ### Type-Safe Helper Usage with Generics Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.4-helper-functions Shows how to use helper functions with custom card types via generic type parameters. Defines a CustomCard interface extending Card with storyPoints, then calls moveCard with the type parameter. ```typescript interface CustomCard extends Card { storyPoints: number } // Type-safe helper usage const updatedBoard = moveCard(board, source, destination) ``` -------------------------------- ### NotionStyles styled component for font and layout customization Source: https://deepwiki.com/christopher-caldwell/react-kanban/4.2-styled-examples Uses Material-UI's `styled` utility to apply Segoe UI fonts and remove default column backgrounds for a Notion-like kanban board. The CSS targets all elements and headings, and overrides the `.react-kanban-column` class to remove padding and background. ```css const NotionStyles = styled('div')` & * { font-family: 'Segoe' !important; } & h1, h2, h3, h4, h5, h6 { font-family: 'Segoe Bold' !important; } & .react-kanban-column { padding: 0; background-color: transparent; } ` ``` -------------------------------- ### TypeScript path mapping in tsconfig.json Source: https://deepwiki.com/christopher-caldwell/react-kanban/5.3-code-quality Defines path aliases for cleaner imports: @/* maps to src/*, @components/* to src/components/*, and @services/* to src/services/*. ```json "paths": { "@/*": ["src/*"], "@components/*": ["src/components/*"], "@services/*": ["src/services/*"] } ``` -------------------------------- ### ControlledBoard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3-api-reference The ControlledBoard component requires external state management. The board state is passed as children and all mutations must be handled by the parent component. ```APIDOC ## ControlledBoard ### Description Requires external state management. The board state is passed as `children` and all mutations must be handled by parent component. ### Props - `children` (KanbanBoard) - Required - The board state. - All props from `SharedProps` - Optional - Shared configuration props. - Callback handlers for state mutations - Optional - Handlers to manage state changes. ### Usage Pattern Refer to the source documentation for detailed usage examples. ``` -------------------------------- ### addColumn Source: https://deepwiki.com/christopher-caldwell/react-kanban/3-api-reference Appends a new column to the board. Requires board and column objects. ```APIDOC ## addColumn ### Description Appends a new column to the board. Requires board and column objects. ### Method Function ### Signature `addColumn(board, column)` ### Parameters - **board** (KanbanBoard) - Required - The board state. - **column** (Column) - Required - The column to add. ### Response Returns the updated board state. ``` -------------------------------- ### renderColumnAdder Source: https://deepwiki.com/christopher-caldwell/react-kanban/4.3-custom-rendering Custom column adder component for adding new columns to the board. The function receives a columnBag object with helper functions and must handle user input collection and call the provided addColumn function. ```APIDOC ## renderColumnAdder ### Description Custom column adders can be implemented using the `renderColumnAdder` prop for controlling how new columns are added to the board. The custom adder component must handle user input collection and call the provided `addColumn` function with the new column data. ### Parameters #### columnBag (Object) - **addColumn** (function) - Required - Adds a new column to the board. Available only in uncontrolled boards. ### Availability - Uncontrolled board only ``` -------------------------------- ### renderCard Source: https://deepwiki.com/christopher-caldwell/react-kanban/4.3-custom-rendering Customizes the rendering of individual cards on the board. Receives the card data and a helper bag with utility functions and state information. ```APIDOC ## renderCard ### Description Customizes the rendering of individual cards on the board. Receives the card data and a helper bag with utility functions and state information. ### Parameters #### Function Parameters - **card** (object) - Required - The card data object - **cardBag** (object) - Required - Object containing helper functions and state #### cardBag Helper Functions - **removeCard** (function) - Removes the card from its column (Uncontrolled only) - **dragging** (boolean) - Indicates if card is being dragged (Always available) ### Usage Pass the `renderCard` prop to `UncontrolledBoard` to customize card rendering. ### Example ```jsx ( // Custom card rendering logic )} /> ``` ``` -------------------------------- ### Basic Card Movement with OnDragEndNotification Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.4-helper-functions Handles drag-and-drop events in a controlled board by updating state with moveCard. The callback receives the card, source, and destination, and returns the updated board. ```typescript // Example from README.md const handleCardMove: OnDragEndNotification = (_card, source, destination) => { setBoard((currentBoard) => { return moveCard(currentBoard, source, destination) }) } ``` -------------------------------- ### addColumn Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.4-helper-functions Adds a new column to the board. ```APIDOC ## addColumn ### Description Adds a new column to the board. ### Parameters - `board` - The current board state - `column` - The column to add ``` -------------------------------- ### Resolve TypeScript path mappings with tscpaths Source: https://deepwiki.com/christopher-caldwell/react-kanban/5.1-build-system Run after TypeScript compilation to rewrite path aliases like '@components/Card' into relative paths in the compiled JavaScript output. Uses tsconfig.json for path mappings, src as source root, and dist as output. ```bash npx tscpaths -p tsconfig.json -s src -o dist ``` -------------------------------- ### ControlledBoard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard The ControlledBoard component is fully generic and supports custom card types through the TCard generic parameter. It allows rendering custom card components and handling drag events. ```APIDOC ## ControlledBoard ### Description The ControlledBoard component is a generic React component that accepts a KanbanBoard and renders it with controlled state. It supports custom card types via the TCard generic parameter. ### Props - **renderCard** (function) - Required - A function that renders a custom card component, receiving the card object - **onCardDragEnd** (function) - Required - Callback fired when a card drag ends - **children** (KanbanBoard) - Required - The board state to render ### Example ```tsx interface CustomCard extends Card { storyPoints: number assignee: string } const board: KanbanBoard = { /* ... */ } renderCard={(card) => { // card.storyPoints and card.assignee are available return }} onCardDragEnd={handleCardMove} > {board} ``` ``` -------------------------------- ### UncontrolledBoard Props Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.2-uncontrolledboard The UncontrolledBoard component accepts props for initial state, event callbacks, rendering customization, and feature toggles. This snippet documents the core required props, event callbacks, and feature control props. ```APIDOC ## UncontrolledBoard Props ### Description The `UncontrolledBoard` component accepts props that fall into several categories: initial state, event callbacks, rendering customization, and feature toggles. ### Required and Core Props | Prop | Type | Purpose | | --- | --- | --- | | `initialBoard` | `KanbanBoard` | Establishes the initial state of the board | | `onNewColumnConfirm` | `(column: Omit, 'id'>) => Promise>` | Required when `allowAddColumn` is true | | `onNewCardConfirm` | `(card: TCard) => Promise` | Required when `allowAddCard` is true | ### Event Callback Props | Event | Callback Signature | When Called | | --- | --- | --- | | Card Drag End | `onCardDragEnd?: OnDragEndNotification` | After card is moved between positions | | Column Drag End | `onColumnDragEnd?: OnDragEndNotification>` | After column is reordered | | Column Added | `onColumnNew?: (args: { board: KanbanBoard; column: Column }) => void` | After new column is added | | Column Removed | `onColumnRemove?: (args: { board: KanbanBoard; column: Column }) => void` | After column is removed | | Card Added | `onCardNew?: (args: { board: KanbanBoard; column: Column; card: TCard }) => void` | After new card is added | | Card Removed | `onCardRemove?: (args: { board: KanbanBoard; column: Column; card: TCard }) => void` | After card is removed | ### Feature Control Props | Prop | Default | Purpose | | --- | --- | --- | | `allowAddColumn` | `true` | Controls whether users can add new columns | | `allowRemoveColumn` | `true` | Controls whether columns can be removed | | `allowRenameColumn` | `true` | Controls whether columns can be renamed | | `allowAddCard` | `true` | Controls whether cards can be added | | `allowRemoveCard` | `true` | Controls whether cards can be removed | | `disableCardDrag` | `false` | Disables card drag and drop | | `disableColumnDrag` | `false` | Disables column reordering | ``` -------------------------------- ### onNewColumnConfirm Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.5-typescript-types Asynchronous confirmation callback for column creation. It receives a new column without an id and returns a Promise of the created column. ```APIDOC ## onNewColumnConfirm ### Description Asynchronous confirmation callback for column creation. It receives a new column without an id and returns a Promise of the created column. ### Type Signature ```typescript onNewColumnConfirm?: (newColumn: Omit, 'id'>) => Promise> ``` ### Parameters - **newColumn** (Omit, 'id'>) - The new column data without an id. ### Return Value - Promise> - A promise resolving to the created column. ``` -------------------------------- ### UncontrolledBoard with TypeScript generic CustomCard Source: https://deepwiki.com/christopher-caldwell/react-kanban/4.2-styled-examples Demonstrates proper TypeScript generic usage with the `CustomCard` interface in the Jira implementation. Ensures type safety for custom card properties like `assigneeId`, `storyPoints`, `ticketType`, and `prLink`. ```tsx initialBoard={board} renderCard={renderCard} renderColumnHeader={renderColumnHeader} /> ``` -------------------------------- ### removeColumn Source: https://deepwiki.com/christopher-caldwell/react-kanban/3-api-reference Removes a column from the board. Requires board and column references. ```APIDOC ## removeColumn ### Description Removes a column from the board. Requires board and column references. ### Method Function ### Signature `removeColumn(board, column)` ### Parameters - **board** (KanbanBoard) - Required - The board state. - **column** (Column) - Required - The column to remove. ### Response Returns the updated board state. ``` -------------------------------- ### moveColumn Source: https://deepwiki.com/christopher-caldwell/react-kanban/3-api-reference Reorders columns within the board. Uses `fromPosition` and `toPosition` coordinates. ```APIDOC ## moveColumn ### Description Reorders columns within the board. Uses `fromPosition` and `toPosition` coordinates. ### Method Function ### Signature `moveColumn(board, fromPosition, toPosition)` ### Parameters - **board** (KanbanBoard) - Required - The board state. - **fromPosition** (number) - Required - The current index of the column. - **toPosition** (number) - Required - The target index for the column. ### Response Returns the updated board state. ``` -------------------------------- ### SharedProps Source: https://deepwiki.com/christopher-caldwell/react-kanban/3-api-reference All board components accept the same core props defined in SharedProps. This interface includes drag and drop configuration, feature toggles, callback handlers, validation callbacks, and render props. ```APIDOC ## SharedProps ### Description All board components accept the same core props defined in `SharedProps`. This interface includes drag and drop configuration, feature toggles, callback handlers, validation callbacks, and render props. ### Properties #### Drag and Drop Configuration - `disableCardDrag` (boolean) - Default: `false` - Disables card drag operations - `disableColumnDrag` (boolean) - Default: `false` - Disables column drag operations - `onCardDragEnd` (OnDragEndNotification) - Card drag completion callback - `onColumnDragEnd` (OnDragEndNotification>) - Column drag completion callback #### Feature Toggles - `allowAddCard` (boolean) - Default: `true` - Enable card addition - `allowRemoveCard` (boolean) - Default: `true` - Enable card removal - `allowRemoveColumn` (boolean) - Default: `true` - Enable column removal - `allowRenameColumn` (boolean) - Default: `true` - Enable column renaming - `allowAddColumn` (boolean) - Default: `true` - Enable column addition #### Callback Handlers - `onColumnRemove` ((info: ColumnCallbackInfo) => void) - Column removal handler - `onCardRemove` ((info: CardCallbackInfo) => void) - Card removal handler - `onColumnRename` ((info: ColumnCallbackInfo) => void) - Column rename handler - `onCardNew` ((info: CardCallbackInfo) => void) - New card handler - `onColumnNew` ((info: ColumnCallbackInfo) => void) - New column handler #### Validation Callbacks - `onNewCardConfirm` ((card: Omit) => Promise) - Card creation validator - must return card with ID - `onNewColumnConfirm` ((column: Omit, 'id'>) => Promise>) - Column creation validator - must return column with ID #### Render Props - `renderCard` ((card: TCard, options: CardBag) => JSX.Element) - Custom card renderer ``` -------------------------------- ### Generic Type Usage with ControlledBoard and CustomCard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Shows how to use the ControlledBoard component with a custom card type via the TCard generic parameter. The CustomCard interface extends Card with storyPoints and assignee, and the renderCard callback can access these properties. ```tsx interface CustomCard extends Card { storyPoints: number assignee: string } const board: KanbanBoard = { /* ... */ } renderCard={(card) => { // card.storyPoints and card.assignee are available return }} onCardDragEnd={handleCardMove} > {board} ``` -------------------------------- ### changeCard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.4-helper-functions Merges properties into an existing card. ```APIDOC ## changeCard ### Description Merges properties into an existing card. ### Parameters - `board` - The current board state - `cardId` - The ID of the card to modify - `object` - The properties to merge into the card ``` -------------------------------- ### renderColumnHeader Source: https://deepwiki.com/christopher-caldwell/react-kanban/4.3-custom-rendering Customizes the rendering of column headers on the board. Provides access to column data and manipulation functions. ```APIDOC ## renderColumnHeader ### Description Customizes the rendering of column headers on the board. Provides access to column data and manipulation functions. ### Parameters #### Function Parameters - **column** (object) - Required - The column data object - **columnBag** (object) - Required - Object containing helper functions #### columnBag Helper Functions - **removeColumn** (function) - Removes the column from the board (Uncontrolled only) - **renameColumn** (function) - Renames the column with provided title (Uncontrolled only) - **addCard** (function) - Adds a new card to the column (Uncontrolled only) #### addCard Options - **{ on: 'top' }** (object) - Optional - Add card at the top of the column - **{ on: 'bottom' }** (object) - Optional - Add card at the bottom (default) ### Usage Pass the `renderColumnHeader` prop to `UncontrolledBoard` to customize column header rendering. ### Example ```jsx ( // Custom column header rendering logic )} /> ``` ``` -------------------------------- ### Drag and Drop Handler with partialRight Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.2-uncontrolledboard Shows the generic drag end handler and its specialized card drag version created via partialRight. The handler updates the board state and invokes a notify callback when provided. ```typescript const handleOnDragEnd = ({ source, destination, subject }, { moveCallback, notifyCallback }) => { const reorderedBoard = moveCallback(board, source, destination) when(notifyCallback)((callback) => callback(subject, source, destination)) setBoard(reorderedBoard) } const handleOnCardDragEnd = partialRight(handleOnDragEnd, { moveCallback: moveCard, notifyCallback: onCardDragEnd }) ``` -------------------------------- ### onNewCardConfirm Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.5-typescript-types Asynchronous confirmation callback for card creation. It receives a card without an id and returns a Promise of the created card. ```APIDOC ## onNewCardConfirm ### Description Asynchronous confirmation callback for card creation. It receives a card without an id and returns a Promise of the created card. ### Type Signature ```typescript onNewCardConfirm?: (card: Omit) => Promise ``` ### Parameters - **card** (Omit) - The card data without an id. ### Return Value - Promise - A promise resolving to the created card. ``` -------------------------------- ### addCard(board, inColumn, card, options) Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Adds a card to a column. This helper function is designed for use with ControlledBoard to manage state changes. ```APIDOC ## addCard(board, inColumn, card, options) ### Description Adds a card to a column. ### Parameters - **board** (KanbanBoard) - Required - The current board state - **inColumn** (Column) - Required - The column to add the card to - **card** (Card) - Required - The card to add - **options** (object) - Optional - Additional options (e.g., position) ### Returns - **KanbanBoard** - The updated board state ``` -------------------------------- ### DragDropContext Integration in BoardContainer Source: https://deepwiki.com/christopher-caldwell/react-kanban/6.3-drag-and-drop-implementation Wraps the board in a DragDropContext with onDragEnd handler. Used in BoardContainer to enable drag-and-drop for columns and cards. ```jsx
{/* Column components */}
``` -------------------------------- ### ControlledBoard onCardDragEnd Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Callback for card drag end events. Provides the moved card, source position, and destination position. ```APIDOC ## ControlledBoard onCardDragEnd ### Description Callback for card drag end events. Provides the moved card, source position, and destination position. ### Parameters - **subject** (Card) - The moved card object - **source** (object) - Origin position with `fromColumnId` and `fromPosition` - **destination** (object) - Target position with `toColumnId` and `toPosition` ``` -------------------------------- ### moveColumn(board, source, destination) Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Reorders columns on the board. This helper function is designed for use with ControlledBoard to manage state changes. ```APIDOC ## moveColumn(board, source, destination) ### Description Reorders columns on the board. ### Parameters - **board** (KanbanBoard) - Required - The current board state - **source** (object) - Required - The source column index - **destination** (object) - Required - The destination column index ### Returns - **KanbanBoard** - The updated board state ``` -------------------------------- ### UncontrolledBoard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3-api-reference The UncontrolledBoard component manages board state internally. It accepts an initialBoard prop and handles all state mutations through internal logic, including drag operations and card/column additions and removals. ```APIDOC ## UncontrolledBoard ### Description Manages board state internally. Accepts `initialBoard` prop and handles all state mutations through internal logic. ### Props - `initialBoard` (KanbanBoard) - Required - The initial state of the board. - All props from `SharedProps` - Optional - Shared configuration props. ### State Management - Internal state initialized from `initialBoard`. - Automatic updates on drag operations. - Built-in card/column addition and removal. ``` -------------------------------- ### changeColumn Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.4-helper-functions Merges properties into an existing column. ```APIDOC ## changeColumn ### Description Merges properties into an existing column. ### Parameters - `board` - The current board state - `column` - The column to modify - `object` - The properties to merge into the column ``` -------------------------------- ### Controlled Board State Management with useState and moveCard Source: https://deepwiki.com/christopher-caldwell/react-kanban/6.2-state-management-patterns Parent component manages board state and passes it as children to ControlledBoard. The handleCardMove callback uses moveCard to update state on drag end. ```tsx // Parent component manages state const [controlledBoard, setBoard] = useState>(initialBoard) const handleCardMove: OnDragEndNotification = (card, source, destination) => { setBoard(currentBoard => moveCard(currentBoard, source, destination)) } // Board state passed as children {controlledBoard} ``` -------------------------------- ### Basic Usage with Default Types Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.5-typescript-types For simple implementations, the default Card interface provides sufficient structure. The board object uses columns with cards that have id, title, and description. ```typescript import { UncontrolledBoard, KanbanBoard } from '@caldwell619/react-kanban' const board: KanbanBoard = { columns: [ { id: 1, title: 'Backlog', cards: [ { id: 1, title: 'Add card', description: 'Add capability to add a card in a column' } ] } ] } ``` -------------------------------- ### ControlledBoard onColumnDragEnd Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Callback for column drag end events. Provides the moved column, source position, and destination position. ```APIDOC ## ControlledBoard onColumnDragEnd ### Description Callback for column drag end events. Provides the moved column, source position, and destination position. ### Parameters - **subject** (Column) - The moved column object - **source** (object) - Origin position with `fromPosition` - **destination** (object) - Target position with `toPosition` ``` -------------------------------- ### ColumnCallbackInfo Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.5-typescript-types Provides structured information about a column-related callback, including the board and column involved. ```APIDOC ## ColumnCallbackInfo ### Description Provides structured information about a column-related callback, including the board and column involved. ### Properties - `board` (KanbanBoard) - Required - The board instance - `column` (Column) - Required - The column instance ``` -------------------------------- ### KanbanBoard interface Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.5-typescript-types Represents the complete board structure. The generic parameter TCard extends Card. ```typescript interface KanbanBoard { columns: Column[] } ``` -------------------------------- ### addCard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3-api-reference Adds a card to a specified column. Supports positioning options to place the card at the top or bottom of the column. ```APIDOC ## addCard ### Description Adds a card to a specified column. Supports positioning options to place the card at the top or bottom of the column. ### Method Function ### Signature `addCard(board, column, card, options)` ### Parameters - **board** (KanbanBoard) - Required - The board state. - **column** (Column) - Required - The target column. - **card** (Card) - Required - The card to add. - **options** (object) - Optional - Positioning options (`top` or `bottom`). ### Response Returns the updated board state. ``` -------------------------------- ### moveCard(board, source, destination) Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.3-controlledboard Moves a card between positions on the board. This helper function is designed for use with ControlledBoard to manage state changes. ```APIDOC ## moveCard(board, source, destination) ### Description Moves a card between positions on the board. ### Parameters - **board** (KanbanBoard) - Required - The current board state - **source** (object) - Required - The source position (column and card index) - **destination** (object) - Required - The destination position (column and card index) ### Returns - **KanbanBoard** - The updated board state ``` -------------------------------- ### addCard Source: https://deepwiki.com/christopher-caldwell/react-kanban/3.4-helper-functions Adds a card to a column at a specified position (top or bottom). ```APIDOC ## addCard ### Description Adds a card to a column at a specified position. ### Parameters - `board` - The current board state - `inColumn` - The column to add the card to - `card` - The card to add - `{on: 'bottom'|'top'}` - The position within the column to add the card ``` -------------------------------- ### Drag State Tracking Render Prop Source: https://deepwiki.com/christopher-caldwell/react-kanban/6.3-drag-and-drop-implementation Cards receive isDragging state via render prop to apply custom styling during drag operations. ```jsx {(provided, { isDragging }) => { return (
{renderCard(isDragging)}
) }} ```