Skip to content

Commit 82522d9

Browse files
committed
release v2.6.0
1 parent 030c94b commit 82522d9

18 files changed

+133
-72
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-widgets",
3-
"version": "2.5.2",
3+
"version": "2.6.0",
44
"main": "dist/react-widgets.js",
55
"description": "A set of input widgets for React",
66
"homepage": "http://jquense.github.io/react-widgets/docs",

dist/css/react-widgets.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ input.rw-input::-moz-focus-inner {
120120
height: 2.286em;
121121
line-height: 2.286em;
122122
padding: 0.429em 0.857em;
123+
background-color: #ffffff;
123124
}
124125
.rw-input[disabled] {
125126
-webkit-box-shadow: none;

dist/react-widgets.js

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/public/docs.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/public/docs.js

Lines changed: 19 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Combobox.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ var ComboBox = React.createClass({
9191
};
9292
},
9393

94-
componentDidMount: function () {
95-
validateList(this.refs.list);
94+
componentDidUpdate: function () {
95+
this.refs.list && validateList(this.refs.list);
9696
},
9797

9898
shouldComponentUpdate: function (nextProps, nextState) {
@@ -133,6 +133,7 @@ var ComboBox = React.createClass({
133133
var listID = this._id("_listbox");
134134
var optID = this._id("_option");
135135
var dropUp = this.props.dropUp;
136+
var renderList = _.isFirstFocusedRender(this) || this.props.open;
136137
var List = this.props.listComponent || this.props.groupBy && GroupableList || PlainList;
137138
var completeType = this.props.suggest ? this.props.filter ? "both" : "inline" : this.props.filter ? "list" : "";
138139

@@ -199,7 +200,7 @@ var ComboBox = React.createClass({
199200
React.createElement(
200201
"div",
201202
null,
202-
React.createElement(List, babelHelpers._extends({ ref: "list"
203+
renderList && React.createElement(List, babelHelpers._extends({ ref: "list"
203204
}, _.pick(this.props, Object.keys(compat.type(List).propTypes)), {
204205
id: listID,
205206
optID: optID,

lib/ComboboxInput.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ var React = require("react"),
55
compat = require("./util/compat");
66

77
module.exports = React.createClass({
8-
displayName: "exports",
8+
9+
displayName: "ComboboxInput",
910

1011
propTypes: {
1112
value: React.PropTypes.string,

lib/DateTimePicker.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ var DateTimePicker = React.createClass({
114114
var timeOptID = this._id("_time_option");
115115
var dateListID = this._id("_cal");
116116
var dropUp = this.props.dropUp;
117+
var renderPopup = _.isFirstFocusedRender(this) || this.props.open;
117118
var value = dateOrNull(this.props.value);
118119
var owns;
119120

@@ -211,7 +212,7 @@ var DateTimePicker = React.createClass({
211212
React.createElement(
212213
"div",
213214
null,
214-
React.createElement(Time, { ref: "timePopup",
215+
renderPopup && React.createElement(Time, { ref: "timePopup",
215216
id: timeListID,
216217
optID: timeOptID,
217218
"aria-hidden": !this.props.open,
@@ -234,7 +235,7 @@ var DateTimePicker = React.createClass({
234235
open: this.props.open === popups.CALENDAR,
235236
duration: this.props.duration,
236237
onRequestClose: this.close },
237-
React.createElement(Calendar, babelHelpers._extends({}, calProps, {
238+
renderPopup && React.createElement(Calendar, babelHelpers._extends({}, calProps, {
238239
ref: "calPopup",
239240
tabIndex: "-1",
240241
id: dateListID,
@@ -324,15 +325,19 @@ var DateTimePicker = React.createClass({
324325

325326
_parse: function (string) {
326327
var format = getFormat(this.props, true),
328+
editFormat = this.props.editFormat,
329+
parse = this.props.parse,
327330
formats = [];
328331

329-
if (typeof this.props.parse === "function") return this.props.parse(string, this.props.culture);
332+
if (typeof parse === "function") return parse(string, this.props.culture);
330333

331-
if (typeof format !== "function") formats.push(format);
334+
if (typeof format === "string") formats.push(format);
332335

333-
if (this.props.parse) formats = formats.concat(this.props.parse);
336+
if (typeof editFormat === "string") formats.push(editFormat);
334337

335-
invariant(formats.length, "React Widgets: there are no specified `parse` formats provided and the `format` prop is a function. " + "the DateTimePicker is unable to parse `%s` into a dateTime, " + "please provide either a parse function or Globalize.js compatible string format", string);
338+
if (parse) formats = formats.concat(this.props.parse);
339+
340+
invariant(formats.length, "React Widgets: there are no specified `parse` formats provided and the `format` prop is a function. " + "the DateTimePicker is unable to parse `%s` into a dateTime, " + "please provide either a parse function or Globalize.js compatible string for `format`", string);
336341

337342
return formatsParser(formats, this.props.culture, string);
338343
},

lib/DropdownList.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ var DropdownList = React.createClass({
8787
focusedItem: data[initialIdx] || data[0] };
8888
},
8989

90-
componentDidMount: function () {
91-
validateList(this.refs.list);
90+
componentDidUpdate: function () {
91+
this.refs.list && validateList(this.refs.list);
9292
},
9393

9494
componentWillReceiveProps: function (props) {
@@ -115,6 +115,7 @@ var DropdownList = React.createClass({
115115
var valueItem = this._dataItem(data, this.props.value);
116116
var optID = this._id("_option");
117117
var dropUp = this.props.dropUp;
118+
var renderList = _.isFirstFocusedRender(this) || this.props.open;
118119
var List = this.props.listComponent || this.props.groupBy && GroupableList || PlainList;
119120

120121
return React.createElement(
@@ -175,7 +176,7 @@ var DropdownList = React.createClass({
175176
"div",
176177
null,
177178
this.props.filter && this._renderFilter(),
178-
React.createElement(List, babelHelpers._extends({ ref: "list"
179+
renderList && React.createElement(List, babelHelpers._extends({ ref: "list"
179180
}, _.pick(this.props, Object.keys(compat.type(List).propTypes)), {
180181
data: data,
181182
optID: optID,

lib/Month.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = React.createClass({
3636

3737
render: function () {
3838
var props = _.omit(this.props, ["max", "min", "value", "onChange"]),
39-
month = dates.visibleDays(this.props.value),
39+
month = dates.visibleDays(this.props.value, this.props.culture),
4040
rows = _.chunk(month, 7);
4141

4242
return React.createElement(

lib/Multiselect.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ var Multiselect = React.createClass({
9393
};
9494
},
9595

96-
componentDidMount: function () {
97-
validateList(this.refs.list);
96+
componentDidUpdate: function () {
97+
this.refs.list && validateList(this.refs.list);
9898
},
9999

100100
componentWillReceiveProps: function (nextProps) {
@@ -127,7 +127,7 @@ var Multiselect = React.createClass({
127127
var items = this._data();
128128
var values = this.state.dataItems;
129129
var dropUp = this.props.dropUp;
130-
130+
var renderPopup = _.isFirstFocusedRender(this) || this.props.open;
131131
var List = this.props.listComponent || this.props.groupBy && GroupableList || PlainList;
132132
var listProps = _.pick(this.props, Object.keys(compat.type(List).propTypes));
133133

@@ -189,7 +189,7 @@ var Multiselect = React.createClass({
189189
React.createElement(
190190
"div",
191191
null,
192-
React.createElement(List, babelHelpers._extends({ ref: "list"
192+
renderPopup && [React.createElement(List, babelHelpers._extends({ ref: "list", key: "0"
193193
}, listProps, {
194194
readOnly: !!listProps.readOnly,
195195
disabled: !!listProps.disabled,
@@ -203,10 +203,9 @@ var Multiselect = React.createClass({
203203
onMove: this._scrollTo,
204204
messages: {
205205
emptyList: this.props.data.length ? this.props.messages.emptyFilter : this.props.messages.emptyList
206-
} })),
207-
this._shouldShowCreate() && React.createElement(
206+
} })), this._shouldShowCreate() && React.createElement(
208207
"ul",
209-
{ className: "rw-list rw-multiselect-create-tag" },
208+
{ className: "rw-list rw-multiselect-create-tag", key: "1" },
210209
React.createElement(
211210
"li",
212211
{ onClick: this._onCreate.bind(null, this.props.searchTerm),
@@ -222,7 +221,7 @@ var Multiselect = React.createClass({
222221
" ",
223222
this.props.messages.createNew
224223
)
225-
)
224+
)]
226225
)
227226
)
228227
);

lib/Popup.js

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,34 @@ var React = require("react"),
66
cn = require("classnames"),
77
compat = require("./util/compat");
88

9+
var transform = config.animate.transform,
10+
support = !!config.animate.endEvent;
11+
12+
function properties(prop, value) {
13+
var TRANSLATION_MAP = config.animate.TRANSLATION_MAP;
14+
15+
if (TRANSLATION_MAP && TRANSLATION_MAP[prop]) return (function () {
16+
var _ref = {};
17+
_ref[transform] = "" + TRANSLATION_MAP[prop] + "(" + value + ")";
18+
return _ref;
19+
})();
20+
21+
return (function () {
22+
var _ref2 = {};
23+
_ref2[prop] = value;
24+
return _ref2;
25+
})();
26+
}
27+
928
var PopupContent = React.createClass({
1029
displayName: "PopupContent",
1130

1231
render: function () {
13-
var child = React.Children.only(this.props.children);
32+
var child = this.props.children;
33+
34+
if (!child) return React.createElement("span", { className: "rw-popup rw-widget" });
35+
36+
child = React.Children.only(this.props.children);
1437

1538
return compat.cloneElement(child, {
1639
className: cn(child.props.className, "rw-popup rw-widget")
@@ -19,7 +42,8 @@ var PopupContent = React.createClass({
1942
});
2043

2144
module.exports = React.createClass({
22-
displayName: "exports",
45+
46+
displayName: "Popup",
2347

2448
propTypes: {
2549
open: React.PropTypes.bool,
@@ -47,8 +71,11 @@ module.exports = React.createClass({
4771
onOpen: function () {} };
4872
},
4973

50-
componentDidMount: function () {
51-
!this.props.open && this.close(0);
74+
// componentDidMount(){
75+
// !this.props.open && this.close(0)
76+
// },
77+
componentWillMount: function () {
78+
!this.props.open && (this._initialPosition = true);
5279
},
5380

5481
componentWillReceiveProps: function (nextProps) {
@@ -71,12 +98,18 @@ module.exports = React.createClass({
7198
var open = _props.open;
7299
var dropUp = _props.dropUp;
73100
var props = babelHelpers.objectWithoutProperties(_props, ["className", "open", "dropUp"]);
101+
var display = open ? "block" : void 0;
102+
var styles = {};
103+
104+
if (this._initialPosition) {
105+
display = "none";
106+
}
74107

75108
return React.createElement(
76109
"div",
77110
babelHelpers._extends({}, props, {
78111
style: babelHelpers._extends({
79-
display: open ? "block" : void 0,
112+
display: display,
80113
height: this.state.height }, props.style),
81114
className: cn(className, "rw-popup-container", { "rw-dropup": dropUp })
82115
}),
@@ -88,6 +121,16 @@ module.exports = React.createClass({
88121
);
89122
},
90123

124+
reset: function () {
125+
var container = compat.findDOMNode(this),
126+
content = compat.findDOMNode(this.refs.content),
127+
style = { display: "block", overflow: "hidden" };
128+
129+
$.css(container, style);
130+
this.height();
131+
$.css(content, properties("top", this.props.dropUp ? "100%" : "-100%"));
132+
},
133+
91134
height: function () {
92135
var el = compat.findDOMNode(this),
93136
content = compat.findDOMNode(this.refs.content),
@@ -107,9 +150,13 @@ module.exports = React.createClass({
107150
el = compat.findDOMNode(this.refs.content);
108151

109152
this.ORGINAL_POSITION = $.css(el, "position");
110-
111153
this._isOpening = true;
112-
this.height();
154+
155+
if (this._initialPosition) {
156+
this._initialPosition = false;
157+
this.reset();
158+
} else this.height();
159+
113160
this.props.onOpening();
114161

115162
anim.className += " rw-popup-animating";

lib/SelectList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ var SelectList = React.createClass({
244244
this.setTimeout("focus", function () {
245245
if (focused) compat.findDOMNode(_this).focus();
246246
if (focused !== _this.state.focused) {
247+
_this.notify(focused ? "onFocus" : "onBlur", e);
247248
_this.setState({ focused: focused });
248249
}
249250
});

lib/less/core.less

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
}
3030

3131
.rw-input {
32-
color: @input-color;
33-
height: @input-height;
34-
line-height: @input-height;
35-
padding: @input-padding;
32+
color: @input-color;
33+
height: @input-height;
34+
line-height: @input-height;
35+
padding: @input-padding;
36+
background-color: @input-bg;
3637

3738
&[disabled] {
3839
.state-disabled();

lib/util/_.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ var _ = module.exports = {
7676
return "" + ((prefix == null ? "" : prefix) + ++idCount);
7777
},
7878

79+
//-- Really specific Component Utilities --
80+
81+
isFirstFocusedRender: function (component) {
82+
return component._firstFocus || component.state.focused && (component._firstFocus = true);
83+
},
84+
7985
ifNotDisabled: function (disabledOnly, fn) {
8086
if (arguments.length === 1) fn = disabledOnly, disabledOnly = false;
8187

lib/util/dates.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,19 @@ var dates = module.exports = _.assign(dateMath, {
9090
return dates.add(dates.firstOfCentury(date), 99, "year");
9191
},
9292

93-
firstVisibleDay: function (date) {
93+
firstVisibleDay: function (date, culture) {
9494
var firstOfMonth = dates.startOf(date, "month");
95-
return dates.startOf(firstOfMonth, "week");
95+
return dates.startOf(firstOfMonth, "week", dates.startOfWeek(culture));
9696
},
9797

98-
lastVisibleDay: function (date) {
98+
lastVisibleDay: function (date, culture) {
9999
var endOfMonth = dates.endOf(date, "month");
100-
return dates.endOf(endOfMonth, "week");
100+
return dates.endOf(endOfMonth, "week", dates.startOfWeek(culture));
101101
},
102102

103-
visibleDays: function (date) {
104-
var current = dates.firstVisibleDay(date),
105-
last = dates.lastVisibleDay(date),
103+
visibleDays: function (date, culture) {
104+
var current = dates.firstVisibleDay(date, culture),
105+
last = dates.lastVisibleDay(date, culture),
106106
days = [];
107107

108108
while (dates.lte(current, last, "day")) {

lib/util/dom/animate.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ if (canUseDOM) {
3030
}
3131

3232
animate.endEvent = transition.endEvent;
33+
animate.transform = transform;
34+
animate.TRANSLATION_MAP = TRANSLATION_MAP;
3335

3436
module.exports = animate;
3537

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-widgets",
3-
"version": "2.5.2",
3+
"version": "2.6.0",
44
"description": "A set of input widgets for React",
55
"main": "lib/index.js",
66
"author": {
@@ -108,4 +108,4 @@
108108
"webpack": "^1.7.0",
109109
"webpack-dev-server": "^1.7.0"
110110
}
111-
}
111+
}

0 commit comments

Comments
 (0)