@omegagrid/commands 0.6.116 → 0.6.118

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.
@@ -10,6 +10,7 @@ export declare class CommandSection {
10
10
  export declare class Command {
11
11
  readonly id: string;
12
12
  readonly name: string;
13
+ readonly value: string;
13
14
  readonly section: string;
14
15
  readonly fn: CommandFunction;
15
16
  readonly requiredParams: number;
@@ -1 +1 @@
1
- {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/model/commands.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;AAE5D,qBAAa,cAAc;aAMT,EAAE,EAAE,MAAM;aACV,IAAI,EAAE,MAAM;IAL7B,SAAgB,QAAQ,uBAA8B;IAC/C,IAAI,UAAQ;gBAGF,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM;IAG7B,UAAU,CAAC,OAAO,EAAE,OAAO;CAI3B;AAED,qBAAa,OAAO;IAEnB,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,EAAE,EAAE,eAAe,CAAC;IACpC,SAAgB,cAAc,EAAE,MAAM,CAAC;gBAE3B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IAMrC,IAAI,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE;CAIxB;AAED,qBAAa,QAAQ;IAEpB,SAAgB,QAAQ,8BAAqC;IAE7D,IAAI,KAAK,WAIR;gBAEW,QAAQ,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;IAIzC,KAAK;IAKL,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,UAAO;IAO/D,aAAa,CAAC,SAAS,EAAE,MAAM;IAI/B,QAAQ,CAAC,OAAO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CAAC,CAAC;QAClE,OAAO,cAAc,CAAC;IACvB,CAAC;CAED","sourcesContent":["import { utils } from \"@omegagrid/core\";\n\nexport type CommandFunction = (...params: string[]) => void;\n\nexport class CommandSection {\n\n\tpublic readonly commands = new Map<string, Command>();\n\tpublic open = true;\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly name: string\n\t) { }\n\n\taddCommand(command: Command) {\n\t\tthis.commands.set(command.id, command);\n\t}\n\n}\n\nexport class Command {\n\n\tpublic readonly id: string;\n\tpublic readonly name: string;\n\tpublic readonly section: string;\n\tpublic readonly fn: CommandFunction;\n\tpublic readonly requiredParams: number;\n\n\tconstructor(options: Partial<Command>) {\n\t\tObject.assign(this, options);\n\t\tthis.id = options.id || options.name;\n\t\tthis.name = options.name || options.id;\n\t}\n\n\texec(...params: string[]) {\n\t\tif (this.fn) this.fn(...params);\n\t}\n\n}\n\nexport class Commands {\n\t\n\tpublic readonly sections = new Map<string, CommandSection>();\n\n\tget count() {\n\t\tlet cnt = 0;\n\t\tthis.sections.forEach(section => cnt += section.commands.size);\n\t\treturn cnt;\n\t}\n\n\tconstructor(commands?: Partial<Command>[]) {\n\t\tif (commands) commands.forEach(c => this.register(c));\n\t}\n\n\tclear() {\n\t\tthis.sections.clear();\n\t\treturn this;\n\t}\n\n\tregisterSection(section: Partial<CommandSection>, append = true) {\n\t\tconst s = append && this.sections.has(section.id) ? this.sections.get(section.id) : new CommandSection(section.id, section.name);\n\t\tsection.commands?.forEach(c => s.commands.set(c.id, c));\n\t\tthis.sections.set(s.id, s);\n\t\treturn s;\n\t}\n\n\tremoveSection(sectionId: string) {\n\t\tthis.sections.delete(sectionId);\n\t}\n\t\n\tregister(command: Partial<Command>) {\n\t\tconst sectionId = command.section || 'default';\n\t\tconst section = this.sections.get(sectionId) || this.registerSection({id: sectionId, name: sectionId});\n\t\tsection.addCommand(new Command(command));\n\t}\n\n\tremove(name: string) {\n\t\tthis.sections.forEach(section => section.commands.delete(name));\n\t}\n\n\tget(name: string) {\n\t\tfor (const section of this.sections.values()) {\n\t\t\tif (section.commands.has(name)) return section.commands.get(name);\n\t\t}\n\t\treturn null;\n\t}\n\n\texec(command: string, ...params: string[]) {\n\t\tthis.get(command)?.exec(...params);\n\t}\n\n\tfilter(term?: string, includeSections = false, emptySections = false): (CommandSection|Command)[] {\n\t\tconst items: (CommandSection|Command)[] = [];\n\t\tconst regex = term == null ? null : new RegExp(utils.escapeRegExp(term), 'ig');\n\t\tfor (const section of this.sections.values()) {\n\t\t\tlet sectionIcluded = false;\n\t\t\tconst sectionMatch = regex ? regex.test(section.name) : true;\n\t\t\tif (sectionMatch && emptySections) {\n\t\t\t\titems.push(section);\n\t\t\t\tsectionIcluded = true;\n\t\t\t}\n\n\t\t\tif (section.open) {\n\t\t\t\tsection.commands.forEach(command => {\n\t\t\t\t\tif (sectionMatch || regex.test(command.name)) {\n\t\t\t\t\t\tif (includeSections && !sectionIcluded) {\n\t\t\t\t\t\t\titems.push(section);\n\t\t\t\t\t\t\tsectionIcluded = 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\tmerge(commands: Commands): Commands {\n\t\tconst mergedCommands = new Commands();\n\t\tthis.sections.forEach(s => mergedCommands.registerSection(s));\n\t\tcommands.sections.forEach(s => mergedCommands.registerSection(s));\n\t\treturn mergedCommands;\n\t}\n\n}"]}
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/model/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAIxC,MAAM,OAAO,cAAc;IAK1B,YACiB,EAAU,EACV,IAAY;QADZ,OAAE,GAAF,EAAE,CAAQ;QACV,SAAI,GAAJ,IAAI,CAAQ;QALb,aAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC/C,SAAI,GAAG,IAAI,CAAC;IAKf,CAA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AAO,CAAC,CAAC;oBACrB,CAAC;gBACF,CAAC,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IAED,KAAK,CAAC,QAAkB;QACvB,MAAM,cAAc,GAAG,IAAI,QAAQ,EAAE,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,OAAO,cAAc,CAAC;IACvB,CAAC;CAED","sourcesContent":["import { utils } from \"@omegagrid/core\";\n\nexport type CommandFunction = (...params: string[]) => void;\n\nexport class CommandSection {\n\n\tpublic readonly commands = new Map<string, Command>();\n\tpublic open = true;\n\n\tconstructor(\n\t\tpublic readonly id: string,\n\t\tpublic readonly name: string\n\t) { }\n\n\taddCommand(command: Command) {\n\t\tthis.commands.set(command.id, command);\n\t}\n\n}\n\nexport class Command {\n\n\tpublic readonly id: string;\n\tpublic readonly name: string;\n\tpublic readonly value: string;\n\tpublic readonly section: string;\n\tpublic readonly fn: CommandFunction;\n\tpublic readonly requiredParams: number;\n\n\tconstructor(options: Partial<Command>) {\n\t\tObject.assign(this, options);\n\t\tthis.id = options.id || options.name;\n\t\tthis.name = options.name || options.id;\n\t}\n\n\texec(...params: string[]) {\n\t\tif (this.fn) this.fn(...params);\n\t}\n\n}\n\nexport class Commands {\n\t\n\tpublic readonly sections = new Map<string, CommandSection>();\n\n\tget count() {\n\t\tlet cnt = 0;\n\t\tthis.sections.forEach(section => cnt += section.commands.size);\n\t\treturn cnt;\n\t}\n\n\tconstructor(commands?: Partial<Command>[]) {\n\t\tif (commands) commands.forEach(c => this.register(c));\n\t}\n\n\tclear() {\n\t\tthis.sections.clear();\n\t\treturn this;\n\t}\n\n\tregisterSection(section: Partial<CommandSection>, append = true) {\n\t\tconst s = append && this.sections.has(section.id) ? this.sections.get(section.id) : new CommandSection(section.id, section.name);\n\t\tsection.commands?.forEach(c => s.commands.set(c.id, c));\n\t\tthis.sections.set(s.id, s);\n\t\treturn s;\n\t}\n\n\tremoveSection(sectionId: string) {\n\t\tthis.sections.delete(sectionId);\n\t}\n\t\n\tregister(command: Partial<Command>) {\n\t\tconst sectionId = command.section || 'default';\n\t\tconst section = this.sections.get(sectionId) || this.registerSection({id: sectionId, name: sectionId});\n\t\tsection.addCommand(new Command(command));\n\t}\n\n\tremove(name: string) {\n\t\tthis.sections.forEach(section => section.commands.delete(name));\n\t}\n\n\tget(name: string) {\n\t\tfor (const section of this.sections.values()) {\n\t\t\tif (section.commands.has(name)) return section.commands.get(name);\n\t\t}\n\t\treturn null;\n\t}\n\n\texec(command: string, ...params: string[]) {\n\t\tthis.get(command)?.exec(...params);\n\t}\n\n\tfilter(term?: string, includeSections = false, emptySections = false): (CommandSection|Command)[] {\n\t\tconst items: (CommandSection|Command)[] = [];\n\t\tconst regex = term == null ? null : new RegExp(utils.escapeRegExp(term), 'ig');\n\t\tfor (const section of this.sections.values()) {\n\t\t\tlet sectionIcluded = false;\n\t\t\tconst sectionMatch = regex ? regex.test(section.name) : true;\n\t\t\tif (sectionMatch && emptySections) {\n\t\t\t\titems.push(section);\n\t\t\t\tsectionIcluded = true;\n\t\t\t}\n\n\t\t\tif (section.open) {\n\t\t\t\tsection.commands.forEach(command => {\n\t\t\t\t\tif (sectionMatch || regex.test(command.name)) {\n\t\t\t\t\t\tif (includeSections && !sectionIcluded) {\n\t\t\t\t\t\t\titems.push(section);\n\t\t\t\t\t\t\tsectionIcluded = 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\tmerge(commands: Commands): Commands {\n\t\tconst mergedCommands = new Commands();\n\t\tthis.sections.forEach(s => mergedCommands.registerSection(s));\n\t\tcommands.sections.forEach(s => mergedCommands.registerSection(s));\n\t\treturn mergedCommands;\n\t}\n\n}"]}
@@ -4,7 +4,8 @@ import { LitElement, TemplateResult, PropertyValues } from 'lit';
4
4
  import { Options } from "../model";
5
5
  export declare class CommandEvent extends Event {
6
6
  readonly command?: Command;
7
- constructor(type: string, command?: Command);
7
+ readonly value?: string;
8
+ constructor(type: string, args?: Partial<CommandEvent>);
8
9
  }
9
10
  export type CommandRenderer = (div: HTMLDivElement, command: Command) => string | TemplateResult<1> | null;
10
11
  export type SectionRenderer = (div: HTMLDivElement, section: CommandSection) => string | TemplateResult<1> | null;
@@ -12,15 +13,24 @@ export declare class CommandWindow extends LitElement {
12
13
  static styles: import("lit").CSSResult[];
13
14
  private inputRef;
14
15
  get input(): HTMLInputElement;
16
+ get inputValue(): string;
15
17
  private listRef;
16
18
  get list(): List;
17
19
  private visibleItems;
18
20
  options: Options;
21
+ /**
22
+ * search = commands are filtered by input value
23
+ * input = commands are not filtered, input is used to enter custom value
24
+ * none = no input, only command list is shown
25
+ */
26
+ mode: 'search' | 'input' | 'none';
27
+ value: string;
19
28
  text: string;
20
29
  commands: Commands;
21
30
  adapter: CommandsAdapter;
22
31
  target: HTMLElement;
23
32
  triggerKey: string;
33
+ placeholder: string;
24
34
  showSections: boolean;
25
35
  requireUpdateCommands: boolean;
26
36
  _commandRenderer: CommandRenderer;
@@ -1 +1 @@
1
- {"version":3,"file":"commandWindow.d.ts","sourceRoot":"","sources":["../../src/ui/commandWindow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAO,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAqB,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,UAAU,EAAQ,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAMvE,OAAO,EA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O,CAAC,OAAO,CAAqB;IACpC,IAAI,IAAI,SAAkC;IAE1C,OAAO,CAAC,YAAY,CAA6B;IAGjD,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IAEH,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAY;IAG7C,KAAK,EAAE,MAAM,CAAC;IAGd,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,WAAkB;IAG1B,OAAO,EAAE,eAAe,CAAC;IAGzB,MAAM,EAAE,WAAW,CAAC;IAGpB,UAAU,SAAQ;IAGlB,WAAW,SAAM;IAGjB,YAAY,UAAQ;IAEpB,qBAAqB,UAAQ;IAE7B,gBAAgB,EAAE,eAAe,CAM/B;IAEF,gBAAgB,EAAE,eAAe,CAW/B;IAEF,IAAI,WAAW,WAA6D;IAE5E,IAAI,CAAC,aAAa,UAAO;IAoCzB,UAAU,MAAO,aAAa,UAuB7B;IAED,QAAQ;;uBAlJR,CAAA;MA2JE;;IAUI,IAAI,CAAC,aAAa,UAAO;IAkB/B,KAAK,CAAC,aAAa,UAAO;IAQ1B,iBAAiB;IAKjB,gBAAgB,MAAO,aAAa,UAMnC;IAEK,UAAU,CAAC,KAAK,EAAE,cAAc;IAYhC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC;IAW9C,SAAS,MAAO,eAAe,UAa9B;IAED,aAAa,EAAE,gBAAgB,CAI9B;IAED,YAAY;IAKN,cAAc;IAgBd,aAAa,CAAC,SAAS,EAAE,MAAM;IAsBrC,cAAc;IAUd,MAAM,0BAmBJ;CAEF"}
@@ -13,15 +13,17 @@ import { debounce } from "ts-debounce";
13
13
  import { style, itemStyle } from "./commandWindow.style";
14
14
  import constants from "../constants";
15
15
  export class CommandEvent extends Event {
16
- constructor(type, command) {
16
+ constructor(type, args) {
17
17
  super(`command.${type}`, { bubbles: true, composed: true });
18
- this.command = command;
18
+ if (args)
19
+ Object.assign(this, args);
19
20
  }
20
21
  }
21
22
  let CommandWindow = class CommandWindow extends LitElement {
22
23
  get input() { return this.inputRef?.value; }
24
+ get inputValue() { return this.input?.value ?? ''; }
23
25
  get list() { return this.listRef?.value; }
24
- get filterValue() { return this.input.value; }
26
+ get filterValue() { return this.mode == 'search' ? this.input.value : null; }
25
27
  exec(dispatchEvent = true) {
26
28
  const tokens = this.input.value.split('>').map(t => t.trim());
27
29
  if (tokens[0].length == 0) {
@@ -29,9 +31,11 @@ let CommandWindow = class CommandWindow extends LitElement {
29
31
  tokens[0] = this.visibleItems[this.list.selectedIndex].name;
30
32
  }
31
33
  }
32
- const command = this.commands.get(tokens[0])
33
- ?? this.visibleItems.find(item => item instanceof Command && item.name == tokens[0]);
34
- if (command) {
34
+ if (this.mode == 'search') {
35
+ const command = this.commands.get(tokens[0])
36
+ ?? this.visibleItems.find(item => item instanceof Command && item.name == tokens[0]);
37
+ if (!command)
38
+ return;
35
39
  if (tokens.length - 1 < command.requiredParams) {
36
40
  tokens.push('');
37
41
  this.input.value = tokens.join(' > ');
@@ -41,17 +45,38 @@ let CommandWindow = class CommandWindow extends LitElement {
41
45
  tokens.shift();
42
46
  command.exec(...tokens);
43
47
  if (dispatchEvent)
44
- this.dispatchEvent(new CommandEvent('exec', command));
48
+ this.dispatchEvent(new CommandEvent('exec', {
49
+ command,
50
+ value: this.inputValue
51
+ }));
45
52
  this.close();
46
53
  }
47
54
  }
55
+ else {
56
+ const command = this.visibleItems[this.list.selectedIndex];
57
+ if (!command)
58
+ return;
59
+ if (dispatchEvent)
60
+ this.dispatchEvent(new CommandEvent('exec', {
61
+ command: command,
62
+ value: this.inputValue
63
+ }));
64
+ this.close();
65
+ }
48
66
  }
49
67
  constructor() {
50
68
  super();
51
69
  this.inputRef = createRef();
52
70
  this.listRef = createRef();
71
+ /**
72
+ * search = commands are filtered by input value
73
+ * input = commands are not filtered, input is used to enter custom value
74
+ * none = no input, only command list is shown
75
+ */
76
+ this.mode = 'search';
53
77
  this.commands = new Commands();
54
78
  this.triggerKey = 'F1';
79
+ this.placeholder = '';
55
80
  this.showSections = false;
56
81
  this.requireUpdateCommands = true;
57
82
  this._commandRenderer = (div, command) => {
@@ -100,10 +125,12 @@ let CommandWindow = class CommandWindow extends LitElement {
100
125
  };
101
126
  this._onKeyUp = debounce(e => {
102
127
  e.stopPropagation();
103
- const excludedKeys = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Shift', 'Enter', this.triggerKey];
104
- if (excludedKeys.indexOf(e.key) == -1) {
105
- this.updateCommands();
106
- this.list.size = this.visibleItems.length;
128
+ if (this.mode == 'search') {
129
+ const excludedKeys = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Shift', 'Enter', this.triggerKey];
130
+ if (excludedKeys.indexOf(e.key) == -1) {
131
+ this.updateCommands();
132
+ this.list.size = this.visibleItems.length;
133
+ }
107
134
  }
108
135
  });
109
136
  this._onTargetKeyDown = (e) => {
@@ -116,10 +143,10 @@ let CommandWindow = class CommandWindow extends LitElement {
116
143
  this._onSelect = (e) => {
117
144
  const item = this.visibleItems[e.index];
118
145
  if (item instanceof Command) {
119
- this.input.value = item.name;
120
- if (e.trigger == ListSelectTrigger.Click || e.trigger == ListSelectTrigger.Enter) {
146
+ if (this.mode == 'search')
147
+ this.input.value = item.name;
148
+ if (e.trigger == ListSelectTrigger.Click || e.trigger == ListSelectTrigger.Enter)
121
149
  this.exec();
122
- }
123
150
  }
124
151
  else {
125
152
  this.input.value = '';
@@ -136,9 +163,14 @@ let CommandWindow = class CommandWindow extends LitElement {
136
163
  };
137
164
  this.render = () => html `
138
165
  <div class="input">
139
- <input type="text" ${ref(this.inputRef)}>
166
+ <input ${ref(this.inputRef)}
167
+ type="text"
168
+ .placeholder="${this.placeholder}"
169
+ .value="${this.value}">
140
170
  </div>
171
+
141
172
  ${this.text != null ? html `<div class="text">${this.text}</div>` : ''}
173
+
142
174
  <div class="list">
143
175
  <og-list ${ref(this.listRef)}
144
176
  maxHeight="300"
@@ -158,7 +190,7 @@ let CommandWindow = class CommandWindow extends LitElement {
158
190
  if (!this.target)
159
191
  throw new Error('target element not set');
160
192
  dom.showElement(this);
161
- this.input.value = '';
193
+ this.input.value = this.value ?? '';
162
194
  if (this.requireUpdateCommands) {
163
195
  this.requireUpdateCommands = false;
164
196
  await this.updateCommands();
@@ -264,6 +296,12 @@ CommandWindow.styles = [style];
264
296
  __decorate([
265
297
  property({ type: Object })
266
298
  ], CommandWindow.prototype, "options", void 0);
299
+ __decorate([
300
+ property({ type: String })
301
+ ], CommandWindow.prototype, "mode", void 0);
302
+ __decorate([
303
+ property({ type: String })
304
+ ], CommandWindow.prototype, "value", void 0);
267
305
  __decorate([
268
306
  property({ type: String })
269
307
  ], CommandWindow.prototype, "text", void 0);
@@ -279,6 +317,9 @@ __decorate([
279
317
  __decorate([
280
318
  property({ type: String })
281
319
  ], CommandWindow.prototype, "triggerKey", void 0);
320
+ __decorate([
321
+ property({ type: String })
322
+ ], CommandWindow.prototype, "placeholder", void 0);
282
323
  __decorate([
283
324
  property({ type: Boolean })
284
325
  ], CommandWindow.prototype, "showSections", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"commandWindow.js","sourceRoot":"","sources":["../../src/ui/commandWindow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAmB,cAAc,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,GAAG,EAA2C,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACz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,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAC;YAC9E,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,EAAC,CAAC,EAAE,GAAG,EAAC,CAAC,CAAC;QACjC,CAAC;IACF,CAAC;;AAnQM,oBAAM,GAAG,CAAC,KAAK,CAAC,AAAV,CAAW;AAWxB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACR;AAGjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;2CACb;AAGZ;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;+CACC;AAG1B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACA;AAGzB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACL;AAGpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACP;AAGlB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;mDACN;AA/BR,aAAa;IADzB,aAAa,CAAC,aAAa,CAAC;GAChB,aAAa,CAuRzB","sourcesContent":["import { Commands, Command, CommandsAdapter, CommandSection } from \"../model\";\nimport { dom, List, ListItemRenderer, ListSelectEvent, ListSelectTrigger } from \"@omegagrid/core\";\nimport { LitElement, html, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { createRef, ref } from 'lit/directives/ref.js';\nimport { debounce } from \"ts-debounce\";\nimport { style, itemStyle } from \"./commandWindow.style\";\nimport constants from \"../constants\";\nimport { Options } from \"../model\";\n\nexport class CommandEvent extends Event {\n\tconstructor(type: string, public readonly command?: Command) {\n\t\tsuper(`command.${type}`, {bubbles: true, composed: true})\n\t}\n}\n\nexport type CommandRenderer = (div: HTMLDivElement, command: Command) => string | TemplateResult<1> | null;\nexport type SectionRenderer = (div: HTMLDivElement, section: CommandSection) => string | TemplateResult<1> | null;\n\n@customElement('og-commands')\nexport class CommandWindow extends LitElement {\n\n\tstatic styles = [style];\n\n\tprivate inputRef = createRef<HTMLInputElement>();\n\tget input() { return this.inputRef?.value; }\n\n\tprivate listRef = createRef<List>();\n\tget list() { return this.listRef?.value; }\n\n\tprivate visibleItems: (Command|CommandSection)[];\n\n\t@property({type: Object})\n\toptions: Options;\n\n\t@property({type: String})\n\ttext: string\n\n\t@property({type: Object})\n\tcommands = new Commands();\n\t\n\t@property({type: Object})\n\tadapter: CommandsAdapter;\n\n\t@property({type: Object})\n\ttarget: HTMLElement;\n\n\t@property({type: String})\n\ttriggerKey = 'F1';\n\t\n\t@property({type: Boolean})\n\tshowSections = false\n\n\trequireUpdateCommands = true;\n\n\t_commandRenderer: CommandRenderer = (div: HTMLDivElement, command: Command) => {\n\t\treturn html`\n\t\t\t<div class=\"command\">\n\t\t\t\t${command.name}\n\t\t\t</div>\n\t\t`;\n\t};\n\n\t_sectionRenderer: SectionRenderer = (div: HTMLDivElement, section: CommandSection) => {\n\t\treturn html`\n\t\t\t<div class=\"section\" @mousedown=\"${(e: MouseEvent) => e.preventDefault()}\">\n\t\t\t\t<div class=\"section-toggle\">\n\t\t\t\t\t<og-fa-icon icon=\"angle-${section.open ? 'down' : 'right'}\"></og-fa-icon>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"section-text\">\n\t\t\t\t\t${section.name}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t`;\n\t};\n\n\tget filterValue() { return this.input.value }\n\n\texec(dispatchEvent = true) {\n\t\tconst tokens = this.input.value.split('>').map(t => t.trim());\n\t\tif (tokens[0].length == 0) {\n\t\t\tif (this.list.selectedIndex > -1 && this.list.selectedIndex < this.visibleItems.length) {\n\t\t\t\ttokens[0] = this.visibleItems[this.list.selectedIndex].name;\n\t\t\t}\n\t\t}\n\n\t\tconst command = this.commands.get(tokens[0])\n\t\t\t?? this.visibleItems.find(item => item instanceof Command && item.name == tokens[0]) as Command;\n\t\t\n\t\tif (command) {\n\t\t\tif (tokens.length - 1 < command.requiredParams) {\n\t\t\t\ttokens.push('');\n\t\t\t\tthis.input.value = tokens.join(' > ');\n\t\t\t\tthis.input.focus();\n\t\t\t} else {\n\t\t\t\ttokens.shift();\n\t\t\t\tcommand.exec(...tokens);\n\t\t\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('exec', command));\n\t\t\t\tthis.close();\n\t\t\t}\n\t\t}\n\t}\n\n\t_onKeyDown = (e: KeyboardEvent) => {\n\t\te.stopPropagation();\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 CommandSection) \n\t\t\t\t\tthis.toggleSection((this.visibleItems[this.list.selectedIndex] as CommandSection).id);\n\t\t\t\telse this.exec();\n\t\t\t\tbreak;\n\t\t\tcase 'Escape':\n\t\t\tcase this.triggerKey:\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.close();\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t_onKeyUp = debounce(e => {\n\t\te.stopPropagation();\n\t\tconst excludedKeys = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Shift', 'Enter', this.triggerKey];\n\t\tif (excludedKeys.indexOf(e.key) == -1) {\n\t\t\tthis.updateCommands();\n\t\t\tthis.list.size = this.visibleItems.length;\n\t\t}\n\t})\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('click', e => e.stopPropagation());\n\t\tthis.addEventListener('keyup', this._onKeyUp);\n\t\tthis.addEventListener('keydown', this._onKeyDown);\n\t\tthis.addEventListener('blur', () => this.close());\n\t}\n\n\tasync open(dispatchEvent = true) {\n\t\tif (!this.target) throw new Error('target element not set');\n\n\t\tdom.showElement(this);\n\t\tthis.input.value = '';\n\t\t\n\t\tif (this.requireUpdateCommands) {\n\t\t\tthis.requireUpdateCommands = false; \n\t\t\tawait this.updateCommands();\n\t\t}\n\t\t\n\t\tthis.input.focus();\n\t\tthis.visibleItems = this.commands.filter(null, this.showSections);\n\t\tthis.updatePosition();\n\t\t\n\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('open'));\n\t}\n\n\tclose(dispatchEvent = true) {\n\t\tif (this.target) {\n\t\t\tdom.hideElement(this);\n\t\t\tthis.target.focus();\n\t\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('close'));\n\t\t}\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 0;\n\t}\n\n\t_onTargetKeyDown = (e: KeyboardEvent) => {\n\t\tif (e.key == this.triggerKey) {\n\t\t\te.stopPropagation();\n\t\t\te.preventDefault();\n\t\t\tthis.open();\n\t\t}\n\t}\n\n\tasync willUpdate(props: PropertyValues) {\n\t\tif (props.has('adapter') && this.adapter) {\n\t\t\tconst options = await this.adapter.getOptions();\n\t\t\tif (options) this.options = options;\n\t\t}\n\n\t\tif (this.options) {\n\t\t\tif (this.options.commandRenderer) this._commandRenderer = this.options.commandRenderer;\n\t\t\tif (this.options.sectionRenderer) this._sectionRenderer = this.options.sectionRenderer;\n\t\t}\n\t}\n\n\tasync updated(props: Map<PropertyKey, unknown>) {\n\t\tif (props.has('target')) {\n\t\t\tconst oldTarget = props.get('target') as HTMLElement;\n\t\t\tif (oldTarget) oldTarget.removeEventListener('keydown', this._onTargetKeyDown);\n\t\t\tif (this.target) this.target.addEventListener('keydown', this._onTargetKeyDown);\n\t\t}\n\t\tif (props.has('adapter')) this.requireUpdateCommands = true;\n\t\tif (props.has('commands')) await this.updateCommands();\n\t\tthis.updatePosition();\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\tthis.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.toggleSection((item as CommandSection).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) => {\n\t\treturn this.visibleItems[index] instanceof CommandSection\n\t\t\t? this._sectionRenderer(div, this.visibleItems[index] as CommandSection)\n\t\t\t: this._commandRenderer(div, this.visibleItems[index] as Command);\n\t}\n\n\tfirstUpdated() {\n\t\tthis.list.itemRenderer = this._itemRenderer;\n\t\tthis.list.addEventListener('select', this._onSelect);\n\t}\n\n\tasync updateCommands() {\n\t\tif (this.adapter) {\n\t\t\tthis.commands.clear();\n\t\t\tconst sections = (await Promise.all([this.adapter.getSections(this.filterValue)]))[0];\n\t\t\tsections.forEach(section => this.commands.registerSection(section, false));\n\t\t\tthis.visibleItems = this.commands.filter(null, this.showSections, true);\n\t\t} else {\n\t\t\tthis.visibleItems = this.commands.filter(this.filterValue, this.showSections);\n\t\t}\n\n\t\tthis.list.size = this.visibleItems.length;\n\t\tthis.list.selectedIndex = this.list.size > 0 ? 0 : -1;\n\t\tthis.list.renderItems(true);\n\t\tawait this.list.updateComplete;\n\t}\n\n\tasync toggleSection(sectionId: string) {\n\t\tconst section = this.commands.sections.get(sectionId);\n\t\tif (section.open) {\n\t\t\tsection.open = false;\n\t\t\tthis.visibleItems = this.commands.filter(this.filterValue, this.showSections, true);\n\t\t\tthis.list.size = this.visibleItems.length;\n\t\t} else {\n\t\t\tsection.open = true;\n\t\t\tif (this.adapter) {\n\t\t\t\tconst commands = (await Promise.all([this.adapter.getCommands(sectionId, this.filterValue)]))[0];\n\t\t\t\tif (commands.length > 0) {\n\t\t\t\t\tsection.commands.clear();\n\t\t\t\t\tcommands.forEach(c => section.addCommand(c));\n\t\t\t\t}\n\t\t\t\tthis.visibleItems = this.commands.filter(null, this.showSections, true);\n\t\t\t} else {\n\t\t\t\tthis.visibleItems = this.commands.filter(this.filterValue, this.showSections, true);\n\t\t\t}\n\t\t}\n\t\tthis.list.size = this.visibleItems.length;\n\t}\n\n\tupdatePosition() {\n\t\tif (this.target) {\n\t\t\tdom.setSize(this, {\n\t\t\t\tw: Math.min(constants.COMMAND_WINDOW_MAX_WIDTH, 0.9 * this.target.clientWidth)\n\t\t\t});\n\t\t\tdom.setCenterPosition(this, this.target, {horizontal: true, vertical: false});\n\t\t\tdom.setPosition(this, {t: 100});\n\t\t}\n\t}\n\n\trender = () => html`\n\t\t<div class=\"input\">\n\t\t\t<input type=\"text\" ${ref(this.inputRef)}>\n\t\t</div>\n\t\t${this.text != null ? html`<div class=\"text\">${this.text}</div>` : ''}\n\t\t<div class=\"list\">\n\t\t\t<og-list ${ref(this.listRef)}\n\t\t\t\tmaxHeight=\"300\"\n\t\t\t\t.customStyle=\"${itemStyle}\"\n\t\t\t\titemHeight=\"22\"\n\t\t\t\tlineHeight=\"20\"\n\t\t\t\tarrowEvents>\n\t\t\t</og-list>\n\t\t</div>\n\t`;\n\n}"]}
1
+ {"version":3,"file":"commandWindow.js","sourceRoot":"","sources":["../../src/ui/commandWindow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAmB,cAAc,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,GAAG,EAA2C,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MA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BAAM,GAAG,CAAC,KAAK,CAAC,AAAV,CAAW;AAYxB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACR;AAQjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;2CACoB;AAG7C;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACX;AAGd;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;2CACZ;AAGb;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;+CACC;AAG1B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;8CACA;AAGzB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACL;AAGpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACP;AAGlB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kDACR;AAGjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;mDACN;AA9CR,aAAa;IADzB,aAAa,CAAC,aAAa,CAAC;GAChB,aAAa,CAsTzB","sourcesContent":["import { Commands, Command, CommandsAdapter, CommandSection } from \"../model\";\nimport { dom, List, ListItemRenderer, ListSelectEvent, ListSelectTrigger } from \"@omegagrid/core\";\nimport { LitElement, html, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { createRef, ref } from 'lit/directives/ref.js';\nimport { debounce } from \"ts-debounce\";\nimport { style, itemStyle } from \"./commandWindow.style\";\nimport constants from \"../constants\";\nimport { Options } from \"../model\";\n\nexport class CommandEvent extends Event {\n\n\treadonly command?: Command;\n\treadonly value?: string;\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) => string | TemplateResult<1> | null;\nexport type SectionRenderer = (div: HTMLDivElement, section: CommandSection) => string | TemplateResult<1> | null;\n\n@customElement('og-commands')\nexport class CommandWindow extends LitElement {\n\n\tstatic styles = [style];\n\n\tprivate inputRef = createRef<HTMLInputElement>();\n\tget input() { return this.inputRef?.value }\n\tget inputValue() { return this.input?.value ?? '' }\n\n\tprivate listRef = createRef<List>();\n\tget list() { return this.listRef?.value; }\n\n\tprivate visibleItems: (Command|CommandSection)[];\n\n\t@property({type: Object})\n\toptions: Options;\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: 'search' | 'input' | 'none' = 'search';\n\n\t@property({type: String})\n\tvalue: string;\n\n\t@property({type: String})\n\ttext: string;\n\n\t@property({type: Object})\n\tcommands = new Commands();\n\t\n\t@property({type: Object})\n\tadapter: CommandsAdapter;\n\n\t@property({type: Object})\n\ttarget: HTMLElement;\n\n\t@property({type: String})\n\ttriggerKey = 'F1';\n\n\t@property({type: String})\n\tplaceholder = '';\n\t\n\t@property({type: Boolean})\n\tshowSections = false\n\n\trequireUpdateCommands = true;\n\n\t_commandRenderer: CommandRenderer = (div: HTMLDivElement, command: Command) => {\n\t\treturn html`\n\t\t\t<div class=\"command\">\n\t\t\t\t${command.name}\n\t\t\t</div>\n\t\t`;\n\t};\n\n\t_sectionRenderer: SectionRenderer = (div: HTMLDivElement, section: CommandSection) => {\n\t\treturn html`\n\t\t\t<div class=\"section\" @mousedown=\"${(e: MouseEvent) => e.preventDefault()}\">\n\t\t\t\t<div class=\"section-toggle\">\n\t\t\t\t\t<og-fa-icon icon=\"angle-${section.open ? 'down' : 'right'}\"></og-fa-icon>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"section-text\">\n\t\t\t\t\t${section.name}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t`;\n\t};\n\n\tget filterValue() { return this.mode == 'search' ? this.input.value : null }\n\n\texec(dispatchEvent = true) {\n\t\tconst tokens = this.input.value.split('>').map(t => t.trim());\n\t\tif (tokens[0].length == 0) {\n\t\t\tif (this.list.selectedIndex > -1 && this.list.selectedIndex < this.visibleItems.length) {\n\t\t\t\ttokens[0] = this.visibleItems[this.list.selectedIndex].name;\n\t\t\t}\n\t\t}\n\n\t\tif (this.mode == 'search') {\n\t\t\tconst command = this.commands.get(tokens[0])\n\t\t\t\t?? this.visibleItems.find(item => item instanceof Command && item.name == tokens[0]) as Command;\n\t\t\tif (!command) return;\n\t\t\tif (tokens.length - 1 < command.requiredParams) {\n\t\t\t\ttokens.push('');\n\t\t\t\tthis.input.value = tokens.join(' > ');\n\t\t\t\tthis.input.focus();\n\t\t\t} else {\n\t\t\t\ttokens.shift();\n\t\t\t\tcommand.exec(...tokens);\n\t\t\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('exec', { \n\t\t\t\t\tcommand, \n\t\t\t\t\tvalue: this.inputValue\n\t\t\t\t}));\n\t\t\t\tthis.close();\n\t\t\t}\n\t\t} else {\n\t\t\tconst command = this.visibleItems[this.list.selectedIndex] as Command;\n\t\t\tif (!command) return;\n\t\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('exec', { \n\t\t\t\tcommand: command,\n\t\t\t\tvalue: this.inputValue\n\t\t\t}));\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t_onKeyDown = (e: KeyboardEvent) => {\n\t\te.stopPropagation();\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 CommandSection) \n\t\t\t\t\tthis.toggleSection((this.visibleItems[this.list.selectedIndex] as CommandSection).id);\n\t\t\t\telse this.exec();\n\t\t\t\tbreak;\n\t\t\tcase 'Escape':\n\t\t\tcase this.triggerKey:\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.close();\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t_onKeyUp = debounce(e => {\n\t\te.stopPropagation();\n\t\tif (this.mode == 'search') {\n\t\t\tconst excludedKeys = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Shift', 'Enter', this.triggerKey];\n\t\t\tif (excludedKeys.indexOf(e.key) == -1) {\n\t\t\t\tthis.updateCommands();\n\t\t\t\tthis.list.size = this.visibleItems.length;\n\t\t\t}\n\t\t}\n\t})\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('click', e => e.stopPropagation());\n\t\tthis.addEventListener('keyup', this._onKeyUp);\n\t\tthis.addEventListener('keydown', this._onKeyDown);\n\t\tthis.addEventListener('blur', () => this.close());\n\t}\n\n\tasync open(dispatchEvent = true) {\n\t\tif (!this.target) throw new Error('target element not set');\n\n\t\tdom.showElement(this);\n\t\tthis.input.value = this.value ?? '';\n\t\t\n\t\tif (this.requireUpdateCommands) {\n\t\t\tthis.requireUpdateCommands = false;\n\t\t\tawait this.updateCommands();\n\t\t}\n\t\t\n\t\tthis.input.focus();\n\t\tthis.visibleItems = this.commands.filter(null, this.showSections);\n\t\tthis.updatePosition();\n\t\t\n\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('open'));\n\t}\n\n\tclose(dispatchEvent = true) {\n\t\tif (this.target) {\n\t\t\tdom.hideElement(this);\n\t\t\tthis.target.focus();\n\t\t\tif (dispatchEvent) this.dispatchEvent(new CommandEvent('close'));\n\t\t}\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 0;\n\t}\n\n\t_onTargetKeyDown = (e: KeyboardEvent) => {\n\t\tif (e.key == this.triggerKey) {\n\t\t\te.stopPropagation();\n\t\t\te.preventDefault();\n\t\t\tthis.open();\n\t\t}\n\t}\n\n\tasync willUpdate(props: PropertyValues) {\n\t\tif (props.has('adapter') && this.adapter) {\n\t\t\tconst options = await this.adapter.getOptions();\n\t\t\tif (options) this.options = options;\n\t\t}\n\n\t\tif (this.options) {\n\t\t\tif (this.options.commandRenderer) this._commandRenderer = this.options.commandRenderer;\n\t\t\tif (this.options.sectionRenderer) this._sectionRenderer = this.options.sectionRenderer;\n\t\t}\n\t}\n\n\tasync updated(props: Map<PropertyKey, unknown>) {\n\t\tif (props.has('target')) {\n\t\t\tconst oldTarget = props.get('target') as HTMLElement;\n\t\t\tif (oldTarget) oldTarget.removeEventListener('keydown', this._onTargetKeyDown);\n\t\t\tif (this.target) this.target.addEventListener('keydown', this._onTargetKeyDown);\n\t\t}\n\t\tif (props.has('adapter')) this.requireUpdateCommands = true;\n\t\tif (props.has('commands')) await this.updateCommands();\n\t\tthis.updatePosition();\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;\t\t\t\n\t\t\tif (e.trigger == ListSelectTrigger.Click || e.trigger == ListSelectTrigger.Enter) this.exec();\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.toggleSection((item as CommandSection).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) => {\n\t\treturn this.visibleItems[index] instanceof CommandSection\n\t\t\t? this._sectionRenderer(div, this.visibleItems[index] as CommandSection)\n\t\t\t: this._commandRenderer(div, this.visibleItems[index] as Command);\n\t}\n\n\tfirstUpdated() {\n\t\tthis.list.itemRenderer = this._itemRenderer;\n\t\tthis.list.addEventListener('select', this._onSelect);\n\t}\n\n\tasync updateCommands() {\n\t\tif (this.adapter) {\n\t\t\tthis.commands.clear();\n\t\t\tconst sections = (await Promise.all([this.adapter.getSections(this.filterValue)]))[0];\n\t\t\tsections.forEach(section => this.commands.registerSection(section, false));\n\t\t\tthis.visibleItems = this.commands.filter(null, this.showSections, true);\n\t\t} else {\n\t\t\tthis.visibleItems = this.commands.filter(this.filterValue, this.showSections);\n\t\t}\n\n\t\tthis.list.size = this.visibleItems.length;\n\t\tthis.list.selectedIndex = this.list.size > 0 ? 0 : -1;\n\t\tthis.list.renderItems(true);\n\t\tawait this.list.updateComplete;\n\t}\n\n\tasync toggleSection(sectionId: string) {\n\t\tconst section = this.commands.sections.get(sectionId);\n\t\tif (section.open) {\n\t\t\tsection.open = false;\n\t\t\tthis.visibleItems = this.commands.filter(this.filterValue, this.showSections, true);\n\t\t\tthis.list.size = this.visibleItems.length;\n\t\t} else {\n\t\t\tsection.open = true;\n\t\t\tif (this.adapter) {\n\t\t\t\tconst commands = (await Promise.all([this.adapter.getCommands(sectionId, this.filterValue)]))[0];\n\t\t\t\tif (commands.length > 0) {\n\t\t\t\t\tsection.commands.clear();\n\t\t\t\t\tcommands.forEach(c => section.addCommand(c));\n\t\t\t\t}\n\t\t\t\tthis.visibleItems = this.commands.filter(null, this.showSections, true);\n\t\t\t} else {\n\t\t\t\tthis.visibleItems = this.commands.filter(this.filterValue, this.showSections, true);\n\t\t\t}\n\t\t}\n\t\tthis.list.size = this.visibleItems.length;\n\t}\n\n\tupdatePosition() {\n\t\tif (this.target) {\n\t\t\tdom.setSize(this, {\n\t\t\t\tw: Math.min(constants.COMMAND_WINDOW_MAX_WIDTH, 0.9 * this.target.clientWidth)\n\t\t\t});\n\t\t\tdom.setCenterPosition(this, this.target, {horizontal: true, vertical: false});\n\t\t\tdom.setPosition(this, {t: 100});\n\t\t}\n\t}\n\n\trender = () => html`\n\t\t<div class=\"input\">\n\t\t\t<input ${ref(this.inputRef)}\n\t\t\t\ttype=\"text\"\n\t\t\t\t.placeholder=\"${this.placeholder}\"\n\t\t\t\t.value=\"${this.value}\">\n\t\t</div>\n\n\t\t${this.text != null ? html`<div class=\"text\">${this.text}</div>` : ''}\n\t\t\n\t\t<div class=\"list\">\n\t\t\t<og-list ${ref(this.listRef)}\n\t\t\t\tmaxHeight=\"300\"\n\t\t\t\t.customStyle=\"${itemStyle}\"\n\t\t\t\titemHeight=\"22\"\n\t\t\t\tlineHeight=\"20\"\n\t\t\t\tarrowEvents>\n\t\t\t</og-list>\n\t\t</div>\n\t`;\n\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/commands",
3
- "version": "0.6.116",
3
+ "version": "0.6.118",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Command window",
6
6
  "main": "./dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "_prepublish": "yarn test && yarn lint"
28
28
  },
29
29
  "dependencies": {
30
- "@omegagrid/core": "^0.6.116",
30
+ "@omegagrid/core": "^0.6.118",
31
31
  "lit": "^3.1.1",
32
32
  "lit-html": "^3.1.1",
33
33
  "ts-debounce": "^4.0.0"