### Install solid-nest with npm, yarn, or pnpm Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This code snippet shows the commands to install the solid-nest library using different package managers: npm, yarn, and pnpm. Choose the command that corresponds to your project's package manager. ```bash npm i solid-nest # or yarn add solid-nest # or pnpm add solid-nest ``` -------------------------------- ### Configure BlockTree with getOptions Example Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Demonstrates how to use the getOptions prop within a BlockTree component to dynamically set configuration for each block based on its type. This example shows conditional spacing, tag assignment, and accepted child tags. ```tsx block.id} getChildren={block => block.children} getOptions={block => ({ spacing: block.type === 'container' ? 20 : 12, tag: block.type, accepts: block.type === 'container' ? ['item'] : [] })}> {/* ... */} ``` -------------------------------- ### Solid-Nest BlockTree State Management Example Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Demonstrates basic state management for the BlockTree component using SolidJS signals. It shows how to handle root block state, selection state, and reorder events. ```tsx import { createSignal } from 'solid-js' import { BlockTree } from 'solid-nest' type MyBlock = { id: string text: string children?: MyBlock[] } function App() { const [root, setRoot] = createSignal({ id: 'root', text: 'Root', children: [] }) const [selection, setSelection] = createSignal<{ blocks?: string[] }>({}) const handleReorder = (event: ReorderEvent) => { // Update your state to reflect the reordering // Implementation depends on your state structure } return ( block.id} getChildren={block => block.children} selection={selection()} onSelectionChange={event => { if (event.kind === 'blocks') { setSelection({ blocks: event.blocks }) } else if (event.kind === 'deselect') { setSelection({}) } }} onReorder={handleReorder} > {props => (
{props.block.text}
{props.children}
)}
) } ``` -------------------------------- ### Basic SolidJS App with BlockTree Component Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This example demonstrates how to set up a basic SolidJS application using the `BlockTree` component from the `solid-nest` library. It defines a `MyBlock` type, initializes a root block structure, and renders the `BlockTree` with custom block rendering logic. ```tsx import { BlockTree, createBlockTree } from 'solid-nest' type MyBlock = { id: string text: string children?: MyBlock[] } function App() { // Define your block structure const root: MyBlock = { id: 'root', text: 'Root', children: [ { id: 'a', text: 'First block' }, { id: 'b', text: 'Second block' }, { id: 'c', text: 'Third block' }, ], } return ( block.id} getChildren={block => block.children} > {/* Defines how each block in the tree should be rendered */} {props => (
{/* Add data-drag-handle to elements that should initiate drag */}

{props.block.text}

{props.children}
)}
) } ``` -------------------------------- ### Customize BlockTree Dropzone Component Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This example illustrates how to provide a custom `Dropzone` component to the `BlockTree`. This allows for visual customization of the area where dragged blocks will be placed upon release. The component can be styled to fill the available space. ```tsx const Dropzone = () => (
Drop here
) {/* ... */} ``` -------------------------------- ### CopyEvent and Clipboard Data Handling Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Details the CopyEvent structure, including the blocks being copied and the DataTransfer object. Provides an example of how to set clipboard data for JSON and plain text formats. ```tsx type CopyEvent = { blocks: T[] // Blocks being copied data: DataTransfer // Clipboard data transfer object } onCopy={(event) => { const json = JSON.stringify(event.blocks) event.data.setData('application/json', json) event.data.setData('text/plain', `Copied ${event.blocks.length} blocks`) }} ``` -------------------------------- ### Configure Block Nesting with Tags in BlockTree Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This example demonstrates how to define and apply tags to control which blocks can be nested within others in a BlockTree. The `getOptions` function is used to specify the `tag` for a block and the types of blocks it `accepts` as children. ```tsx type MyBlock = { id: string type: 'container' | 'item' text: string children?: MyBlock[] } const root: MyBlock = { id: 'root', type: 'container', text: 'Root', children: [ { id: 'container', type: 'container', text: 'Container', children: [], }, { id: 'item1', type: 'item', text: 'Item', }, ], } block.id} getChildren={block => block.children} getOptions={block => ({ tag: block.type, accepts: block.type === 'container' ? ['item'] : [] })} > {/* ... */} ``` -------------------------------- ### PasteEvent Structure and Data Parsing Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Describes the PasteEvent, which includes the target placement for pasting and the DataTransfer object. Includes an example of parsing JSON data from the clipboard and preparing to insert blocks. ```tsx type PasteEvent = { place: Place // Where the data should be pasted data: DataTransfer // Clipboard data transfer object } onPaste={(event) => { const json = event.data.getData('application/json') if (json) { const blocks = JSON.parse(json) // Insert blocks at `event.place` } }} ``` -------------------------------- ### Manage BlockTree State with createBlockTree (SolidJS) Source: https://context7.com/rafferty97/solid-nest/llms.txt Utilizes the `createBlockTree` helper function to manage the state for the BlockTree component. This example demonstrates adding new blocks, updating block data via an input field, and integrating with the `BlockTree` component. It simplifies state management by providing event handlers directly. ```tsx import { createBlockTree, BlockTree } from 'solid-nest' import { createUniqueId } from 'solid-js' type MyBlock = { key: string data: string children?: MyBlock[] } function App() { const initialData: MyBlock = { key: 'root', data: '', children: [ { key: '1', data: 'Drag me' }, { key: '2', data: 'Or drag me' }, { key: '3', data: 'Reorder us!' }, ], } const props = createBlockTree(initialData) const addBlock = () => { props.onInsert({ place: { parent: props.root.key, before: null }, blocks: [{ key: createUniqueId(), data: 'New block' }], }) } const updateBlockData = (key: string, newData: string) => { props.updateBlock(key, { data: newData }) } return (
{block => (
updateBlockData(block.key, e.currentTarget.value)} onPointerDown={e => e.stopPropagation()} />
)}
) } ``` -------------------------------- ### Implement Draggable Block with Event Handling Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Shows how to make a block element draggable by adding the 'data-drag-handle' attribute. It also includes an example of preventing event propagation for focusable elements like inputs within a draggable block. ```tsx props => (

{props.block.text}

ev.stopPropagation()} />
) ``` -------------------------------- ### Customizing Solid-Nest Components: Dropzone, Placeholder, DragContainer (TypeScript/JSX) Source: https://context7.com/rafferty97/solid-nest/llms.txt Replace default Solid-Nest UI components for dropzones, placeholders, and drag containers with custom implementations. This example shows how to define and use custom React components for these elements to tailor the user interface and experience. Dependencies include 'solid-nest' and 'solid-js'. ```tsx import { BlockTree, createBlockTree, DragContainerProps } from 'solid-nest' import { Show } from 'solid-js' type MyBlock = { key: string text: string children?: MyBlock[] } const CustomDropzone = () => (
Drop here
) const CustomPlaceholder = (props: { parent: string }) => (
No items yet. Drag blocks here.
) const CustomDragContainer = (props: DragContainerProps) => (
{props.children} 1}>
{props.blocks.length}
) function App() { const props = createBlockTree({ key: 'root', text: '', children: [ { key: '1', text: 'Block 1', children: [] }, { key: '2', text: 'Block 2', children: [] }, ], }) return ( {block => (
{block.block.text}
{block.children}
)}
) } ``` -------------------------------- ### Custom Block Type Definition for solid-nest Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This example shows how to define a custom TypeScript type for your blocks when using the `solid-nest` library. The `BlockTree` component is flexible and does not enforce a specific block structure, allowing you to define properties like `id`, `text`, and `children` as needed. ```typescript type MyBlock = { id: string text: string children?: MyBlock[] } block.id} getChildren={block => block.children} > {/* ... */} ``` -------------------------------- ### BlockTree Component Configuration and Props Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This snippet illustrates the various props available for the `BlockTree` component in `solid-nest`. It covers essential props for defining the tree structure, handling selections, and managing events like insertion, reordering, and removal. ```tsx block.id} getChildren={block => block.children} getOptions={block => ({ spacing: 16, tag: 'item' })} // The currently selected blocks selection={{ blocks: ['key1', 'key2'] }} // Various event handlers; because this is a controlled component, // the state of the tree won't update unless these are handled onSelectionChange={event => {}} onInsert={event => {}} onReorder={event => {}} onRemove={event => {}} // ...various additional events and configuration props, documented below > {/* A function to render each block in the tree */} {props => } ``` -------------------------------- ### Selection Types Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Explains the structure of the `Selection` object used for tracking selected blocks or insertion points. ```APIDOC ## Selection Types ### Description This section describes the `Selection` type, which represents the current selection state within the `BlockTree`, including selected blocks or insertion points. ### Method N/A (Type Definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Type Definition ```ts type Selection = { blocks?: K[] place?: Place } ``` ### Notes A `Selection` can represent either a set of blocks or a specific insertion place, but not both simultaneously. ``` -------------------------------- ### BlockTree Props API Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This section details the various props accepted by the BlockTree component for configuration and behavior. ```APIDOC ## BlockTree Props API ### Description The `BlockTree` component accepts a range of props to customize its functionality, including data handling, event management, and visual appearance. ### Method N/A (Component Props) ### Endpoint N/A (Component) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Props Table | Prop | Type | Default | Description | |------|------|---------|-------------| | `root` | `R` | *required* | The root block of the tree | | `children` | `Component>` | *required* | Render function for blocks | | `getKey` | `(block: T | R) => K` | *required* | Function to get a block's unique key | | `getChildren` | `(block: T | R) => T[] | null | undefined` | | Function to get a block's children | | `getOptions` | `(block: T | R) => BlockOptions | null | undefined` | | Function to get a block's options | | `selection` | `Selection` | | Current selection | | `onSelectionChange` | `(event: SelectionEvent) => void` | | Called when selection changes | | `onInsert` | `EventHandler>` | | Called when blocks are inserted | | `onReorder` | `EventHandler>` | | Called when blocks are reordered | | `onRemove` | `EventHandler>` | | Called when blocks are removed | | `onCopy` | `EventHandler>` | | Called when blocks are copied | | `onCut` | `EventHandler>` | | Called when blocks are cut | | `onPaste` | `EventHandler>` | | Called when blocks are pasted | | `transitionDuration` | `number` | `200` | Animation duration (ms) | | `dragThreshold` | `number` | `10` | Distance cursor must move (px) to start drag | | `fixedHeightWhileDragging` | `boolean` | `false` | Fix container height during drag operations | | `multiselect` | `boolean` | `true` | Enable multi-selection | | `dropzone` | `Component<{}>` | | Custom dropzone component | | `placeholder` | `Component<{ parent: K }>` | | Custom placeholder component | | `dragContainer` | `Component>` | | Custom drag container component | ``` -------------------------------- ### Block Options Type Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Defines the structure for block-specific configuration options returned by `getOptions`. ```APIDOC ## Block Options Type ### Description The `BlockOptions` type specifies the configuration settings that can be provided for individual blocks within the `BlockTree`. ### Method N/A (Type Definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Type Definition ```ts type BlockOptions = { spacing?: number // Spacing between children (in pixels) tag?: string // Tag for drag-and-drop constraints accepts?: string[] // Array of tags this block accepts as children } ``` ``` -------------------------------- ### Block Render Props Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Details the props passed to the custom render function for each block. ```APIDOC ## Block Render Props ### Description Describes the props provided to the custom render function for each block in the `BlockTree`, enabling detailed control over block appearance and behavior. ### Method N/A (Render Function Props) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```tsx props => (

{props.block.text}

ev.stopPropagation()} />
) ``` ### Response #### Success Response (200) N/A #### Response Example N/A ### Props Table | Prop | Type | Description | |------|------|-------------| | `key` | `K` | Block's unique key | | `block` | `T` | The block data | | `selected` | `boolean` | Whether block is currently selected | | `dragging` | `boolean` | Whether block is being dragged | | `children` | `JSX.Element` | Rendered child blocks | ### Notes - The `children` prop should be rendered to display nested blocks. - To allow elements within a block to receive focus (e.g., input fields), use `event.stopPropagation()` on the `onPointerDown` event handler to prevent the block itself from being selected. ``` -------------------------------- ### Render BlockTree with Custom UI (SolidJS) Source: https://context7.com/rafferty97/solid-nest/llms.txt Demonstrates how to use the BlockTree component to render a hierarchical structure. It includes drag-and-drop handles, selection styling, and basic event handling for selection, reordering, and removal. Customizes the appearance of each block based on its selected and dragging state. ```tsx import { BlockTree, createBlockTree } from 'solid-nest' import { createSignal } from 'solid-js' type MyBlock = { key: string text: string children?: MyBlock[] } function App() { const root: MyBlock = { key: 'root', text: 'Root', children: [ { key: 'a', text: 'First block' }, { key: 'b', text: 'Second block', children: [ { key: 'c', text: 'Nested block' } ]}, ], } const [selection, setSelection] = createSignal<{ blocks?: string[] }>({}) return ( block.key} getChildren={block => block.children} selection={selection()} onSelectionChange={event => { if (event.kind === 'blocks') { setSelection({ blocks: event.blocks }) } else if (event.kind === 'deselect') { setSelection({}) } }} onReorder={event => { console.log('Reorder blocks:', event.keys, 'to:', event.place) }} onRemove={event => { console.log('Remove blocks:', event.keys) }} > {props => (

{props.block.text}

{props.children}
)}
) } ``` -------------------------------- ### Customize BlockTree Placeholder Component Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This code snippet shows how to replace the default `Placeholder` component in `BlockTree` with a custom implementation. The custom component receives the parent block's key and can be used to display custom messages or UI elements when a block has no children. ```tsx const Placeholder = ({ parent }) => (
No items in {parent}
) {/* ... */} ``` -------------------------------- ### Handle Block Selection in Solid-Nest (TypeScript/React) Source: https://context7.com/rafferty97/solid-nest/llms.txt Demonstrates how to manage block selection modes (single, multi, range) using the BlockTree component in Solid-Nest. It utilizes the `selection` and `onSelectionChange` props to track and update selected blocks or insertion points. Dependencies include 'solid-nest'. ```tsx import { BlockTree, Selection, SelectionEvent } from 'solid-nest' type MyBlock = { key: string text: string children?: MyBlock[] } function App() { const [root, setRoot] = createSignal({ key: 'root', text: '', children: [ { key: '1', text: 'Click me' }, { key: '2', text: 'Cmd+Click to multi-select' }, { key: '3', text: 'Shift+Click for range select' }, ] }) const [selection, setSelection] = createSignal>({}) const handleSelectionChange = (event: SelectionEvent) => { if (event.kind === 'blocks') { console.log('Selection mode:', event.mode) // 'set', 'toggle', or 'range' console.log('Selected blocks:', event.blocks) setSelection({ blocks: event.blocks }) } else if (event.kind === 'place') { console.log('Selected insertion point:', event.place) setSelection({ place: event.place }) } else if (event.kind === 'deselect') { console.log('Deselected') setSelection({}) } } return ( block.key} getChildren={block => block.children} selection={selection()} onSelectionChange={handleSelectionChange} multiselect={true} > {props => (
{props.block.text}
)}
) } ``` -------------------------------- ### Handle Reordering, Insertion, and Removal Events in Solid-Nest (TypeScript) Source: https://context7.com/rafferty97/solid-nest/llms.txt Demonstrates how to manage reorder, insert, and remove events using Solid-Nest's BlockTree component. It utilizes SolidJS's createStore and produce for immutable state updates. The functions findBlock, removeBlocks, and insertBlocks are custom helpers for data manipulation. ```tsx import { BlockTree, ReorderEvent, InsertEvent, RemoveEvent, Place } from 'solid-nest' import { createStore, produce } from 'solid-js/store' type MyBlock = { key: string text: string children?: MyBlock[] } function App() { const [root, setRoot] = createStore({ key: 'root', text: '', children: [ { key: '1', text: 'Item 1', children: [] }, { key: '2', text: 'Item 2', children: [] }, ], }) const findBlock = (block: MyBlock, key: string): MyBlock | undefined => { if (block.key === key) return block for (const child of block.children ?? []) { const result = findBlock(child, key) if (result) return result } return undefined } const removeBlocks = (block: MyBlock, keys: string[], collected: MyBlock[] = []): MyBlock[] => { block.children = block.children?.filter(child => { if (keys.includes(child.key)) { collected.push(child) return false } removeBlocks(child, keys, collected) return true }) return collected } const insertBlocks = (block: MyBlock, blocks: MyBlock[], place: Place) => { const parent = findBlock(block, place.parent) if (!parent) return parent.children ??= [] if (place.before !== null) { const index = parent.children.findIndex(c => c.key === place.before) parent.children.splice(index, 0, ...blocks) } else { parent.children.push(...blocks) } } const handleReorder = (event: ReorderEvent) => { setRoot(produce(root => { const blocks = removeBlocks(root, event.keys) insertBlocks(root, blocks, event.place) })) } const handleInsert = (event: InsertEvent) => { setRoot(produce(root => { insertBlocks(root, event.blocks, event.place) })) } const handleRemove = (event: RemoveEvent) => { setRoot(produce(root => { removeBlocks(root, event.keys) })) } return ( block.key} getChildren={block => block.children} onReorder={handleReorder} onInsert={handleInsert} onRemove={handleRemove} > {props => (
{props.block.text}
{props.children}
)}
) } ``` -------------------------------- ### EventHandler Type Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Defines the generic `EventHandler` type used for callbacks in the BlockTree component. ```APIDOC ## EventHandler Type ### Description This section defines the `EventHandler` type, which is a generic function signature used for all event callbacks within the `BlockTree` component. ### Method N/A (Type Definition) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ### Type Definition ```ts export type EventHandler = (event: E) => void ``` ``` -------------------------------- ### ReorderEvent Structure Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Defines the structure for ReorderEvent, which is triggered when blocks are reordered using drag-and-drop. It includes the keys of the moved blocks and their new placement. ```tsx type ReorderEvent = { keys: K[] // Keys of blocks being moved place: { parent: K // Parent block key before: K | null // Insert before this key, or `null` for end } } ``` -------------------------------- ### CutEvent Structure Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Defines the CutEvent, similar to CopyEvent, containing the blocks being cut and the DataTransfer object. It's typically followed by block removal. ```tsx type CutEvent = { blocks: T[] // Blocks being cut data: DataTransfer // Clipboard data transfer object } ``` -------------------------------- ### Clipboard Operations with Custom Data Formats in Solid-Nest (TypeScript/JSX) Source: https://context7.com/rafferty97/solid-nest/llms.txt Implement copy, cut, and paste functionalities using custom MIME types for clipboard data. This involves defining handlers for CopyEvent, CutEvent, and PasteEvent to serialize and deserialize block data, allowing for rich clipboard interactions. It requires the 'solid-nest' library. ```tsx import { BlockTree, createBlockTree, CopyEvent, CutEvent, PasteEvent } from 'solid-nest' type MyBlock = { key: string text: string children?: MyBlock[] } function App() { const props = createBlockTree({ key: 'root', text: '', children: [ { key: '1', text: 'Select and copy me (Cmd+C)' }, { key: '2', text: 'Or cut me (Cmd+X)' }, { key: '3', text: 'Then paste (Cmd+V)' }, ], }) const handleCopy = (event: CopyEvent) => { const json = JSON.stringify(event.blocks) const plainText = event.blocks.map(b => b.text).join('\n') event.data.setData('application/json', json) event.data.setData('text/plain', plainText) console.log('Copied blocks:', event.blocks) } const handleCut = (event: CutEvent) => { const json = JSON.stringify(event.blocks) const plainText = event.blocks.map(b => b.text).join('\n') event.data.setData('application/json', json) event.data.setData('text/plain', plainText) // Remove the cut blocks const keys = event.blocks.map(b => b.key) props.onRemove({ keys }) console.log('Cut blocks:', event.blocks) } const handlePaste = (event: PasteEvent) => { const json = event.data.getData('application/json') if (json) { try { const blocks = JSON.parse(json) as MyBlock[] // Generate new keys for pasted blocks const newBlocks = blocks.map(block => ({ ...block, key: crypto.randomUUID(), })) props.onInsert({ blocks: newBlocks, place: event.place, }) console.log('Pasted blocks at:', event.place) } catch (error) { console.error('Failed to parse clipboard data:', error) } } } return ( {props => (
{props.block.text}
)}
) } ``` -------------------------------- ### Implement Tag-Based Nesting Constraints in Solid-Nest (TypeScript/React) Source: https://context7.com/rafferty97/solid-nest/llms.txt Shows how to enforce nesting rules in Solid-Nest by defining `tag` and `accepts` properties within the `getOptions` function. This allows specific block types to contain only certain other block types. Dependencies include 'solid-nest'. ```tsx import { BlockTree, createBlockTree, BlockOptions } from 'solid-nest' type MyBlock = { key: string type: 'container' | 'item' text: string children?: MyBlock[] } function App() { const root: MyBlock = { key: 'root', type: 'container', text: '', children: [ { key: '1', type: 'container', text: 'Container (accepts items only)', children: [] }, { key: '2', type: 'item', text: 'Item 1' }, { key: '3', type: 'item', text: 'Item 2' }, ], } const props = createBlockTree(root) const getOptions = (block: MyBlock): BlockOptions => { if (block.type === 'container') { return { spacing: 16, tag: 'container', accepts: ['item'] // Only accepts items, not other containers } } else { return { spacing: 12, tag: 'item', accepts: [] // Items cannot contain children } } } return ( {props => (
{props.block.type}: {props.block.text} {props.block.type === 'container' && (
{props.children}
)}
)}
) } ``` -------------------------------- ### InsertEvent Structure Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Represents an event fired when new blocks are inserted into the BlockTree. It contains the blocks being inserted and the target placement information (parent and before key). ```tsx type InsertEvent = { blocks: T[] // Blocks being inserted place: { parent: K // Parent block key before: K | null // Insert before this key, or `null` for end } } ``` -------------------------------- ### Define Block Options Type in TypeScript Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Defines the structure for block-specific configuration options, including spacing, drag-and-drop tags, and accepted child tags. This type is used by the getOptions prop of the BlockTree component. ```tsx type BlockOptions = { spacing?: number // Spacing between children (in pixels) tag?: string // Tag for drag-and-drop constraints accepts?: string[] // Array of tags this block accepts as children } ``` -------------------------------- ### Customize BlockTree DragContainer Component Source: https://github.com/rafferty97/solid-nest/blob/main/README.md This code provides a custom `DragContainer` component for the `BlockTree`. This component wraps the blocks being dragged and can be used to alter the drag visual feedback. It receives the dragged blocks and their rendered children, allowing for custom elements like item count badges. ```tsx const DragContainer = (props: DragContainerProps) => (
{props.children} 1}> {props.blocks.length} items
) {/* ... */} ``` -------------------------------- ### SelectionEvent Types and Structure Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Defines the discriminated union type for SelectionEvent, which can represent block selection, gap clicks, or deselection. It includes properties like kind, key, mode, blocks, and place, depending on the event variant. ```tsx type SelectionEvent = | { kind: 'blocks' // A block was clicked key: K // The block that was clicked mode: SelectionMode // The selection mode (explained below) blocks: K[] // The new set of selected blocks } | { kind: 'place' // A gap between blocks was clicked place: Place // The insertion point that was clicked } | { kind: 'deselect' // Focus was lost from the block tree } ``` -------------------------------- ### Define Selection Type in TypeScript Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Defines the structure for representing the selection state within the BlockTree. A selection can consist of an array of block keys or a specific placement for insertion, but not both simultaneously. ```ts type Selection = { blocks?: K[] place?: Place } ``` -------------------------------- ### Define Generic Event Handler Type Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Defines a generic EventHandler type, which is a callback function that accepts an event object of a specific type E. This is used for various event props in the BlockTree component. ```ts export type EventHandler = (event: E) => void ``` -------------------------------- ### RemoveEvent Structure Source: https://github.com/rafferty97/solid-nest/blob/main/README.md Represents the RemoveEvent, fired when blocks are removed from the tree. It simply contains an array of the keys of the blocks that were removed. ```tsx type RemoveEvent = { keys: K[] // Keys of blocks being removed } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.