@shuyun-ep-team/loyalty-lp4-components
企业版忠诚度LP4组件库
Last updated 3 days ago by pickerlee .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install @shuyun-ep-team/loyalty-lp4-components 
SYNC missed versions from official npm registry.

企业版忠诚度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);

Current Tags

  • 2.16.3                                ...           latest (3 days ago)

92 Versions

  • 2.16.3                                ...           3 days ago
  • 2.16.2                                ...           4 days ago
  • 2.16.1                                ...           7 days ago
  • 2.16.0                                ...           12 days ago
  • 2.15.0                                ...           13 days ago
  • 2.14.3                                ...           a month ago
  • 2.14.2 [deprecated]           ...           a month ago
  • 2.14.1 [deprecated]           ...           a month ago
  • 2.14.0                                ...           a month ago
  • 2.13.0                                ...           a month ago
  • 2.12.0                                ...           a month ago
  • 2.11.0                                ...           a month ago
  • 2.10.0                                ...           a month ago
  • 2.9.1                                ...           a month ago
  • 2.9.0                                ...           a month ago
  • 2.8.0                                ...           a month ago
  • 2.7.3                                ...           2 months ago
  • 2.7.2                                ...           2 months ago
  • 2.7.1                                ...           2 months ago
  • 2.7.0                                ...           2 months ago
  • 2.6.1                                ...           2 months ago
  • 2.6.0                                ...           2 months ago
  • 2.5.5                                ...           2 months ago
  • 2.5.4                                ...           2 months ago
  • 2.5.3                                ...           2 months ago
  • 2.5.2                                ...           2 months ago
  • 2.5.1                                ...           2 months ago
  • 2.5.0                                ...           2 months ago
  • 2.4.3                                ...           3 months ago
  • 2.4.2                                ...           3 months ago
  • 2.4.1                                ...           3 months ago
  • 2.4.0                                ...           3 months ago
  • 2.3.0                                ...           3 months ago
  • 2.2.1                                ...           5 months ago
  • 2.2.0                                ...           5 months ago
  • 2.1.0                                ...           5 months ago
  • 2.0.11                                ...           5 months ago
  • 2.0.10                                ...           5 months ago
  • 2.0.9                                ...           5 months ago
  • 2.0.8                                ...           5 months ago
  • 2.0.7                                ...           5 months ago
  • 2.0.6                                ...           5 months ago
  • 2.0.5                                ...           5 months ago
  • 2.0.4                                ...           6 months ago
  • 2.0.3                                ...           6 months ago
  • 2.0.2                                ...           6 months ago
  • 1.9.4                                ...           6 months ago
  • 2.0.1                                ...           6 months ago
  • 2.0.0                                ...           6 months ago
  • 1.9.3                                ...           6 months ago
  • 1.9.2                                ...           6 months ago
  • 1.9.1                                ...           6 months ago
  • 1.9.0                                ...           6 months ago
  • 1.8.0                                ...           6 months ago
  • 1.7.6                                ...           6 months ago
  • 1.7.5                                ...           6 months ago
  • 1.7.4                                ...           6 months ago
  • 1.7.3                                ...           6 months ago
  • 1.7.2                                ...           7 months ago
  • 1.7.1                                ...           7 months ago
  • 1.7.0                                ...           7 months ago
  • 1.6.1                                ...           7 months ago
  • 1.6.0                                ...           7 months ago
  • 1.5.2                                ...           7 months ago
  • 1.5.1                                ...           7 months ago
  • 1.5.0                                ...           7 months ago
  • 1.4.0                                ...           7 months ago
  • 1.3.5                                ...           7 months ago
  • 1.3.4                                ...           7 months ago
  • 1.3.3                                ...           7 months ago
  • 1.3.2                                ...           7 months ago
  • 1.3.1                                ...           7 months ago
  • 1.3.0                                ...           7 months ago
  • 1.2.5                                ...           7 months ago
  • 1.2.4                                ...           7 months ago
  • 1.2.3                                ...           7 months ago
  • 1.2.2                                ...           7 months ago
  • 1.2.1                                ...           7 months ago
  • 1.2.0                                ...           7 months ago
  • 1.1.0                                ...           8 months ago
  • 1.0.11                                ...           8 months ago
  • 1.0.10                                ...           8 months ago
  • 1.0.9                                ...           8 months ago
  • 1.0.8                                ...           8 months ago
  • 1.0.7                                ...           8 months ago
  • 1.0.6                                ...           8 months ago
  • 1.0.5                                ...           8 months ago
  • 1.0.4                                ...           8 months ago
  • 1.0.3                                ...           8 months ago
  • 1.0.2                                ...           8 months ago
  • 1.0.1                                ...           8 months ago
  • 1.0.0                                ...           8 months ago
Downloads
Today 3
This Week 3
This Month 299
Last Day 0
Last Week 154
Last Month 350
Dev Dependencies (39)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |