Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fancy-select

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fancy-select - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

render.js

64

index.js
var mercury = require('mercury')
var document = require('global/document')
var cloneDeep = require('lodash.clonedeep')
var stringWidth = require('styled-string-width')
var slice = Array.prototype.slice
var Update = require('./update')
FancySelect.render = require('./view')
FancySelect.render = require('./render')

@@ -43,34 +45,14 @@ var OptionTree = require('option-tree')

var events = {
backspace: mercury.input(),
select: mercury.input(),
dropdown: mercury.input(),
input: mercury.input(),
refocus: mercury.input(),
close: mercury.input(),
next: tree.next,
prev: tree.prev,
readPath: function (data, path) {
return NavTree(data).readPath(path)
}
}
var events = mercury.input([
'backspace', 'select', 'dropdown', 'input',
'refocus', 'close', 'next', 'prev'
])
events.select(function () {
tree.select.apply(null, slice.call(arguments))
tree.setQuery('')
})
events.backspace(function () {
if (!state.query()) tree.pop()
})
var placeholder = mercury.value(data.placeholder || '')
events.input(function (val) {
tree.setQuery(val.query)
})
events.dropdown(function (open) {
state.isOpen.set(open)
})
var state = mercury.struct({
tree: tree,
events: events,
templates: data.templates,
value: tree.state.value,

@@ -81,8 +63,28 @@ filtered: tree.state.filtered,

options: tree.state.options,
isOpen: mercury.value(true),
placeholder: mercury.value(data.placeholder || ''),
separator: mercury.value(data.separator || ',')
placeholder: placeholder,
separator: mercury.value(data.separator || ','),
inputWidth: mercury.computed([
tree.state.query, placeholder
], function maxWidth () {
var one, max = 0, strs = slice.call(arguments)
strs.forEach(function (str) {
one = stringWidth(str, '.fancy-select input')
if (one > max) max = one
})
return max + 10
})
})
// wire up events
for (var k in Update) {
if (typeof events[k] === 'function') {
events[k](Update[k].bind(null, state))
} else {
events[k] = Update[k].bind(null, state)
}
}
return {

@@ -89,0 +91,0 @@ state: state,

{
"name": "fancy-select",
"description": "fancy select",
"version": "0.7.0",
"version": "0.7.1",
"repository": {

@@ -15,3 +15,5 @@ "url": "nrw/fancy-select"

"dependencies": {
"array-equal": "^1.0.0",
"global": "^4.2.1",
"insert-css": "^0.2.0",
"lodash.clonedeep": "^2.4.1",

@@ -21,6 +23,8 @@ "mercury": "^6.0.1",

"option-tree": "^0.2.0",
"rcss": "^0.1.3"
"styled-string-width": "^0.1.2"
},
"devDependencies": {
"brfs": "^1.2.0",
"function-bind": "^1.0.0",
"nib": "^1.0.3",
"raf": "^2.0.2",

@@ -30,3 +34,8 @@ "synthetic-dom-events": "^0.2.2",

"zuul": "^1.10.1"
},
"browserify": {
"transform": [
"brfs"
]
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc