# @birchui/svelte API reference

> Svelte components and actions for Birch UI

```bash
npm install @birchui/svelte
```

## @birchui/svelte

### createSvelteAction

Kind: function. Import from `@birchui/svelte`.

```ts
function createSvelteAction<TOptions, TEvents extends object, TWidget extends Widget<TOptions, TEvents>>(definition: WidgetDefinition<TOptions, TEvents, TWidget>): WidgetAction<TOptions, TEvents, TWidget>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `definition` | `WidgetDefinition<TOptions, TEvents, TWidget>` |  |

### toActionParams

Kind: function. Import from `@birchui/svelte`.

```ts
function toActionParams<TOptions, TEvents extends object, TWidget extends Widget<TOptions, TEvents>>(definition: WidgetDefinition<TOptions, TEvents, TWidget>, props: Record<string, unknown>): WidgetActionParams<TOptions, TEvents, TWidget>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `definition` | `WidgetDefinition<TOptions, TEvents, TWidget>` |  |
| `props` | `Record<string, unknown>` |  |

### birchGrid

Kind: const. Import from `@birchui/svelte`.

```ts
const birchGrid: WidgetAction<GridOptions<any>, GridEvents<any>, GridApi<any>>
```

### BirchGrid

Kind: const. Import from `@birchui/svelte`.

```ts
const BirchGrid: BirchGridComponent
```

### BirchGridComponent

Kind: interface. Import from `@birchui/svelte`.

```ts
interface BirchGridComponent
<TRow = RowData>(this: void, internals: ComponentInternals, props: BirchGridProps<TRow>): ReturnType<Component<BirchGridProps<TRow>>>
```

| Property | Type | Description |
| --- | --- | --- |
| `element?` | `typeof HTMLElement` |  |
| `z_$$bindings?` | `'api'` |  |

### WidgetActionReturn

Kind: interface. Import from `@birchui/svelte`.

```ts
interface WidgetActionReturn<TParams>
```

| Property | Type | Description |
| --- | --- | --- |
| `update` | `(params: TParams) => void` |  |
| `destroy` | `() => void` |  |

### BirchComponentProps

Kind: type. Import from `@birchui/svelte`.

```ts
type BirchComponentProps<TOptions, TEvents extends object, TWidget> = TOptions &
  EventHandlerProps<TEvents> & {
    class?: string;
    style?: string;
    api?: TWidget | null;
  };
```

### BirchGridProps

Kind: type. Import from `@birchui/svelte`.

```ts
type BirchGridProps<TRow = RowData> = BirchComponentProps<GridOptions<TRow>, GridEvents<TRow>, GridApi<TRow>>;
```

### ComponentPropsOf

Kind: type. Import from `@birchui/svelte`.

```ts
type ComponentPropsOf<TDefinition> =
  TDefinition extends WidgetDefinition<infer TOptions, infer TEvents, infer TWidget>
    ? BirchComponentProps<TOptions, TEvents, TWidget>
    : never;
```

### EventHandlerProps

Kind: type. Import from `@birchui/svelte`.

```ts
type EventHandlerProps<TEvents extends object> = {
  [K in keyof TEvents & string as `on${Capitalize<K>}`]?: (payload: TEvents[K]) => void;
};
```

### EventHandlers

Kind: type. Import from `@birchui/svelte`.

```ts
type EventHandlers<TEvents extends object> = {
  [K in keyof TEvents]?: (payload: TEvents[K]) => void;
};
```

### WidgetAction

Kind: type. Import from `@birchui/svelte`.

```ts
type WidgetAction<TOptions, TEvents extends object, TWidget> = (
  node: HTMLElement,
  params: WidgetActionParams<TOptions, TEvents, TWidget>,
) => WidgetActionReturn<WidgetActionParams<TOptions, TEvents, TWidget>>;
```

### WidgetActionParams

Kind: type. Import from `@birchui/svelte`.

```ts
type WidgetActionParams<TOptions, TEvents extends object, TWidget> = TOptions & {
  on?: EventHandlers<TEvents>;
  onReady?: (api: TWidget) => void;
};
```

## @birchui/svelte/document

### birchDocumentEditor

Kind: const. Import from `@birchui/svelte/document`.

```ts
const birchDocumentEditor: WidgetAction<DocumentEditorOptions, DocumentEditorEvents, DocumentEditorApi>
```

### BirchDocumentEditor

Kind: const. Import from `@birchui/svelte/document`.

```ts
const BirchDocumentEditor: Component<BirchDocumentEditorProps, object, 'api'>
```

### BirchDocumentEditorProps

Kind: type. Import from `@birchui/svelte/document`.

```ts
type BirchDocumentEditorProps = BirchComponentProps<
  DocumentEditorOptions,
  DocumentEditorEvents,
  DocumentEditorApi
>;
```

## @birchui/svelte/pdf

### birchPdfViewer

Kind: const. Import from `@birchui/svelte/pdf`.

```ts
const birchPdfViewer: WidgetAction<PdfViewerOptions, PdfViewerEvents, PdfViewerApi>
```

### BirchPdfViewer

Kind: const. Import from `@birchui/svelte/pdf`.

```ts
const BirchPdfViewer: Component<BirchPdfViewerProps, object, 'api'>
```

### BirchPdfViewerProps

Kind: type. Import from `@birchui/svelte/pdf`.

```ts
type BirchPdfViewerProps = BirchComponentProps<PdfViewerOptions, PdfViewerEvents, PdfViewerApi>;
```

## @birchui/svelte/scheduler

### birchScheduler

Kind: const. Import from `@birchui/svelte/scheduler`.

```ts
const birchScheduler: WidgetAction<SchedulerOptions<SchedulerEvent, SchedulerResource>, SchedulerEvents<SchedulerEvent, SchedulerResource>, SchedulerApi<SchedulerEvent, SchedulerResource>>
```

### BirchScheduler

Kind: const. Import from `@birchui/svelte/scheduler`.

```ts
const BirchScheduler: Component<BirchSchedulerProps, object, 'api'>
```

### BirchSchedulerProps

Kind: type. Import from `@birchui/svelte/scheduler`.

```ts
type BirchSchedulerProps = ComponentPropsOf<typeof schedulerDefinition>;
```
