Skip to content

Commit d6e30e8

Browse files
committed
Merge branch 'release/0.9.0'
2 parents 497f4d1 + a93cc12 commit d6e30e8

9 files changed

+35
-11
lines changed

API.md

+4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
| groups | [Group] | collection of objects where each object must atleast have a groupId property|
2020
| groupsAsColumns | Boolean | display option groups in columns|
2121
| hideResetButton | Boolean | hides the reset button, even if the select element is not empty |
22+
| highlightedUid | object | the uid (unique id) of the currently highlighted option, uid of an option is obtained from the `uid` prop defined below |
2223
| name | String | defaults to undefined, provide a name property to create an hidden input element for html form serialization |
2324
| open | Boolean | controls the visibility of the dropdown menu |
2425
| onBlur | Event -> Void | `({originalEvent :: e, value :: Item, open :: Boolean}){}` |
2526
| onFocus | Event -> Void | `({originalEvent :: e, value :: Item, open :: Boolean}){}` |
27+
| onHighlightedUidChange | object -> Void | `(uid){}` invoked when the highlighted option changes |
2628
| onKeyboardSelectionFailed | Int -> Void | `(keyCode){}` fired when the user hits the return key on an empty list of options |
2729
| onOpenChange | Boolean -> Void | `(open){}` open is true if the dropdown opened and false if it closed|
30+
| onPaste | Event -> Void | invoked when the user pastes text in the input field and `props.valueFromPaste` is not specified|
2831
| onSearchChange | String -> Void | `(search){}` invoked when the search text in the input field changes|
2932
| onValueChange | Item -> Void | `(selectedValue){}` invoked when the user selects an option (by click on enter)|
3033
| options | [Item] | list of items by default each option object MUST have label & value property, otherwise you must implement the render* & filterOptions methods|
@@ -48,6 +51,7 @@
4851
| transitionLeaveTimeout | Number | duration specified in milliseconds, it must match the transition duration specified under the CSS class `.slide-leave-active` |
4952
| uid | (Eq e) => Item -> e | `(item){return item.value}` returns a unique id for a given option, defaults to the value property|
5053
| value | Item | the selected value, i.e. one of the objects in the options array|
54+
| valueFromPaste | [Item] -> Item -> String -> Item | `(options, value, pastedText){}` invoked when the user pastes text in the input field, here you can convert the pasted text into an item that will then show up as selected |
5155

5256
### SimpleSelect methods
5357

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# React Selectize
22

3+
## v0.9.0 / 18th March 2016
4+
* added `on-paste` and `value-from-paste` props to `SimpleSelect`
5+
* added `highlighted-uid` and `on-highlighted-uid-change` props to track the current highlighted option
6+
* fixed a bug in `dropdown-direction` prop
7+
38
## v0.8.4 / 4th March 2016
49
* added `tether-props` prop to customize the parent element (defaults to body)
510
* expose `highlighted-ui` & `on-highlighted-uid-change` props for `MultiSelect`

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ styles & features inspired by [React Select](http://jedwatson.github.io/react-se
1313

1414
[![](http://i.imgsafe.co/rQmogzn.gif)](http://furqanZafar.github.io/react-selectize/)
1515

16-
- [Changelog](CHANGELOG.md) (last updated on 4th March 2016)
16+
- [Changelog](CHANGELOG.md) (last updated on 18th March 2016)
1717
- [API Reference](API.md)
1818

1919
# Motivation
@@ -51,7 +51,7 @@ to include the default styles add the following import statement to your stylus
5151
`@import 'node_modules/react-selectize/themes/index.css'`
5252

5353
* **bower:**
54-
`bower install https://npmcdn.com/react-selectize@0.8.4/bower.zip`
54+
`bower install https://npmcdn.com/react-selectize@0.9.0/bower.zip`
5555

5656
* **1998 script tag:**
5757
```html
@@ -66,10 +66,10 @@ to include the default styles add the following import statement to your stylus
6666
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.1.1/js/tether.min.js" type="text/javascript" ></script>
6767

6868
<!-- REACT SELECTIZE -->
69-
<script src="https://npmcdn.com/react-selectize@0.8.4/dist/index.min.js" type="text/javascript" ></script>
69+
<script src="https://npmcdn.com/react-selectize@0.9.0/dist/index.min.js" type="text/javascript" ></script>
7070

7171
<!-- THEMES (default, bootstrap3, material) -->
72-
<link rel="stylesheet" href="https://npmcdn.com/react-selectize@0.8.4/dist/index.min.css"/>
72+
<link rel="stylesheet" href="https://npmcdn.com/react-selectize@0.9.0/dist/index.min.css"/>
7373

7474
</head>
7575
</html>

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-selectize",
3-
"version": "0.8.4",
3+
"version": "0.9.0",
44
"homepage": "https://github.com/furqanZafar/react-selectize",
55
"authors": [
66
"Furqan Zafar (Mac Pro) <[email protected]>"

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-selectize",
3-
"version": "0.8.4",
3+
"version": "0.9.0",
44
"description": "A Stateless & Flexible Select component for React inspired by Selectize",
55
"main": "src/index.js",
66
"scripts": {

src/DropdownMenu.ls

+5-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ module.exports = create-class do
121121

122122
on-mouse-out: !~>
123123
if !@props.scroll-lock
124-
@props.on-highlighted-uid-change undefined
124+
<~ @props.on-highlighted-uid-change undefined
125125

126126
render-item: @props.render-option
127127
} <<<
@@ -131,7 +131,7 @@ module.exports = create-class do
131131
on-click: !~> @props.on-option-click @props.highlighted-uid
132132
on-mouse-over: ({current-target}) !~>
133133
if !@props.scroll-lock
134-
@props.on-highlighted-uid-change uid
134+
<~ @props.on-highlighted-uid-change uid
135135

136136
# render-dropdown :: ComputedState -> ReactElement
137137
render-dropdown: ({dynamic-class-name}) ->
@@ -186,7 +186,9 @@ module.exports = create-class do
186186
component-did-update: !->
187187
dropdown-menu = find-DOM-node @refs.dropdown-menu-wrapper ? @refs.dropdown-menu
188188
..?style.bottom = switch
189-
| @props.dropdown-direction == -1 => @props.bottom-anchor!.offset-height + dropdown-menu.style.margin-bottom
189+
| @props.dropdown-direction == -1 =>
190+
"#{@props.bottom-anchor!.offset-height + dropdown-menu.style.margin-bottom}px"
191+
190192
| _ => ""
191193

192194
# highlight-and-scroll-to-option :: Int, (() -> ())? -> ()

src/MultiSelect.ls

-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ module.exports = React.create-class do
215215
(o, callback) ~>
216216
<~ @set-state "#{p}" : o
217217
callback!
218-
219218
@props[camelize "on-#{p}-change"] o, (->)
220219

221220
# both p and its change callback are coming from state

src/ReactSelectize.ls

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ module.exports = create-class do
411411

412412
# if the list of options was closed then reset highlighted-uid
413413
if !@props.open and prev-props.open
414-
@props.on-highlighted-uid-change undefined
414+
<~ @props.on-highlighted-uid-change undefined
415415

416416
# component-will-receive-props :: Props -> ()
417417
component-will-receive-props: (props) !->

src/SimpleSelect.ls

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{is-equal-to-object} = require \prelude-extension
33
{create-factory, DOM:{div, img, span}}:React = require \react
44
ReactSelectize = create-factory require \./ReactSelectize
5+
{cancel-event} = require \./utils
56

67
module.exports = React.create-class do
78

@@ -27,6 +28,7 @@ module.exports = React.create-class do
2728
on-blur: ((e) !->) # :: # Event -> ()
2829
on-focus: ((e) !->) # :: Event -> ()
2930
on-keyboard-selection-failed: ((which) !-> ) # :: Int -> ()
31+
on-paste: ((e) !-> true) # Event -> Boolean
3032
# on-search-change :: String -> ()
3133
# on-value-change :: Item -> ()
3234
# open :: Boolean
@@ -188,6 +190,18 @@ module.exports = React.create-class do
188190

189191
on-focus: (e) !~> @props.on-focus {value, open, original-event: e}
190192

193+
# on-paste :: Event -> Boolean
194+
on-paste:
195+
| typeof @props?.value-from-paste == \undefined => @props.on-paste
196+
| _ => ({clipboard-data}:e) ~>
197+
value-from-paste = @props.value-from-paste options, value, clipboard-data.get-data \text
198+
if value-from-paste
199+
do ~>
200+
<~ on-value-change value-from-paste
201+
<~ on-search-change ""
202+
on-open-change false
203+
cancel-event e
204+
191205
# STYLE
192206
placeholder: @props.placeholder
193207
style: @props.style

0 commit comments

Comments
 (0)