@omegagrid/commands 0.10.103 → 0.10.104

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.
@@ -1 +1 @@
1
- {"version":3,"file":"commandsFlowAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/commandsFlowAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC/C,IAAI,CAAC,EAAE;QACN,QAAQ,EAAE,iBAAiB,EAAE,CAAC;QAC9B,IAAI,CAAC,EAAE,WAAW,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF,CAAA;AAED,qBAAa,mBAAoB,SAAQ,eAAe;IAEvD,QAAQ,CAAC,GAAG,iCAAwC;IACpD,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAc;IAEnC,OAAO,CAAC,SAAS,CAA2B;IAC5C,IAAI,QAAQ,IAGQ,iBAAiB,EAAE,CADtC;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAUtC;gBAEW,QAAQ,EAAE,iBAAiB,EAAE;IAKzC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,EAAE,GAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IAM1E,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM;IAetC,KAAK;IAUL,UAAU,IAAI,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,IAAI;CAI3C"}
1
+ {"version":3,"file":"commandsFlowAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/commandsFlowAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC/C,IAAI,CAAC,EAAE;QACN,QAAQ,EAAE,iBAAiB,EAAE,CAAC;QAC9B,IAAI,CAAC,EAAE,WAAW,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACF,CAAA;AAED,qBAAa,mBAAoB,SAAQ,eAAe;IAEvD,QAAQ,CAAC,GAAG,iCAAwC;IACpD,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,aAAa,CAAc;IAEnC,OAAO,CAAC,SAAS,CAA2B;IAC5C,IAAI,QAAQ,IAGQ,iBAAiB,EAAE,CADtC;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAUtC;gBAEW,QAAQ,EAAE,iBAAiB,EAAE;IAKzC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,EAAE,GAAC,OAAO,CAAC,aAAa,EAAE,CAAC;IAM1E,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM;IAetC,KAAK;IAUL,UAAU,IAAI,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,IAAI;CAI3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"commandsFlowAdapter.js","sourceRoot":"","sources":["../../src/adapters/commandsFlowAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,eAAe,EAAE,MAAM,WAAW,CAAC;AAU1D,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAQvD,IAAI,QAAQ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;IAED,UAAU;QACT,OAAO,IAAI,CAAC;IACb,CAAC;CAED","sourcesContent":["import { CommandSource, Command, CommandMode } from \"../model/commands\";\nimport { Options } from \"../model/options\";\nimport { CommandQuery, CommandsAdapter } from \"./adapter\";\n\nexport type FlowCommandSource = CommandSource & {\n\tnext?: {\n\t\tcommands: FlowCommandSource[];\n\t\tmode?: CommandMode;\n\t\ttext?: string;\n\t};\n}\n\nexport class CommandsFlowAdapter extends CommandsAdapter {\n\n\treadonly map = new Map<string, FlowCommandSource>();\n\tprivate commandChain: Command[] = [];\n\tprivate _originalText: string;\n\tprivate _originalMode: CommandMode;\n\n\tprivate _commands: FlowCommandSource[] = [];\n\tget commands() {\n\t\treturn this._commands;\n\t}\n\tset commands(value: FlowCommandSource[]) {\n\t\tthis._commands = value;\n\t\tthis.map.clear();\n\t\tconst map = (commands: FlowCommandSource[]) => {\n\t\t\tcommands.forEach(c => {\n\t\t\t\tthis.map.set(c.id ?? c.name, c);\n\t\t\t\tif (c.next?.commands) map(c.next.commands);\n\t\t\t});\n\t\t};\n\t\tmap(this._commands);\n\t}\n\n\tconstructor(commands: FlowCommandSource[]) {\n\t\tsuper();\n\t\tthis.commands = commands;\n\t}\n\t\t\n\tgetCommands(query: CommandQuery): CommandSource[]|Promise<CommandSource[]> {\n\t\tconst lastCommand = this.commandChain.length ? this.commandChain[this.commandChain.length - 1] : null;\n\t\tconst nextCommands = lastCommand ? this.map.get(lastCommand.id)?.next?.commands : null;\n\t\treturn this.filterCommands(nextCommands ? nextCommands : this.commands, query);\n\t}\n\n\texec(command: Command, _value?: string) {\n\t\tconst next = this.map.get(command.id)?.next;\n\t\tif (next?.commands?.length) {\n\t\t\tthis.commandChain.push(command);\n\t\t\tif (this._originalText == null) this._originalText = this.component.text;\n\t\t\tif (this._originalMode == null) this._originalMode = this.component.mode;\n\t\t\tif (next.text != null) this.component.text = next.text;\n\t\t\tif (next.mode != null) this.component.mode = next.mode;\n\t\t} else {\n\t\t\tthis.reset();\n\t\t}\n\n\t\tthis.component.updateCommands();\n\t}\n\n\treset() {\n\t\tthis.commandChain = [];\n\t\tif (this.component) {\n\t\t\tthis.component.text = this._originalText;\n\t\t\tthis.component.mode = this._originalMode;\n\t\t}\n\t\tthis._originalText = null;\n\t\tthis._originalMode = null;\n\t}\n\n\tgetOptions(): Options|Promise<Options>|null {\n\t\treturn null;\n\t}\n\n}"]}
1
+ {"version":3,"file":"commandsFlowAdapter.js","sourceRoot":"","sources":["../../src/adapters/commandsFlowAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,eAAe,EAAE,MAAM,WAAW,CAAC;AAU1D,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IAQvD,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,GAAG,GAAG,CAAC,QAA6B,EAAE,EAAE;YAC7C,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBACpB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAChC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ;oBAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC;QACF,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAED,YAAY,QAA6B;QACxC,KAAK,EAAE,CAAC;QAtBA,QAAG,GAAG,IAAI,GAAG,EAA6B,CAAC;QAC5C,iBAAY,GAAc,EAAE,CAAC;QAI7B,cAAS,GAAwB,EAAE,CAAC;QAkB3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1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P,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;YACzC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;QAC1C,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,UAAU;QACT,OAAO,IAAI,CAAC;IACb,CAAC;CAED","sourcesContent":["import { TemplateResult } from \"lit-html\";\nimport { CommandSource, Command, CommandMode } from \"../model/commands\";\nimport { Options } from \"../model/options\";\nimport { CommandQuery, CommandsAdapter } from \"./adapter\";\n\nexport type FlowCommandSource = CommandSource & {\n\tnext?: {\n\t\tcommands: FlowCommandSource[];\n\t\tmode?: CommandMode;\n\t\ttext?: string;\n\t};\n}\n\nexport class CommandsFlowAdapter extends CommandsAdapter {\n\n\treadonly map = new Map<string, FlowCommandSource>();\n\tprivate commandChain: Command[] = [];\n\tprivate _originalText: string|TemplateResult<1>;\n\tprivate _originalMode: CommandMode;\n\n\tprivate _commands: FlowCommandSource[] = [];\n\tget commands() {\n\t\treturn this._commands;\n\t}\n\tset commands(value: FlowCommandSource[]) {\n\t\tthis._commands = value;\n\t\tthis.map.clear();\n\t\tconst map = (commands: FlowCommandSource[]) => {\n\t\t\tcommands.forEach(c => {\n\t\t\t\tthis.map.set(c.id ?? c.name, c);\n\t\t\t\tif (c.next?.commands) map(c.next.commands);\n\t\t\t});\n\t\t};\n\t\tmap(this._commands);\n\t}\n\n\tconstructor(commands: FlowCommandSource[]) {\n\t\tsuper();\n\t\tthis.commands = commands;\n\t}\n\t\t\n\tgetCommands(query: CommandQuery): CommandSource[]|Promise<CommandSource[]> {\n\t\tconst lastCommand = this.commandChain.length ? this.commandChain[this.commandChain.length - 1] : null;\n\t\tconst nextCommands = lastCommand ? this.map.get(lastCommand.id)?.next?.commands : null;\n\t\treturn this.filterCommands(nextCommands ? nextCommands : this.commands, query);\n\t}\n\n\texec(command: Command, _value?: string) {\n\t\tconst next = this.map.get(command.id)?.next;\n\t\tif (next?.commands?.length) {\n\t\t\tthis.commandChain.push(command);\n\t\t\tif (this._originalText == null) this._originalText = this.component.text;\n\t\t\tif (this._originalMode == null) this._originalMode = this.component.mode;\n\t\t\tif (next.text != null) this.component.text = next.text;\n\t\t\tif (next.mode != null) this.component.mode = next.mode;\n\t\t} else {\n\t\t\tthis.reset();\n\t\t}\n\n\t\tthis.component.updateCommands();\n\t}\n\n\treset() {\n\t\tthis.commandChain = [];\n\t\tif (this.component) {\n\t\t\tthis.component.text = this._originalText;\n\t\t\tthis.component.mode = this._originalMode;\n\t\t}\n\t\tthis._originalText = null;\n\t\tthis._originalMode = null;\n\t}\n\n\tgetOptions(): Options|Promise<Options>|null {\n\t\treturn null;\n\t}\n\n}"]}
@@ -1,13 +1,14 @@
1
1
  import { FloatingWindow } from "@omegagrid/core";
2
- import { Command, CommandMode, CommandSource } from "./model";
2
+ import { Command, CommandMode, CommandSource, Options } from "./model";
3
3
  import { CommandWindow } from "./ui";
4
- import { LitElement } from "lit";
4
+ import { LitElement, TemplateResult } from "lit";
5
5
  import { CommonCommandType } from "./common";
6
6
  import { CommandsFlowAdapter, FlowCommandSource } from "./adapters";
7
7
  export type OpenCommandsOptions = {
8
8
  value?: string;
9
- text?: string;
9
+ text?: string | TemplateResult<1>;
10
10
  mode?: CommandMode;
11
+ options?: Partial<Options>;
11
12
  /** input placeholder (used when the active section does not define its own) */
12
13
  placeholder?: string;
13
14
  content: CommandSource[] | CommonCommandType;
@@ -25,6 +26,7 @@ export declare class CommandManager {
25
26
  private _rejectCallback;
26
27
  private _adapter;
27
28
  private _commands;
29
+ private _origOptions;
28
30
  get commands(): FlowCommandSource[];
29
31
  constructor(target: LitElement);
30
32
  clear(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"commandManager.d.ts","sourceRoot":"","sources":["../src/commandManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAO,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAgB,aAAa,EAAE,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAkB,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpE,MAAM,MAAM,mBAAmB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,aAAa,EAAE,GAAG,iBAAiB,CAAC;CAChD,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ,CAAA;AAED,qBAAa,cAAc;IAad,QAAQ,CAAC,MAAM,EAAE,UAAU;IAXvC,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,gBAAgB,CAAuC;IAC/D,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAA2B;IAE5C,IAAI,QAAQ,wBAEX;gBAEoB,MAAM,EAAE,UAAU;IAEvC,KAAK;IAKL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Aa,cAAc;IAcd,QAAQ,CAAC,MAAM,EAAE,UAAU;IAZvC,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,gBAAgB,CAAuC;IAC/D,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,YAAY,CAAU;IAE9B,IAAI,QAAQ,wBAEX;gBAEoB,MAAM,EAAE,UAAU;IAEvC,KAAK;IAKL,GAAG,CAAC,QAAQ,EAAE,iBAAiB,GAAC,iBAAiB,EAAE;IAKnD,IAAI,OAAO,wBAIV;IAED,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,OAAO,CAad;IAED,IAAI,IAAI,kBAIP;IAED,IAAI,aAAa,mBAWhB;IAEK,IAAI,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,GAAC,IAAI,CAAC;IAwCtE,KAAK;IAOL,cAAc;CAMd"}
@@ -1,4 +1,4 @@
1
- import { dom, log } from "@omegagrid/core";
1
+ import { dom, log, utils } from "@omegagrid/core";
2
2
  import { createCommands } from "./common";
3
3
  import { CommandsFlowAdapter } from "./adapters";
4
4
  export class CommandManager {
@@ -70,6 +70,14 @@ export class CommandManager {
70
70
  this.menu.value = options.value;
71
71
  this.menu.mode = options.mode || 'search';
72
72
  this.menu.placeholder = options.placeholder ?? '';
73
+ if (!this._origOptions)
74
+ this._origOptions = this.menu.options;
75
+ if (options.options) {
76
+ this.menu.options = utils.mergeDeep({}, this._origOptions, options.options);
77
+ }
78
+ else {
79
+ this.menu.options = this._origOptions;
80
+ }
73
81
  if (Array.isArray(options.content)) {
74
82
  this.menu.commands = options.content;
75
83
  this.menu.adapter = null;
@@ -1 +1 @@
1
- {"version":3,"file":"commandManager.js","sourceRoot":"","sources":["../src/commandManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAkB,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B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAElB,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC;YAChC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;QAC/B,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,cAAc;QACb,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,EAAC,CAAC,CAAC;QACpE,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAC;QAC5F,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,EAAC,CAAC,EAAE,EAAE,EAAC,CAAC,CAAC;IAC9C,CAAC;CAED","sourcesContent":["import { dom, FloatingWindow, log } from \"@omegagrid/core\";\nimport { Command, CommandMode, CommandSource } from \"./model\";\nimport { CommandEvent, CommandWindow } from \"./ui\";\nimport { LitElement } from \"lit\";\nimport { createCommands, CommonCommandType } from \"./common\";\nimport { CommandsFlowAdapter, FlowCommandSource } from \"./adapters\";\n\nexport type OpenCommandsOptions = {\n value?: string;\n text?: string;\n mode?: CommandMode;\n /** input placeholder (used when the active section does not define its own) */\n placeholder?: string;\n content: CommandSource[] | CommonCommandType;\n}\n\nexport type CommandResult = {\n\tcommand: Command;\n\tvalue?: string;\n\tid?: string;\n}\n\nexport class CommandManager {\n\n\tprivate _menu: CommandWindow;\n\tprivate _menuContainer: FloatingWindow;\n\tprivate _resolveCallback: (result: CommandResult|null) => void;\n\tprivate _rejectCallback: () => void;\n\tprivate _adapter: CommandsFlowAdapter;\n\tprivate _commands: FlowCommandSource[] = [];\n\n\tget commands() {\n\t\treturn this._commands;\n\t}\n\t\n\tconstructor(readonly target: LitElement) { }\n\n\tclear() {\n\t\tthis._commands = [];\n\t\tthis._adapter = null;\n\t}\n\n\tadd(commands: FlowCommandSource|FlowCommandSource[]) {\n\t\tthis._commands.push(...(Array.isArray(commands) ? commands : [commands]));\n\t\tthis._adapter = null;\n\t}\n\n\tget adapter() {\n\t\tif (this._adapter) return this._adapter;\n\t\tthis._adapter = new CommandsFlowAdapter(this._commands);\n\t\treturn this._adapter;\n\t}\n\n\tprivate cleanCallbacks() {\n\t\tif (this._rejectCallback) this._rejectCallback();\n\t\tthis._resolveCallback = null;\n\t\tthis._rejectCallback = null;\n\t}\n\n\tprivate _onExec = (e: CommandEvent) => {\n\t\tlog.getLogger().info(`trigger command: ${e.command.id}`);\n\t\tif (this._resolveCallback) this._resolveCallback({\n\t\t\tcommand: e.command,\n\t\t\tid: e.command?.id,\n\t\t\tvalue: e.value,\n\t\t});\n\t\tthis._resolveCallback = null;\n\t\tthis._rejectCallback = null;\n\n\t\tif (this.adapter.map.get(e.command.id)?.next == null) {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\tget menu() {\n\t\treturn this._menu ?? (this._menu = dom.createElement<CommandWindow>('og-commands', {\n\t\t\tlisteners: [['command.exec', this._onExec]]\n\t\t}));\n\t}\n\t\n\tget menuContainer() {\n\t\tif (this._menuContainer) return this._menuContainer;\n\t\tthis._menuContainer = dom.createElement<FloatingWindow>('og-floating-window', {\n\t\t\tlisteners: [['hide', () => {\n\t\t\t\tthis.target?.focus();\n\t\t\t\tthis.adapter?.reset();\n\t\t\t}]]\n\t\t});\n\t\tthis.menu.slot = 'content';\n\t\tthis._menuContainer.appendChild(this.menu);\n\t\treturn this._menuContainer;\n\t}\n\n\tasync open(options?: OpenCommandsOptions): Promise<CommandResult|null> {\n\t\tlog.getLogger().info('open menu');\n\t\tthis.target.shadowRoot.appendChild(this.menuContainer);\n\t\tthis.menuContainer.show();\n\t\toptions ??= {content: null};\n\n\t\tthis.menu.text = options.text;\n\t\tthis.menu.value = options.value;\n\t\tthis.menu.mode = options.mode || 'search';\n\t\tthis.menu.placeholder = options.placeholder ?? '';\n\n\t\tif (Array.isArray(options.content)) {\n\t\t\tthis.menu.commands = options.content;\n\t\t\tthis.menu.adapter = null;\n\t\t} else if (typeof options.content === 'string') {\n\t\t\tthis.menu.commands = createCommands(options.content);\n\t\t\tthis.menu.adapter = null;\n\t\t} else {\n\t\t\tthis.menu.commands = null;\n\t\t\tthis.menu.adapter = this.adapter;\n\t\t}\n\n\t\tawait this.menu.updateComplete;\n\t\tthis.menu.focus();\n\n\t\tthis.updatePosition();\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis._resolveCallback = resolve;\n\t\t\tthis._rejectCallback = reject;\n\t\t});\n\t}\n\n\tclose() {\n\t\tthis.menuContainer.hide(false);\n\t\tthis.menuContainer.remove();\n\t\tthis.cleanCallbacks();\n\t\tthis.target?.focus();\n\t}\n\n\tupdatePosition() {\n\t\tdom.setSize(this.menuContainer, {w: 0.9 * this.target.clientWidth});\n\t\tdom.setCenterPosition(this.menuContainer, this.target, {horizontal: true, vertical: false});\n\t\tdom.setPosition(this.menuContainer, {t: 50});\n\t}\n\n}"]}
1
+ {"version":3,"file":"commandManager.js","sourceRoot":"","sources":["../src/commandManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAkB,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIlE,OAAO,EAAE,cAAc,EAAqB,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAqB,MAAM,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I,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAC1B,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAClC,CAAC;QAED,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAElB,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC;YAChC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;QAC/B,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;IACtB,CAAC;IAED,cAAc;QACb,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,EAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,EAAC,CAAC,CAAC;QACpE,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAC;QAC5F,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,EAAC,CAAC,EAAE,EAAE,EAAC,CAAC,CAAC;IAC9C,CAAC;CAED","sourcesContent":["import { dom, FloatingWindow, log, utils } from \"@omegagrid/core\";\nimport { Command, CommandMode, CommandSource, Options } from \"./model\";\nimport { CommandEvent, CommandWindow } from \"./ui\";\nimport { LitElement, TemplateResult } from \"lit\";\nimport { createCommands, CommonCommandType } from \"./common\";\nimport { CommandsFlowAdapter, FlowCommandSource } from \"./adapters\";\n\nexport type OpenCommandsOptions = {\n value?: string;\n text?: string|TemplateResult<1>;\n mode?: CommandMode;\n\toptions?: Partial<Options>;\n /** input placeholder (used when the active section does not define its own) */\n placeholder?: string;\n content: CommandSource[] | CommonCommandType;\n}\n\nexport type CommandResult = {\n\tcommand: Command;\n\tvalue?: string;\n\tid?: string;\n}\n\nexport class CommandManager {\n\n\tprivate _menu: CommandWindow;\n\tprivate _menuContainer: FloatingWindow;\n\tprivate _resolveCallback: (result: CommandResult|null) => void;\n\tprivate _rejectCallback: () => void;\n\tprivate _adapter: CommandsFlowAdapter;\n\tprivate _commands: FlowCommandSource[] = [];\n\tprivate _origOptions: Options;\n\n\tget commands() {\n\t\treturn this._commands;\n\t}\n\t\n\tconstructor(readonly target: LitElement) { }\n\n\tclear() {\n\t\tthis._commands = [];\n\t\tthis._adapter = null;\n\t}\n\n\tadd(commands: FlowCommandSource|FlowCommandSource[]) {\n\t\tthis._commands.push(...(Array.isArray(commands) ? commands : [commands]));\n\t\tthis._adapter = null;\n\t}\n\n\tget adapter() {\n\t\tif (this._adapter) return this._adapter;\n\t\tthis._adapter = new CommandsFlowAdapter(this._commands);\n\t\treturn this._adapter;\n\t}\n\n\tprivate cleanCallbacks() {\n\t\tif (this._rejectCallback) this._rejectCallback();\n\t\tthis._resolveCallback = null;\n\t\tthis._rejectCallback = null;\n\t}\n\n\tprivate _onExec = (e: CommandEvent) => {\n\t\tlog.getLogger().info(`trigger command: ${e.command.id}`);\n\t\tif (this._resolveCallback) this._resolveCallback({\n\t\t\tcommand: e.command,\n\t\t\tid: e.command?.id,\n\t\t\tvalue: e.value,\n\t\t});\n\t\tthis._resolveCallback = null;\n\t\tthis._rejectCallback = null;\n\n\t\tif (this.adapter.map.get(e.command.id)?.next == null) {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\tget menu() {\n\t\treturn this._menu ?? (this._menu = dom.createElement<CommandWindow>('og-commands', {\n\t\t\tlisteners: [['command.exec', this._onExec]]\n\t\t}));\n\t}\n\t\n\tget menuContainer() {\n\t\tif (this._menuContainer) return this._menuContainer;\n\t\tthis._menuContainer = dom.createElement<FloatingWindow>('og-floating-window', {\n\t\t\tlisteners: [['hide', () => {\n\t\t\t\tthis.target?.focus();\n\t\t\t\tthis.adapter?.reset();\n\t\t\t}]]\n\t\t});\n\t\tthis.menu.slot = 'content';\n\t\tthis._menuContainer.appendChild(this.menu);\n\t\treturn this._menuContainer;\n\t}\n\n\tasync open(options?: OpenCommandsOptions): Promise<CommandResult|null> {\n\t\tlog.getLogger().info('open menu');\n\t\tthis.target.shadowRoot.appendChild(this.menuContainer);\n\t\tthis.menuContainer.show();\n\t\toptions ??= {content: null};\n\n\t\tthis.menu.text = options.text;\n\t\tthis.menu.value = options.value;\n\t\tthis.menu.mode = options.mode || 'search';\n\t\tthis.menu.placeholder = options.placeholder ?? '';\n\n\t\tif (!this._origOptions) this._origOptions = this.menu.options;\n\t\tif (options.options) {\n\t\t\tthis.menu.options = utils.mergeDeep({}, this._origOptions, options.options);\n\t\t} else {\n\t\t\tthis.menu.options = this._origOptions;\n\t\t}\n\n\t\tif (Array.isArray(options.content)) {\n\t\t\tthis.menu.commands = options.content;\n\t\t\tthis.menu.adapter = null;\n\t\t} else if (typeof options.content === 'string') {\n\t\t\tthis.menu.commands = createCommands(options.content);\n\t\t\tthis.menu.adapter = null;\n\t\t} else {\n\t\t\tthis.menu.commands = null;\n\t\t\tthis.menu.adapter = this.adapter;\n\t\t}\n\n\t\tawait this.menu.updateComplete;\n\t\tthis.menu.focus();\n\n\t\tthis.updatePosition();\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis._resolveCallback = resolve;\n\t\t\tthis._rejectCallback = reject;\n\t\t});\n\t}\n\n\tclose() {\n\t\tthis.menuContainer.hide(false);\n\t\tthis.menuContainer.remove();\n\t\tthis.cleanCallbacks();\n\t\tthis.target?.focus();\n\t}\n\n\tupdatePosition() {\n\t\tdom.setSize(this.menuContainer, {w: 0.9 * this.target.clientWidth});\n\t\tdom.setCenterPosition(this.menuContainer, this.target, {horizontal: true, vertical: false});\n\t\tdom.setPosition(this.menuContainer, {t: 50});\n\t}\n\n}"]}
package/dist/common.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CommandFunction, CommandSource } from '@omegagrid/commands';
2
- export type CommonCommandType = 'yes_no' | 'apply' | 'ok';
2
+ export type CommonCommandType = 'yes_no' | 'apply' | 'ok' | 'save_discard_cancel';
3
3
  export declare const commandFactories: Record<CommonCommandType, (exec?: CommandFunction) => CommandSource[]>;
4
4
  export declare const createCommands: (type: CommonCommandType, exec?: CommandFunction) => CommandSource[];
5
5
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGrE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,aAAa,EAAE,CAanG,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,MAAM,iBAAiB,EAAE,OAAO,eAAe,KAAG,aAAa,EAE7F,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGrE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,qBAAqB,CAAC;AAElF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,eAAe,KAAK,aAAa,EAAE,CAkBnG,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,MAAM,iBAAiB,EAAE,OAAO,eAAe,KAAG,aAAa,EAE7F,CAAC"}
package/dist/common.js CHANGED
@@ -4,6 +4,11 @@ export const commandFactories = {
4
4
  { id: 'Y', name: msg('Yes'), exec },
5
5
  { id: 'N', name: msg('No'), exec }
6
6
  ],
7
+ 'save_discard_cancel': (exec) => [
8
+ { id: 'save', name: msg('Save changes'), icon: { icon: 'save', color: 'var(--og-colortype-green-background-color)' }, exec },
9
+ { id: 'discard', name: msg('Discard changes'), icon: { icon: 'trash', color: 'var(--og-colortype-red-background-color)' }, exec },
10
+ { id: 'cancel', name: msg('Cancel'), icon: 'times', exec }
11
+ ],
7
12
  'apply': (exec) => [
8
13
  { id: 'apply', name: msg('Apply'), exec },
9
14
  { id: 'cancel', name: msg('Cancel'), exec }
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAI1C,MAAM,CAAC,MAAM,gBAAgB,GAA2E;IACvG,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;QACnB,EAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC;QACjC,EAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAC;KAChC;IACD,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,EAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,IAAI,EAAC;QACvC,EAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAC;KACzC;IACD,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;QACf,EAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC;QAC5B,EAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAC;KACzC;CACD,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAuB,EAAE,IAAsB,EAAmB,EAAE;IAClG,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC,CAAC","sourcesContent":["import { CommandFunction, CommandSource } from '@omegagrid/commands';\nimport { msg } from '@omegagrid/localize';\n\nexport type CommonCommandType = 'yes_no' | 'apply' | 'ok';\n\nexport const commandFactories: Record<CommonCommandType, (exec?: CommandFunction) => CommandSource[]> = {\n\t'yes_no': (exec) => [\n\t\t{id: 'Y', name: msg('Yes'), exec},\n\t\t{id: 'N', name: msg('No'), exec}\n\t],\n\t'apply': (exec) => [\n\t\t{id: 'apply', name: msg('Apply'), exec},\n\t\t{id: 'cancel', name: msg('Cancel'), exec}\n\t],\n\t'ok': (exec) => [\n\t\t{id: 'ok', name: 'OK', exec},\n\t\t{id: 'cancel', name: msg('Cancel'), exec}\n\t]\n};\n\nexport const createCommands = (type: CommonCommandType, exec?: CommandFunction): CommandSource[] => {\n\treturn commandFactories[type](exec);\n};\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAI1C,MAAM,CAAC,MAAM,gBAAgB,GAA2E;IACvG,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC;QACnB,EAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC;QACjC,EAAC,EAAE,EAAE,GAAG,EAAE,IAAI,E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'@omegagrid/localize';\n\nexport type CommonCommandType = 'yes_no' | 'apply' | 'ok' | 'save_discard_cancel';\n\nexport const commandFactories: Record<CommonCommandType, (exec?: CommandFunction) => CommandSource[]> = {\n\t'yes_no': (exec) => [\n\t\t{id: 'Y', name: msg('Yes'), exec},\n\t\t{id: 'N', name: msg('No'), exec}\n\t],\n\t'save_discard_cancel': (exec) => [\n\t\t{id: 'save', name: msg('Save changes'), icon: {icon: 'save', color: 'var(--og-colortype-green-background-color)'}, exec},\n\t\t{id: 'discard', name: msg('Discard changes'), icon: {icon: 'trash', color: 'var(--og-colortype-red-background-color)'}, exec},\n\t\t{id: 'cancel', name: msg('Cancel'), icon: 'times', exec}\n\t],\n\t'apply': (exec) => [\n\t\t{id: 'apply', name: msg('Apply'), exec},\n\t\t{id: 'cancel', name: msg('Cancel'), exec}\n\t],\n\t'ok': (exec) => [\n\t\t{id: 'ok', name: 'OK', exec},\n\t\t{id: 'cancel', name: msg('Cancel'), exec}\n\t]\n};\n\nexport const createCommands = (type: CommonCommandType, exec?: CommandFunction): CommandSource[] => {\n\treturn commandFactories[type](exec);\n};\n"]}
@@ -1,5 +1,6 @@
1
1
  import { CustomProperties, IconSpec } from "@omegagrid/core";
2
2
  import { TabItem } from "@omegagrid/tabs";
3
+ import { CommandRenderer } from "../ui";
3
4
  export type CommandSectionSwitch = {
4
5
  key: string;
5
6
  value: string;
@@ -11,7 +12,7 @@ export type CommandsSection = TabItem & {
11
12
  triggerCommand?: string;
12
13
  switches?: CommandSectionSwitch[];
13
14
  };
14
- export type CommandMode = 'search' | 'input' | 'none';
15
+ export type CommandMode = 'search' | 'input' | 'none' | 'menu';
15
16
  export type CommandInput = {
16
17
  id: string;
17
18
  value?: string;
@@ -22,7 +23,9 @@ export type CommandSource = {
22
23
  name?: string;
23
24
  value?: string;
24
25
  group?: string;
26
+ icon?: IconSpec | string;
25
27
  exec?: CommandFunction;
28
+ renderer?: CommandRenderer;
26
29
  props?: CustomProperties;
27
30
  };
28
31
  export declare class Command {
@@ -30,6 +33,8 @@ export declare class Command {
30
33
  name: string;
31
34
  group: string;
32
35
  props: CustomProperties;
36
+ renderer?: CommandRenderer;
37
+ icon?: IconSpec | string;
33
38
  private _exec;
34
39
  constructor(source?: CommandSource);
35
40
  populate(source: CommandSource): void;
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/model/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAS,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,MAAM,oBAAoB,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,GAAC,MAAM,CAAC;CACvB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,oBAAoB,EAAE,CAAC;CAClC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,YAAY,GAAG;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AACxD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,GAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAEvF,MAAM,MAAM,aAAa,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,I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AAG,CAAC,IAAI,EAAE,MAAM;IAOhB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAI/B,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,aAAa,UAAQ,EAAE,WAAW,UAAQ,GAAG,CAAC,YAAY,GAAC,OAAO,CAAC,EAAE;CAmC3F"}
@@ -10,6 +10,8 @@ export class Command {
10
10
  this.group = source.group || 'default';
11
11
  this._exec = source.exec;
12
12
  this.props = source.props;
13
+ this.renderer = source.renderer;
14
+ this.icon = source.icon;
13
15
  }
14
16
  getSourceData() {
15
17
  return {
@@ -18,6 +20,8 @@ export class Command {
18
20
  group: this.group,
19
21
  props: this.props,
20
22
  exec: this._exec,
23
+ renderer: this.renderer,
24
+ icon: this.icon,
21
25
  };
22
26
  }
23
27
  exec(value) {
@@ -1 +1 @@
1
- {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/model/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,EAAE,MAAM,iBAAiB,CAAC;AA6BpE,MAAM,OAAO,OAAO;IASnB,YAAY,MAAsB;QACjC,IAAI,MAAM;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,MAAqB;QAC7B,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,aAAa;QACZ,OAAO;YACN,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI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G,KAAK,CAAC;YAC1B,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACzD,IAAI,UAAU,IAAI,WAAW,EAAE,CAAC;gBAC/B,IAAI,aAAa,EAAE,CAAC;oBACnB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC;gBACD,aAAa,GAAG,IAAI,CAAC;YACtB,CAAC;YAED,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBAChB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;oBAChC,IAAI,UAAU,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC5C,IAAI,aAAa,IAAI,CAAC,aAAa,EAAE,CAAC;4BACrC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;4BAClB,aAAa,GAAG,IAAI,CAAC;wBACtB,CAAC;wBACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACrB,CAAC;gBACF,CAAC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CASD","sourcesContent":["import { CustomProperties, IconSpec, utils } from \"@omegagrid/core\";\nimport { TabItem } from \"@omegagrid/tabs\";\n\nexport type CommandSectionSwitch = {\n\tkey: string,\n\tvalue: string,\n\tchecked?: boolean,\n\ticon?: IconSpec|string,\n}\n\nexport type CommandsSection = TabItem & {\n\tplaceholder?: string,\n\ttriggerCommand?: string,\n\tswitches?: CommandSectionSwitch[],\n}\n\nexport type CommandMode = 'search' | 'input' | 'none';\nexport type CommandInput = {id: string, value?: string};\nexport type CommandFunction = (command: Command, value?: string) => void|Promise<void>;\n\t\nexport type CommandSource = {\n\tid?: string;\n\tname?: string;\n\tvalue?: string;\n\tgroup?: string;\n\texec?: CommandFunction;\n\tprops?: CustomProperties;\n}\n\nexport class Command {\n\n\tid: string;\n\tname: string;\n\tgroup: string;\n\tprops: CustomProperties;\n\n\tprivate _exec: CommandFunction;\n\n\tconstructor(source?: CommandSource) {\n\t\tif (source) this.populate(source);\n\t}\n\n\tpopulate(source: CommandSource) {\n\t\tthis.id = source.id || source.name;\n\t\tthis.name = source.name || source.id;\n\t\tthis.group = source.group || 'default';\n\t\tthis._exec = source.exec;\n\t\tthis.props = source.props;\n\t}\n\n\tgetSourceData(): CommandSource {\n\t\treturn {\n\t\t\tid: this.id,\n\t\t\tname: this.name,\n\t\t\tgroup: this.group,\n\t\t\tprops: this.props,\n\t\t\texec: this._exec,\n\t\t};\n\t}\n\n\texec(value?: string) {\n\t\treturn this._exec ? this._exec(this, value) : null;\n\t}\n\n}\n\nexport type CommandGroupSource = {\n\tid: string,\n\tname?: string\n\tcommands?: CommandSource[];\n}\n\nexport class CommandGroup {\n\n\tpublic readonly commands = new Map<string, Command>();\n\tpublic readonly id: string;\n\tpublic readonly name: string;\n\tpublic open = true;\n\n\tconstructor(source: CommandGroupSource) {\n\t\tthis.id = source.id || source.name;\n\t\tthis.name = source.name || source.id;\n\t\tsource.commands?.forEach(c => this.addCommand(c));\n\t}\n\n\taddCommand(command: Command|CommandSource) {\n\t\tconst cmd = command instanceof Command ? command : new Command(command);\n\t\tthis.commands.set(cmd.id, cmd);\n\t}\n\n\tgetSourceData(): CommandGroupSource {\n\t\treturn {\n\t\t\tid: this.id,\n\t\t\tname: this.name,\n\t\t\tcommands: Array.from([...this.commands].map(([_, c]) => c.getSourceData())),\n\t\t};\n\t}\n\n}\n\nexport class Commands {\n\t\n\tpublic readonly groups = new Map<string, CommandGroup>();\n\n\tget count() {\n\t\tlet cnt = 0;\n\t\tthis.groups.forEach(group => cnt += group.commands.size);\n\t\treturn cnt;\n\t}\n\n\tconstructor(commands?: CommandSource[]) {\n\t\tif (commands) commands.forEach(c => this.register(c));\n\t}\n\n\tclear() {\n\t\tthis.groups.clear();\n\t\treturn this;\n\t}\n\n\tregisterGroup(group: CommandGroupSource) {\n\t\tconst g = this.groups.has(group.id) ? this.groups.get(group.id) : new CommandGroup(group);\n\t\tgroup.commands?.forEach(c => g.commands.set(c.id, new Command(c)));\n\t\tthis.groups.set(g.id, g);\n\t\treturn g;\n\t}\n\n\tremoveSection(sectionId: string) {\n\t\tthis.groups.delete(sectionId);\n\t}\n\t\n\tregister(command: Command|CommandSource) {\n\t\tconst groupId = command.group || 'default';\n\t\tconst group = this.groups.get(groupId) || this.registerGroup({id: groupId, name: groupId});\n\t\tgroup.addCommand(command);\n\t}\n\n\tremove(name: string) {\n\t\tthis.groups.forEach(group => group.commands.delete(name));\n\t}\n\n\tget(name: string) {\n\t\tfor (const group of this.groups.values()) {\n\t\t\tif (group.commands.has(name)) return group.commands.get(name);\n\t\t}\n\t\treturn null;\n\t}\n\n\texec(id: string, value?: string) {\n\t\treturn this.get(id)?.exec(value);\n\t}\n\n\tfilter(term?: string, includeGroups = false, emptyGroups = false): (CommandGroup|Command)[] {\n\t\tconst items: (CommandGroup|Command)[] = [];\n\t\tconst regex = term == null ? null : new RegExp(utils.escapeRegExp(term), 'ig');\n\t\tfor (const group of this.groups.values()) {\n\t\t\tlet groupIncluded = false;\n\t\t\tconst groupMatch = regex ? regex.test(group.name) : true;\n\t\t\tif (groupMatch && emptyGroups) {\n\t\t\t\tif (includeGroups) {\n\t\t\t\t\titems.push(group);\n\t\t\t\t}\n\t\t\t\tgroupIncluded = true;\n\t\t\t}\n\n\t\t\tif (group.open) {\n\t\t\t\tgroup.commands.forEach(command => {\n\t\t\t\t\tif (groupMatch || regex.test(command.name)) {\n\t\t\t\t\t\tif (includeGroups && !groupIncluded) {\n\t\t\t\t\t\t\titems.push(group);\n\t\t\t\t\t\t\tgroupIncluded = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\titems.push(command);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn items;\n\t}\n\n\t// merge(commands: Commands): Commands {\n\t// \tconst mergedCommands = new Commands();\n\t// \tthis.groups.forEach(g => mergedCommands.registerGroup(g.getSourceData()));\n\t// \tcommands.groups.forEach(g => mergedCommands.registerGroup(g.getSourceData()));\n\t// \treturn mergedCommands;\n\t// }\n\n}"]}
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/model/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAgCpE,MAAM,OAAO,OAAO;IAWnB,YAAY,MAAsB;QACjC,IAAI,MAAM;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ,CAAC,MAAqB;QAC7B,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,aAAa;QACZ,OAAO;YACN,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC;IACH,CAAC;IAED,IAAI,CAAC,KAAc;QAClB,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EAAE,CAAC;gBAC/B,IAAI,aAAa,EAAE,CAAC;oBACnB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC;gBACD,aAAa,GAAG,IAAI,CAAC;YACtB,CAAC;YAED,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBAChB,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;oBAChC,IAAI,UAAU,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC5C,IAAI,aAAa,IAAI,CAAC,aAAa,EAAE,CAAC;4BACrC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;4BAClB,aAAa,GAAG,IAAI,CAAC;wBACtB,CAAC;wBACD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACrB,CAAC;gBACF,CAAC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CASD","sourcesContent":["import { CustomProperties, IconSpec, utils } from \"@omegagrid/core\";\nimport { TabItem } from \"@omegagrid/tabs\";\nimport { CommandRenderer } from \"../ui\";\n\nexport type CommandSectionSwitch = {\n\tkey: string,\n\tvalue: string,\n\tchecked?: boolean,\n\ticon?: IconSpec|string,\n}\n\nexport type CommandsSection = TabItem & {\n\tplaceholder?: string,\n\ttriggerCommand?: string,\n\tswitches?: CommandSectionSwitch[],\n}\n\nexport type CommandMode = 'search' | 'input' | 'none' | 'menu';\nexport type CommandInput = {id: string, value?: string};\nexport type CommandFunction = (command: Command, value?: string) => void|Promise<void>;\n\t\nexport type CommandSource = {\n\tid?: string;\n\tname?: string;\n\tvalue?: string;\n\tgroup?: string;\n\ticon?: IconSpec|string;\n\texec?: CommandFunction;\n\trenderer?: CommandRenderer;\n\tprops?: CustomProperties;\n}\n\nexport class Command {\n\n\tid: string;\n\tname: string;\n\tgroup: string;\n\tprops: CustomProperties;\n\trenderer?: CommandRenderer;\n\ticon?: IconSpec|string;\n\n\tprivate _exec: CommandFunction;\n\n\tconstructor(source?: CommandSource) {\n\t\tif (source) this.populate(source);\n\t}\n\n\tpopulate(source: CommandSource) {\n\t\tthis.id = source.id || source.name;\n\t\tthis.name = source.name || source.id;\n\t\tthis.group = source.group || 'default';\n\t\tthis._exec = source.exec;\n\t\tthis.props = source.props;\n\t\tthis.renderer = source.renderer;\n\t\tthis.icon = source.icon;\n\t}\n\n\tgetSourceData(): CommandSource {\n\t\treturn {\n\t\t\tid: this.id,\n\t\t\tname: this.name,\n\t\t\tgroup: this.group,\n\t\t\tprops: this.props,\n\t\t\texec: this._exec,\n\t\t\trenderer: this.renderer,\n\t\t\ticon: this.icon,\n\t\t};\n\t}\n\n\texec(value?: string) {\n\t\treturn this._exec ? this._exec(this, value) : null;\n\t}\n\n}\n\nexport type CommandGroupSource = {\n\tid: string,\n\tname?: string\n\tcommands?: CommandSource[];\n}\n\nexport class CommandGroup {\n\n\tpublic readonly commands = new Map<string, Command>();\n\tpublic readonly id: string;\n\tpublic readonly name: string;\n\tpublic open = true;\n\n\tconstructor(source: CommandGroupSource) {\n\t\tthis.id = source.id || source.name;\n\t\tthis.name = source.name || source.id;\n\t\tsource.commands?.forEach(c => this.addCommand(c));\n\t}\n\n\taddCommand(command: Command|CommandSource) {\n\t\tconst cmd = command instanceof Command ? command : new Command(command);\n\t\tthis.commands.set(cmd.id, cmd);\n\t}\n\n\tgetSourceData(): CommandGroupSource {\n\t\treturn {\n\t\t\tid: this.id,\n\t\t\tname: this.name,\n\t\t\tcommands: Array.from([...this.commands].map(([_, c]) => c.getSourceData())),\n\t\t};\n\t}\n\n}\n\nexport class Commands {\n\t\n\tpublic readonly groups = new Map<string, CommandGroup>();\n\n\tget count() {\n\t\tlet cnt = 0;\n\t\tthis.groups.forEach(group => cnt += group.commands.size);\n\t\treturn cnt;\n\t}\n\n\tconstructor(commands?: CommandSource[]) {\n\t\tif (commands) commands.forEach(c => this.register(c));\n\t}\n\n\tclear() {\n\t\tthis.groups.clear();\n\t\treturn this;\n\t}\n\n\tregisterGroup(group: CommandGroupSource) {\n\t\tconst g = this.groups.has(group.id) ? this.groups.get(group.id) : new CommandGroup(group);\n\t\tgroup.commands?.forEach(c => g.commands.set(c.id, new Command(c)));\n\t\tthis.groups.set(g.id, g);\n\t\treturn g;\n\t}\n\n\tremoveSection(sectionId: string) {\n\t\tthis.groups.delete(sectionId);\n\t}\n\t\n\tregister(command: Command|CommandSource) {\n\t\tconst groupId = command.group || 'default';\n\t\tconst group = this.groups.get(groupId) || this.registerGroup({id: groupId, name: groupId});\n\t\tgroup.addCommand(command);\n\t}\n\n\tremove(name: string) {\n\t\tthis.groups.forEach(group => group.commands.delete(name));\n\t}\n\n\tget(name: string) {\n\t\tfor (const group of this.groups.values()) {\n\t\t\tif (group.commands.has(name)) return group.commands.get(name);\n\t\t}\n\t\treturn null;\n\t}\n\n\texec(id: string, value?: string) {\n\t\treturn this.get(id)?.exec(value);\n\t}\n\n\tfilter(term?: string, includeGroups = false, emptyGroups = false): (CommandGroup|Command)[] {\n\t\tconst items: (CommandGroup|Command)[] = [];\n\t\tconst regex = term == null ? null : new RegExp(utils.escapeRegExp(term), 'ig');\n\t\tfor (const group of this.groups.values()) {\n\t\t\tlet groupIncluded = false;\n\t\t\tconst groupMatch = regex ? regex.test(group.name) : true;\n\t\t\tif (groupMatch && emptyGroups) {\n\t\t\t\tif (includeGroups) {\n\t\t\t\t\titems.push(group);\n\t\t\t\t}\n\t\t\t\tgroupIncluded = true;\n\t\t\t}\n\n\t\t\tif (group.open) {\n\t\t\t\tgroup.commands.forEach(command => {\n\t\t\t\t\tif (groupMatch || regex.test(command.name)) {\n\t\t\t\t\t\tif (includeGroups && !groupIncluded) {\n\t\t\t\t\t\t\titems.push(group);\n\t\t\t\t\t\t\tgroupIncluded = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\titems.push(command);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn items;\n\t}\n\n\t// merge(commands: Commands): Commands {\n\t// \tconst mergedCommands = new Commands();\n\t// \tthis.groups.forEach(g => mergedCommands.registerGroup(g.getSourceData()));\n\t// \tcommands.groups.forEach(g => mergedCommands.registerGroup(g.getSourceData()));\n\t// \treturn mergedCommands;\n\t// }\n\n}"]}
@@ -24,7 +24,7 @@ export declare class CommandWindow extends LitElement {
24
24
  value: string;
25
25
  sectionPosition: 'top' | 'bottom' | 'left' | 'right';
26
26
  dropdownWidth: number;
27
- text: string;
27
+ text: string | TemplateResult<1>;
28
28
  commands: CommandSource[];
29
29
  adapter: CommandsAdapter;
30
30
  target: HTMLElement;
@@ -48,7 +48,7 @@ export declare class CommandWindow extends LitElement {
48
48
  value: string;
49
49
  };
50
50
  get filterValue(): string;
51
- get commandRenderer(): CommandRenderer;
51
+ getCommandRenderer(index: number): CommandRenderer;
52
52
  get groupRenderer(): GroupRenderer;
53
53
  exec(dispatchEvent?: boolean): Promise<void>;
54
54
  _onKeyDown: (e: KeyboardEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"commandWindow.d.ts","sourceRoot":"","sources":["../../src/ui/commandWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAe,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrH,OAAO,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAe,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,eAAe,EAAqB,MAAM,iBAAiB,CAAC;AACzJ,OAAO,EAAE,UAAU,EAAQ,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAKvE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,qBAAa,YAAa,SAAQ,KAAK;IAEtC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,Q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WAAW,YAEd;IAED,UAAU,+BAiBJ;IAEN,cAAc,+BAYP;IAEP,IAAI,WAAW,YAGd;IAED,cAAc,+BA2BP;IAEP,MAAM,0BAyCJ;CAEF"}
@@ -20,7 +20,12 @@ export class CommandEvent extends Event {
20
20
  }
21
21
  }
22
22
  const DEFAULT_COMMAND_RENDERER = (_div, command) => {
23
- return html `<div class="command">${command.name}</div>`;
23
+ return html `
24
+ <div class="command">
25
+ ${command.icon ? html `<og-icon .icon="${command.icon}" style="margin-right: 8px;"></og-icon>` : ''}
26
+ ${command.name}
27
+ </div>
28
+ `;
24
29
  };
25
30
  const DEFAULT_GROUP_RENDERER = (_div, group) => {
26
31
  return html `
@@ -53,8 +58,11 @@ let CommandWindow = class CommandWindow extends LitElement {
53
58
  get filterValue() {
54
59
  return this.mode == 'search' ? this.parsedInput?.value ?? '' : '';
55
60
  }
56
- get commandRenderer() {
57
- return this.options?.commandRenderer || DEFAULT_COMMAND_RENDERER;
61
+ getCommandRenderer(index) {
62
+ const command = this.visibleItems[index];
63
+ if (command instanceof Command && command.renderer)
64
+ return command.renderer;
65
+ return command.renderer || this.options?.commandRenderer || DEFAULT_COMMAND_RENDERER;
58
66
  }
59
67
  get groupRenderer() {
60
68
  return this.options?.groupRenderer || DEFAULT_GROUP_RENDERER;
@@ -167,17 +175,18 @@ let CommandWindow = class CommandWindow extends LitElement {
167
175
  }
168
176
  }
169
177
  else {
170
- this.input.value = '';
178
+ if (this.input)
179
+ this.input.value = '';
171
180
  if (e.trigger == ListSelectTrigger.Click || e.trigger == ListSelectTrigger.Enter) {
172
181
  this.toggleGroup(item.id);
173
182
  }
174
183
  }
175
- setTimeout(() => this.input.focus());
184
+ setTimeout(() => this.input?.focus());
176
185
  };
177
186
  this._itemRenderer = (div, index, opts) => {
178
187
  return this.visibleItems[index] instanceof CommandGroup
179
188
  ? this.groupRenderer(div, this.visibleItems[index], opts)
180
- : this.commandRenderer(div, this.visibleItems[index], opts);
189
+ : this.getCommandRenderer(index)(div, this.visibleItems[index], opts);
181
190
  };
182
191
  this._updateToken = 0;
183
192
  this.renderTabs = () => this.sections?.length > 1 ? html `
@@ -240,7 +249,7 @@ let CommandWindow = class CommandWindow extends LitElement {
240
249
  </div>
241
250
  ` : '';
242
251
  this.render = () => html `
243
- <div class="input">
252
+ <div class="input" style="${styleMap(this.mode == 'menu' ? { maxHeight: '0', overflow: 'hidden', padding: '0' } : {})}">
244
253
  ${this.sectionPosition == 'left' ? this.renderDropdown() : ''}
245
254
 
246
255
  <input
@@ -250,7 +259,7 @@ let CommandWindow = class CommandWindow extends LitElement {
250
259
  .value="${this.value ?? ''}">
251
260
 
252
261
  ${this.sectionPosition == 'right' ? this.renderDropdown() : ''}
253
- </div>
262
+ </div>
254
263
 
255
264
  ${this.sectionPosition != 'bottom' ? this.renderControls() : ''}
256
265
 
@@ -292,7 +301,8 @@ let CommandWindow = class CommandWindow extends LitElement {
292
301
  this.input?.focus();
293
302
  }
294
303
  clearFilter(updateCommands = true) {
295
- this.input.value = '';
304
+ if (this.input)
305
+ this.input.value = '';
296
306
  this.focus();
297
307
  if (updateCommands)
298
308
  this.updateCommands();
@@ -455,7 +465,7 @@ __decorate([
455
465
  property({ type: Number })
456
466
  ], CommandWindow.prototype, "dropdownWidth", void 0);
457
467
  __decorate([
458
- property({ type: String })
468
+ property()
459
469
  ], CommandWindow.prototype, "text", void 0);
460
470
  __decorate([
461
471
  property({ type: Array })
@@ -1 +1 @@
1
- {"version":3,"file":"commandWindow.js","sourceRoot":"","sources":["../../src/ui/commandWindow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAmB,WAAW,EAA8B,MAAM,UAAU,CAAC;AAErH,OAAO,EAAU,GAAG,EAA0F,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzJ,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,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AAC,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC;+CACE;AAG1B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACA;AAGzB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACL;AAIpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kDACR;AAIjB;IADC,KAAK,EAAE;wDACe;AAGvB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;iDACR;AAGlB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACF;AAGvB;IADC,KAAK,EAAE;+CACwC;AAGhD;IADC,KAAK,EAAE;yDACe;AAGvB;IADC,KAAK,EAAE;gDACU;AAGlB;IADC,KAAK,CAAC,OAAO,CAAC;kDACa;AAG5B;IADC,KAAK,CAAC,SAAS,CAAC;2CACN;AAGX;IADC,KAAK,CAAC,OAAO,CAAC;4CACS;AAGxB;IADC,KAAK,CAAC,kBAAkB,CAAC;+CACH;AAvEX,aAAa;IADzB,aAAa,CAAC,aAAa,CAAC;GAChB,aAAa,CAwezB","sourcesContent":["import { Commands, Command, CommandGroup, CommandsSection, initOptions, CommandMode, CommandSource } from \"../model\";\nimport { CommandsAdapter} from \"../adapters\";\nimport { Button, dom, DropdownList, events, List, ListItemRenderer, ListItemRendererOptions, ListSelectEvent, ListSelectTrigger } from \"@omegagrid/core\";\nimport { LitElement, html, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { debounce } from \"ts-debounce\";\nimport { style, itemStyle } from \"./commandWindow.style\";\nimport { styleMap } from \"lit-html/directives/style-map.js\";\nimport { TabEvent } from \"@omegagrid/tabs\";\nimport { msg } from \"@omegagrid/localize\";\n\nexport class CommandEvent extends Event {\n\n\treadonly command?: Command;\n\treadonly value?: string;\n\treadonly section?: CommandsSection;\n\n\tconstructor(type: string, args?: Partial<CommandEvent>) {\n\t\tsuper(`command.${type}`, {bubbles: true, composed: true})\n\t\tif (args) Object.assign(this, args);\n\t}\n}\n\nexport type CommandRenderer = (div: HTMLDivElement, command: Command, opts?: ListItemRendererOptions) => string | void | TemplateResult<1> | null;\nexport type GroupRenderer = (div: HTMLDivElement, group: CommandGroup, opts?: ListItemRendererOptions) => string | void | TemplateResult<1> | null;\n\nconst DEFAULT_COMMAND_RENDERER: CommandRenderer = (_div: HTMLDivElement, command: Command) => {\n\treturn html`<div class=\"command\">${command.name}</div>`;\n};\n\nconst DEFAULT_GROUP_RENDERER: GroupRenderer = (_div: HTMLDivElement, group: CommandGroup) => {\n\treturn html`\n\t\t<div class=\"group\" @mousedown=\"${(e: MouseEvent) => e.preventDefault()}\">\n\t\t\t<div class=\"group-toggle\">\n\t\t\t\t<og-icon icon=\"angle-${group.open ? 'down' : 'right'}\"></og-icon>\n\t\t\t</div>\n\n\t\t\t<div class=\"group-text\">\n\t\t\t\t${group.name}\n\t\t\t</div>\n\t\t</div>\n\t`;\n};\n\n@customElement('og-commands')\nexport class CommandWindow extends LitElement {\n\n\tstatic styles = [style];\n\n\tprivate visibleItems: (Command|CommandGroup)[];\n\n\t@property({type: Object})\n\toptions = initOptions();\n\n\t/**\n\t * search = commands are filtered by input value\n\t * input = commands are not filtered, input is used to enter custom value\n\t * none = no input, only command list is shown\n\t */\n\t@property({type: String})\n\tmode: CommandMode = 'search';\n\n\t@property({type: String})\n\tvalue: string;\n\n\t@property({type: String, reflect: true})\n\tsectionPosition: 'top'|'bottom'|'left'|'right' = 'right';\n\n\t@property({type: Number})\n\tdropdownWidth = 100;\n\n\t@property({type: String})\n\ttext: string;\n\n\t@property({type: Array})\n\tcommands: CommandSource[];\n\n\t@property({type: Object})\n\tadapter: CommandsAdapter;\n\n\t@property({type: Object})\n\ttarget: HTMLElement;\n\n\t/** default input placeholder, sections can override it with their own */\n\t@property({type: String})\n\tplaceholder = '';\n\n\t/** currently displayed placeholder (section placeholder or the default one) */\n\t@state()\n\tactivePlaceholder = '';\n\n\t@property({type: Boolean})\n\tshowGroups = false\n\n\t@property({type: Object})\n\tmodel = new Commands();\n\n\t@state()\n\tsections: CommandsSection[] = [{id: 'default'}];\n\n\t@state()\n\tactiveSectionIndex = 0;\n\n\t@state()\n\tnoResults = false;\n\n\t@query('.list')\n\tlistWrapper: HTMLDivElement;\n\n\t@query('og-list')\n\tlist: List;\n\n\t@query('input')\n\tinput: HTMLInputElement;\n\n\t@query('og-dropdown-list')\n\tdropdown: DropdownList;\n\n\tget activeSection() { return this.sections?.[this.activeSectionIndex] }\n\n\tget inputValue() { return this.input?.value ?? '' }\n\tget parsedInput() {\n\t\tconst input = this.inputValue;\n\t\tconst chunks = input.split(' ', 2);\n\t\tif (chunks.length > 1) {\n\t\t\tconst section = (this.sections ?? []).findIndex(s => s?.triggerCommand == chunks[0]);\n\t\t\tconst value = section > -1 ? chunks[1] ?? '' : input;\n\t\t\treturn { section, value };\n\t\t} else {\n\t\t\treturn { section: -1, value: input};\n\t\t}\n\t}\n\n\tget filterValue() {\n\t\treturn this.mode == 'search' ? this.parsedInput?.value ?? '' : '';\n\t}\n\n\tget commandRenderer(): CommandRenderer {\n\t\treturn this.options?.commandRenderer || DEFAULT_COMMAND_RENDERER;\n\t}\n\n\tget groupRenderer(): GroupRenderer {\n\t\treturn this.options?.groupRenderer || DEFAULT_GROUP_RENDERER;\n\t}\n\n\tasync exec(dispatchEvent = true) {\n\t\tconst input = this.parsedInput;\n\t\tconst command = this.visibleItems[this.list.selectedIndex];\n\n\t\tif (!(command instanceof Command)) return;\n\n\t\tthis.clearFilter(false);\n\n\t\tcommand.exec(input.value);\n\t\tif (this.adapter) {\n\t\t\tthis.adapter.exec(command, input.value);\n\t\t}\n\n\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('exec', {\n\t\t\tcommand: command,\n\t\t\tsection: this.sections.find(s => s.id === input.section),\n\t\t\tvalue: input.value\n\t\t}));\n\t}\n\n\t_onKeyDown = (e: KeyboardEvent) => {\n\t\tif (e.key != 'Escape') e.stopPropagation();\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowDown':\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.list.moveDown();\n\t\t\t\tbreak;\n\t\t\tcase 'ArrowUp':\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.list.moveUp();\n\t\t\t\tbreak;\n\t\t\tcase 'Enter':\n\t\t\t\te.preventDefault();\n\t\t\t\tif (this.visibleItems[this.list.selectedIndex] instanceof CommandGroup)\n\t\t\t\t\tthis.toggleGroup((this.visibleItems[this.list.selectedIndex] as CommandGroup).id);\n\t\t\t\telse this.exec();\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t_debounceInput = debounce(() => {\n\t\tif (this.mode == 'search') {\n\t\t\tconst input = this.parsedInput;\n\t\t\tif (input.section > -1) {\n\t\t\t\tthis.activeSectionIndex = input.section;\n\t\t\t\tthis.input.value = '';\n\t\t\t\tthis.updateCommands(true);\n\t\t\t} else {\n\t\t\t\tthis.updateCommands();\n\t\t\t}\n\t\t} else if (this.mode == 'none') { // online highlight first match\n\t\t\tconst input = this.parsedInput;\n\t\t\tconst commands = this.model.filter(input.value, false) as Command[];\n\t\t\tif (commands.length > 0) {\n\t\t\t\tconst index = this.visibleItems.findIndex(item => item instanceof Command && item.id === commands[0].id);\n\t\t\t\tif (index > -1) {\n\t\t\t\t\tthis.list.selectedIndex = index;\n\t\t\t\t\tthis.list.renderItems(true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, this.options.inputDelay);\n\n\t_onInput = (e: InputEvent) => {\n\t\te.stopPropagation();\n\t\tthis._debounceInput();\n\t}\n\n\t_onSectionSelect = async (e: TabEvent) => {\n\t\tif (this.activeSectionIndex == e.index) return;\n\t\tthis.activeSectionIndex = e.index;\n\t\tthis.updateCommands(true);\n\t\tthis.focus();\n\t}\n\n\t_onDropdownChange = async (_e: events.ChangeEvent) => {\n\t\tthis.activeSectionIndex = this.sections.findIndex(s => s.id === this.dropdown.value);\n\t\tthis.updateCommands(true);\n\t\tthis.focus();\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('click', e => e.stopPropagation());\n\t\tthis.addEventListener('keydown', this._onKeyDown);\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 0;\n\t}\n\n\tfocus() {\n\t\tthis.input?.focus();\n\t}\n\n\tclearFilter(updateCommands = true) {\n\t\tthis.input.value = '';\n\t\tthis.focus();\n\t\tif (updateCommands) this.updateCommands();\n\t}\n\n\tasync willUpdate(props: PropertyValues) {\n\t\tif (props.has('adapter') && this.adapter) {\n\t\t\tthis.adapter.attach(this);\n\t\t\tconst sections = await this.adapter.getSections();\n\t\t\tconst options = await this.adapter.getOptions(sections?.length ? sections[0].id : null);\n\t\t\tthis.sections = sections;\n\t\t\tif (options) this.options = initOptions(options);\n\t\t} else {\n\t\t\tif (props.has('commands') && this.commands) {\n\t\t\t\tthis.model.clear();\n\t\t\t\tthis.commands.forEach(c => this.model.register(c));\n\t\t\t}\n\n\t\t\tif (props.has('options')) {\n\t\t\t\tthis.options = initOptions(this.options);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync updated(props: Map<PropertyKey, unknown>) {\n\t\tif (['commands', 'adapter', 'model', 'activeSectionIndex'].some(p => props.has(p))) {\n\t\t\tawait this.updateCommands(true);\n\t\t}\n\t}\n\n\t_onSelect = (e: ListSelectEvent) => {\n\t\tconst item = this.visibleItems[e.index];\n\t\tif (item instanceof Command) {\n\t\t\tif (this.mode == 'search') this.input.value = item.name;\n\t\t\tif (e.trigger == ListSelectTrigger.Click || e.trigger == ListSelectTrigger.Enter) {\n\t\t\t\tthis.exec();\n\t\t\t}\n\t\t} else {\n\t\t\tthis.input.value = '';\n\t\t\tif (e.trigger == ListSelectTrigger.Click || e.trigger == ListSelectTrigger.Enter) {\n\t\t\t\tthis.toggleGroup((item as CommandGroup).id);\n\t\t\t}\n\t\t}\n\n\t\tsetTimeout(() => this.input.focus());\n\t}\n\n\t_itemRenderer: ListItemRenderer = (div: HTMLDivElement, index: number, opts?: ListItemRendererOptions) => {\n\t\treturn this.visibleItems[index] instanceof CommandGroup\n\t\t\t? this.groupRenderer(div, this.visibleItems[index] as CommandGroup, opts)\n\t\t\t: this.commandRenderer(div, this.visibleItems[index] as Command, opts);\n\t}\n\n\tprivate _updateToken = 0;\n\n\tasync updateCommands(updateOptions = false) {\n\t\tif (this.adapter) {\n\t\t\tthis.model.clear();\n\t\t\tconst switches = this.activeSection?.switches?.filter(s => s.checked).map(s => s.key) || [];\n\n\t\t\tif (updateOptions) {\n\t\t\t\tconst options = await this.adapter.getOptions(this.activeSection?.id);\n\t\t\t\tthis.options = initOptions(options);\n\t\t\t}\n\n\t\t\tthis._updateToken++; // prevents race conditions when multiple requests are made in quick succession\n\t\t\tconst updateToken = this._updateToken;\n\n\t\t\tconst [groups, commands] = (await Promise.all([this.adapter.getGroups({\n\t\t\t\tsectionId: this.activeSection?.id,\n\t\t\t\tfilter: this.filterValue,\n\t\t\t\tswitches\n\t\t\t}), this.adapter.getCommands({\n\t\t\t\tsectionId: this.activeSection?.id,\n\t\t\t\tfilter: this.filterValue,\n\t\t\t\tswitches\n\t\t\t})]));\n\n\t\t\tif (updateToken != this._updateToken) return;\n\n\t\t\tgroups?.forEach(group => this.model.registerGroup(group));\n\t\t\tcommands?.forEach(command => this.model.register(command));\n\t\t\tthis.visibleItems = this.model.filter(null, this.showGroups, true);\n\t\t} else {\n\t\t\tthis.visibleItems = this.model.filter(this.filterValue, this.showGroups);\n\t\t}\n\n\t\tthis.activePlaceholder = this.activeSection?.placeholder || this.placeholder || '';\n\t\tthis.list.reset();\n\t\tthis.list.size = this.visibleItems.length;\n\t\tthis.list.selectedIndex = this.visibleItems.findIndex(item => item instanceof Command) ?? 0;\n\t\tthis.list.renderItems(true);\n\t\tthis.noResults = this.visibleItems.length == 0;\n\t}\n\n\tasync toggleGroup(groupId: string) {\n\t\tconst group = this.model.groups.get(groupId);\n\t\tthis.list.reset();\n\n\t\tif (group.open) {\n\t\t\tgroup.open = false;\n\t\t\tthis.visibleItems = this.model.filter(this.filterValue, this.showGroups, true);\n\t\t\tthis.list.size = this.visibleItems.length;\n\t\t} else {\n\t\t\tgroup.open = true;\n\t\t\tif (this.adapter) {\n\t\t\t\tconst commands = (await Promise.all([this.adapter.getCommands({\n\t\t\t\t\tsectionId: this.activeSection?.id,\n\t\t\t\t\tgroupId,\n\t\t\t\t\tfilter: this.filterValue\n\t\t\t\t})]))[0];\n\n\t\t\t\tif (commands.length > 0) {\n\t\t\t\t\tgroup.commands.clear();\n\t\t\t\t\tcommands.forEach(c => {\n\t\t\t\t\t\tif (!c.group || c.group == groupId) group.addCommand(c);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tthis.visibleItems = this.model.filter(null, this.showGroups, true);\n\t\t\t} else {\n\t\t\t\tthis.visibleItems = this.model.filter(this.filterValue, this.showGroups, true);\n\t\t\t}\n\t\t}\n\t\tthis.list.size = this.visibleItems.length;\n\t\tthis.requestUpdate();\n\t}\n\n\tasync toggleCollapse() {\n\t\tconst open = this.isCollapsed;\n\t\tconst groups = [...this.model.groups.values()];\n\t\tthis.list.reset();\n\n\t\tif (open && this.adapter) {\n\t\t\t// load commands of groups that are being opened, same as in toggleGroup\n\t\t\tawait Promise.all(groups.filter(g => !g.open).map(async group => {\n\t\t\t\tconst commands = await this.adapter.getCommands({\n\t\t\t\t\tsectionId: this.activeSection?.id,\n\t\t\t\t\tgroupId: group.id,\n\t\t\t\t\tfilter: this.filterValue\n\t\t\t\t});\n\n\t\t\t\tif (commands?.length > 0) {\n\t\t\t\t\tgroup.commands.clear();\n\t\t\t\t\tcommands.forEach(c => {\n\t\t\t\t\t\tif (!c.group || c.group == group.id) group.addCommand(c);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}));\n\t\t}\n\n\t\tgroups.forEach(g => g.open = open);\n\n\t\tthis.visibleItems = this.adapter\n\t\t\t? this.model.filter(null, this.showGroups, true)\n\t\t\t: this.model.filter(this.filterValue, this.showGroups, true);\n\n\t\tthis.list.size = this.visibleItems.length;\n\t\tthis.list.selectedIndex = Math.max(0, this.visibleItems.findIndex(item => item instanceof Command));\n\t\tthis.list.renderItems(true);\n\t\tthis.requestUpdate(); // visibleItems is not reactive, refresh collapse button icon\n\t\tthis.focus();\n\t}\n\n\tprivate getSectionTitle(section: CommandsSection) {\n\t\treturn (section.title ?? section.id) + (section.triggerCommand ? ` (${section.triggerCommand})` : '');\n\t}\n\n\tlayout() {\n\t\tif (!this.listWrapper) return;\n\n\t\tthis.listWrapper.style.transition = `flex-basis 0.2s ease-in-out`;\n\t\tthis.listWrapper.style.flexBasis = dom.px(this.list.offsetHeight);\n\t\tdom.setSize(this.listWrapper, {h: this.list.offsetHeight});\n\t}\n\n\tget hasControls() {\n\t\treturn this.activeSection?.switches?.length > 0 || this.options.collapseToggle;\n\t}\n\n\trenderTabs = () => this.sections?.length > 1 ? html`\n\t\t<og-container\n\t\t\t.horizontalSliderPosition=\"${this.sectionPosition == 'top' ? 'bottom' : 'top'}\"\n\t\t\tscrollMode=\"horizontal\"\n\t\t\tsliderSize=\"4\">\n\t\t\t<og-tabs\n\t\t\t\tslot=\"content\"\n\t\t\t\tclass=\"tabs\"\n\t\t\t\ttabSize=\"stretch\"\n\t\t\t\ttabAlign=\"center\"\n\t\t\t\tstyle=\"${styleMap({borderTop: this.sectionPosition == 'bottom' ? '1px solid var(--og-border)' : ''})}\"\n\t\t\t\t@tab.select=\"${this._onSectionSelect}\"\n\t\t\t\t.position=\"${this.sectionPosition == 'top' ? 'top' : 'bottom'}\"\n\t\t\t\t.selectedIndex=\"${this.activeSectionIndex}\"\n\t\t\t\t.items=\"${this.sections.map(section => ({...section, title: this.getSectionTitle(section)}))}\">\n\t\t\t</og-tabs>\n\t\t</og-container>\n\t` : ''\n\n\trenderDropdown = () => this.sections?.length > 1 ? html`\n\t\t<og-dropdown-list\n\t\t\tstyle=\"${styleMap({flex: `0 0 ${this.dropdownWidth}px`})}\"\n\t\t\tcolor=\"transparent\"\n\t\t\t.value=\"${this.activeSection?.id}\"\n\t\t\t@change=\"${this._onDropdownChange}\"\n\t\t\t.items=\"${this.sections.map(section => ({\n\t\t\t\tk: section.id as string,\n\t\t\t\tv: this.getSectionTitle(section),\n\t\t\t\ticon: section.icon\n\t\t\t}))}\">\n\t\t</og-dropdown-list>\n\t` : '';\n\n\tget isCollapsed() {\n\t\tif (!(this.visibleItems?.[0] instanceof CommandGroup)) return false;\n\t\treturn !this.visibleItems[0].open;\n\t}\n\n\trenderControls = () => this.hasControls ? html`\n\t\t<div class=\"controls\">\n\t\t\t<div class=\"switches\">\n\t\t\t\t${this.activeSection?.switches?.map((s) => html`\n\t\t\t\t\t<og-button\n\t\t\t\t\t\ttype=\"toggle\"\n\t\t\t\t\t\t.text=\"${s.value}\"\n\t\t\t\t\t\t.state=\"${s.checked ? 'checked' : 'unchecked'}\"\n\t\t\t\t\t\t@click=\"${(e: PointerEvent) => {\n\t\t\t\t\t\t\ts.checked = (e.target as Button).state === 'checked';\n\t\t\t\t\t\t\tthis.focus();\n\t\t\t\t\t\t\tthis.updateCommands();\n\t\t\t\t\t\t}}\">\n\t\t\t\t\t</og-button>\n\t\t\t\t`)}\n\t\t\t</div>\n\n\t\t\t${this.options.collapseToggle && this.visibleItems?.[0] ? html`\n\t\t\t\t<div class=\"buttons\">\n\t\t\t\t\t<og-button\n\t\t\t\t\t\tcolor=\"transparent\"\n\t\t\t\t\t\t.icon=\"${this.isCollapsed ? 'square-plus' : 'square-minus'}\"\n\t\t\t\t\t\t@click=\"${() => this.toggleCollapse()}\">\n\t\t\t\t\t</og-button>\n\t\t\t\t</div>\t\n\t\t\t` : ''}\n\t\t</div>\n\t` : '';\n\n\trender = () => html`\n\t\t<div class=\"input\">\n\t\t\t${this.sectionPosition == 'left' ? this.renderDropdown() : ''}\n\n\t\t\t<input\n\t\t\t\ttype=\"text\"\n\t\t\t\t@input=\"${this._onInput}\"\n\t\t\t\t.placeholder=\"${this.activePlaceholder || this.placeholder}\"\n\t\t\t\t.value=\"${this.value ?? ''}\">\n\n\t\t\t${this.sectionPosition == 'right' ? this.renderDropdown() : ''}\n\t\t</div>\n\n\t\t${this.sectionPosition != 'bottom' ? this.renderControls() : ''}\n\n\t\t${this.text != null ? html`<div class=\"text\">${this.text}</div>` : ''}\n\n\t\t${this.sectionPosition == 'top' ? this.renderTabs() : ''}\n\n\t\t${this.noResults ? html`\n\t\t\t<div class=\"no-results\">${msg('No results found')}</div>\n\t\t` : ''}\n\n\t\t<div class=\"list\">\n\t\t\t<og-list\n\t\t\t\tanimations\n\t\t\t\tarrowEvents\n\t\t\t\tmaxHeight=\"300\"\n\t\t\t\t?dynamicItemHeight=\"${this.options?.commandRenderer != null}\"\n\t\t\t\t.customStyle=\"${[this.options?.itemStyle, itemStyle]}\"\n\t\t\t\t.lineHeight=\"${this.options.itemHeight - 2}\"\n\t\t\t\t.itemHeight=\"${this.options.itemHeight}\"\n\t\t\t\t.itemRenderer=\"${this._itemRenderer}\"\n\t\t\t\t@select=\"${this._onSelect}\"\n\t\t\t\t@render=\"${() => this.layout()}\">\n\t\t\t</og-list>\n\t\t</div>\n\n\t\t${this.sectionPosition == 'bottom' ? this.renderControls() : ''}\n\n\t\t${this.sectionPosition == 'bottom' ? this.renderTabs() : ''}\n\t`;\n\n}\n"]}
1
+ {"version":3,"file":"commandWindow.js","sourceRoot":"","sources":["../../src/ui/commandWindow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAmB,WAAW,EAA8B,MAAM,UAAU,CAAC;AAErH,OAAO,EAAU,GAAG,EAA0F,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzJ,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KA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,CAAC;GAChB,aAAa,CA0ezB","sourcesContent":["import { Commands, Command, CommandGroup, CommandsSection, initOptions, CommandMode, CommandSource } from \"../model\";\nimport { CommandsAdapter} from \"../adapters\";\nimport { Button, dom, DropdownList, events, List, ListItemRenderer, ListItemRendererOptions, ListSelectEvent, ListSelectTrigger } from \"@omegagrid/core\";\nimport { LitElement, html, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { debounce } from \"ts-debounce\";\nimport { style, itemStyle } from \"./commandWindow.style\";\nimport { styleMap } from \"lit-html/directives/style-map.js\";\nimport { TabEvent } from \"@omegagrid/tabs\";\nimport { msg } from \"@omegagrid/localize\";\n\nexport class CommandEvent extends Event {\n\n\treadonly command?: Command;\n\treadonly value?: string;\n\treadonly section?: CommandsSection;\n\n\tconstructor(type: string, args?: Partial<CommandEvent>) {\n\t\tsuper(`command.${type}`, {bubbles: true, composed: true})\n\t\tif (args) Object.assign(this, args);\n\t}\n}\n\nexport type CommandRenderer = (div: HTMLDivElement, command: Command, opts?: ListItemRendererOptions) => string | void | TemplateResult<1> | null;\nexport type GroupRenderer = (div: HTMLDivElement, group: CommandGroup, opts?: ListItemRendererOptions) => string | void | TemplateResult<1> | null;\n\nconst DEFAULT_COMMAND_RENDERER: CommandRenderer = (_div: HTMLDivElement, command: Command) => {\n\treturn html`\n\t\t<div class=\"command\">\n\t\t\t${command.icon ? html`<og-icon .icon=\"${command.icon}\" style=\"margin-right: 8px;\"></og-icon>` : ''}\n\t\t\t${command.name}\n\t\t</div>\n\t`;\n};\n\nconst DEFAULT_GROUP_RENDERER: GroupRenderer = (_div: HTMLDivElement, group: CommandGroup) => {\n\treturn html`\n\t\t<div class=\"group\" @mousedown=\"${(e: MouseEvent) => e.preventDefault()}\">\n\t\t\t<div class=\"group-toggle\">\n\t\t\t\t<og-icon icon=\"angle-${group.open ? 'down' : 'right'}\"></og-icon>\n\t\t\t</div>\n\n\t\t\t<div class=\"group-text\">\n\t\t\t\t${group.name}\n\t\t\t</div>\n\t\t</div>\n\t`;\n};\n\n@customElement('og-commands')\nexport class CommandWindow extends LitElement {\n\n\tstatic styles = [style];\n\n\tprivate visibleItems: (Command|CommandGroup)[];\n\n\t@property({type: Object})\n\toptions = initOptions();\n\n\t/**\n\t * search = commands are filtered by input value\n\t * input = commands are not filtered, input is used to enter custom value\n\t * none = no input, only command list is shown\n\t */\n\t@property({type: String})\n\tmode: CommandMode = 'search';\n\n\t@property({type: String})\n\tvalue: string;\n\n\t@property({type: String, reflect: true})\n\tsectionPosition: 'top'|'bottom'|'left'|'right' = 'right';\n\n\t@property({type: Number})\n\tdropdownWidth = 100;\n\n\t@property()\n\ttext: string|TemplateResult<1>;\n\n\t@property({type: Array})\n\tcommands: CommandSource[];\n\n\t@property({type: Object})\n\tadapter: CommandsAdapter;\n\n\t@property({type: Object})\n\ttarget: HTMLElement;\n\n\t/** default input placeholder, sections can override it with their own */\n\t@property({type: String})\n\tplaceholder = '';\n\n\t/** currently displayed placeholder (section placeholder or the default one) */\n\t@state()\n\tactivePlaceholder = '';\n\n\t@property({type: Boolean})\n\tshowGroups = false\n\n\t@property({type: Object})\n\tmodel = new Commands();\n\n\t@state()\n\tsections: CommandsSection[] = [{id: 'default'}];\n\n\t@state()\n\tactiveSectionIndex = 0;\n\n\t@state()\n\tnoResults = false;\n\n\t@query('.list')\n\tlistWrapper: HTMLDivElement;\n\n\t@query('og-list')\n\tlist: List;\n\n\t@query('input')\n\tinput: HTMLInputElement;\n\n\t@query('og-dropdown-list')\n\tdropdown: DropdownList;\n\n\tget activeSection() { return this.sections?.[this.activeSectionIndex] }\n\n\tget inputValue() { return this.input?.value ?? '' }\n\tget parsedInput() {\n\t\tconst input = this.inputValue;\n\t\tconst chunks = input.split(' ', 2);\n\t\tif (chunks.length > 1) {\n\t\t\tconst section = (this.sections ?? []).findIndex(s => s?.triggerCommand == chunks[0]);\n\t\t\tconst value = section > -1 ? chunks[1] ?? '' : input;\n\t\t\treturn { section, value };\n\t\t} else {\n\t\t\treturn { section: -1, value: input};\n\t\t}\n\t}\n\n\tget filterValue() {\n\t\treturn this.mode == 'search' ? this.parsedInput?.value ?? '' : '';\n\t}\n\n\tgetCommandRenderer(index: number): CommandRenderer {\n\t\tconst command = this.visibleItems[index] as Command;\n\t\tif (command instanceof Command && command.renderer) return command.renderer;\n\t\treturn command.renderer || this.options?.commandRenderer || DEFAULT_COMMAND_RENDERER;\n\t}\n\n\tget groupRenderer(): GroupRenderer {\n\t\treturn this.options?.groupRenderer || DEFAULT_GROUP_RENDERER;\n\t}\n\n\tasync exec(dispatchEvent = true) {\n\t\tconst input = this.parsedInput;\n\t\tconst command = this.visibleItems[this.list.selectedIndex];\n\n\t\tif (!(command instanceof Command)) return;\n\n\t\tthis.clearFilter(false);\n\n\t\tcommand.exec(input.value);\n\t\tif (this.adapter) {\n\t\t\tthis.adapter.exec(command, input.value);\n\t\t}\n\n\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('exec', {\n\t\t\tcommand: command,\n\t\t\tsection: this.sections.find(s => s.id === input.section),\n\t\t\tvalue: input.value\n\t\t}));\n\t}\n\n\t_onKeyDown = (e: KeyboardEvent) => {\n\t\tif (e.key != 'Escape') e.stopPropagation();\n\n\t\tswitch (e.key) {\n\t\t\tcase 'ArrowDown':\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.list.moveDown();\n\t\t\t\tbreak;\n\t\t\tcase 'ArrowUp':\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.list.moveUp();\n\t\t\t\tbreak;\n\t\t\tcase 'Enter':\n\t\t\t\te.preventDefault();\n\t\t\t\tif (this.visibleItems[this.list.selectedIndex] instanceof CommandGroup)\n\t\t\t\t\tthis.toggleGroup((this.visibleItems[this.list.selectedIndex] as CommandGroup).id);\n\t\t\t\telse this.exec();\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t_debounceInput = debounce(() => {\n\t\tif (this.mode == 'search') {\n\t\t\tconst input = this.parsedInput;\n\t\t\tif (input.section > -1) {\n\t\t\t\tthis.activeSectionIndex = input.section;\n\t\t\t\tthis.input.value = '';\n\t\t\t\tthis.updateCommands(true);\n\t\t\t} else {\n\t\t\t\tthis.updateCommands();\n\t\t\t}\n\t\t} else if (this.mode == 'none') { // online highlight first match\n\t\t\tconst input = this.parsedInput;\n\t\t\tconst commands = this.model.filter(input.value, false) as Command[];\n\t\t\tif (commands.length > 0) {\n\t\t\t\tconst index = this.visibleItems.findIndex(item => item instanceof Command && item.id === commands[0].id);\n\t\t\t\tif (index > -1) {\n\t\t\t\t\tthis.list.selectedIndex = index;\n\t\t\t\t\tthis.list.renderItems(true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, this.options.inputDelay);\n\n\t_onInput = (e: InputEvent) => {\n\t\te.stopPropagation();\n\t\tthis._debounceInput();\n\t}\n\n\t_onSectionSelect = async (e: TabEvent) => {\n\t\tif (this.activeSectionIndex == e.index) return;\n\t\tthis.activeSectionIndex = e.index;\n\t\tthis.updateCommands(true);\n\t\tthis.focus();\n\t}\n\n\t_onDropdownChange = async (_e: events.ChangeEvent) => {\n\t\tthis.activeSectionIndex = this.sections.findIndex(s => s.id === this.dropdown.value);\n\t\tthis.updateCommands(true);\n\t\tthis.focus();\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('click', e => e.stopPropagation());\n\t\tthis.addEventListener('keydown', this._onKeyDown);\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 0;\n\t}\n\n\tfocus() {\n\t\tthis.input?.focus();\n\t}\n\n\tclearFilter(updateCommands = true) {\n\t\tif (this.input) this.input.value = '';\n\t\tthis.focus();\n\t\tif (updateCommands) this.updateCommands();\n\t}\n\n\tasync willUpdate(props: PropertyValues) {\n\t\tif (props.has('adapter') && this.adapter) {\n\t\t\tthis.adapter.attach(this);\n\t\t\tconst sections = await this.adapter.getSections();\n\t\t\tconst options = await this.adapter.getOptions(sections?.length ? sections[0].id : null);\n\t\t\tthis.sections = sections;\n\t\t\tif (options) this.options = initOptions(options);\n\t\t} else {\n\t\t\tif (props.has('commands') && this.commands) {\n\t\t\t\tthis.model.clear();\n\t\t\t\tthis.commands.forEach(c => this.model.register(c));\n\t\t\t}\n\n\t\t\tif (props.has('options')) {\n\t\t\t\tthis.options = initOptions(this.options);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync updated(props: Map<PropertyKey, unknown>) {\n\t\tif (['commands', 'adapter', 'model', 'activeSectionIndex'].some(p => props.has(p))) {\n\t\t\tawait this.updateCommands(true);\n\t\t}\n\t}\n\n\t_onSelect = (e: ListSelectEvent) => {\n\t\tconst item = this.visibleItems[e.index];\n\t\tif (item instanceof Command) {\n\t\t\tif (this.mode == 'search') this.input.value = item.name;\n\t\t\tif (e.trigger == ListSelectTrigger.Click || e.trigger == ListSelectTrigger.Enter) {\n\t\t\t\tthis.exec();\n\t\t\t}\n\t\t} else {\n\t\t\tif (this.input) this.input.value = '';\n\t\t\tif (e.trigger == ListSelectTrigger.Click || e.trigger == ListSelectTrigger.Enter) {\n\t\t\t\tthis.toggleGroup((item as CommandGroup).id);\n\t\t\t}\n\t\t}\n\n\t\tsetTimeout(() => this.input?.focus());\n\t}\n\n\t_itemRenderer: ListItemRenderer = (div: HTMLDivElement, index: number, opts?: ListItemRendererOptions) => {\n\t\treturn this.visibleItems[index] instanceof CommandGroup\n\t\t\t? this.groupRenderer(div, this.visibleItems[index] as CommandGroup, opts)\n\t\t\t: this.getCommandRenderer(index)(div, this.visibleItems[index] as Command, opts);\n\t}\n\n\tprivate _updateToken = 0;\n\n\tasync updateCommands(updateOptions = false) {\n\t\tif (this.adapter) {\n\t\t\tthis.model.clear();\n\t\t\tconst switches = this.activeSection?.switches?.filter(s => s.checked).map(s => s.key) || [];\n\n\t\t\tif (updateOptions) {\n\t\t\t\tconst options = await this.adapter.getOptions(this.activeSection?.id);\n\t\t\t\tthis.options = initOptions(options);\n\t\t\t}\n\n\t\t\tthis._updateToken++; // prevents race conditions when multiple requests are made in quick succession\n\t\t\tconst updateToken = this._updateToken;\n\n\t\t\tconst [groups, commands] = (await Promise.all([this.adapter.getGroups({\n\t\t\t\tsectionId: this.activeSection?.id,\n\t\t\t\tfilter: this.filterValue,\n\t\t\t\tswitches\n\t\t\t}), this.adapter.getCommands({\n\t\t\t\tsectionId: this.activeSection?.id,\n\t\t\t\tfilter: this.filterValue,\n\t\t\t\tswitches\n\t\t\t})]));\n\n\t\t\tif (updateToken != this._updateToken) return;\n\n\t\t\tgroups?.forEach(group => this.model.registerGroup(group));\n\t\t\tcommands?.forEach(command => this.model.register(command));\n\t\t\tthis.visibleItems = this.model.filter(null, this.showGroups, true);\n\t\t} else {\n\t\t\tthis.visibleItems = this.model.filter(this.filterValue, this.showGroups);\n\t\t}\n\n\t\tthis.activePlaceholder = this.activeSection?.placeholder || this.placeholder || '';\n\t\tthis.list.reset();\n\t\tthis.list.size = this.visibleItems.length;\n\t\tthis.list.selectedIndex = this.visibleItems.findIndex(item => item instanceof Command) ?? 0;\n\t\tthis.list.renderItems(true);\n\t\tthis.noResults = this.visibleItems.length == 0;\n\t}\n\n\tasync toggleGroup(groupId: string) {\n\t\tconst group = this.model.groups.get(groupId);\n\t\tthis.list.reset();\n\n\t\tif (group.open) {\n\t\t\tgroup.open = false;\n\t\t\tthis.visibleItems = this.model.filter(this.filterValue, this.showGroups, true);\n\t\t\tthis.list.size = this.visibleItems.length;\n\t\t} else {\n\t\t\tgroup.open = true;\n\t\t\tif (this.adapter) {\n\t\t\t\tconst commands = (await Promise.all([this.adapter.getCommands({\n\t\t\t\t\tsectionId: this.activeSection?.id,\n\t\t\t\t\tgroupId,\n\t\t\t\t\tfilter: this.filterValue\n\t\t\t\t})]))[0];\n\n\t\t\t\tif (commands.length > 0) {\n\t\t\t\t\tgroup.commands.clear();\n\t\t\t\t\tcommands.forEach(c => {\n\t\t\t\t\t\tif (!c.group || c.group == groupId) group.addCommand(c);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tthis.visibleItems = this.model.filter(null, this.showGroups, true);\n\t\t\t} else {\n\t\t\t\tthis.visibleItems = this.model.filter(this.filterValue, this.showGroups, true);\n\t\t\t}\n\t\t}\n\t\tthis.list.size = this.visibleItems.length;\n\t\tthis.requestUpdate();\n\t}\n\n\tasync toggleCollapse() {\n\t\tconst open = this.isCollapsed;\n\t\tconst groups = [...this.model.groups.values()];\n\t\tthis.list.reset();\n\n\t\tif (open && this.adapter) {\n\t\t\t// load commands of groups that are being opened, same as in toggleGroup\n\t\t\tawait Promise.all(groups.filter(g => !g.open).map(async group => {\n\t\t\t\tconst commands = await this.adapter.getCommands({\n\t\t\t\t\tsectionId: this.activeSection?.id,\n\t\t\t\t\tgroupId: group.id,\n\t\t\t\t\tfilter: this.filterValue\n\t\t\t\t});\n\n\t\t\t\tif (commands?.length > 0) {\n\t\t\t\t\tgroup.commands.clear();\n\t\t\t\t\tcommands.forEach(c => {\n\t\t\t\t\t\tif (!c.group || c.group == group.id) group.addCommand(c);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}));\n\t\t}\n\n\t\tgroups.forEach(g => g.open = open);\n\n\t\tthis.visibleItems = this.adapter\n\t\t\t? this.model.filter(null, this.showGroups, true)\n\t\t\t: this.model.filter(this.filterValue, this.showGroups, true);\n\n\t\tthis.list.size = this.visibleItems.length;\n\t\tthis.list.selectedIndex = Math.max(0, this.visibleItems.findIndex(item => item instanceof Command));\n\t\tthis.list.renderItems(true);\n\t\tthis.requestUpdate(); // visibleItems is not reactive, refresh collapse button icon\n\t\tthis.focus();\n\t}\n\n\tprivate getSectionTitle(section: CommandsSection) {\n\t\treturn (section.title ?? section.id) + (section.triggerCommand ? ` (${section.triggerCommand})` : '');\n\t}\n\n\tlayout() {\n\t\tif (!this.listWrapper) return;\n\n\t\tthis.listWrapper.style.transition = `flex-basis 0.2s ease-in-out`;\n\t\tthis.listWrapper.style.flexBasis = dom.px(this.list.offsetHeight);\n\t\tdom.setSize(this.listWrapper, {h: this.list.offsetHeight});\n\t}\n\n\tget hasControls() {\n\t\treturn this.activeSection?.switches?.length > 0 || this.options.collapseToggle;\n\t}\n\n\trenderTabs = () => this.sections?.length > 1 ? html`\n\t\t<og-container\n\t\t\t.horizontalSliderPosition=\"${this.sectionPosition == 'top' ? 'bottom' : 'top'}\"\n\t\t\tscrollMode=\"horizontal\"\n\t\t\tsliderSize=\"4\">\n\t\t\t<og-tabs\n\t\t\t\tslot=\"content\"\n\t\t\t\tclass=\"tabs\"\n\t\t\t\ttabSize=\"stretch\"\n\t\t\t\ttabAlign=\"center\"\n\t\t\t\tstyle=\"${styleMap({borderTop: this.sectionPosition == 'bottom' ? '1px solid var(--og-border)' : ''})}\"\n\t\t\t\t@tab.select=\"${this._onSectionSelect}\"\n\t\t\t\t.position=\"${this.sectionPosition == 'top' ? 'top' : 'bottom'}\"\n\t\t\t\t.selectedIndex=\"${this.activeSectionIndex}\"\n\t\t\t\t.items=\"${this.sections.map(section => ({...section, title: this.getSectionTitle(section)}))}\">\n\t\t\t</og-tabs>\n\t\t</og-container>\n\t` : ''\n\n\trenderDropdown = () => this.sections?.length > 1 ? html`\n\t\t<og-dropdown-list\n\t\t\tstyle=\"${styleMap({flex: `0 0 ${this.dropdownWidth}px`})}\"\n\t\t\tcolor=\"transparent\"\n\t\t\t.value=\"${this.activeSection?.id}\"\n\t\t\t@change=\"${this._onDropdownChange}\"\n\t\t\t.items=\"${this.sections.map(section => ({\n\t\t\t\tk: section.id as string,\n\t\t\t\tv: this.getSectionTitle(section),\n\t\t\t\ticon: section.icon\n\t\t\t}))}\">\n\t\t</og-dropdown-list>\n\t` : '';\n\n\tget isCollapsed() {\n\t\tif (!(this.visibleItems?.[0] instanceof CommandGroup)) return false;\n\t\treturn !this.visibleItems[0].open;\n\t}\n\n\trenderControls = () => this.hasControls ? html`\n\t\t<div class=\"controls\">\n\t\t\t<div class=\"switches\">\n\t\t\t\t${this.activeSection?.switches?.map((s) => html`\n\t\t\t\t\t<og-button\n\t\t\t\t\t\ttype=\"toggle\"\n\t\t\t\t\t\t.text=\"${s.value}\"\n\t\t\t\t\t\t.state=\"${s.checked ? 'checked' : 'unchecked'}\"\n\t\t\t\t\t\t@click=\"${(e: PointerEvent) => {\n\t\t\t\t\t\t\ts.checked = (e.target as Button).state === 'checked';\n\t\t\t\t\t\t\tthis.focus();\n\t\t\t\t\t\t\tthis.updateCommands();\n\t\t\t\t\t\t}}\">\n\t\t\t\t\t</og-button>\n\t\t\t\t`)}\n\t\t\t</div>\n\n\t\t\t${this.options.collapseToggle && this.visibleItems?.[0] ? html`\n\t\t\t\t<div class=\"buttons\">\n\t\t\t\t\t<og-button\n\t\t\t\t\t\tcolor=\"transparent\"\n\t\t\t\t\t\t.icon=\"${this.isCollapsed ? 'square-plus' : 'square-minus'}\"\n\t\t\t\t\t\t@click=\"${() => this.toggleCollapse()}\">\n\t\t\t\t\t</og-button>\n\t\t\t\t</div>\t\n\t\t\t` : ''}\n\t\t</div>\n\t` : '';\n\n\trender = () => html`\n\t\t<div class=\"input\" style=\"${styleMap(this.mode == 'menu' ? {maxHeight: '0', overflow: 'hidden', padding: '0'} : {})}\">\n\t\t\t${this.sectionPosition == 'left' ? this.renderDropdown() : ''}\n\n\t\t\t<input\n\t\t\t\ttype=\"text\"\n\t\t\t\t@input=\"${this._onInput}\"\n\t\t\t\t.placeholder=\"${this.activePlaceholder || this.placeholder}\"\n\t\t\t\t.value=\"${this.value ?? ''}\">\n\n\t\t\t${this.sectionPosition == 'right' ? this.renderDropdown() : ''}\n\t\t</div>\t\n\n\t\t${this.sectionPosition != 'bottom' ? this.renderControls() : ''}\n\n\t\t${this.text != null ? html`<div class=\"text\">${this.text}</div>` : ''}\n\n\t\t${this.sectionPosition == 'top' ? this.renderTabs() : ''}\n\n\t\t${this.noResults ? html`\n\t\t\t<div class=\"no-results\">${msg('No results found')}</div>\n\t\t` : ''}\n\n\t\t<div class=\"list\">\n\t\t\t<og-list\n\t\t\t\tanimations\n\t\t\t\tarrowEvents\n\t\t\t\tmaxHeight=\"300\"\n\t\t\t\t?dynamicItemHeight=\"${this.options?.commandRenderer != null}\"\n\t\t\t\t.customStyle=\"${[this.options?.itemStyle, itemStyle]}\"\n\t\t\t\t.lineHeight=\"${this.options.itemHeight - 2}\"\n\t\t\t\t.itemHeight=\"${this.options.itemHeight}\"\n\t\t\t\t.itemRenderer=\"${this._itemRenderer}\"\n\t\t\t\t@select=\"${this._onSelect}\"\n\t\t\t\t@render=\"${() => this.layout()}\">\n\t\t\t</og-list>\n\t\t</div>\n\n\t\t${this.sectionPosition == 'bottom' ? this.renderControls() : ''}\n\n\t\t${this.sectionPosition == 'bottom' ? this.renderTabs() : ''}\n\t`;\n\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/commands",
3
- "version": "0.10.103",
3
+ "version": "0.10.104",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Command window",
6
6
  "main": "./dist/index.js",
@@ -27,9 +27,9 @@
27
27
  "_prepublish": "yarn test && yarn lint"
28
28
  },
29
29
  "dependencies": {
30
- "@omegagrid/core": "^0.10.103",
31
- "@omegagrid/localize": "^0.10.103",
32
- "@omegagrid/tabs": "^0.10.103",
30
+ "@omegagrid/core": "^0.10.104",
31
+ "@omegagrid/localize": "^0.10.104",
32
+ "@omegagrid/tabs": "^0.10.104",
33
33
  "lit": "^3.1.1",
34
34
  "lit-html": "^3.1.1",
35
35
  "ts-debounce": "^4.0.0"