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

selector-core

v0.6.3

Published

selector

Downloads

10

Readme

selector-core

selector-core

Build Status NPM version Downloads Standard Version Conventional Commits


✨ Features

  • The simulation Javascript to UI
  • No UI

🔧 Installation

yarn add selector-core
npm i selector-core -S

🎬 Getting started

Simple:

import Selector,{ISValueModel} from "selector-core"

const DataSource: ISValueModel[] = [{
  leble: "React",
  value: "react"
},{
  leble: "Vue",
  value: "vuew"
},{
  leble: "Angular",
  value: "angular"
},{
  lable: "TaobalMiniapp",
  value: "tabobao_miniapp"
}]

const selector = new Selector(DataSource)

🎭 Examples

import Selector,{ISValueModel} from "selector-core"

const DataSource: ISValueModel[] = [{
  leble: "React",
  value: "react"
},{
  leble: "Vue",
  value: "vuew"
},{
  leble: "Angular",
  value: "angular"
},{
  lable: "TaobalMiniapp",
  value: "tabobao_miniapp"
}]

const InitValues = []

const selector = new Selector(DataSource,InitValues)

let values = selector.getValues()
// ==>
// []

let dataSource = selector.getDataSource()
/* ==>
[{
  leble: "React",
  value: "react",
  isCurrent: false, // built-in
  indexValue: 0 // built-in
},{
  leble: "Vue",
  value: "vuew",
  isCurrent: false, // built-in
  indexValue: 1 // built-in
},{
  leble: "Angular",
  value: "angular",
  isCurrent: false, // built-in
  indexValue: 2 // built-in
},{
  lable: "TaobalMiniapp",
  value: "tabobao_miniapp",
  isCurrent: false, // built-in
  indexValue: 3 // built-in
}]
*/

// select values
selector.change([dataSource[3]]).getValues()
/* ==>
{
  lable: "TaobalMiniapp",
  value: "tabobao_miniapp"
}
*/

// invert selection
selector.change([dataSource[3]]).getValues()
/* ==>
[]
*/

The constructor arguments

Selector(dataSource: ISValueModel[] = [], values: ISValueModel[] = [])

| 参数名(name) | 说明(explain) | 必填(required) | 类型(types) | 默认值(default) | 备注(PS) | | ------ | ---- | ---- | ---- | ------ | ---- | | | | | | | | | dataSource | 可选数据模型(selectable values) | 是(Y) | ISValueModel[] | 无(null)| | | values | 已选值(selected values) | 否(N) | ISValueModel[] | 无(null)| |

The instance API

getValues(): IValueModel[]

  • 获取当前已选的values(Get the selected values)。

getDataSource(): ISValueModel[]

  • 获取 dataSource (可选值), 将内置isCurrentisCurrent 属性(Get the dataSource value(selectable values), property isCurrent,indexValue will be built-in)

change(values: ISValueModel, mode?: InserMode = InserMode.SINGLE)

  • 改变某些可选项的状态,如果没被选中(不在values里面),将被选中;如果已经被选中(在values)里面,将被剔除
  • values: 必须是在DataSource里面的选项
  • mode: 单选(sigle)还是多选(multi),默认为单选。

removeValues(values: ISValueModel[])

  • 从values里面剔除某些已选中值。

inserValue(values: ISValueModel[], mode: InserMode)

  • 往values里面插入某些值,该值必须在dataSource里面。
  • mode=sigle: values 将直接替换掉已有的值
  • mode=multi: values 将在已选择值后面添加

initDataSource(dataSource: ISValueModel[] = [])

  • 将改变实例的dataSource,当前选择器的values不变

initValues(values: ISValueModel[] = [])

  • 将改变实例的values,当前选择器的dataSource不变

init(dataSource: ISValueModel[] = [], values: IValueModel[] = [])

  • 同时改变valuesdataSource

🥂 License

MIT as always