interface for entity action element
This commit is contained in:
committed by
Jacob Overgaard
parent
bef85206d1
commit
8298de95c2
@@ -1,4 +1,5 @@
|
||||
import type { UmbEntityAction } from '../entity-action.interface.js';
|
||||
import type { UmbEntityActionElement } from '../entity-action-element.interface.js';
|
||||
import { UmbActionExecutedEvent } from '@umbraco-cms/backoffice/event';
|
||||
import { html, nothing, ifDefined, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import type { UUIMenuItemEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
@@ -6,10 +7,13 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
||||
import type { ManifestEntityAction, MetaEntityActionDefaultKind } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
@customElement('umb-entity-action')
|
||||
export class UmbEntityActionElement<
|
||||
MetaType extends MetaEntityActionDefaultKind = MetaEntityActionDefaultKind,
|
||||
ApiType extends UmbEntityAction<MetaType> = UmbEntityAction<MetaType>,
|
||||
> extends UmbLitElement {
|
||||
export class UmbEntityActionDefaultElement<
|
||||
MetaType extends MetaEntityActionDefaultKind = MetaEntityActionDefaultKind,
|
||||
ApiType extends UmbEntityAction<MetaType> = UmbEntityAction<MetaType>,
|
||||
>
|
||||
extends UmbLitElement
|
||||
implements UmbEntityActionElement
|
||||
{
|
||||
#api?: ApiType;
|
||||
|
||||
// TODO: Do these need to be properties? [NL]
|
||||
@@ -36,6 +40,11 @@ export class UmbEntityActionElement<
|
||||
@state()
|
||||
_href?: string;
|
||||
|
||||
async focus() {
|
||||
await this.updateComplete;
|
||||
this.shadowRoot?.querySelector('uui-menu-item')?.focus();
|
||||
}
|
||||
|
||||
async #onClickLabel(event: UUIMenuItemEvent) {
|
||||
if (!this._href) {
|
||||
event.stopPropagation();
|
||||
@@ -66,10 +75,10 @@ export class UmbEntityActionElement<
|
||||
`;
|
||||
}
|
||||
}
|
||||
export default UmbEntityActionElement;
|
||||
export default UmbEntityActionDefaultElement;
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'umb-entity-action': UmbEntityActionElement;
|
||||
'umb-entity-action': UmbEntityActionDefaultElement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
export interface UmbEntityActionElement extends UmbControllerHostElement {}
|
||||
@@ -4,6 +4,7 @@ export * from './entity-action-list.element.js';
|
||||
export * from './entity-action.event.js';
|
||||
export * from './entity-action.interface.js';
|
||||
export * from './types.js';
|
||||
export type * from './entity-action-element.interface.js';
|
||||
|
||||
export { UmbRequestReloadStructureForEntityEvent } from './request-reload-structure-for-entity.event.js';
|
||||
export { UMB_ENTITY_ACTION_DEFAULT_KIND_MANIFEST } from './default/default.action.kind.js';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { ConditionTypes } from '../conditions/types.js';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type { UmbEntityAction } from '@umbraco-cms/backoffice/entity-action';
|
||||
import type { UmbEntityAction, UmbEntityActionElement } from '@umbraco-cms/backoffice/entity-action';
|
||||
import type { ManifestElementAndApi, ManifestWithDynamicConditions } from '@umbraco-cms/backoffice/extension-api';
|
||||
import type { UmbModalToken, UmbPickerModalData, UmbPickerModalValue } from '@umbraco-cms/backoffice/modal';
|
||||
|
||||
@@ -9,7 +8,7 @@ import type { UmbModalToken, UmbPickerModalData, UmbPickerModalValue } from '@um
|
||||
* For example for content you may wish to create a new document etc
|
||||
*/
|
||||
export interface ManifestEntityAction<MetaType extends MetaEntityAction = MetaEntityAction>
|
||||
extends ManifestElementAndApi<UmbControllerHostElement, UmbEntityAction<MetaType>>,
|
||||
extends ManifestElementAndApi<UmbEntityActionElement, UmbEntityAction<MetaType>>,
|
||||
ManifestWithDynamicConditions<ConditionTypes> {
|
||||
type: 'entityAction';
|
||||
forEntityTypes: Array<string>;
|
||||
|
||||
Reference in New Issue
Block a user