@omegagrid/commands 0.6.79 → 0.6.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/adapter.d.ts +2 -0
- package/dist/model/adapter.d.ts.map +1 -1
- package/dist/model/adapter.js +3 -0
- package/dist/model/adapter.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/options.d.ts +8 -0
- package/dist/model/options.d.ts.map +1 -0
- package/dist/model/options.js +12 -0
- package/dist/model/options.js.map +1 -0
- package/dist/ui/commandWindow.d.ts +7 -4
- package/dist/ui/commandWindow.d.ts.map +1 -1
- package/dist/ui/commandWindow.js +25 -15
- package/dist/ui/commandWindow.js.map +1 -1
- package/package.json +2 -2
package/dist/model/adapter.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ComponentAdapter } from "@omegagrid/core";
|
|
2
2
|
import { Command, CommandSection } from "./commands";
|
|
3
|
+
import { Options } from "./options";
|
|
3
4
|
export declare abstract class CommandsAdapter extends ComponentAdapter {
|
|
4
5
|
abstract getSections(filter?: string): CommandSection[] | Promise<CommandSection[]>;
|
|
5
6
|
abstract getCommands(sectionId: string, filter?: string): Command[] | Promise<Command[]>;
|
|
7
|
+
getOptions(): Options | Promise<Options> | null;
|
|
6
8
|
}
|
|
7
9
|
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/model/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/model/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,8BAAsB,eAAgB,SAAQ,gBAAgB;IAE7D,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,GAAC,OAAO,CAAC,cAAc,EAAE,CAAC;IACjF,QAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,GAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAEtF,UAAU,IAAI,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,IAAI;CAI3C"}
|
package/dist/model/adapter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/model/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/model/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAInD,MAAM,OAAgB,eAAgB,SAAQ,gBAAgB;IAK7D,UAAU;QACT,OAAO,IAAI,CAAC;IACb,CAAC;CAED","sourcesContent":["import { ComponentAdapter } from \"@omegagrid/core\";\nimport { Command, CommandSection } from \"./commands\";\nimport { Options } from \"./options\";\n\nexport abstract class CommandsAdapter extends ComponentAdapter {\n\t\n\tabstract getSections(filter?: string): CommandSection[]|Promise<CommandSection[]>;\n\tabstract getCommands(sectionId: string, filter?: string): Command[]|Promise<Command[]>;\n\n\tgetOptions(): Options|Promise<Options>|null {\n\t\treturn null;\n\t}\n\n}"]}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
package/dist/model/index.js
CHANGED
package/dist/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC","sourcesContent":["export * from './commands';\nexport * from './adapter'
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC","sourcesContent":["export * from './commands';\nexport * from './adapter';\nexport * from './options';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommonOptions } from "@omegagrid/core";
|
|
2
|
+
import { CommandRenderer, SectionRenderer } from "../ui";
|
|
3
|
+
export type Options = {
|
|
4
|
+
commandRenderer?: CommandRenderer;
|
|
5
|
+
sectionRenderer?: SectionRenderer;
|
|
6
|
+
} & CommonOptions;
|
|
7
|
+
export declare function initOptions(options?: Partial<Options>, origOptions?: Options): Options;
|
|
8
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/model/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,MAAM,OAAO,GAAG;IACrB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,eAAe,CAAC;CAClC,GAAG,aAAa,CAAC;AAIlB,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAE,OAAc,GAAG,OAAO,CAS5F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { initCommonOptions } from "@omegagrid/core";
|
|
2
|
+
const DEFAULT_OPTIONS = {};
|
|
3
|
+
export function initOptions(options, origOptions = null) {
|
|
4
|
+
const opts = {
|
|
5
|
+
...initCommonOptions(options, origOptions),
|
|
6
|
+
...DEFAULT_OPTIONS,
|
|
7
|
+
...origOptions,
|
|
8
|
+
...options,
|
|
9
|
+
};
|
|
10
|
+
return opts;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/model/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AAQnE,MAAM,eAAe,GAAqB,EAAE,CAAC;AAE7C,MAAM,UAAU,WAAW,CAAC,OAA0B,EAAE,cAAuB,IAAI;IAClF,MAAM,IAAI,GAAG;QACZ,GAAG,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC;QAC1C,GAAG,eAAe;QAClB,GAAG,WAAW;QACd,GAAG,OAAO;KACV,CAAC;IAEF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { initCommonOptions, CommonOptions } from \"@omegagrid/core\";\nimport { CommandRenderer, SectionRenderer } from \"../ui\";\n\nexport type Options = {\n\tcommandRenderer?: CommandRenderer,\n\tsectionRenderer?: SectionRenderer,\n} & CommonOptions;\n\nconst DEFAULT_OPTIONS: Partial<Options> = {};\n\nexport function initOptions(options?: Partial<Options>, origOptions: Options = null): Options {\n\tconst opts = {\n\t\t...initCommonOptions(options, origOptions),\n\t\t...DEFAULT_OPTIONS,\n\t\t...origOptions,\n\t\t...options,\n\t};\n\n\treturn opts;\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Commands, Command, CommandsAdapter, CommandSection } from "../model";
|
|
2
2
|
import { List, ListItemRenderer, ListSelectEvent } from "@omegagrid/core";
|
|
3
|
-
import { LitElement, TemplateResult } from 'lit';
|
|
3
|
+
import { LitElement, TemplateResult, PropertyValues } from 'lit';
|
|
4
|
+
import { Options } from "../model";
|
|
4
5
|
export declare class CommandEvent extends Event {
|
|
5
6
|
readonly command?: Command;
|
|
6
7
|
constructor(type: string, command?: Command);
|
|
@@ -14,6 +15,7 @@ export declare class CommandWindow extends LitElement {
|
|
|
14
15
|
private listRef;
|
|
15
16
|
get list(): List;
|
|
16
17
|
private visibleItems;
|
|
18
|
+
options: Options;
|
|
17
19
|
text: string;
|
|
18
20
|
commands: Commands;
|
|
19
21
|
adapter: CommandsAdapter;
|
|
@@ -21,8 +23,8 @@ export declare class CommandWindow extends LitElement {
|
|
|
21
23
|
triggerKey: string;
|
|
22
24
|
showSections: boolean;
|
|
23
25
|
requireUpdateCommands: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
_commandRenderer: CommandRenderer;
|
|
27
|
+
_sectionRenderer: SectionRenderer;
|
|
26
28
|
get filterValue(): string;
|
|
27
29
|
exec(dispatchEvent?: boolean): void;
|
|
28
30
|
_onKeyDown: (e: KeyboardEvent) => void;
|
|
@@ -35,7 +37,8 @@ export declare class CommandWindow extends LitElement {
|
|
|
35
37
|
close(dispatchEvent?: boolean): void;
|
|
36
38
|
connectedCallback(): void;
|
|
37
39
|
_onTargetKeyDown: (e: KeyboardEvent) => void;
|
|
38
|
-
|
|
40
|
+
willUpdate(props: PropertyValues): Promise<void>;
|
|
41
|
+
updated(props: Map<PropertyKey, unknown>): Promise<void>;
|
|
39
42
|
_onSelect: (e: ListSelectEvent) => void;
|
|
40
43
|
_itemRenderer: ListItemRenderer;
|
|
41
44
|
firstUpdated(): 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,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,MAAM,KAAK,CAAC;
|
|
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,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,qBAAa,YAAa,SAAQ,KAAK;aACI,OAAO,CAAC,EAAE,OAAO;gBAA/C,IAAI,EAAE,MAAM,EAAkB,OAAO,CAAC,EAAE,OAAO;CAG3D;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,KAAK,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAC3G,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,KAAK,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAElH,qBACa,aAAc,SAAQ,UAAU;IAE5C,MAAM,CAAC,MAAM,4BAAW;IAExB,OAAO,CAAC,QAAQ,CAAiC;IACjD,IAAI,KAAK,qBAAmC;IAE5C,OAAO,CAAC,OAAO,CAAqB;IACpC,IAAI,IAAI,SAAkC;IAE1C,OAAO,CAAC,YAAY,CAA6B;IAGjD,OAAO,EAAE,OAAO,CAAC;IAGjB,IAAI,EAAE,MAAM,CAAA;IAGZ,QAAQ,WAAkB;IAG1B,OAAO,EAAE,eAAe,CAAC;IAGzB,MAAM,EAAE,WAAW,CAAC;IAGpB,UAAU,SAAQ;IAGlB,YAAY,UAAQ;IAEpB,qBAAqB,UAAQ;IAE7B,gBAAgB,EAAE,eAAe,CAM/B;IAEF,gBAAgB,EAAE,eAAe,CAW/B;IAEF,IAAI,WAAW,WAA8B;IAE7C,IAAI,CAAC,aAAa,UAAO;IAyBzB,UAAU,MAAO,aAAa,UAuB7B;IAED,QAAQ;;uBArHqB,CAAC;MA4H5B;;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,UAe9B;IAED,aAAa,EAAE,gBAAgB,CAI9B;IAED,YAAY;IAKN,cAAc;IAgBd,aAAa,CAAC,SAAS,EAAE,MAAM;IAsBrC,cAAc;IAUd,MAAM,0BAcJ;CAEF"}
|
package/dist/ui/commandWindow.js
CHANGED
|
@@ -54,14 +54,14 @@ let CommandWindow = class CommandWindow extends LitElement {
|
|
|
54
54
|
this.triggerKey = 'F1';
|
|
55
55
|
this.showSections = false;
|
|
56
56
|
this.requireUpdateCommands = true;
|
|
57
|
-
this.
|
|
57
|
+
this._commandRenderer = (div, command) => {
|
|
58
58
|
return html `
|
|
59
59
|
<div class="command">
|
|
60
60
|
${command.name}
|
|
61
61
|
</div>
|
|
62
62
|
`;
|
|
63
63
|
};
|
|
64
|
-
this.
|
|
64
|
+
this._sectionRenderer = (div, section) => {
|
|
65
65
|
return html `
|
|
66
66
|
<div class="section" @mousedown="${(e) => e.preventDefault()}">
|
|
67
67
|
<div class="section-toggle">
|
|
@@ -131,8 +131,8 @@ let CommandWindow = class CommandWindow extends LitElement {
|
|
|
131
131
|
};
|
|
132
132
|
this._itemRenderer = (div, index) => {
|
|
133
133
|
return this.visibleItems[index] instanceof CommandSection
|
|
134
|
-
? this.
|
|
135
|
-
: this.
|
|
134
|
+
? this._sectionRenderer(div, this.visibleItems[index])
|
|
135
|
+
: this._commandRenderer(div, this.visibleItems[index]);
|
|
136
136
|
};
|
|
137
137
|
this.render = () => html `
|
|
138
138
|
<div class="input">
|
|
@@ -181,17 +181,30 @@ let CommandWindow = class CommandWindow extends LitElement {
|
|
|
181
181
|
super.connectedCallback();
|
|
182
182
|
this.tabIndex = 0;
|
|
183
183
|
}
|
|
184
|
-
async
|
|
185
|
-
if (
|
|
186
|
-
const
|
|
184
|
+
async willUpdate(props) {
|
|
185
|
+
if (props.has('adapter') && this.adapter) {
|
|
186
|
+
const options = await this.adapter.getOptions();
|
|
187
|
+
if (options)
|
|
188
|
+
this.options = options;
|
|
189
|
+
}
|
|
190
|
+
if (this.options) {
|
|
191
|
+
if (this.options.commandRenderer)
|
|
192
|
+
this._commandRenderer = this.options.commandRenderer;
|
|
193
|
+
if (this.options.sectionRenderer)
|
|
194
|
+
this._sectionRenderer = this.options.sectionRenderer;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async updated(props) {
|
|
198
|
+
if (props.has('target')) {
|
|
199
|
+
const oldTarget = props.get('target');
|
|
187
200
|
if (oldTarget)
|
|
188
201
|
oldTarget.removeEventListener('keydown', this._onTargetKeyDown);
|
|
189
202
|
if (this.target)
|
|
190
203
|
this.target.addEventListener('keydown', this._onTargetKeyDown);
|
|
191
204
|
}
|
|
192
|
-
if (
|
|
205
|
+
if (props.has('adapter'))
|
|
193
206
|
this.requireUpdateCommands = true;
|
|
194
|
-
if (
|
|
207
|
+
if (props.has('commands'))
|
|
195
208
|
await this.updateCommands();
|
|
196
209
|
this.updatePosition();
|
|
197
210
|
}
|
|
@@ -248,6 +261,9 @@ let CommandWindow = class CommandWindow extends LitElement {
|
|
|
248
261
|
}
|
|
249
262
|
};
|
|
250
263
|
CommandWindow.styles = [style];
|
|
264
|
+
__decorate([
|
|
265
|
+
property({ type: Object })
|
|
266
|
+
], CommandWindow.prototype, "options", void 0);
|
|
251
267
|
__decorate([
|
|
252
268
|
property({ type: String })
|
|
253
269
|
], CommandWindow.prototype, "text", void 0);
|
|
@@ -266,12 +282,6 @@ __decorate([
|
|
|
266
282
|
__decorate([
|
|
267
283
|
property({ type: Boolean })
|
|
268
284
|
], CommandWindow.prototype, "showSections", void 0);
|
|
269
|
-
__decorate([
|
|
270
|
-
property({ type: Object })
|
|
271
|
-
], CommandWindow.prototype, "commandRenderer", void 0);
|
|
272
|
-
__decorate([
|
|
273
|
-
property({ type: Object })
|
|
274
|
-
], CommandWindow.prototype, "sectionRenderer", void 0);
|
|
275
285
|
CommandWindow = __decorate([
|
|
276
286
|
customElement('og-commands')
|
|
277
287
|
], CommandWindow);
|
|
@@ -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,EAAkB,MAAM,KAAK,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EA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ACL;AAGpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACP;AAGlB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;mDACN;AAKpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;sDAOvB;AAGF;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;sDAYvB;AArDU,aAAa;IADzB,aAAa,CAAC,aAAa,CAAC;GAChB,aAAa,CA0QzB","sourcesContent":["import { Commands, Command, CommandsAdapter, CommandSection } from \"../model\";\nimport { dom, List, ListItemRenderer, ListSelectEvent, ListSelectTrigger } from \"@omegagrid/core\";\nimport { LitElement, html, TemplateResult } 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\";\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: 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@property({type: Object})\n\tcommandRenderer: 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@property({type: Object})\n\tsectionRenderer: 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 updated(properties: Map<PropertyKey, unknown>) {\n\t\tif (properties.has('target')) {\n\t\t\tconst oldTarget = properties.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 (properties.has('adapter')) this.requireUpdateCommands = true;\n\t\tif (properties.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,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,MAAM,OAAO,YAAa,SAAQ,KAAK;IACtC,YAAY,IAAY,EAAkB,OAAiB;QAC1D,KAAK,CAAC,WAAW,IAAI,EAAE,EAAE,EAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAA;QADhB,YAAO,GAAP,OAAO,CAAU;IAE3D,CAAC;CACD;AAMM,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAK5C,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAG5C,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;IAgD1C,IAAI,WAAW,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAA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C;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}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omegagrid/commands",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.81",
|
|
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.
|
|
30
|
+
"@omegagrid/core": "^0.6.81",
|
|
31
31
|
"lit": "^3.1.1",
|
|
32
32
|
"lit-html": "^3.1.1",
|
|
33
33
|
"ts-debounce": "^4.0.0"
|