# @birchui/element API reference

> Birch UI custom elements

```bash
npm install @birchui/element
```

## @birchui/element

### createElementClass

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

```ts
function createElementClass<TOptions, TEvents extends object, TWidget extends Widget<TOptions, TEvents>, TKey extends keyof TOptions & string = never>(definition: WidgetDefinition<TOptions, TEvents, TWidget>, config: ElementConfig<TOptions, TKey> = {}): BirchElementConstructor<BirchElementInstance<TOptions, TEvents, TWidget, TKey>>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `definition` | `WidgetDefinition<TOptions, TEvents, TWidget>` |  |
| `config?` | `ElementConfig<TOptions, TKey>` |  |

### createElementRegistration

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

```ts
function createElementRegistration<TOptions, TEvents extends object, TWidget extends Widget<TOptions, TEvents>, TKey extends keyof TOptions & string = never>(definition: WidgetDefinition<TOptions, TEvents, TWidget>, config: ElementConfig<TOptions, TKey> = {}): ElementRegistration<BirchElementInstance<TOptions, TEvents, TWidget, TKey>>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `definition` | `WidgetDefinition<TOptions, TEvents, TWidget>` |  |
| `config?` | `ElementConfig<TOptions, TKey>` |  |

### defineBirchGrid

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

```ts
function defineBirchGrid(tagName: string = gridDefinition.tagName): BirchElementConstructor<BirchGridElement> | undefined
```

| Parameter | Type | Description |
| --- | --- | --- |
| `tagName?` | `string` |  |

### getBirchGridElement

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

```ts
function getBirchGridElement(): BirchElementConstructor<BirchGridElement>
```

### GRID_ATTRIBUTES

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

```ts
const GRID_ATTRIBUTES: { readonly theme: "string"; readonly density: "string"; readonly 'row-height': "number"; readonly 'header-height': "number"; readonly 'quick-filter': "string"; readonly 'license-key': "string"; readonly locale: "string"; }
```

### GRID_OPTION_KEYS

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

```ts
const GRID_OPTION_KEYS: readonly ["columns", "rows", "getRowId", "rowHeight", "headerHeight", "floatingFilters", "quickFilter", "sort", "multiSort", "filterModel", "rowSelection", "checkboxSelection", "pagination", "theme", "density", "defaultColumn", "modules", "licenseKey", "overscanRows", "overscanColumns", "rowClass", "emptyMessage", "injectStyles", "locale", "stripes", "groupBy", "groupDefaultExpanded", "groupPanel", "groupColumn", "groupTotals", "treeData", "getDataPath", "getParentId", "pivot", "rangeSelection", "fillHandle", "clipboard", "statusBar", "masterDetail"]
```

### BirchElement

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

```ts
interface BirchElement<TOptions, TEvents extends object, TWidget> extends HTMLElement
```

| Property | Type | Description |
| --- | --- | --- |
| `options` | `Partial<TOptions>` |  |
| `readonly api` | `TWidget \| null` |  |
| `set` | `<K extends keyof TOptions>(key: K, value: TOptions[K] \| undefined) => void` |  |
| `create` | `() => TWidget \| null` |  |
| `addEventListener` | `<K extends keyof ElementEventMap<TEvents>>(type: K, listener: (this: this, event: ElementEventMap<TEvents>[K]) => unknown, options?: boolean \| AddEventListenerOptions) => void \| (type: string, listener: EventListenerOrEventListenerObject, options?: boolean \| AddEventListenerOptions) => void` | The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) |
| `removeEventListener` | `<K extends keyof ElementEventMap<TEvents>>(type: K, listener: (this: this, event: ElementEventMap<TEvents>[K]) => unknown, options?: boolean \| EventListenerOptions) => void \| (type: string, listener: EventListenerOrEventListenerObject, options?: boolean \| EventListenerOptions) => void` | The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) |

### BirchElementConstructor

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

```ts
interface BirchElementConstructor<TInstance extends HTMLElement>
new (): TInstance
```

| Property | Type | Description |
| --- | --- | --- |
| `readonly prototype` | `TInstance` |  |
| `readonly observedAttributes` | `readonly string[]` |  |

### ElementConfig

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

```ts
interface ElementConfig<TOptions, TKey extends keyof TOptions & string = never>
```

| Property | Type | Description |
| --- | --- | --- |
| `optionKeys?` | `readonly TKey[]` |  |
| `attributes?` | `Readonly<Record<string, AttributeType>>` |  |
| `requiredOptions?` | `readonly (keyof TOptions & string)[]` |  |

### ElementRegistration

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

```ts
interface ElementRegistration<TInstance extends HTMLElement>
```

| Property | Type | Description |
| --- | --- | --- |
| `getElement` | `() => BirchElementConstructor<TInstance>` |  |
| `define` | `(tagName?: string) => BirchElementConstructor<TInstance> \| undefined` |  |

### AttributeType

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

```ts
type AttributeType = 'string' | 'number' | 'boolean';
```

### BirchElementInstance

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

```ts
type BirchElementInstance<
  TOptions,
  TEvents extends object,
  TWidget,
  TKey extends keyof TOptions & string = never,
> = BirchElement<TOptions, TEvents, TWidget> & { [K in TKey]: TOptions[K] | undefined };
```

### BirchGridElement

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

```ts
type BirchGridElement<TRow = RowData> = BirchElementInstance<
  GridOptions<TRow>,
  GridEvents<TRow>,
  GridApi<TRow>,
  GridElementOptionKey
>;
```

### ElementEventMap

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

```ts
type ElementEventMap<TEvents extends object> = HTMLElementEventMap & {
  [K in keyof TEvents & string as KebabCase<K>]: CustomEvent<TEvents[K]>;
};
```

### ElementInstanceOf

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

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

### GridElementOptionKey

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

```ts
type GridElementOptionKey = (typeof GRID_OPTION_KEYS)[number];
```

### KebabCase

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

```ts
type KebabCase<S extends string> = S extends `${infer Head}${infer Tail}`
  ? `${Head extends Lowercase<Head> ? Head : `-${Lowercase<Head>}`}${KebabCase<Tail>}`
  : S;
```

## @birchui/element/document

### defineBirchDocumentEditor

Kind: function. Import from `@birchui/element/document`.

```ts
function defineBirchDocumentEditor(tagName: string = documentEditorDefinition.tagName): BirchElementConstructor<BirchDocumentEditorElement> | undefined
```

| Parameter | Type | Description |
| --- | --- | --- |
| `tagName?` | `string` |  |

### getBirchDocumentEditorElement

Kind: function. Import from `@birchui/element/document`.

```ts
function getBirchDocumentEditorElement(): BirchElementConstructor<BirchDocumentEditorElement>
```

### BirchDocumentEditorElement

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

```ts
type BirchDocumentEditorElement = BirchElementInstance<
  DocumentEditorOptions,
  DocumentEditorEvents,
  DocumentEditorApi
>;
```

## @birchui/element/pdf

### defineBirchPdfViewer

Kind: function. Import from `@birchui/element/pdf`.

```ts
function defineBirchPdfViewer(tagName: string = pdfViewerDefinition.tagName): BirchElementConstructor<BirchPdfViewerElement> | undefined
```

| Parameter | Type | Description |
| --- | --- | --- |
| `tagName?` | `string` |  |

### getBirchPdfViewerElement

Kind: function. Import from `@birchui/element/pdf`.

```ts
function getBirchPdfViewerElement(): BirchElementConstructor<BirchPdfViewerElement>
```

### BirchPdfViewerElement

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

```ts
type BirchPdfViewerElement = BirchElementInstance<PdfViewerOptions, PdfViewerEvents, PdfViewerApi>;
```

## @birchui/element/scheduler

### defineBirchScheduler

Kind: function. Import from `@birchui/element/scheduler`.

```ts
function defineBirchScheduler(tagName: string = schedulerDefinition.tagName): BirchElementConstructor<BirchSchedulerElement> | undefined
```

| Parameter | Type | Description |
| --- | --- | --- |
| `tagName?` | `string` |  |

### getBirchSchedulerElement

Kind: function. Import from `@birchui/element/scheduler`.

```ts
function getBirchSchedulerElement(): BirchElementConstructor<BirchSchedulerElement>
```

### BirchSchedulerElement

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

```ts
type BirchSchedulerElement = ElementInstanceOf<typeof schedulerDefinition>;
```
