fancy-select
Advanced tools
Comparing version 0.7.0 to 0.7.1
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" | ||
] | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
12753
14
358
8
7
3
1
+ Addedarray-equal@^1.0.0
+ Addedinsert-css@^0.2.0
+ Addedstyled-string-width@^0.1.2
+ Addedarray-equal@1.0.2(transitive)
+ Addedinsert-css@0.2.0(transitive)
+ Addedstyled-string-width@0.1.2(transitive)
- Removedrcss@^0.1.3
- Removedcharenc@0.0.2(transitive)
- Removedcrypt@0.0.2(transitive)
- Removeddeep-extend@0.2.11(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedrcss@0.1.5(transitive)
- Removedsha1@1.1.1(transitive)
- Removedvalid-css-props@0.0.5(transitive)
- Removedvalid-media-queries@0.0.3(transitive)