Skip to content

Commit

Permalink
Fix XO
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzyCzech committed Dec 4, 2023
1 parent 2a8ed2d commit d2da0da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
5 changes: 2 additions & 3 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export type Hotkey = {
* @see https://github.com/jaywcjlove/hotkeys-js#option
*/
splitKey?: string;
}

};

export type Action = {
/**
Expand Down Expand Up @@ -66,7 +65,7 @@ export type Action = {
/**
* Handler of the action (optional)
*/
onAction?: (action: Action, isDialogOpen?: Boolean) => { keepOpen?: boolean };
onAction?: (action: Action, isDialogOpen?: boolean) => {keepOpen?: boolean};

/**
* Tags of the action (optional)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class CmdAction extends LitElement {
*/
private get hotkeys() {
if (this.action?.hotkey) {
const hotkeys = (typeof this.action.hotkey === 'object' ? this.action.hotkey?.key as string : this.action.hotkey as string)
const hotkeys = (typeof this.action.hotkey === 'object' ? this.action.hotkey?.key || '' : this.action.hotkey)
.replace('cmd', '⌘')
.replace('shift', '⇧')
.replace('alt', '⌥')
Expand Down
26 changes: 11 additions & 15 deletions src/cmd-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {type CmdAction} from './cmd-action.js';
import './cmd-action.js'; // eslint-disable-line import/no-unassigned-import
import style from './style.css?inline'; // eslint-disable-line n/file-extension-in-import


@customElement('cmd-dialog')
export class CmdDialog extends LitElement {
static override styles = unsafeCSS(style);
Expand All @@ -37,22 +36,14 @@ export class CmdDialog extends LitElement {
@property({type: String}) hotkey = 'cmd+k,ctrl+k';

/**
* Callback when dialog is closed
*/
@property({type: Function}) onClose = () => {
};

/**
* Callback when dialog is opened
* Callback when dialog is closed (optional)
*/
@property({type: Function}) onOpen = () => {
};
@property({type: Function}) onClose = Function;

/**
* Hotkeys instance
* @private
* Callback when dialog is opened (optional)
*/
@state() private _hotkeys: Hotkeys = hotkeys.noConflict();
@property({type: Function}) onOpen = Function;

/**
* Array of actions
Expand All @@ -64,6 +55,12 @@ export class CmdDialog extends LitElement {
},
}) actions = [] as Action[];

/**
* Hotkeys instance
* @private
*/
@state() private readonly _hotkeys: Hotkeys = hotkeys.noConflict();

/**
* Search input value
* @private
Expand Down Expand Up @@ -180,8 +177,7 @@ export class CmdDialog extends LitElement {
if (changedProperties.has('actions')) {
// Register action hotkeys
for (const action of this.actions.filter(item => Boolean(item.hotkey))) {

const {key, ...options} = typeof action.hotkey === 'object' ? action.hotkey : {key: action.hotkey as string, scope: 'all'};
const {key, ...options} = typeof action.hotkey === 'object' ? action.hotkey : {key: action.hotkey!, scope: 'all'};

hotkeys(
key,
Expand Down

1 comment on commit d2da0da

@vercel
Copy link

@vercel vercel bot commented on d2da0da Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cmd-dialog – ./

cmd-dialog-git-main-ozzyczech.vercel.app
cmd-dialog-ozzyczech.vercel.app
cmd-dialog.vercel.app

Please sign in to comment.