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 🙏

© 2025 – Pkg Stats / Ryan Hefner

legions-lunar

v0.0.9

Published

> 连接增强器,提高业务产出效率

Downloads

30

Readme

legions-lunar

TODO: 基于 mobx 数据流的 React 库修饰器集合

Usage

npm i legions-lunar/ --save

API

submittingAutoMessage

import React from 'react';
import { observer, bind } from 'legions/store-react';
import {submittingAutoMessage} from 'legions-lunar/mobx-decorator';

@bind({ store: UserInfoStore })
@observer
export default class CustomsCommodity extends React.Component<IProps, IState> {
    @submittingAutoMessage<CustomsCommodity>({
        state: 'DeleteCustomsCommondity', sideEffect: (that) => {
            that.initData();
        },
    })
    deleteCustomsCommondity(ids: string) {
        this.props.store.deleteCustomsCommondity(ids);
    }
}

confirmAnnotation

import React from 'react';
import { observer, bind } from 'legions/store-react';
import {confirmAnnotation} from 'legions-lunar/mobx-decorator';

@bind({ store: UserInfoStore })
@observer
export default class CustomsCommodity extends React.Component<IProps, IState> {
    @confirmAnnotation<ModalDemo>({
        onCancel: (that) => {
            console.log(that);
        },
        confirmType: 'delete',
    })
    onDeleteConfirm() {
        console.log('444',this);
    }

    @confirmAnnotation<ModalDemo>({
        onCancel: (that) => {
            console.log(that);
        },
        title: (that) => that.renderTitle(),
        content: (that) => that.renderContent(),
        confirmType: 'confirm',
    })
    onConfirmAnnotation() {
        console.log('444',this);
    }

    @confirmAnnotation<ModalDemo>({
        confirmType: 'message',
        type: (that) => 'error',
        /*  title: 'This is a notification message',
         content: 'This is a notification message', */
        title: (that) => that.renderTitle(),
        content: (that) => that.renderContent(),

    })
    onConfirmMesssage() {
        console.log('444',this);
    }
}

loadProgress

import React from 'react';
import { observer, bind } from 'legions/store-react';
import { loadProgress } from 'legions-lunar/mobx-decorator';

@bind({ store: UserInfoStore })
@observer
export default class CustomsCommodity extends React.Component<IProps, IState> {
  @loadProgress({ state: 'driverDetailAfterSave' })
  componentWillMount() {}
}

Moadl

import {
  OpenDeleteConfirm,
  OpenConfirm,
  OpenModal,
} from 'legions-lunar/antd-toolkit';

LabeledValueValidator

下拉框开启 labelInValue 时的特殊表单验证规则

import { LabeledValueValidator } from 'legions-lunar/antd-toolkit';

Model

数据模型

import { HlLabeledValue, BaseFormFields } from 'legions-lunar/model';

const selectOptionLabel = new HlLabeledValue(); // 下拉选项Lable模型

// BaseFormFields  基于antd form 表单模型基础类

/*
 * @Author:
 * @Date:
 * @describle:
 */

import {
  FormRuleProperty,
  createFormRule,
} from 'legions-lunar/async.validator';
import { IBaseFormFields } from 'legions-lunar/types/model/BaseFormFields';
import { BaseFormFields,HlLabeledValue} from 'legions-lunar/model';

export class FormFields extends BaseFormFields {
    @FormRuleProperty({
        required: true,
        name: 'multiline',
        error: '多行文本格式错误,应输入22',
        desc: '多行文本',
        type: 'string',
        /* regex:/^[1-9]\d*$/, // 自定义验证规则 */
        validator: (value, error, callback) => {
        // 自定义验证规则
        if (value !== '22') {
            callback(new Error(error));
        } else {
            callback();
        }
        },
    })
    multiline: IBaseFormFields<string> = {
        value: '',
    };

    FormRuleProperty({
        required: true,
        name: 'switched',
        error: '格式错误',
        desc: 'switched',
        type:'boolean',
    })
    switched:IBaseFormFields<boolean>= {
        value:false,
    }
    @FormRuleProperty({
        required: true,
        name: 'checkboxs',
        error: '多选框',
        desc: 'checkboxs',
        type:'array',
    })
    checkboxs:IBaseFormFields<string[]>= {
        value:void 0,
    }
    @FormRuleProperty({
        required:true,
        name: 'selectPage',
        error: '下拉分页不能为空',
        desc: '下拉分页',
        type:'object',
    })
    selectPage: IBaseFormFields<HlLabeledValue>= {
        /* value:{key:'101',label:'(101)阿富汗',title:'101',keyValue:'101'}, */
        value:undefined,
    }
  constructor(form?: FormFields) {
    super();
    FormFields.initMapPropsToFields.call(this,form);
  }
}

export class FormInfoRule extends FormFields {
  constructor(form?: FormFields) {
    super(form);
    createFormRule(FormFields, this);
  }
}

shortHash

对象生成 hash

import { shortHash } from 'legions-lunar/object-hash';

schedule

订阅监听 mobx 数据方法

import { schedule, ISchedule } from 'legions-lunar/schedule';

let subscription: ISchedule = schedule([this.watch.bind(this)]);

// 取消订阅

subscription.unsubscribe();