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

@shuyun-ep-team/loyalty-lp4-components

v2.18.2

Published

企业版忠诚度LP4组件库

Downloads

21

Readme

企业版忠诚度LP4组件库

发布

node scripts/publish.js

表达式编辑器

Usage

import ExpressionEditor from '@shuyun-ep-team/loyalty-lp4-components/editor';

const customHints: ICustomHint[] = [
  /**
   * 基础版配置
   */
  {
    text: '自定义模板',
    value: `1 + 1 > 2`
  },
  /**
   * 可自定义命中逻辑的配置
   */
  {
    text: 'custom template',
    value: '{{C}} {{A}} {{B}} {{D}}',
    test(input: string) {
      return !!input.trim() && 'custom template'.includes(input);
    }
  },

  /**
   * 可自定义命中逻辑
   * 可自定义显示文本
   */
  {
    text: 'custom template',
    value: '{{C}} {{A}} {{B}} {{D}}',
    test(input: string) {
      return !!input.trim() && 'custom template'.includes(input);
    },
    render($li, input: string) {
      $li.innerHTML = highlight('custom template', input, 'cm-hint-matched-keyword');
    },
  }
  ];

<ExpressionEditor
    fqn={this.fqn}
    value="1 + 2 == 3"
    disabled={false}
    placeholder="忠诚度LP4高级表达式"
    errorMessage="表达式解析错误"
    onChange={this.onEditorValueChange}
    functions={['SUM', 'AVG', 'COUNT']}
    declarations={['Date', 'Time', 'DateTime']}
    customHints={customHints}
    operatorReplacements={[code: '&&', name: '且']}
    customProperties={[
      { id: 1, name: '姓名', dataType: 'String' },
      { id: 2, name: '年龄', dataType: 'Integer', disabled: true },
      { id: 3, name: '生日', dataType: 'DateTime' }
    ]}
    onRef={editor => this.editor = editor}
/>
// 预览模式
import ExpressionPreview from '@shuyun-ep-team/loyalty-lp4-components/editor/preview';

<ExpressionPreview
    fqn={this.fqn}
    value="1 + 2 == 3"
    functions={['SUM', 'AVG', 'COUNT']}
    declarations={['Date', 'Time', 'DateTime']}
    operatorReplacements={[code: '&&', name: '且']}
    customProperties={[
      { id: 1, name: '姓名', dataType: 'String' },
      { id: 2, name: '年龄', dataType: 'Integer', disabled: true },
      { id: 3, name: '生日', dataType: 'DateTime' }
    ]}
/>

表达式类型推导

Usage

import ExpressionInference, { getCustomProperies, getSpecialTokens } from '@shuyun-ep-team/loyalty-lp4-components/ast';

const input = '{3} > DateTime("2019-01-17T06:57:58.390Z")';
const config = {
  functions: ['SUM', 'AVG', 'COUNT'],
  declarations: ['Date', 'Time', 'DateTime'],
  customProperties: [
    { id: 1, name: '姓名', dataType: 'String' },
    { id: 2, name: '年龄', dataType: 'Integer', disabled: true },
    { id: 3, name: '生日', dataType: 'DateTime' }
  ]
};

// 推断表达式返回的数据类型
console.log(ExpressionInference(input, config)); // Boolean

// 获取表达式中被使用的属性(已废弃,不建议使用)
console.log(getCustomProperies(input, config)); // [{ id: 3, name: '生日', dataType: 'DateTime' }


// 获取表达式中用到的特殊属性集合(仅做模式匹配),例如 自定义属性
const {
  customProperties, // 自定义属性
  pointAccounts, // 积分账户
  gradeHierarchies // 等级体系
} = getSpecialTokens(input, config);