Skip to content

Commit ce83e15

Browse files
committed
rebuild
1 parent c06eb88 commit ce83e15

30 files changed

Lines changed: 1243 additions & 878 deletions

dist/css/react-widgets.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.

dist/react-widgets-globalize.js

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
}
8989

9090
function globalizeLocalizers(globalize) {
91-
var localizers = globalize.load ? newGlobalize(globalize) : oldGlobalize(globalize);
91+
var localizers = globalize.locale && !globalize.cultures ? newGlobalize(globalize) : oldGlobalize(globalize);
9292

9393
_configure2['default'].setLocalizers(localizers);
9494
return localizers;
@@ -149,8 +149,9 @@
149149

150150
propType: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.func]),
151151

152-
parse: function parse(value, format, culture) {
153-
return locale(culture).parseNumber(value, format);
152+
// TODO major bump consistent ordering
153+
parse: function parse(value, culture) {
154+
return locale(culture).parseNumber(value);
154155
},
155156

156157
format: function format(value, _format2, culture) {
@@ -161,6 +162,11 @@
161162
return locale(culture).formatNumber(value, _format2);
162163
},
163164

165+
decimalChar: function decimalChar(format, culture) {
166+
var str = this.format(1.1, { raw: '0.0' }, culture);
167+
return str[str.length - 2] || '.';
168+
},
169+
164170
precision: function precision(format) {
165171
return !format || format.maximumFractionDigits == null ? null : format.maximumFractionDigits;
166172
}
@@ -225,12 +231,25 @@
225231
}
226232
};
227233

234+
function formatData(format, _culture) {
235+
var culture = getCulture(_culture),
236+
numFormat = culture.numberFormat;
237+
238+
if (typeof format === 'string') {
239+
if (format.indexOf('p') !== -1) numFormat = numFormat.percent;
240+
if (format.indexOf('c') !== -1) numFormat = numFormat.curency;
241+
}
242+
243+
return numFormat;
244+
}
245+
228246
var number = {
229247

230248
formats: {
231249
'default': 'D'
232250
},
233251

252+
// TODO major bump consistent ordering
234253
parse: function parse(value, culture) {
235254
return globalize.parseFloat(value, 10, culture);
236255
},
@@ -239,20 +258,17 @@
239258
return globalize.format(value, _format4, culture);
240259
},
241260

242-
precision: function precision(format, _culture) {
243-
var culture = getCulture(_culture),
244-
numFormat = culture.numberFormat;
245-
246-
if (typeof format === 'string') {
247-
if (format.length > 1) return parseFloat(format.substr(1));
261+
decimalChar: function decimalChar(format, culture) {
262+
var data = formatData(format, culture);
263+
return data['.'] || '.';
264+
},
248265

249-
if (format.indexOf('p') !== -1) numFormat = numFormat.percent;
250-
if (format.indexOf('c') !== -1) numFormat = numFormat.curency;
266+
precision: function precision(format, _culture) {
267+
var data = formatData(format, _culture);
251268

252-
return numFormat.decimals || null;
253-
}
269+
if (typeof format === 'string' && format.length > 1) return parseFloat(format.substr(1));
254270

255-
return null;
271+
return data ? data.decimals : null;
256272
}
257273
};
258274

dist/react-widgets-moment.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@
116116
},
117117

118118
parse: function parse(value, format, culture) {
119-
return value ? getMoment(culture, value, format).toDate() : null;
119+
if (!value) return null;
120+
var m = getMoment(culture, value, format);
121+
if (m.isValid()) return m.toDate();
122+
return null;
120123
},
121124

122125
format: function format(value, _format, culture) {

dist/react-widgets-simple-number.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,40 +79,55 @@
7979

8080
var _deconstructNumberFormat2 = babelHelpers.interopRequireDefault(_deconstructNumberFormat);
8181

82-
function simpleNumber() {
82+
var defaults = {
83+
decimal: '.',
84+
grouping: ','
85+
};
86+
87+
function simpleNumber(options) {
88+
var _babelHelpers$_extends = babelHelpers._extends({}, defaults, options);
89+
90+
var decimal = _babelHelpers$_extends.decimal;
91+
var grouping = _babelHelpers$_extends.grouping;
8392

8493
var localizer = {
8594
formats: {
86-
'default': '-#,##0.'
95+
'default': '-#' + grouping + '##0' + decimal
8796
},
8897

89-
parse: function parse(value, format) {
98+
// TODO major bump consistent ordering
99+
parse: function parse(value, culture, format) {
90100
if (format) {
91-
var data = _deconstructNumberFormat2['default'](format);
92-
93-
if (data.negativeLeftPos !== -1) value = value.substr(data.negativeLeftPos + 1);
94-
95-
if (data.negativeRightPos !== -1) value = value.substring(0, data.negativeRightPos);
101+
var data = _deconstructNumberFormat2['default'](format),
102+
negative = data.negativeLeftSymbol && value.indexOf(data.negativeLeftSymbol) !== -1 || data.negativeRightSymbol && value.indexOf(data.negativeRightSymbol) !== -1;
96103

97-
value = value.replace(data.prefix, '').replace(data.suffix, '');
104+
value = value.replace(data.negativeLeftSymbol, '').replace(data.negativeRightSymbol, '').replace(data.prefix, '').replace(data.suffix, '');
98105

99106
var halves = value.split(data.decimalChar);
100107

101108
if (data.integerSeperator) halves[0] = halves[0].replace(new RegExp('\\' + data.integerSeperator, 'g'));
102109

103110
if (data.decimalsSeparator) halves[1] = halves[1].replace(new RegExp('\\' + data.decimalsSeparator, 'g'));
104111

105-
value = halves.join(data.decimalChar);
106-
}
107-
var number = parseFloat(value);
112+
if (halves[1] === '') halves.pop();
113+
114+
value = halves.join('.');
115+
value = +value;
116+
117+
if (negative) value = -1 * value;
118+
} else value = parseFloat(value);
108119

109-
return number;
120+
return isNaN(value) ? null : value;
110121
},
111122

112123
format: function format(value, _format) {
113124
return _formatNumberWithString2['default'](value, _format);
114125
},
115126

127+
decimalChar: function decimalChar(format) {
128+
return format && _deconstructNumberFormat2['default'](format).decimalsSeparator || '.';
129+
},
130+
116131
precision: function precision(format) {
117132
var data = _deconstructNumberFormat2['default'](format);
118133
return data.maxRight !== -1 ? data.maxRight : null;

0 commit comments

Comments
 (0)