@api-client/ui 0.5.40 → 0.5.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@api-client/ui",
3
- "version": "0.5.40",
3
+ "version": "0.5.41",
4
4
  "description": "Internal UI component library for the API Client ecosystem.",
5
5
  "license": "UNLICENSED",
6
6
  "main": "build/src/index.js",
@@ -1,18 +1,20 @@
1
- import { MenuItem } from './MenuItem.js'
2
- import { genId } from './IdGenerator.js'
1
+ import { MenuItem } from './internals/MenuItem.js'
2
+ import { genId } from './internals/IdGenerator.js'
3
3
  import type {
4
4
  CommandBase,
5
5
  ContextMenuCommand,
6
6
  ContextMenuExecuteDetail,
7
7
  CustomMenuEventDetail,
8
+ MenuContext,
8
9
  MenuOptions,
9
10
  MenuPoint,
10
11
  MenuTriggerInfo,
11
- } from './types.js'
12
- import type ContextMenuElement from './ContextualMenuElement.js'
12
+ } from './internals/types.js'
13
+ import type ContextMenuElement from './internals/ContextualMenuElement.js'
13
14
  import { Logger, ILogObj } from 'tslog'
15
+ export type * from './internals/types.js'
14
16
 
15
- import '../contextual-menu.js'
17
+ import './contextual-menu.js'
16
18
 
17
19
  function cancelEvent(e: Event): void {
18
20
  e.preventDefault()
@@ -248,7 +250,7 @@ export class ContextualMenu<S = unknown> extends EventTarget {
248
250
  * Register a list of commands to be rendered in the menu when triggered.
249
251
  * This overrides previously registered commands.
250
252
  */
251
- registerCommands(commands: CommandBase<S>[]): void {
253
+ registerCommands(commands: (CommandBase<S> | ContextMenuCommand<S>)[]): void {
252
254
  if (!Array.isArray(commands) || !commands.length) {
253
255
  this.logger.warn('registerCommands called with empty array')
254
256
  return
@@ -259,7 +261,7 @@ export class ContextualMenu<S = unknown> extends EventTarget {
259
261
  /**
260
262
  * Adds a single command to the menu.
261
263
  */
262
- addCommand(command: CommandBase<S>): void {
264
+ addCommand(command: CommandBase<S> | ContextMenuCommand<S>): void {
263
265
  if (!this.commands) {
264
266
  this.commands = []
265
267
  }
@@ -338,11 +340,33 @@ export class ContextualMenu<S = unknown> extends EventTarget {
338
340
  customData,
339
341
  target,
340
342
  }
343
+ this.beforeRender()
341
344
  this.render(placementPoint, commands)
342
345
  target.setAttribute('active', '')
343
346
  return true
344
347
  }
345
348
 
349
+ /**
350
+ * A lifecycle method called before the `render()` method.
351
+ */
352
+ protected beforeRender(): void {
353
+ const { beforeRender } = this.options
354
+ if (!beforeRender) {
355
+ return
356
+ }
357
+ const context: MenuContext = {
358
+ store: this.store,
359
+ target: this.triggerInfo?.target || this.workspace,
360
+ root: this.workspace,
361
+ customData: this.triggerInfo?.customData,
362
+ }
363
+ try {
364
+ beforeRender(context)
365
+ } catch {
366
+ // ...
367
+ }
368
+ }
369
+
346
370
  /**
347
371
  * @param placementPoint The workspace position of where to place the menu.
348
372
  * @param commands The commands render
@@ -15,6 +15,13 @@ export interface MenuOptions {
15
15
  * would render this context menu and in another system's & browser context menu.
16
16
  */
17
17
  cancelNativeWhenHandled?: boolean
18
+ /**
19
+ * Called before the menu is rendered.
20
+ * Specifically, it is called right before the internal `render()` method is called.
21
+ * It doesn't allow you to modify the menu items, but you can perform any setup
22
+ * before the menu is rendered.
23
+ */
24
+ beforeRender?: (ctx: MenuContext) => void
18
25
  }
19
26
 
20
27
  export interface MenuPoint {
@@ -22,11 +29,7 @@ export interface MenuPoint {
22
29
  y: number
23
30
  }
24
31
 
25
- interface LifecycleContext<S> {
26
- /**
27
- * The id of the command.
28
- */
29
- id: string
32
+ export interface MenuContext<S = unknown> {
30
33
  /**
31
34
  * The object store to be used to store menu item data.
32
35
  */
@@ -45,14 +48,21 @@ interface LifecycleContext<S> {
45
48
  customData?: unknown
46
49
  }
47
50
 
51
+ interface LifecycleContext<S = unknown> extends MenuContext<S> {
52
+ /**
53
+ * The id of the command.
54
+ */
55
+ id: string
56
+ }
57
+
48
58
  export interface EnabledMenuOptions<S = unknown> extends LifecycleContext<S> {}
49
59
 
50
- export interface CheckedMenuOptions<S> extends LifecycleContext<S> {}
60
+ export interface CheckedMenuOptions<S = unknown> extends LifecycleContext<S> {}
51
61
 
52
62
  /**
53
63
  * Options passed to the `visible()` callback function.
54
64
  */
55
- export type VisibleOptions<S> = EnabledMenuOptions<S>
65
+ export type VisibleOptions<S = unknown> = EnabledMenuOptions<S>
56
66
 
57
67
  export interface CommandExecuteOptions<S = unknown> extends LifecycleContext<S> {
58
68
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContextualMenu.d.ts","sourceRoot":"","sources":["../../../../../src/elements/contextual-menu/internals/ContextualMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAElB,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,kBAAkB,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAEvC,OAAO,uBAAuB,CAAA;AAO9B;;;;;GAKG;AACH,qBAAa,cAAc,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,WAAW;;IAuDjD,SAAS,EAAE,WAAW;IApD/B;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;OAEG;IACH,KAAK,EAAE,CAAC,CAAU;IAElB;;OAEG;IACH,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAK;IAE5B;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAA;IAE7B;;OAEG;IACH,OAAO,EAAE,WAAW,CAAA;IAEpB,WAAW,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAA;IAInC,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,OAAO,EAQvB;IAED,SAAS,CAAC,MAA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EACZ,cAAc,EAAE,SAAS,EACzB,WAAW,EAAE,SAAS,EACtB,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO;IAiBV;;;OAGG;IACH,MAAM,CAAC,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAuBhE;;;;;OAKG;IACH,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE;IA4BxF;;OAEG;IACH,OAAO,IAAI,IAAI;IAgBf;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI;CA6BnD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContextualMenu.js","sourceRoot":"","sources":["../../../../../src/elements/contextual-menu/internals/ContextualMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAWxC,OAAO,EAAE,MAAM,EAAW,MAAM,OAAO,CAAA;AAEvC,OAAO,uBAAuB,CAAA;AAE9B,SAAS,WAAW,CAAC,CAAQ;IAC3B,CAAC,CAAC,cAAc,EAAE,CAAA;IAClB,CAAC,CAAC,eAAe,EAAE,CAAA;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,cAA4B,SAAQ,WAAW;IAuDjD;IAtDT,eAAe,GAAG,KAAK,CAAA;IAEvB;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,eAAe,CAAA;IAC7B,CAAC;IAED;;OAEG;IACH,KAAK,GAAM,EAAO,CAAA;IAElB;;OAEG;IACH,QAAQ,GAAkB,EAAE,CAAA;IAE5B;;OAEG;IACH,WAAW,CAAkB;IAE7B;;OAEG;IACH,OAAO,CAAa;IAEpB,WAAW,CAAwB;IAEnC,MAAM,GAAG,KAAK,CA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C,CAAc;QACzC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAA;QAC1C,MAAM,GAAG,GAAG,OAAmB,CAAA;QAC/B,MAAM,aAAa,GAAG,MAAkB,CAAA;QACxC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;QAC9C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,WAA8B,CAAA;QACpE,IAAI,CAAC,OAAO,EAAE,CAAA;QACd,IAAI,aAAa,IAAI,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YAC3D,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAA;QAC/E,CAAC;aAAM,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACvB,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;QAC/D,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAA6B;gBACvC,EAAE,EAAE,GAAG,CAAC,EAAE;gBACV,KAAK;gBACL,MAAM;gBACN,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE,KAAK;gBACjB,UAAU;gBACV,kBAAkB,EAAE,IAAI;gBACxB,IAAI,EAAE,GAAG;aACV,CAAA;YACD,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,SAAS,EAAE;gBACzB,MAAM;aACP,CAAC,CACH,CAAA;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { MenuItem } from './MenuItem.js'\nimport { genId } from './IdGenerator.js'\nimport type {\n CommandBase,\n ContextMenuCommand,\n ContextMenuExecuteDetail,\n CustomMenuEventDetail,\n MenuOptions,\n MenuPoint,\n MenuTriggerInfo,\n} from './types.js'\nimport type ContextMenuElement from './ContextualMenuElement.js'\nimport { Logger, ILogObj } from 'tslog'\n\nimport '../contextual-menu.js'\n\nfunction cancelEvent(e: Event): void {\n e.preventDefault()\n e.stopPropagation()\n}\n\n/**\n * The base class for the context menu. It can be used as is but in some specific cases\n * you may want to extend this class to be able to find command target accurately.\n *\n * @template S - The definition of the store passed to commands.\n */\nexport class ContextualMenu<S = unknown> extends EventTarget {\n #connectedValue = false\n\n /**\n * @returns true when the menu is connected to the `workspace`.\n */\n get connected(): boolean {\n return this.#connectedValue\n }\n\n /**\n * The store initialized with this context menu. Passed to the lifecycle functions.\n */\n store: S = {} as S\n\n /**\n * The root level menu commands\n */\n commands: MenuItem<S>[] = []\n\n /**\n * An information about the trigger that initialized this menu.\n */\n triggerInfo?: MenuTriggerInfo\n\n /**\n * The Menu configuration options.\n */\n options: MenuOptions\n\n currentMenu?: ContextMenuElement<S>\n\n #debug = false\n\n get debug(): boolean {\n return this.#debug\n }\n\n set debug(value: boolean) {\n if (this.#debug === value) {\n return\n }\n this.#debug = value\n if (this.logger) {\n this.logger.settings.minLevel = value ? 0 : 4\n }\n }\n\n protected logger: Logger<ILogObj>\n\n /**\n * @param workspace The root element that is the click handler\n * @param opts The Menu configuration options.\n */\n constructor(\n public workspace: HTMLElement,\n opts: MenuOptions = {}\n ) {\n super()\n\n this.options = { ...opts }\n\n this.logger = new Logger({ minLevel: this.debug ? 0 : 4, name: 'context-menu', hideLogPositionForProduction: true })\n\n this.contextHandler = this.contextHandler.bind(this)\n this.clickHandler = this.clickHandler.bind(this)\n this.keydownHandler = this.keydownHandler.bind(this)\n this.customMenuHandler = this.customMenuHandler.bind(this)\n this.menuTriggerHandler = this.menuTriggerHandler.bind(this)\n }\n\n /**\n * Starts listening on user events\n */\n connect(): void {\n this.logger.debug('Connecting contextual menu...')\n this.workspace.addEventListener('contextmenu', this.contextHandler)\n this.workspace.addEventListener('custommenu', this.customMenuHandler as EventListener)\n window.addEventListener('click', this.clickHandler)\n window.addEventListener('keydown', this.keydownHandler)\n this.#connectedValue = true\n }\n\n /**\n * Cleans up the listeners\n */\n disconnect(): void {\n this.logger.debug('Disconnecting contextual menu...')\n this.workspace.removeEventListener('contextmenu', this.contextHandler)\n this.workspace.removeEventListener('custommenu', this.customMenuHandler as EventListener)\n window.removeEventListener('click', this.clickHandler)\n window.removeEventListener('keydown', this.keydownHandler)\n this.#connectedValue = false\n }\n\n /**\n * Reads {x,y} point of the click from the pointer event.\n *\n * Override this method to customize position reading.\n */\n readTargetClickPosition(e: MouseEvent): MenuPoint {\n const result: MenuPoint = {\n x: e.clientX,\n y: e.clientY,\n }\n this.logger.debug('readTargetClickPosition result:', result)\n return result\n }\n\n /**\n * Override this method to customize finding event click target.\n * @param e Finds the click target from the event\n */\n findTarget(e: MouseEvent): HTMLElement | SVGElement | undefined {\n this.logger.debug('findTarget results with \"e.target\"')\n return e.target as HTMLElement | SVGElement | undefined\n }\n\n /**\n * Maps an element to the target name used by the commands.\n * By default it returns `root` when the click target element is the `workspace` or\n * a combination of element name and list of all classes otherwise.\n *\n * Override this method to customize target name reading.\n *\n * @param element The context click target\n * @returns The target name.\n */\n elementToTarget(element: HTMLElement | SVGElement): string | undefined {\n if (element === this.workspace) {\n this.logger.debug('elementToTarget result:', 'root')\n return 'root'\n }\n if (!element.localName) {\n this.logger.debug('elementToTarget result:', undefined)\n return undefined\n }\n let name = element.localName\n const cls = Array.from(element.classList).join('.')\n if (cls) {\n name += `.${cls}`\n }\n this.logger.debug('elementToTarget result:', name)\n return name\n }\n\n /**\n * Handler for the context menu event.\n */\n protected contextHandler(e: MouseEvent): void {\n // if (!this.options.cancelNativeWhenHandled) {\n // cancelEvent(e);\n // }\n this.destroy()\n const target = this.findTarget(e)\n if (!target) {\n return\n }\n const name = this.elementToTarget(target)\n this.logger.debug('contextHandler', 'target:', target.localName, 'name:', name)\n if (!name) {\n return\n }\n // since the context menu has fixed position it doesn't matter what the context\n // is as the menu is rendered over all elements.\n // The `readTargetClickPosition()` is used to determine click target for the commands.\n const clickPoint = {\n x: e.clientX,\n y: e.clientY,\n }\n const targetPoint = this.readTargetClickPosition(e)\n const rendered = this.build(target, name, clickPoint, targetPoint)\n if (rendered) {\n cancelEvent(e)\n } else if (this.options.cancelNativeWhenHandled) {\n cancelEvent(e)\n }\n }\n\n /**\n * A handler for the `custommenu` event handler to trigger the menu without the user interaction.\n */\n protected customMenuHandler(e: CustomEvent<CustomMenuEventDetail>): void {\n cancelEvent(e)\n const { name, x = 0, y = 0, actionTarget = this.workspace, clickEvent, customData } = e.detail\n const clickPoint = {\n x,\n y,\n }\n const targetPoint = clickEvent ? this.readTargetClickPosition(clickEvent) : clickPoint\n this.build(actionTarget, name, clickPoint, targetPoint, customData)\n }\n\n /**\n * Handles the click event on the document to close the menu is the click\n * is outside the menu.\n */\n protected clickHandler(e: MouseEvent): void {\n if (!this.currentMenu || e.defaultPrevented) {\n return\n }\n const elm = e.target as Element\n const inside = this.currentMenu.contains(elm)\n if (!inside) {\n this.logger.debug('Click outside the menu. Destroing...')\n this.destroy()\n }\n }\n\n /**\n * Closes the menu when ESC is pressed\n */\n protected keydownHandler(e: KeyboardEvent): void {\n if (e.key === 'Escape' && this.currentMenu) {\n this.logger.debug('Escape key detected. Destroing the menu...')\n this.destroy()\n }\n }\n\n /**\n * Register a list of commands to be rendered in the menu when triggered.\n * This overrides previously registered commands.\n */\n registerCommands(commands: CommandBase<S>[]): void {\n if (!Array.isArray(commands) || !commands.length) {\n this.logger.warn('registerCommands called with empty array')\n return\n }\n this.commands = this.prepareCommands(commands)\n }\n\n /**\n * Adds a single command to the menu.\n */\n addCommand(command: CommandBase<S>): void {\n if (!this.commands) {\n this.commands = []\n }\n const item = this.prepareCommands([command])[0]\n this.commands.push(item)\n }\n\n /**\n * Prepares incoming commands for the internal use.\n * @param commands - The commands to process.\n */\n protected prepareCommands(commands: CommandBase<S>[]): MenuItem<S>[] {\n const result: MenuItem<S>[] = []\n commands.forEach((item) => {\n if (!item) {\n return\n }\n const { type = 'normal' } = item\n switch (type) {\n case 'separator':\n result.push(new MenuItem(item))\n break\n case 'label':\n result.push(new MenuItem(item))\n break\n case 'normal':\n case 'radio':\n {\n const normalized = this.normalizeMenuItem(item as ContextMenuCommand<S>)\n result.push(new MenuItem(normalized))\n }\n break\n default:\n }\n })\n return result\n }\n\n protected normalizeMenuItem(item: ContextMenuCommand<S>): ContextMenuCommand<S> {\n const cp = { ...item }\n if (!cp.id) {\n cp.id = genId()\n }\n if (Array.isArray(cp.children) && cp.children.length) {\n cp.children = this.prepareCommands(cp.children)\n } else if (cp.children) {\n cp.children = undefined\n }\n return cp\n }\n\n /**\n * Builds the menu for the target.\n *\n * @param target The element that triggered the menu\n * @param name The `target` name declared in the commands.\n * @param placementPoint The workspace position of where to place the menu.\n * @param targetPoint The workspace position of the click target\n * @param customData Any data to set on the instance to pass to the `execute` and `enabled` functions.\n */\n build(\n target: HTMLElement | SVGElement,\n name: string,\n placementPoint: MenuPoint,\n targetPoint: MenuPoint,\n customData?: unknown\n ): boolean {\n this.triggerInfo = undefined\n const commands = this.listCommands(name, target)\n this.logger.debug('build', 'commands discovered', commands.length)\n if (!commands.length) {\n return false\n }\n this.triggerInfo = {\n point: targetPoint,\n customData,\n target,\n }\n this.render(placementPoint, commands)\n target.setAttribute('active', '')\n return true\n }\n\n /**\n * @param placementPoint The workspace position of where to place the menu.\n * @param commands The commands render\n */\n render(placementPoint: MenuPoint, commands: MenuItem<S>[]): void {\n const { workspace } = this\n const menu = document.createElement('contextual-menu') as unknown as ContextMenuElement<S>\n menu.store = this.store\n menu.target = this.triggerInfo?.target\n menu.customData = this.triggerInfo?.customData\n menu.workspace = workspace\n menu.classList.add('context-menu')\n menu.commands = commands\n menu.style.top = `${placementPoint.y}px`\n menu.style.left = `${placementPoint.x}px`\n menu.setAttribute('tabindex', '0')\n\n if (workspace.shadowRoot) {\n workspace.shadowRoot.append(menu)\n } else {\n this.workspace.append(menu)\n }\n this.currentMenu = menu\n menu.focus()\n menu.addEventListener('trigger', this.menuTriggerHandler as EventListener)\n }\n\n /**\n * Lists all commands that matches the target.\n *\n * @param targetName The build target name\n * @param targetElement The element that triggered the menu\n */\n listCommands(targetName: string, targetElement: HTMLElement | SVGElement): MenuItem<S>[] {\n this.logger.debug('listCommands')\n const { commands = [] } = this\n const result: MenuItem<S>[] = []\n const filter = ['all', targetName]\n this.logger.debug('listCommands', 'filter:', filter)\n commands.forEach((cmd) => {\n this.logger.silly('listCommands', 'matching tharget', cmd.target)\n if (Array.isArray(cmd.target)) {\n const hasTarget = cmd.target.some((item) => filter.includes(item))\n if (hasTarget) {\n result.push(cmd)\n }\n } else if (filter.includes(cmd.target || '')) {\n result.push(cmd)\n } else {\n try {\n if (targetElement.matches(cmd.target || '')) {\n result.push(cmd)\n }\n } catch {\n //\n }\n }\n })\n return result\n }\n\n /**\n * Removes the currently rendered menu.\n */\n destroy(): void {\n if (!this.currentMenu) {\n return\n }\n ;(this.triggerInfo as MenuTriggerInfo).target.removeAttribute('active')\n this.triggerInfo = undefined\n const { workspace } = this\n if (workspace.shadowRoot) {\n workspace.shadowRoot.removeChild(this.currentMenu)\n } else {\n workspace.removeChild(this.currentMenu)\n }\n this.currentMenu.removeEventListener('trigger', this.menuTriggerHandler as EventListener)\n this.currentMenu = undefined\n }\n\n /**\n * Handler for the `trigger` event dispatched by the menu\n */\n protected menuTriggerHandler(e: CustomEvent): void {\n const { item, command, parent } = e.detail\n const cmd = command as MenuItem\n const parentCommand = parent as MenuItem\n const { triggerInfo, workspace, store } = this\n const { point, target, customData } = triggerInfo as MenuTriggerInfo\n this.destroy()\n if (parentCommand && parentCommand.execute && !cmd.execute) {\n parentCommand.trigger(cmd, store, target, workspace, point, customData, item)\n } else if (cmd.execute) {\n cmd.trigger(cmd, store, target, workspace, point, customData)\n } else {\n const detail: ContextMenuExecuteDetail = {\n id: cmd.id,\n store,\n target,\n root: workspace,\n clickPoint: point,\n customData,\n selectedSubcommand: item,\n item: cmd,\n }\n this.dispatchEvent(\n new CustomEvent('execute', {\n detail,\n })\n )\n }\n }\n}\n"]}