## class: `WyFileMenu`, `wy-file-menu`

File actions, with Publish and Discard while editing. Publish is disabled until the editor has produced a draft,
and Discard both drops the draft and leaves edit mode, so it doubles as the way to close an unchanged edit.

In preview mode with an unsaved draft, the dropdown starts with Publish and Discard, which act on the draft
without opening the editor, and the toolbar has a single "Continue editing" button while the draft itself is the
viewed entry (`draftActive`); a stored version viewed alongside the draft gets no toolbar button. Without a draft,
editing starts from
the Edit item first in the dropdown instead, which is hidden while an older version (`oldVersionActive`) is viewed
since editing always starts from the current version. Comments are a toolbar button without a draft and move
into the dropdown while a draft exists, so the toolbar holds only "Continue editing" then.

**Used sub components:**

*   [`<wy-dropdown>`](./ui/wy-dropdown)
*   [`<wy-dropdown-item>`](./ui/wy-dropdown)
*   [`<wy-dropdown-divider>`](./ui/wy-dropdown)
*   [`<wy-icon>`](./ui/wy-icon)

### Fields

| Name               | Type                         | Default                                                                                                                      | Description                                                                                                                                                                                                                                                                                                      | Inherited From |
| ------------------ | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
| `file`             | `FileType \| undefined`      |                                                                                                                              | File to operate on when rendering menu actions.                                                                                                                                                                                                                                                                  |                |
| `small`            | `boolean`                    | `false`                                                                                                                      | Render the dropdown using compact button styling.                                                                                                                                                                                                                                                                |                |
| `hasEdit`          | `boolean`                    | `false`                                                                                                                      |                                                                                                                                                                                                                                                                                                                  |                |
| `hasComments`      | `boolean`                    | `false`                                                                                                                      |                                                                                                                                                                                                                                                                                                                  |                |
| `hasVersions`      | `boolean`                    | `false`                                                                                                                      |                                                                                                                                                                                                                                                                                                                  |                |
| `hasSubscribe`     | `boolean`                    | `true`                                                                                                                       | Whether the subscribe/unsubscribe item may be shown. Defaults to true since the item is otherwise gated by&#xA;a \`subscribe\` listener; set to false for attachments, which cannot be subscribed to on their own.                                                                                               |                |
| `hasRename`        | `boolean`                    | `true`                                                                                                                       | Whether the rename item may be shown. Defaults to true since the item is otherwise gated by an \`edit-name\`&#xA;listener and the file rename feature; set to false for attachments, which inherit the features of the block&#xA;that opened them (e.g. file rename from the Files block) but are not renamable. |                |
| `editActive`       | `boolean`                    | `false`                                                                                                                      | Indicates edit mode if available.                                                                                                                                                                                                                                                                                |                |
| `editNameActive`   | `boolean`                    | `false`                                                                                                                      | Indicates edit mode if available.                                                                                                                                                                                                                                                                                |                |
| `draftActive`      | `boolean`                    | `false`                                                                                                                      | Whether the unsaved draft is the viewed entry in preview mode. "Continue editing" is only offered while the&#xA;draft itself is on screen, not while a stored version is viewed alongside it.                                                                                                                    |                |
| `oldVersionActive` | `boolean`                    | `false`                                                                                                                      | Whether an older stored version is shown instead of the current one. Editing always starts from the current&#xA;version, so the Edit item is hidden to avoid suggesting that the shown version would be edited.                                                                                                  |                |
| `commentsActive`   | `boolean`                    | `false`                                                                                                                      |                                                                                                                                                                                                                                                                                                                  |                |
| `versionsActive`   | `boolean`                    | `false`                                                                                                                      |                                                                                                                                                                                                                                                                                                                  |                |
| `hasEventListener` | `{ [key: string]: boolean }` | `{ save: false, edit: false, "edit-name": false, subscribe: false, trash: false, restore: false, "delete-forever": false, }` | Tracks which action events have listeners attached.                                                                                                                                                                                                                                                              |                |

### Methods

| Name               | Description                             | Parameters                                                                                                | Return | Inherited From |
| ------------------ | --------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------ | -------------- |
| `addEventListener` |                                         | `type: string, listener: EventListenerOrEventListenerObject, options: boolean \| AddEventListenerOptions` | `void` |                |
| `removeDraft`      | Removes any draft for the current file. |                                                                                                           |        |                |
| `isNotTemp`        |                                         |                                                                                                           |        |                |

### Events

| Name             | Type                         | Description                                        | Inherited From |
| ---------------- | ---------------------------- | -------------------------------------------------- | -------------- |
| `save`           | `FileSaveEventType`          | Emitted when file save is requested.               |                |
| `edit`           | `FileEditEventType`          | Emitted when file edit mode change is requested.   |                |
| `edit-name`      | `FileEditNameEventType`      | Emitted when rename mode should be activated.      |                |
| `subscribe`      | `FileSubscribeEventType`     | Emitted when subscribe/unsubscribe is requested.   |                |
| `trash`          | `FileTrashEventType`         | Emitted when a file should be moved to trash.      |                |
| `restore`        | `FileRestoreEventType`       | Emitted when a trashed file should be restored.    |                |
| `delete-forever` | `FileDeleteForeverEventType` | Emitted when a file should be permanently deleted. |                |
| `comments`       | `FileCommentsEventType`      | Emitted when file comments should be opened.       |                |
| `versions`       | `FileVersionsEventType`      | Emitted when file versions should be opened.       |                |

### Attributes

| Name               | Field            | Inherited From |
| ------------------ | ---------------- | -------------- |
| `file`             | file             |                |
| `small`            | small            |                |
| `hasEdit`          | hasEdit          |                |
| `hasComments`      | hasComments      |                |
| `hasVersions`      | hasVersions      |                |
| `hasSubscribe`     | hasSubscribe     |                |
| `hasRename`        | hasRename        |                |
| `editActive`       | editActive       |                |
| `editNameActive`   | editNameActive   |                |
| `draftActive`      | draftActive      |                |
| `oldVersionActive` | oldVersionActive |                |
| `commentsActive`   | commentsActive   |                |
| `versionsActive`   | versionsActive   |                |
| `hasEventListener` | hasEventListener |                |

### Slots

| Name | Description                |
| ---- | -------------------------- |
|      | Additional file menu items |

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

### Methods

| Name               | Privacy   | Description                                                               | Parameters      | Return | Inherited From |
| ------------------ | --------- | ------------------------------------------------------------------------- | --------------- | ------ | -------------- |
| `dispatchComments` | protected | Emit a \`comments\` event containing for showing or hiding file comments. | `show: boolean` |        |                |
| `dispatchVersions` | protected | Emit a \`versions\` event for showing or hiding file versions.            | `show: boolean` |        |                |
| `toggleEdit`       | protected |                                                                           |                 |        |                |
| `toggleEditName`   | protected |                                                                           |                 |        |                |
| `toggleComments`   | protected |                                                                           |                 |        |                |
| `toggleVersions`   | protected |                                                                           |                 |        |                |

</details>

<hr/>

## Exports

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