## class: `WyFileGrid`, `wy-file-grid`

Grid view renderer for files (card view).

**Used sub components:**

*   [`<wy-file-menu>`](./wy-file-menu)
*   [`<wy-icon>`](./ui/wy-icon)
*   [`<wy-button>`](./ui/wy-button)

### Fields

| Name    | Type                      | Default | Description                   | Inherited From |
| ------- | ------------------------- | ------- | ----------------------------- | -------------- |
| `files` | `FileType[] \| undefined` |         | Files to display in the grid. |                |

### Methods

| Name                    | Description                                                          | Parameters                                      | Return                       | Inherited From    |
| ----------------------- | -------------------------------------------------------------------- | ----------------------------------------------- | ---------------------------- | ----------------- |
| `dispatchFileOpen`      | Emit a \`file-open\` event requesting preview for the given file.    | `fileId: number, tab: "comments" \| "versions"` |                              |                   |
| `dispatchOrder`         | Emit an \`order\` event with the selected sort order.                | `order: FileOrderType`                          |                              |                   |
| `dispatchEditName`      | Emit an \`edit-name\` event to enter rename mode for the given file. | `file: FileType`                                |                              |                   |
| `dispatchRename`        | Emit a \`rename\` event containing the updated file name.            | `file: FileType, name: string`                  |                              |                   |
| `dispatchTrash`         | Emit a \`trash\` event to move the file to the recycle bin.          | `file: FileType`                                |                              |                   |
| `dispatchRestore`       | Emit a \`restore\` event to recover a trashed file.                  | `file: FileType`                                |                              |                   |
| `dispatchDeleteForever` | Emit a \`delete-forever\` event to permanently remove a file.        | `file: FileType`                                |                              |                   |
| `dispatchSubscribe`     | Emit a \`subscribe\` event toggling file subscription.               | `file: FileType, subscribe: boolean`            |                              |                   |
| `whenReady`             | Resolves when the component has rendered first time.                 |                                                 | `Promise<WeavySubComponent>` | WeavySubComponent |

### Events

| Name             | Type                            | Description                                      | Inherited From    |
| ---------------- | ------------------------------- | ------------------------------------------------ | ----------------- |
| `file-open`      | `FileOpenEventType`             | Emitted when a file should be opened in preview. |                   |
| `order`          | `OrderEventType<FileOrderType>` | Emitted when the user changes sort order.        |                   |
| `edit-name`      | `FileEditNameEventType`         | Emitted when rename mode is activated.           |                   |
| `rename`         | `FileRenameEventType`           | Emitted when a file is renamed.                  |                   |
| `trash`          | `FileTrashEventType`            | Emitted when a file is trashed.                  |                   |
| `restore`        | `FileRestoreEventType`          | Emitted when a file is restored.                 |                   |
| `delete-forever` | `FileDeleteForeverEventType`    | Emitted when a file is permanently deleted.      |                   |
| `subscribe`      | `FileSubscribeEventType`        | Emitted when subscribe state is toggled.         |                   |
| `ready`          | `CustomEvent`                   | When the component has rendered.                 | WeavySubComponent |

### CSS Parts

| Name                  | Description                    |
| --------------------- | ------------------------------ |
| `wy-grid`             | Card grid layout               |
| `wy-card`             | Card root container            |
| `wy-trashed`          | Modifier for trashed cards     |
| `wy-card-hover`       | Hoverable card modifier        |
| `wy-highlight`        | Highlighted card modifier      |
| `wy-card-actions`     | Container for per-card actions |
| `wy-card-image`       | Thumbnail image area           |
| `wy-card-image-top`   | Modifier for image top area    |
| `wy-card-icon`        | Icon area for non-image files  |
| `wy-card-title`       | Card title area                |
| `wy-card-text`        | Text in the card               |
| `wy-card-button-icon` | Title action / badge           |
| `wy-badge`            | Badge used for comment counts  |

<details><summary>Private API</summary>

### Fields

| Name                | Privacy | Type                                                  | Default                                                              | Description | Inherited From    |
| ------------------- | ------- | ----------------------------------------------------- | -------------------------------------------------------------------- | ----------- | ----------------- |
| `#resolveContextId` | private | `(contextId: ContextIdType) => void \| undefined`     |                                                                      |             | WeavySubComponent |
| `#whenContextId`    | private |                                                       | `new Promise<ContextIdType>((r) => { this.#resolveContextId = r; })` |             | WeavySubComponent |
| `#resolveUser`      | private | `(user: UserType) => void \| undefined`               |                                                                      |             | WeavySubComponent |
| `#whenUser`         | private |                                                       | `new Promise<UserType>((r) => { this.#resolveUser = r; })`           |             | WeavySubComponent |
| `#resolveWeavy`     | private | `(weavy: WeavyType) => void \| undefined`             |                                                                      |             | WeavySubComponent |
| `#whenWeavy`        | private |                                                       | `new Promise<WeavyType>((r) => { this.#resolveWeavy = r; })`         |             | WeavySubComponent |
| `#resolveReady`     | private | `(component: WeavySubComponent) => void \| undefined` |                                                                      |             | WeavySubComponent |
| `#whenReady`        | private |                                                       | `new Promise<WeavySubComponent>((r) => { this.#resolveReady = r; })` |             | WeavySubComponent |

</details>

<hr/>

## Exports

| Kind                        | Name           | Declaration | Module                         | Package |
| --------------------------- | -------------- | ----------- | ------------------------------ | ------- |
| `js`                        | `WyFileGrid`   | WyFileGrid  | lib/components/wy-file-grid.ts |         |
| `custom-element-definition` | `wy-file-grid` | WyFileGrid  | lib/components/wy-file-grid.ts |         |
