npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ibizstudio/quick-action-bar

v0.0.1-beta.2

Published

stencilJs 组件开发基本脚手架

Downloads

190

Readme

指令快捷操作栏

使用示例

1. 根据自身需求实现 ListDataProvider、DataItemProvider 接口,此为操作栏列表的数据适配器

/**
 * 操作栏默认模式数据适配器
 *
 * @author chitanda
 * @date 2022-06-28 18:06:54
 * @export
 * @class DefaultModeDataProvider
 * @implements {ListDataProvider<DefaultModeDataItemProvider>}
 */
export class DefaultModeDataProvider implements ListDataProvider<DefaultModeDataItemProvider> {
  /**
   * 列表行内点击指令
   *
   * @author chitanda
   * @date 2022-06-30 11:06:49
   * @type {string}
   */
  command: string = CommandConst.DEFAULT_MODE_CLICK;

  list: DefaultModeDataItemProvider[] = [];

  constructor() {
    // 注册列表行内点击指令
    commands.register(
      CommandConst.DEFAULT_MODE_CLICK,
      async (data: DefaultModeDataItemProvider) => {
        const { keyboards } = data.mode.opts;
        Mousetrap.trigger(keyboards instanceof Array ? keyboards[0] : keyboards);
      },
      {
        id: CommandConst.DEFAULT_MODE_CLICK,
        title: '默认模式点击',
      },
    );
  }

  /**
   * 过滤展示列表
   *
   * @author chitanda
   * @date 2022-06-29 14:06:49
   * @param {string} [searchVal]
   * @return {*}  {Promise<DefaultModeDataItemProvider[]>}
   */
  async getItems(_searchVal?: string): Promise<DefaultModeDataItemProvider[]> {
    // 减一是因为默认模式不需要显示
    if (quickActionModeRegister.size - 1 !== this.list.length) {
      this.list = [];
      const modes = quickActionModeRegister.getModes();
      for (let i = 1; i < modes.length; i++) {
        const mode = modes[i];
        this.list.push(new DefaultModeDataItemProvider(i.toString(), mode));
      }
    }
    return this.list;
  }
}
/**
 * 列表数据项
 *
 * @author chitanda
 * @date 2022-06-28 18:06:15
 * @export
 * @class DefaultModeDataItemProvider
 * @implements {DataItemProvider}
 */
export class DefaultModeDataItemProvider implements DataItemProvider {
  readonly id: string = '';
  readonly label: string;
  readonly tooltip?: string;
  readonly icon?: string;
  readonly description?: string;
  readonly mode: QuickActionMode;

  /**
   * Creates an instance of DefaultModeDataItemProvider.
   *
   * @author chitanda
   * @date 2022-06-30 11:06:54
   * @param {string} id
   * @param {QuickActionMode} mode
   */
  constructor(id: string, mode: QuickActionMode) {
    const { opts } = mode;
    this.mode = mode;
    this.id = id;
    this.label = opts.title;
    this.icon = opts.icon;
    this.description = opts.description;
  }
}

2. 注册新适配的模式

  quickActionModeRegister.addModel({
    title: '默认模式',
    tooltip: '默认模式提示',
    description: '默认模式描述',
    icon: './assets/svg/icon-default.svg',
    type: ModeType.DEFAULT,
    keyboards: 'ctrl+p',
    tag: '',
    provider: new DefaultModeDataProvider(),
  });