diff --git a/build/browser.config.js b/build/browser.config.js index 7265228d6..90b9bfbbd 100644 --- a/build/browser.config.js +++ b/build/browser.config.js @@ -9,17 +9,23 @@ module.exports = makeConfig({ minimize: false, - entry: './lib/index.js', + entry: { + 'react-widgets': './lib/index.js', + 'react-widgets-globalize': './lib/localizers/globalize.js', + 'react-widgets-moment': './lib/localizers/moment.js', + 'react-widgets-simple-number': './lib/localizers/simple-number.js' + }, output: { path: path.join(__dirname, '../dist'), - filename: 'react-widgets.js', + filename: '[name].js', library: 'ReactWidgets', libraryTarget: 'umd' }, externals: { - globalize: 'Globalize', + '../configure': 'ReactWidgets', + 'react-dom': { root: 'ReactDOM', commonjs: 'react-dom', diff --git a/build/configure-shim.js b/build/configure-shim.js new file mode 100644 index 000000000..e69de29bb diff --git a/build/dev.config.js b/build/dev.config.js index 6b3277d7e..fbe20055f 100644 --- a/build/dev.config.js +++ b/build/dev.config.js @@ -11,6 +11,16 @@ module.exports = makeConfig({ entry: path.join(__dirname, '../dev/dev.jsx'), + loaders: [ + { + test: /globalize/, + loader: 'imports?define=>false' + }, + { + test: /cldr-data.+\.js$/, + loader: 'imports?define=>false' + } + ], output: { filename: 'bundle.js', path: __dirname, diff --git a/build/localizers.config.js b/build/localizers.config.js new file mode 100644 index 000000000..bb2fb7b36 --- /dev/null +++ b/build/localizers.config.js @@ -0,0 +1,25 @@ +var path = require('path') + , makeConfig = require('./make-config'); + +module.exports = makeConfig({ + noCompile: true, + banner: true, + minimize: false, + production: true, + + entry: { + 'react-widgets-globalize': './lib/localizers/globalize.js', + 'react-widgets-moment': './lib/localizers/moment.js', + 'react-widgets-simple-number': './lib/localizers/simple-number.js' + }, + + output: { + path: path.join(__dirname, '../dist'), + filename: '[name].js' + }, + + externals: { + '../configure': 'window.ReactWidgets', + react: 'window.React' + } +}) diff --git a/build/make-config.js b/build/make-config.js index d359c3b97..e07d882ee 100644 --- a/build/make-config.js +++ b/build/make-config.js @@ -8,6 +8,7 @@ module.exports = function makeConfig(options){ , plugins = options.plugins || [] var loaders = [ + { test: /\.json$/, loader: 'json-loader' }, { test: /\.css$/, loader: options.extractStyles ? ExtractTextPlugin.extract('style-loader', 'css-loader') : 'style-loader!css-loader' }, diff --git a/dev/dev.jsx b/dev/dev.jsx index 6b7e7ca56..74435200a 100644 --- a/dev/dev.jsx +++ b/dev/dev.jsx @@ -1,77 +1,40 @@ 'use strict'; require('../src/less/react-widgets.less') -//require('react-a11y')(); -var configure = require('../src/configure') -var localizers = require('../src/globalize-localizers') - -configure.setLocalizers(localizers(window.Globalize)) - -//configure.setGlobalizeInstance(window.Globalize); +var Globalize = require('globalize') +var localizers = require('../src/localizers/globalize') +var numberLocalizer = require('../src/localizers/simple-number') + +Globalize.load( + require('cldr-data/main/en-GB/ca-gregorian.json'), + require('cldr-data/main/en-GB/currencies.json'), + require('cldr-data/main/en-GB/dateFields.json'), + require('cldr-data/main/en-GB/numbers.json'), + require('cldr-data/supplemental/numberingSystems.json'), + require('cldr-data/supplemental/currencyData.json'), + require('cldr-data/supplemental/likelySubtags.json'), + require('cldr-data/supplemental/timeData.json'), + require('cldr-data/supplemental/weekData.json') +); +Globalize.locale('en-GB') + +localizers(Globalize) +numberLocalizer() var React = require('react/addons') -//var jquery = require('jquery') var index = require('../src') var dates = require('../src/util/dates') var DropdownList = require('../src/DropdownList.jsx') var Multiselect = require('../src/Multiselect.jsx') var Calendar = require('../src/Calendar.jsx') -// var DatePicker = require('../src/DateTimePicker.jsx') -// var NumberPicker = require('../src/NumberPicker.jsx') +var DateTimePicker = require('../src/DateTimePicker.jsx') +var NumberPicker = require('../src/NumberPicker.jsx') // var ComboBox = require('../src/Combobox.jsx') // var SelectList = require('../src/SelectList.jsx') // var List = require('../src/List.jsx') var chance = new (require('chance')) -// var moment = require('moment') - -// var endOfDecade = date => moment(date).add(10, 'year').add(-1, 'millisecond').toDate() -// var endOfCentury = date => moment(date).add(100, 'year').add(-1, 'millisecond').toDate() - -// configure.setDateLocalizer({ -// formats: { -// date: 'L', -// time: 'LT', -// default: 'lll', -// header: 'MMMM YYYY', -// footer: 'LL', -// weekday: (day, culture, localizer) => moment().locale(culture).weekday(day).format('dd'), - -// dayOfMonth: 'DD', -// month: 'MMM', -// year: 'YYYY', - -// decade: (date, culture, localizer) => { -// return localizer.format(date, 'YYYY', culture) -// + ' - ' + localizer.format(endOfDecade(date), 'YYYY', culture) -// }, - -// century: (date, culture, localizer) => { -// return localizer.format(date, 'YYYY', culture) -// + ' - ' + localizer.format(endOfCentury(date), 'YYYY', culture) -// } -// }, - -// firstOfWeek(culture){ -// return moment.localeData(culture).firstDayOfWeek() -// }, - -// parse(value, format, culture){ -// return moment(value, format).locale(culture).toDate() -// }, - -// format(value, format, culture){ -// return moment(value).locale(culture).format(format) -// } -// }) - - -// configure.setAnimate((element, props, duration, ease, callback) => { -// return jquery(element).animate(props, duration, callback) -// }) - - var App = React.createClass({ getInitialState: function(){ @@ -140,11 +103,12 @@ var App = React.createClass({ > add - + this.setState({ calDate })} /> + diff --git a/dist/react-widgets-globalize.js b/dist/react-widgets-globalize.js new file mode 100644 index 000000000..ad7ffb6a6 --- /dev/null +++ b/dist/react-widgets-globalize.js @@ -0,0 +1,360 @@ +/*! (c) 2015 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ +var ReactWidgetLocalizer = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var babelHelpers = __webpack_require__(1); + + exports.__esModule = true; + exports['default'] = globalizeLocalizers; + + var _react = __webpack_require__(2); + + var _configure = __webpack_require__(3); + + var _configure2 = babelHelpers.interopRequireDefault(_configure); + + function endOfDecade(date) { + date = new Date(date); + date.setFullYear(date.getFullYear() + 10); + date.setMilliseconds(date.getMilliseconds() - 1); + return date; + } + + function endOfCentury(date) { + date = new Date(date); + date.setFullYear(date.getFullYear() + 100); + date.setMilliseconds(date.getMilliseconds() - 1); + return date; + } + + function globalizeLocalizers(globalize) { + var localizers = globalize.load ? newGlobalize(globalize) : oldGlobalize(globalize); + + _configure2['default'].setLocalizers(localizers); + return localizers; + } + + function newGlobalize(globalize) { + var locale = function locale(culture) { + return culture ? globalize(culture) : globalize; + }; + + var date = { + + formats: { + date: { date: 'short' }, + time: { time: 'short' }, + 'default': { datetime: 'medium' }, + header: 'MMMM yyyy', + footer: { date: 'full' }, + weekday: 'eeeeee', + dayOfMonth: 'dd', + month: 'MMM', + year: 'yyyy', + + decade: function decade(dt, culture, l) { + return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfDecade(dt), l.formats.year, culture); + }, + + century: function century(dt, culture, l) { + return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfCentury(dt), l.formats.year, culture); + } + }, + + propType: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object, _react.PropTypes.func]), + + firstOfWeek: function firstOfWeek(culture) { + var date = new Date(); + //cldr-data doesn't seem to be zero based + var localeDay = Math.max(parseInt(locale(culture).formatDate(date, { raw: 'e' }), 10) - 1, 0); + + return Math.abs(date.getDay() - localeDay); + }, + + parse: function parse(value, format, culture) { + format = typeof format === 'string' ? { raw: format } : format; + return locale(culture).parseDate(value, format); + }, + + format: function format(value, _format, culture) { + _format = typeof _format === 'string' ? { raw: _format } : _format; + return locale(culture).formatDate(value, _format); + } + }; + + var number = { + formats: { + 'default': { maximumFractionDigits: 0 } + }, + + propType: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.func]), + + parse: function parse(value, format, culture) { + return locale(culture).parseNumber(value, format); + }, + + format: function format(value, _format2, culture) { + return value == null ? value : locale(culture).formatNumber(value, _format2); + }, + + precision: function precision(format) { + return !format || format.maximumFractionDigits == null ? null : format.maximumFractionDigits; + } + }; + return { date: date, number: number }; + } + + function oldGlobalize(globalize) { + var shortNames = Object.create(null); + + function getCulture(culture) { + return culture ? globalize.findClosestCulture(culture) : globalize.culture(); + } + + function firstOfWeek(culture) { + culture = getCulture(culture); + return culture && culture.calendar.firstDay || 0; + } + + function shortDay(dayOfTheWeek) { + var culture = getCulture(arguments[1]), + name = culture.name, + start = firstOfWeek(culture), + days = function days() { + var days = culture.calendar.days.namesShort.slice(); + return start === 0 ? days : days.concat(days.splice(0, start)); + }; + + var names = shortNames[name] || (shortNames[name] = days()); + + return names[dayOfTheWeek.getDay()]; + } + + var date = { + + formats: { + date: 'd', + time: 't', + 'default': 'f', + header: 'MMMM yyyy', + footer: 'D', + weekday: shortDay, + dayOfMonth: 'dd', + month: 'MMM', + year: 'yyyy', + + decade: function decade(dt, culture, l) { + return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfDecade(dt), l.formats.year, culture); + }, + + century: function century(dt, culture, l) { + return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfCentury(dt), l.formats.year, culture); + } + }, + + firstOfWeek: firstOfWeek, + + parse: function parse(value, format, culture) { + return globalize.parseDate(value, format, culture); + }, + + format: function format(value, _format3, culture) { + return globalize.format(value, _format3, culture); + } + }; + + var number = { + + formats: { + 'default': 'D' + }, + + parse: function parse(value, culture) { + return globalize.parseFloat(value, 10, culture); + }, + + format: function format(value, _format4, culture) { + return globalize.format(value, _format4, culture); + }, + + precision: function precision(format, _culture) { + var culture = getCulture(_culture), + numFormat = culture.numberFormat; + + if (typeof format === 'string') { + if (format.length > 1) return parseFloat(format.substr(1)); + + if (format.indexOf('p') !== -1) numFormat = numFormat.percent; + if (format.indexOf('c') !== -1) numFormat = numFormat.curency; + + return numFormat.decimals || null; + } + + return null; + } + }; + + return { date: date, number: number }; + } + module.exports = exports['default']; + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports === "object") { + factory(exports); + } else { + factory(root.babelHelpers = {}); + } + })(this, function (global) { + var babelHelpers = global; + + babelHelpers.createDecoratedObject = function (descriptors) { + var target = {}; + + for (var i = 0; i < descriptors.length; i++) { + var descriptor = descriptors[i]; + var decorators = descriptor.decorators; + var key = descriptor.key; + delete descriptor.key; + delete descriptor.decorators; + descriptor.enumerable = true; + descriptor.configurable = true; + if ("value" in descriptor || descriptor.initializer) descriptor.writable = true; + + if (decorators) { + for (var f = 0; f < decorators.length; f++) { + var decorator = decorators[f]; + + if (typeof decorator === "function") { + descriptor = decorator(target, key, descriptor) || descriptor; + } else { + throw new TypeError("The decorator for method " + descriptor.key + " is of the invalid type " + typeof decorator); + } + } + } + + if (descriptor.initializer) { + descriptor.value = descriptor.initializer.call(target); + } + + Object.defineProperty(target, key, descriptor); + } + + return target; + }; + + babelHelpers.objectWithoutProperties = function (obj, keys) { + var target = {}; + + for (var i in obj) { + if (keys.indexOf(i) >= 0) continue; + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; + target[i] = obj[i]; + } + + return target; + }; + + babelHelpers.interopRequireWildcard = function (obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + } + + newObj["default"] = obj; + return newObj; + } + }; + + babelHelpers.interopRequireDefault = function (obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; + }; + + babelHelpers._extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + }) + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + module.exports = window.React; + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + module.exports = window.ReactWidgets; + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/dist/react-widgets-moment.js b/dist/react-widgets-moment.js new file mode 100644 index 000000000..a532d354f --- /dev/null +++ b/dist/react-widgets-moment.js @@ -0,0 +1,234 @@ +/*! (c) 2015 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ +var ReactWidgetLocalizer = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var babelHelpers = __webpack_require__(1); + + exports.__esModule = true; + + var _configure = __webpack_require__(3); + + var _configure2 = babelHelpers.interopRequireDefault(_configure); + + function endOfDecade(date) { + date = new Date(date); + date.setFullYear(date.getFullYear() + 10); + date.setMilliseconds(date.getMilliseconds() - 1); + return date; + } + + function endOfCentury(date) { + date = new Date(date); + date.setFullYear(date.getFullYear() + 100); + date.setMilliseconds(date.getMilliseconds() - 1); + return date; + } + + exports['default'] = function (moment) { + if (typeof moment !== 'function') throw new TypeError('You must provide a valid moment object'); + + var localField = typeof moment().locale === 'function' ? 'locale' : 'lang', + hasLocaleData = !!moment.localeData; + + if (!hasLocaleData) throw new TypeError('The Moment localizer depends on the `localeData` api, please provide a moment object v2.2.0 or higher'); + + function getMoment(culture, value, format) { + return culture ? moment(value, format)[localField](culture) : moment(value, format); + } + + var localizer = { + formats: { + date: 'L', + time: 'LT', + 'default': 'lll', + header: 'MMMM YYYY', + footer: 'LL', + weekday: 'dd', + dayOfMonth: 'DD', + month: 'MMM', + year: 'YYYY', + + decade: function decade(date, culture, localizer) { + return localizer.format(date, 'YYYY', culture) + ' - ' + localizer.format(endOfDecade(date), 'YYYY', culture); + }, + + century: function century(date, culture, localizer) { + return localizer.format(date, 'YYYY', culture) + ' - ' + localizer.format(endOfCentury(date), 'YYYY', culture); + } + }, + + firstOfWeek: function firstOfWeek(culture) { + return moment.localeData(culture).firstDayOfWeek(); + }, + + parse: function parse(value, format, culture) { + return getMoment(culture, value, format).toDate(); + }, + + format: function format(value, _format, culture) { + return getMoment(culture, value, _format).format(_format); + } + }; + + _configure2['default'].setDateLocalizer(localizer); + + return localizer; + }; + + module.exports = exports['default']; + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports === "object") { + factory(exports); + } else { + factory(root.babelHelpers = {}); + } + })(this, function (global) { + var babelHelpers = global; + + babelHelpers.createDecoratedObject = function (descriptors) { + var target = {}; + + for (var i = 0; i < descriptors.length; i++) { + var descriptor = descriptors[i]; + var decorators = descriptor.decorators; + var key = descriptor.key; + delete descriptor.key; + delete descriptor.decorators; + descriptor.enumerable = true; + descriptor.configurable = true; + if ("value" in descriptor || descriptor.initializer) descriptor.writable = true; + + if (decorators) { + for (var f = 0; f < decorators.length; f++) { + var decorator = decorators[f]; + + if (typeof decorator === "function") { + descriptor = decorator(target, key, descriptor) || descriptor; + } else { + throw new TypeError("The decorator for method " + descriptor.key + " is of the invalid type " + typeof decorator); + } + } + } + + if (descriptor.initializer) { + descriptor.value = descriptor.initializer.call(target); + } + + Object.defineProperty(target, key, descriptor); + } + + return target; + }; + + babelHelpers.objectWithoutProperties = function (obj, keys) { + var target = {}; + + for (var i in obj) { + if (keys.indexOf(i) >= 0) continue; + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; + target[i] = obj[i]; + } + + return target; + }; + + babelHelpers.interopRequireWildcard = function (obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + } + + newObj["default"] = obj; + return newObj; + } + }; + + babelHelpers.interopRequireDefault = function (obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; + }; + + babelHelpers._extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + }) + +/***/ }, +/* 2 */, +/* 3 */ +/***/ function(module, exports) { + + module.exports = window.ReactWidgets; + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/dist/react-widgets-simple-number.js b/dist/react-widgets-simple-number.js new file mode 100644 index 000000000..da3abdecd --- /dev/null +++ b/dist/react-widgets-simple-number.js @@ -0,0 +1,722 @@ +/*! (c) 2015 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ +var ReactWidgetLocalizer = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var babelHelpers = __webpack_require__(1); + + exports.__esModule = true; + exports['default'] = simpleNumber; + + var _configure = __webpack_require__(3); + + var _configure2 = babelHelpers.interopRequireDefault(_configure); + + var _formatNumberWithString = __webpack_require__(4); + + var _formatNumberWithString2 = babelHelpers.interopRequireDefault(_formatNumberWithString); + + var _deconstructNumberFormat = __webpack_require__(5); + + var _deconstructNumberFormat2 = babelHelpers.interopRequireDefault(_deconstructNumberFormat); + + function simpleNumber() { + + var localizer = { + formats: { + 'default': '-#,##0.' + }, + + parse: function parse(value, format) { + if (format) { + var data = _deconstructNumberFormat2['default'](format); + + if (data.negativeLeftPos !== -1) value = value.substr(data.negativeLeftPos + 1); + + if (data.negativeRightPos !== -1) value = value.substring(0, data.negativeRightPos); + + value = value.replace(data.prefix, '').replace(data.suffix, ''); + + var halves = value.split(data.decimalChar); + + if (data.integerSeperator) halves[0] = halves[0].replace(new RegExp('\\' + data.integerSeperator, 'g')); + + if (data.decimalsSeparator) halves[1] = halves[1].replace(new RegExp('\\' + data.decimalsSeparator, 'g')); + + value = halves.join(data.decimalChar); + } + var number = parseFloat(value); + + return number; + }, + + format: function format(value, _format) { + return _formatNumberWithString2['default'](value, _format); + }, + + precision: function precision(format) { + var data = _deconstructNumberFormat2['default'](format); + return data.maxRight !== -1 ? data.maxRight : null; + } + }; + + _configure2['default'].setNumberLocalizer(localizer); + return localizer; + } + + module.exports = exports['default']; + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports === "object") { + factory(exports); + } else { + factory(root.babelHelpers = {}); + } + })(this, function (global) { + var babelHelpers = global; + + babelHelpers.createDecoratedObject = function (descriptors) { + var target = {}; + + for (var i = 0; i < descriptors.length; i++) { + var descriptor = descriptors[i]; + var decorators = descriptor.decorators; + var key = descriptor.key; + delete descriptor.key; + delete descriptor.decorators; + descriptor.enumerable = true; + descriptor.configurable = true; + if ("value" in descriptor || descriptor.initializer) descriptor.writable = true; + + if (decorators) { + for (var f = 0; f < decorators.length; f++) { + var decorator = decorators[f]; + + if (typeof decorator === "function") { + descriptor = decorator(target, key, descriptor) || descriptor; + } else { + throw new TypeError("The decorator for method " + descriptor.key + " is of the invalid type " + typeof decorator); + } + } + } + + if (descriptor.initializer) { + descriptor.value = descriptor.initializer.call(target); + } + + Object.defineProperty(target, key, descriptor); + } + + return target; + }; + + babelHelpers.objectWithoutProperties = function (obj, keys) { + var target = {}; + + for (var i in obj) { + if (keys.indexOf(i) >= 0) continue; + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; + target[i] = obj[i]; + } + + return target; + }; + + babelHelpers.interopRequireWildcard = function (obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + } + + newObj["default"] = obj; + return newObj; + } + }; + + babelHelpers.interopRequireDefault = function (obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; + }; + + babelHelpers._extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + }) + +/***/ }, +/* 2 */, +/* 3 */ +/***/ function(module, exports) { + + module.exports = window.ReactWidgets; + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var deconstructNumberFormat = __webpack_require__(5); + var formatFactory = __webpack_require__(6); + + exports = module.exports = function formatNumberWithString(value, requiredFormat, overrideOptions) { + + var deconstructedFormat = [] + + if (requiredFormat) deconstructedFormat = deconstructNumberFormat(requiredFormat.trim()); + + value = (value === null ? '' : value); + value = value + ''; //make a string + value = value.length ? value.trim() : ''; + + var options = []; + + var format = formatFactory({ + negativeType: deconstructedFormat.negativeType, + negativeLeftSymbol: deconstructedFormat.negativeLeftSymbol, + negativeRightSymbol: deconstructedFormat.negativeRightSymbol, + negativeLeftOut: deconstructedFormat.negativeLeftPos === 0, + negativeRightOut: deconstructedFormat.negativeRightPos === 0, + prefix: deconstructedFormat.prefix, + suffix: deconstructedFormat.suffix, + integerSeparator: deconstructedFormat.integerSeparator, + decimalsSeparator: deconstructedFormat.decimalsSeparator, + decimal: deconstructedFormat.decimalChar, + padLeft: deconstructedFormat.padLeft, + padRight: deconstructedFormat.padRight, + round: deconstructedFormat.maxRight, + truncate: null + }) + + return format(value, overrideOptions); + + }; + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + + 'use strict'; + + + exports = module.exports = function deconstructNumberFormat(requiredFormat) { + + + var format= requiredFormat || '-9,999.90'; + + format=format.trim(); //ignore leading and trailing spaces + + // ********************************************************************************* + // find position and type of negative and contents of prefix and suffix text + // ********************************************************************************* + + var negativeType = '', negativeRightSymbol = '', negativeLeftSymbol = '', + negativeRightPos = -1, negativeLeftPos = -1, + absFormat, + prefix = '', suffix = ''; + + // brackets as negative + if (/^([^()]+)?[(]([^09#]+)?[09#., ]+([^)]+)?[)](.+)?$/.test(format)) { + negativeType = 'brackets'; + negativeLeftPos = format.indexOf("("); + negativeLeftSymbol = '(' + if (negativeLeftPos > 0) { //after prefix + prefix = format.slice(0, negativeLeftPos); + } else { + prefix = format.search(/0|9|#/) > 0 ? format.slice(1, format.search(/0|9|#/)) : ""; + } + format = format.slice(prefix.length+1); + + negativeRightPos = format.indexOf(")"); + negativeRightSymbol = ')' + if (negativeRightPos < format.length-1) { //before prefix + suffix = format.slice(negativeRightPos+1); + format = format.slice(0, negativeRightPos); + } else { + suffix = format.search(/[^09#,.]([^09#](.+)?)?[)]$/) > -1 ? format.slice(format.search(/[^09#,.]([^09#](.+)?)?[)]$/), -1) : ""; + format = format.slice(0, format.length - suffix.length - 1); + negativeRightPos = 0; + } + + } else if (format.indexOf("-") === -1){ + //positive values only + negativeType = 'none'; + prefix = format.search(/[.,]?[09#]/) > 0 ? format.slice(0, format.search(/[.,]?[09#]/)) : ""; + format = format.slice(prefix.length); + suffix = format.search(/[^09#,.]([^09#]+|$)/) > -1 ? format.slice(format.search(/[^09#,.]([^09#]+|$)/)) : ""; + format = format.slice(0, format.length-suffix.length); + + } else if (/^([^09#-]+)?-.+$/.test(format)) { + //negative symbol to left of number (before or after prefix) + negativeType = 'left'; + negativeLeftPos = format.indexOf("-"); + negativeLeftSymbol = '-' + if (negativeLeftPos > 0) { //after prefix + prefix = format.slice(0, negativeLeftPos); + } else { + prefix = format.search(/[09#]/) > 0 ? format.slice(1, format.search(/[09#]/)) : ""; + } + format = format.slice(prefix.length+1); + suffix = format.search(/[^09#,.]([^09#]+|$)/) > -1 ? format.slice(format.search(/[^09#,.]([^09#]+|$)/)) : ""; + format = format.slice(0, format.length-suffix.length); + + } else { + //negative symbol to right of number (before or after suffix) + prefix = format.search(/[09#]/) > 0 ? format.slice(0, format.search(/[09#]/)) : ""; + format = format.slice(prefix.length); + negativeType = 'right'; + negativeRightSymbol = '-' + negativeRightPos = format.lastIndexOf("-"); + if (negativeRightPos < format.length-1) { //before suffix + suffix = format.slice(negativeRightPos+1); + format = format.slice(0, negativeRightPos); + } else { + suffix = format.search(/[^09#,.]([^09#](.+)?)?-$/) > -1 ? format.slice(format.search(/[^09#,.]([^09#](.+)?)?-$/), format.length-1) : ""; + format = format.slice(0, format.length - suffix.length - 1); + negativeRightPos = 0; + } + } + + // ********************************************************************************* + //include spaces with negative symbols + // ********************************************************************************* + + //When negative is before prefix move spaces from start of prefix to end of negative symbol + while (negativeLeftPos === 0 && prefix && prefix[0] === ' ') { + negativeLeftSymbol = negativeLeftSymbol + ' '; + prefix = prefix.slice(1); + } + + //When negative follows suffix move spaces end of suffix to start of negative symbol + while (negativeRightPos === 0 && suffix && suffix[suffix.length-1] === ' ') { + negativeRightSymbol = ' ' + negativeRightSymbol; + suffix = suffix.slice(0, -1); + } + + //When negative follows prefix move spaces from start of format to end of negative symbol + while (negativeLeftPos > 0 && format.length && format[0] === ' ') { + negativeLeftSymbol = negativeLeftSymbol + ' '; + format = format.slice(1); + } + + //When negative before suffix move spaces from end of format to start of negative symbol + while (negativeRightPos > 0 && format.length && format[format.length-1] === ' ') { + negativeRightSymbol = ' ' + negativeRightSymbol; + format = format.slice(0, -1); + } + + var absMask = format; + + // ********************************************************************************* + //find the decimal character and parts of absolute format + // ********************************************************************************* + + var decimalChar = '', decimalsPart = '', integerPart = '', decimalsSeparator = '', integerSeparator = ''; + + //if last char is a ',' and there are no other commas then use this as decimal point + if (format[format.length-1] === ',' && format.indexOf(',') === format.length-1) { + decimalChar = ','; + //otherwise use consider '.' + } else if (format.indexOf('.') > -1) { + if (format.indexOf('.') === format.lastIndexOf('.')) { + decimalChar = "."; + } else { + // two of '.' means this must be the separator, so assume ',' is the decimal + decimalChar = ','; + } + //otherwise use ',' if it exists and there is only one + } else if (format.indexOf(',') > -1) { + if (format.indexOf(',') === format.lastIndexOf(',')) { + decimalChar = ','; + } else { + decimalChar = '.'; + } + } + + if (decimalChar && format.indexOf(decimalChar)>-1) { + decimalsPart = format.slice(format.indexOf(decimalChar)+1); + integerPart = format.slice(0,format.indexOf(decimalChar)); + } else { + integerPart = format; + decimalsPart = ''; + } + + while (decimalsPart.length && decimalsPart.search(/[., ]$/) > -1) { + decimalsPart = decimalsPart.slice(0, -1); + } + + while (integerPart.length && integerPart[0].search(/[., ]/) > -1) { + integerPart = integerPart.slice(1); + } + + //find the thousands/thousanths separators + if (integerPart && integerPart.search(/[., ]/) > 0) { + integerSeparator = integerPart[integerPart.search(/[., ]/)]; + integerPart = integerPart.replace(/[., ]/g, ""); + } + + if (decimalsPart && decimalsPart.search(/[., ]/) > 0) { + decimalsSeparator = decimalsPart[decimalsPart.search(/[., ]/)]; + decimalsPart = decimalsPart.replace(/[., ]/g, ""); + } + + if ((integerPart.length && !(/^[09#]+$/).test(integerPart)) || (decimalsPart.length && !(/^[09#]+$/).test(decimalsPart))) {return false}; + + // ********************************************************************************* + //resolve length and padding + // ********************************************************************************* + + var padLeft, maxLeft, padRight, maxRight; + padLeft = integerPart.indexOf("0") >= 0 ? integerPart.length - integerPart.indexOf("0") : -1; + maxLeft = integerPart.length === 0 ||integerPart[0] === "0" || integerPart[0] === "9" ? integerPart.length : -1; + padRight = decimalsPart.indexOf("0") >= 0 ? decimalsPart.lastIndexOf("0")+1 : -1; + maxRight = decimalsPart.length === 0 || decimalsPart[decimalsPart.length-1] === "0" || decimalsPart[decimalsPart.length-1] === "9" ? decimalsPart.length : -1; + + // ********************************************************************************* + // output + // ********************************************************************************* + + var deconstructedFormat = { + negativeType: negativeType, + negativeLeftPos: negativeLeftPos, + negativeRightPos: negativeRightPos, + negativeLeftSymbol: negativeLeftSymbol, + negativeRightSymbol: negativeRightSymbol, + suffix: suffix, + prefix: prefix, + absMask: absMask, + decimalChar: decimalChar, + integerSeparator: integerSeparator, + decimalsSeparator: decimalsSeparator, + padLeft: padLeft, + maxLeft: maxLeft, + padRight: padRight, + maxRight: maxRight + } + + return deconstructedFormat; + }; + +/***/ }, +/* 6 */ +/***/ function(module, exports) { + + + module.exports = formatter; + + function formatter(options) { + options = options || {}; + + + // ********************************************************************************************* + // Set defaults for negatives + // options.negative, options.negativeOut, options.separator retained for backward compatibility + // ********************************************************************************************* + + // type of negative; default left + options.negativeType = options.negativeType || (options.negative === 'R' ? 'right' : 'left') + + // negative symbols '-' or '()' + if (typeof options.negativeLeftSymbol !== 'string') { + switch (options.negativeType) { + case 'left': + options.negativeLeftSymbol = '-'; + break; + case 'brackets': + options.negativeLeftSymbol = '('; + break; + default: + options.negativeLeftSymbol = ''; + } + } + if (typeof options.negativeRightSymbol !== 'string') { + switch (options.negativeType) { + case 'right': + options.negativeRightSymbol = '-'; + break; + case 'brackets': + options.negativeRightSymbol = ')'; + break; + default: + options.negativeRightSymbol = ''; + } + } + + // whether negative symbol should be inside/outside prefix and suffix + + if (typeof options.negativeLeftOut !== "boolean") { + options.negativeLeftOut = (options.negativeOut === false ? false : true); + } + if (typeof options.negativeRightOut !== "boolean") { + options.negativeRightOut = (options.negativeOut === false ? false : true); + } + + //prefix and suffix + options.prefix = options.prefix || ''; + options.suffix = options.suffix || ''; + + //separators + if (typeof options.integerSeparator !== 'string') { + options.integerSeparator = (typeof options.separator === 'string' ? options.separator : ','); + } + options.decimalsSeparator = typeof options.decimalsSeparator === 'string' ? options.decimalsSeparator : ''; + options.decimal = options.decimal || '.'; + + //padders + options.padLeft = options.padLeft || -1 //default no padding + options.padRight = options.padRight || -1 //default no padding + + function format(number, overrideOptions) { + overrideOptions = overrideOptions || {}; + + if (number || number === 0) { + number = '' + number;//convert number to string if it isn't already + } else { + return ''; + } + + //identify a negative number and make it absolute + var output = []; + var negative = number.charAt(0) === '-'; + number = number.replace(/^\-/g, ''); + + //Prepare output with left hand negative and/or prefix + if (!options.negativeLeftOut && !overrideOptions.noUnits) { + output.push(options.prefix); + } + if (negative) { + output.push(options.negativeLeftSymbol); + } + if (options.negativeLeftOut && !overrideOptions.noUnits) { + output.push(options.prefix); + } + + //Format core number + number = number.split('.'); + if (options.round != null) round(number, options.round); + if (options.truncate != null) number[1] = truncate(number[1], options.truncate); + if (options.padLeft > 0) number[0] = padLeft(number[0], options.padLeft); + if (options.padRight > 0) number[1] = padRight(number[1], options.padRight); + if (!overrideOptions.noSeparator && number[1]) number[1] = addDecimalSeparators(number[1], options.decimalsSeparator); + if (!overrideOptions.noSeparator && number[0]) number[0] = addIntegerSeparators(number[0], options.integerSeparator); + output.push(number[0]); + if (number[1]) { + output.push(options.decimal); + output.push(number[1]); + } + + //Prepare output with right hand negative and/or prefix + if (options.negativeRightOut && !overrideOptions.noUnits) { + output.push(options.suffix); + } + if (negative) { + output.push(options.negativeRightSymbol); + } + if (!options.negativeRightOut && !overrideOptions.noUnits) { + output.push(options.suffix); + } + + //join output and return + return output.join(''); + } + + format.negative = options.negative; + format.negativeOut = options.negativeOut; + format.negativeType = options.negativeType; + format.negativeLeftOut = options.negativeLeftOut; + format.negativeLeftSymbol = options.negativeLeftSymbol; + format.negativeRightOut = options.negativeRightOut; + format.negativeRightSymbol = options.negativeRightSymbol; + format.prefix = options.prefix; + format.suffix = options.suffix; + format.separate = options.separate; + format.integerSeparator = options.integerSeparator; + format.decimalsSeparator = options.decimalsSeparator; + format.decimal = options.decimal; + format.padLeft = options.padLeft; + format.padRight = options.padRight; + format.truncate = options.truncate; + format.round = options.round; + + function unformat(number, allowedSeparators) { + allowedSeparators = allowedSeparators || []; + if (options.allowedSeparators) { + options.allowedSeparators.forEach(function (s) { allowedSeparators.push (s); }); + } + allowedSeparators.push(options.integerSeparator); + allowedSeparators.push(options.decimalsSeparator); + number = number.replace(options.prefix, ''); + number = number.replace(options.suffix, ''); + var newNumber = number; + do { + number = newNumber; + for (var i = 0; i < allowedSeparators.length; i++) { + newNumber = newNumber.replace(allowedSeparators[i], ''); + } + } while (newNumber != number); + return number; + } + format.unformat = unformat; + + function validate(number, allowedSeparators) { + number = unformat(number, allowedSeparators); + number = number.split(options.decimal); + if (number.length > 2) { + return false; + } else if (options.truncate != null && number[1] && number[1].length > options.truncate) { + return false; + } else if (options.round != null && number[1] && number[1].length > options.round) { + return false; + } else { + return /^-?\d+\.?\d*$/.test(number); + } + } + return format; + } + + //where x is already the integer part of the number + function addIntegerSeparators(x, separator) { + x += ''; + if (!separator) return x; + var rgx = /(\d+)(\d{3})/; + while (rgx.test(x)) { + x = x.replace(rgx, '$1' + separator + '$2'); + } + return x; + } + + //where x is already the decimal part of the number + function addDecimalSeparators(x, separator) { + x += ''; + if (!separator) return x; + var rgx = /(\d{3})(\d+)/; + while (rgx.test(x)) { + x = x.replace(rgx, '$1' + separator + '$2'); + } + return x; + } + + //where x is the integer part of the number + function padLeft(x, padding) { + x = x + ''; + var buf = []; + while (buf.length + x.length < padding) { + buf.push('0'); + } + return buf.join('') + x; + } + + //where x is the decimals part of the number + function padRight(x, padding) { + if (x) { + x += ''; + } else { + x = ''; + } + var buf = []; + while (buf.length + x.length < padding) { + buf.push('0'); + } + return x + buf.join(''); + } + function truncate(x, length) { + if (x) { + x += ''; + } + if (x && x.length > length) { + return x.substr(0, length); + } else { + return x; + } + } + + //where number is an array with 0th item as integer string and 1st item as decimal string (no negatives) + function round(number, places) { + if (number[1] && places >= 0 && number[1].length > places) { + //truncate to correct number of decimal places + var decim = number[1].slice(0, places); + //if next digit was >= 5 we need to round up + if (+(number[1].substr(places, 1)) >= 5) { + decim = (+decim + 1) + '' + if (decim.length > places) { + //adding one has made it longer + decim = decim.substring(1); //ignore the 1 at the beginning which is the carry to the integer part + number[0] = (+number[0]+1) + '' //add 1 to the integer part + } + } + number[1] = decim; + } + return number; + } + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/dist/react-widgets.js b/dist/react-widgets.js index 8e6e1938c..eba98ed8f 100644 --- a/dist/react-widgets.js +++ b/dist/react-widgets.js @@ -8,7 +8,7 @@ exports["ReactWidgets"] = factory(require("react"), require("react-dom")); else root["ReactWidgets"] = factory(root["React"], root["ReactDOM"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_29__) { +})(this, function(__WEBPACK_EXTERNAL_MODULE_21__, __WEBPACK_EXTERNAL_MODULE_32__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -57,32 +57,30 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */(function(process) {'use strict'; + var babelHelpers = __webpack_require__(2); + + var configure = __webpack_require__(3); + if (process.env.NODE_ENV !== 'production') { [Array.prototype.some, Array.prototype.filter, Array.prototype.reduce].forEach(function (method) { if (!method) throw new Error('One or more ES5 features is not available to ReactWidgets: http://jquense.github.io/react-widgets/docs/#/getting-started/browser'); }); } - module.exports = { - - DropdownList: __webpack_require__(2), - Combobox: __webpack_require__(55), - - Calendar: __webpack_require__(59), - DateTimePicker: __webpack_require__(73), - - NumberPicker: __webpack_require__(76), - - Multiselect: __webpack_require__(79), - SelectList: __webpack_require__(83), - - configure: __webpack_require__(84), + module.exports = babelHelpers._extends({}, configure, { + DropdownList: __webpack_require__(22), + Combobox: __webpack_require__(57), + Calendar: __webpack_require__(61), + DateTimePicker: __webpack_require__(75), + NumberPicker: __webpack_require__(78), + Multiselect: __webpack_require__(81), + SelectList: __webpack_require__(84), utils: { - ReplaceTransitionGroup: __webpack_require__(71), - SlideTransition: __webpack_require__(70) + ReplaceTransitionGroup: __webpack_require__(73), + SlideTransition: __webpack_require__(72) } - }; + }); /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }, @@ -186,624 +184,428 @@ return /******/ (function(modules) { // webpackBootstrap /* 2 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var babelHelpers = __webpack_require__(3); + var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { + if (true) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof exports === "object") { + factory(exports); + } else { + factory(root.babelHelpers = {}); + } + })(this, function (global) { + var babelHelpers = global; - exports.__esModule = true; + babelHelpers.createDecoratedObject = function (descriptors) { + var target = {}; - var _react = __webpack_require__(4); + for (var i = 0; i < descriptors.length; i++) { + var descriptor = descriptors[i]; + var decorators = descriptor.decorators; + var key = descriptor.key; + delete descriptor.key; + delete descriptor.decorators; + descriptor.enumerable = true; + descriptor.configurable = true; + if ("value" in descriptor || descriptor.initializer) descriptor.writable = true; - var _react2 = babelHelpers.interopRequireDefault(_react); + if (decorators) { + for (var f = 0; f < decorators.length; f++) { + var decorator = decorators[f]; - var _domHelpersActiveElement = __webpack_require__(5); + if (typeof decorator === "function") { + descriptor = decorator(target, key, descriptor) || descriptor; + } else { + throw new TypeError("The decorator for method " + descriptor.key + " is of the invalid type " + typeof decorator); + } + } + } - var _domHelpersActiveElement2 = babelHelpers.interopRequireDefault(_domHelpersActiveElement); + if (descriptor.initializer) { + descriptor.value = descriptor.initializer.call(target); + } - var _domHelpersQueryContains = __webpack_require__(8); + Object.defineProperty(target, key, descriptor); + } - var _domHelpersQueryContains2 = babelHelpers.interopRequireDefault(_domHelpersQueryContains); + return target; + }; - var _classnames = __webpack_require__(10); + babelHelpers.objectWithoutProperties = function (obj, keys) { + var target = {}; - var _classnames2 = babelHelpers.interopRequireDefault(_classnames); + for (var i in obj) { + if (keys.indexOf(i) >= 0) continue; + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; + target[i] = obj[i]; + } - var _util_ = __webpack_require__(11); + return target; + }; - var _util_2 = babelHelpers.interopRequireDefault(_util_); + babelHelpers.interopRequireWildcard = function (obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; - var _Popup = __webpack_require__(12); + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + } - var _Popup2 = babelHelpers.interopRequireDefault(_Popup); + newObj["default"] = obj; + return newObj; + } + }; - var _utilCompat = __webpack_require__(28); + babelHelpers.interopRequireDefault = function (obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; + }; - var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); + babelHelpers._extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; - var _utilPropTypes = __webpack_require__(30); + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } - var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); + return target; + }; + }) - var _List = __webpack_require__(32); +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { - var _List2 = babelHelpers.interopRequireDefault(_List); + 'use strict'; - var _ListGroupable = __webpack_require__(38); + var babelHelpers = __webpack_require__(2); - var _ListGroupable2 = babelHelpers.interopRequireDefault(_ListGroupable); + exports.__esModule = true; - var _utilValidateListInterface = __webpack_require__(40); + var _utilConfiguration = __webpack_require__(4); - var _utilValidateListInterface2 = babelHelpers.interopRequireDefault(_utilValidateListInterface); + var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); - var _uncontrollable = __webpack_require__(41); + var _utilLocalizers = __webpack_require__(18); - var _uncontrollable2 = babelHelpers.interopRequireDefault(_uncontrollable); + var localizers = babelHelpers.interopRequireWildcard(_utilLocalizers); + exports['default'] = { - var _utilDataHelpers = __webpack_require__(34); + setAnimate: function setAnimate(animatefn) { + _utilConfiguration2['default'].animate = animatefn; + }, - var _utilInteraction = __webpack_require__(45); + setLocalizers: function setLocalizers(_ref) { + var date = _ref.date; + var number = _ref.number; - var _utilWidgetHelpers = __webpack_require__(35); + date && this.setDateLocalizer(date); + number && this.setNumberLocalizer(number); + }, - var omit = _util_2['default'].omit; - var pick = _util_2['default'].pick; - var result = _util_2['default'].result; + setDateLocalizer: localizers.setDate, - var propTypes = { - //-- controlled props ----------- - value: _react2['default'].PropTypes.any, - onChange: _react2['default'].PropTypes.func, - open: _react2['default'].PropTypes.bool, - onToggle: _react2['default'].PropTypes.func, - //------------------------------------ + setNumberLocalizer: localizers.setNumber + }; + module.exports = exports['default']; - data: _react2['default'].PropTypes.array, - valueField: _react2['default'].PropTypes.string, - textField: _utilPropTypes2['default'].accessor, +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { - valueComponent: _utilPropTypes2['default'].elementType, - itemComponent: _utilPropTypes2['default'].elementType, - listComponent: _utilPropTypes2['default'].elementType, + 'use strict'; - groupComponent: _utilPropTypes2['default'].elementType, - groupBy: _utilPropTypes2['default'].accessor, + var babelHelpers = __webpack_require__(2); - onSelect: _react2['default'].PropTypes.func, + exports.__esModule = true; - searchTerm: _react2['default'].PropTypes.string, - onSearch: _react2['default'].PropTypes.func, + var _domAnimate = __webpack_require__(5); - busy: _react2['default'].PropTypes.bool, + var _domAnimate2 = babelHelpers.interopRequireDefault(_domAnimate); - delay: _react2['default'].PropTypes.number, + function error() { + throw new Error('[React Widgets] You are attempting to use a widget that requires localization (DateTimePicker, NumberPicker)' + 'but there is no localizer set. In order to use these widgets please install a localizer'); + } - dropUp: _react2['default'].PropTypes.bool, - duration: _react2['default'].PropTypes.number, //popup + var dummy = { + formats: error, + parse: error, + format: error, + firstOfWeek: error + }; - disabled: _utilPropTypes2['default'].disabled, + exports['default'] = { - readOnly: _utilPropTypes2['default'].readOnly, + animate: _domAnimate2['default'], - messages: _react2['default'].PropTypes.shape({ - open: _utilPropTypes2['default'].message, - emptyList: _utilPropTypes2['default'].message, - emptyFilter: _utilPropTypes2['default'].message, - filterPlaceholder: _utilPropTypes2['default'].message - }) + locale: { + date: dummy, + number: dummy + } }; + module.exports = exports['default']; - var DropdownList = _react2['default'].createClass(babelHelpers.createDecoratedObject([{ - key: 'displayName', - initializer: function initializer() { - return 'DropdownList'; - } - }, { - key: 'mixins', - initializer: function initializer() { - return [__webpack_require__(46), __webpack_require__(47), __webpack_require__(48), __webpack_require__(49), __webpack_require__(54), __webpack_require__(37)()]; - } - }, { - key: 'propTypes', - initializer: function initializer() { - return propTypes; - } - }, { - key: 'getDefaultProps', - value: function getDefaultProps() { - return { - delay: 500, - value: '', - open: false, - data: [], - searchTerm: '', - messages: msgs(), - ariaActiveDescendantKey: 'dropdownlist' - }; - } - }, { - key: 'getInitialState', - value: function getInitialState() { - var _props = this.props; - var open = _props.open; - var filter = _props.filter; - var value = _props.value; - var data = _props.data; - var searchTerm = _props.searchTerm; - var valueField = _props.valueField; +/***/ }, +/* 5 */ +/***/ function(module, exports, __webpack_require__) { - var processed = filter ? this.filter(data, searchTerm) : data, - initialIdx = _utilDataHelpers.dataIndexOf(data, value, valueField); + 'use strict'; - return { - filteredData: open && filter ? processed : null, - selectedItem: processed[initialIdx], - focusedItem: processed[initialIdx] || data[0] - }; - } - }, { - key: 'componentDidUpdate', - value: function componentDidUpdate() { - this.refs.list && _utilValidateListInterface2['default'](this.refs.list); - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(props) { - var open = props.open; - var filter = props.filter; - var value = props.value; - var data = props.data; - var searchTerm = props.searchTerm; - var valueField = props.valueField; + var babelHelpers = __webpack_require__(2); - var processed = filter ? this.filter(data, searchTerm) : data, - idx = _utilDataHelpers.dataIndexOf(data, value, valueField); + exports.__esModule = true; + exports['default'] = animate; - this.setState({ - filteredData: open && filter ? processed : null, - selectedItem: processed[idx], - focusedItem: processed[! ~idx ? 0 : idx] - }); - } - }, { - key: 'render', - value: function render() { - var _cx, - _this = this; + var _domHelpersUtilHyphenate = __webpack_require__(6); - var _props2 = this.props; - var className = _props2.className; - var tabIndex = _props2.tabIndex; - var filter = _props2.filter; - var valueField = _props2.valueField; - var textField = _props2.textField; - var groupBy = _props2.groupBy; - var messages = _props2.messages; - var data = _props2.data; - var busy = _props2.busy; - var dropUp = _props2.dropUp; - var placeholder = _props2.placeholder; - var value = _props2.value; - var open = _props2.open; - var disabled = _props2.disabled; - var readOnly = _props2.readOnly; - var ValueComponent = _props2.valueComponent; - var List = _props2.listComponent; - - List = List || groupBy && _ListGroupable2['default'] || _List2['default']; + var _domHelpersUtilHyphenate2 = babelHelpers.interopRequireDefault(_domHelpersUtilHyphenate); - var elementProps = omit(this.props, Object.keys(propTypes)); - var listProps = pick(this.props, Object.keys(_utilCompat2['default'].type(List).propTypes)); - var popupProps = pick(this.props, Object.keys(_utilCompat2['default'].type(_Popup2['default']).propTypes)); + var _domHelpersStyle = __webpack_require__(7); - var _state = this.state; - var focusedItem = _state.focusedItem; - var selectedItem = _state.selectedItem; - var focused = _state.focused; + var _domHelpersStyle2 = babelHelpers.interopRequireDefault(_domHelpersStyle); - var items = this._data(), - valueItem = _utilDataHelpers.dataItem(data, value, valueField), - // take value from the raw data - listID = _utilWidgetHelpers.instanceId(this, '__listbox'); + var _domHelpersEventsOn = __webpack_require__(14); - var shouldRenderList = _utilWidgetHelpers.isFirstFocusedRender(this) || open; + var _domHelpersEventsOn2 = babelHelpers.interopRequireDefault(_domHelpersEventsOn); - messages = msgs(messages); + var _domHelpersEventsOff = __webpack_require__(16); - return _react2['default'].createElement( - 'div', - babelHelpers._extends({}, elementProps, { - ref: 'input', - role: 'combobox', - tabIndex: tabIndex || '0', - 'aria-expanded': open, - 'aria-haspopup': true, - 'aria-owns': listID, - 'aria-busy': !!busy, - 'aria-live': !open && 'polite', - //aria-activedescendant={activeID} - 'aria-autocomplete': 'list', - 'aria-disabled': disabled, - 'aria-readonly': readOnly, - onKeyDown: this._keyDown, - onClick: this._click, - onFocus: this._focus.bind(null, true), - onBlur: this._focus.bind(null, false), - className: _classnames2['default'](className, 'rw-dropdownlist', 'rw-widget', (_cx = { - 'rw-state-disabled': disabled, - 'rw-state-readonly': readOnly, - 'rw-state-focus': focused, - 'rw-rtl': this.isRtl() + var _domHelpersEventsOff2 = babelHelpers.interopRequireDefault(_domHelpersEventsOff); - }, _cx['rw-open' + (dropUp ? '-up' : '')] = open, _cx)) }), - _react2['default'].createElement( - 'span', - { className: 'rw-dropdownlist-picker rw-select rw-btn' }, - _react2['default'].createElement( - 'i', - { className: 'rw-i rw-i-caret-down' + (busy ? ' rw-loading' : '') }, - _react2['default'].createElement( - 'span', - { className: 'rw-sr' }, - result(messages.open, this.props) - ) - ) - ), - _react2['default'].createElement( - 'div', - { - className: 'rw-input' - }, - !valueItem && placeholder ? _react2['default'].createElement( - 'span', - { className: 'rw-placeholder' }, - placeholder - ) : this.props.valueComponent ? _react2['default'].createElement(ValueComponent, { item: valueItem }) : _utilDataHelpers.dataText(valueItem, textField) - ), - _react2['default'].createElement( - _Popup2['default'], - babelHelpers._extends({}, popupProps, { - onOpen: function () { - return _this.focus(); - }, - onOpening: function () { - return _this.refs.list.forceUpdate(); - }, - onRequestClose: this.close - }), - _react2['default'].createElement( - 'div', - null, - filter && this._renderFilter(messages), - shouldRenderList && _react2['default'].createElement(List, babelHelpers._extends({ ref: 'list' - }, listProps, { - data: items, - id: listID, - 'aria-live': open && 'polite', - 'aria-labelledby': _utilWidgetHelpers.instanceId(this), - 'aria-hidden': !this.props.open, - selected: selectedItem, - focused: open ? focusedItem : null, - onSelect: this._onSelect, - onMove: this._scrollTo, - messages: { - emptyList: data.length ? messages.emptyFilter : messages.emptyList - } })) - ) - ) - ); - } - }, { - key: '_renderFilter', - value: function _renderFilter(messages) { - var _this2 = this; + var _domHelpersTransitionProperties = __webpack_require__(17); - return _react2['default'].createElement( - 'div', - { ref: 'filterWrapper', className: 'rw-filter-input' }, - _react2['default'].createElement( - 'span', - { className: 'rw-select rw-btn' }, - _react2['default'].createElement('i', { className: 'rw-i rw-i-search' }) - ), - _react2['default'].createElement('input', { ref: 'filter', className: 'rw-input', - placeholder: _util_2['default'].result(messages.filterPlaceholder, this.props), - value: this.props.searchTerm, - onChange: function (e) { - return _utilWidgetHelpers.notify(_this2.props.onSearch, e.target.value); - } }) - ); - } - }, { - key: '_focus', - decorators: [_utilInteraction.widgetEnabled], - value: function _focus(focused, e) { - var _this3 = this; + var _domHelpersTransitionProperties2 = babelHelpers.interopRequireDefault(_domHelpersTransitionProperties); - this.setTimeout('focus', function () { - if (!focused) _this3.close(); + var has = Object.prototype.hasOwnProperty, + reset = {}, + TRANSLATION_MAP = { + left: 'translateX', + right: 'translateX', + top: 'translateY', + bottom: 'translateY' + }; - if (focused !== _this3.state.focused) { - _utilWidgetHelpers.notify(_this3.props[focused ? 'onFocus' : 'onBlur'], e); - _this3.setState({ focused: focused }); - } - }); - } - }, { - key: '_onSelect', - decorators: [_utilInteraction.widgetEditable], - value: function _onSelect(data) { - this.close(); - _utilWidgetHelpers.notify(this.props.onSelect, data); - this.change(data); - this.focus(this); - } - }, { - key: '_click', - decorators: [_utilInteraction.widgetEditable], - value: function _click(e) { - var wrapper = this.refs.filterWrapper; + reset[_domHelpersTransitionProperties2['default'].property] = reset[_domHelpersTransitionProperties2['default'].duration] = reset[_domHelpersTransitionProperties2['default'].delay] = reset[_domHelpersTransitionProperties2['default'].timing] = ''; - if (!this.props.filter || !this.props.open) this.toggle();else if (!_domHelpersQueryContains2['default'](_utilCompat2['default'].findDOMNode(wrapper), e.target)) this.close(); + animate.endEvent = _domHelpersTransitionProperties2['default'].end; + animate.transform = _domHelpersTransitionProperties2['default'].transform; + animate.TRANSLATION_MAP = TRANSLATION_MAP; - _utilWidgetHelpers.notify(this.props.onClick, e); - } - }, { - key: '_keyDown', - decorators: [_utilInteraction.widgetEditable], - value: function _keyDown(e) { - var _this4 = this; + // super lean animate function for transitions + // doesn't support all translations to keep it matching the jquery API + /** + * code in part from: Zepto 1.1.4 | zeptojs.com/license + */ - var self = this, - key = e.key, - alt = e.altKey, - list = this.refs.list, - filtering = this.props.filter, - focusedItem = this.state.focusedItem, - selectedItem = this.state.selectedItem, - isOpen = this.props.open, - closeWithFocus = function closeWithFocus() { - _this4.close(), _utilCompat2['default'].findDOMNode(_this4).focus(); - }; + function animate(node, properties, duration, easing, callback) { + var cssProperties = [], + fakeEvent = { target: node, currentTarget: node }, + cssValues = {}, + transforms = '', + fired; - if (key === 'End') { - if (isOpen) this.setState({ focusedItem: list.last() });else change(list.last()); - e.preventDefault(); - } else if (key === 'Home') { - if (isOpen) this.setState({ focusedItem: list.first() });else change(list.first()); - e.preventDefault(); - } else if (key === 'Escape' && isOpen) { - closeWithFocus(); - } else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) { - change(this.state.focusedItem, true); - } else if (key === 'ArrowDown') { - if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem)); - e.preventDefault(); - } else if (key === 'ArrowUp') { - if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem)); - e.preventDefault(); - } else if (!(this.props.filter && isOpen)) this.search(String.fromCharCode(e.keyCode), function (item) { - isOpen ? _this4.setState({ focusedItem: item }) : change(item); - }); + if (typeof easing === 'function') callback = easing, easing = null; - _utilWidgetHelpers.notify(this.props.onKeyDown, [e]); + if (!_domHelpersTransitionProperties2['default'].end) duration = 0; + if (duration === undefined) duration = 200; - function change(item, fromList) { - if (!item) return; - fromList ? self._onSelect(item) : self.change(item); - } - } - }, { - key: 'change', - value: function change(data) { - if (!_util_2['default'].isShallowEqual(data, this.props.value)) { - _utilWidgetHelpers.notify(this.props.onChange, data); - _utilWidgetHelpers.notify(this.props.onSearch, ''); - this.close(); + for (var key in properties) if (has.call(properties, key)) { + if (/(top|bottom)/.test(key)) transforms += TRANSLATION_MAP[key] + '(' + properties[key] + ') ';else { + cssValues[key] = properties[key]; + cssProperties.push(_domHelpersUtilHyphenate2['default'](key)); } } - }, { - key: 'focus', - value: function focus(target) { - var inst = target || (this.props.filter && this.props.open ? this.refs.filter : this.refs.input); - if (_domHelpersActiveElement2['default']() !== _utilCompat2['default'].findDOMNode(inst)) _utilCompat2['default'].findDOMNode(inst).focus(); + if (transforms) { + cssValues[_domHelpersTransitionProperties2['default'].transform] = transforms; + cssProperties.push(_domHelpersTransitionProperties2['default'].transform); } - }, { - key: '_data', - value: function _data() { - return this.state.filteredData || this.props.data.concat(); + + if (duration > 0) { + cssValues[_domHelpersTransitionProperties2['default'].property] = cssProperties.join(', '); + cssValues[_domHelpersTransitionProperties2['default'].duration] = duration / 1000 + 's'; + cssValues[_domHelpersTransitionProperties2['default'].delay] = 0 + 's'; + cssValues[_domHelpersTransitionProperties2['default'].timing] = easing || 'linear'; + + _domHelpersEventsOn2['default'](node, _domHelpersTransitionProperties2['default'].end, done); + + setTimeout(function () { + if (!fired) done(fakeEvent); + }, duration + 500); } - }, { - key: 'search', - value: function search(character, cb) { - var _this5 = this; - var word = ((this._searchTerm || '') + character).toLowerCase(); + node.clientLeft; // trigger page reflow + _domHelpersStyle2['default'](node, cssValues); - this._searchTerm = word; + if (duration <= 0) setTimeout(done.bind(null, fakeEvent), 0); - this.setTimeout('search', function () { - var list = _this5.refs.list, - key = _this5.props.open ? 'focusedItem' : 'selectedItem', - item = list.next(_this5.state[key], word); + function done(event) { + if (event.target !== event.currentTarget) return; - _this5._searchTerm = ''; - if (item) cb(item); - }, this.props.delay); - } - }, { - key: 'open', - value: function open() { - _utilWidgetHelpers.notify(this.props.onToggle, true); - } - }, { - key: 'close', - value: function close() { - _utilWidgetHelpers.notify(this.props.onToggle, false); - } - }, { - key: 'toggle', - value: function toggle() { - this.props.open ? this.close() : this.open(); + fired = true; + _domHelpersEventsOff2['default'](event.target, _domHelpersTransitionProperties2['default'].end, done); + _domHelpersStyle2['default'](node, reset); + callback && callback.call(this); } - }])); - - function msgs(msgs) { - return babelHelpers._extends({ - open: 'open dropdown', - filterPlaceholder: '', - emptyList: 'There are no items in this list', - emptyFilter: 'The filter returned no results' - }, msgs); } - exports['default'] = _uncontrollable2['default'](DropdownList, { open: 'onToggle', value: 'onChange', searchTerm: 'onSearch' }); module.exports = exports['default']; /***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { +/* 6 */ +/***/ function(module, exports) { - var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { - if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (typeof exports === "object") { - factory(exports); - } else { - factory(root.babelHelpers = {}); - } - })(this, function (global) { - var babelHelpers = global; + 'use strict'; - babelHelpers.createDecoratedObject = function (descriptors) { - var target = {}; + var rUpper = /([A-Z])/g; - for (var i = 0; i < descriptors.length; i++) { - var descriptor = descriptors[i]; - var decorators = descriptor.decorators; - var key = descriptor.key; - delete descriptor.key; - delete descriptor.decorators; - descriptor.enumerable = true; - descriptor.configurable = true; - if ("value" in descriptor || descriptor.initializer) descriptor.writable = true; + module.exports = function hyphenate(string) { + return string.replace(rUpper, '-$1').toLowerCase(); + }; - if (decorators) { - for (var f = 0; f < decorators.length; f++) { - var decorator = decorators[f]; +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { - if (typeof decorator === "function") { - descriptor = decorator(target, key, descriptor) || descriptor; - } else { - throw new TypeError("The decorator for method " + descriptor.key + " is of the invalid type " + typeof decorator); - } - } - } + 'use strict'; - if (descriptor.initializer) { - descriptor.value = descriptor.initializer.call(target); - } + var camelize = __webpack_require__(8), + hyphenate = __webpack_require__(10), + _getComputedStyle = __webpack_require__(11), + removeStyle = __webpack_require__(13); - Object.defineProperty(target, key, descriptor); - } + var has = Object.prototype.hasOwnProperty; - return target; - }; + module.exports = function style(node, property, value) { + var css = '', + props = property; - babelHelpers.objectWithoutProperties = function (obj, keys) { - var target = {}; + if (typeof property === 'string') { - for (var i in obj) { - if (keys.indexOf(i) >= 0) continue; - if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; - target[i] = obj[i]; - } + if (value === undefined) return node.style[camelize(property)] || _getComputedStyle(node).getPropertyValue(hyphenate(property));else (props = {})[property] = value; + } - return target; - }; + for (var key in props) if (has.call(props, key)) { + !props[key] && props[key] !== 0 ? removeStyle(node, hyphenate(key)) : css += hyphenate(key) + ':' + props[key] + ';'; + } - babelHelpers.interopRequireWildcard = function (obj) { - if (obj && obj.__esModule) { - return obj; - } else { - var newObj = {}; + node.style.cssText += ';' + css; + }; - if (obj != null) { - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; - } - } +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { - newObj["default"] = obj; - return newObj; - } - }; + /** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/camelizeStyleName.js + */ - babelHelpers.interopRequireDefault = function (obj) { - return obj && obj.__esModule ? obj : { - "default": obj - }; - }; + 'use strict'; + var camelize = __webpack_require__(9); + var msPattern = /^-ms-/; - babelHelpers._extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; + module.exports = function camelizeStyleName(string) { + return camelize(string.replace(msPattern, 'ms-')); + }; - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } +/***/ }, +/* 9 */ +/***/ function(module, exports) { - return target; - }; + "use strict"; - babelHelpers.classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - }; - }) + var rHyphen = /-(.)/g; + + module.exports = function camelize(string) { + return string.replace(rHyphen, function (_, chr) { + return chr.toUpperCase(); + }); + }; /***/ }, -/* 4 */ -/***/ function(module, exports) { +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + /** + * Copyright 2013-2014, Facebook, Inc. + * All rights reserved. + * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/hyphenateStyleName.js + */ + + "use strict"; + + var hyphenate = __webpack_require__(6); + var msPattern = /^ms-/; - module.exports = __WEBPACK_EXTERNAL_MODULE_4__; + module.exports = function hyphenateStyleName(string) { + return hyphenate(string).replace(msPattern, "-ms-"); + }; /***/ }, -/* 5 */ +/* 11 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(6); + var babelHelpers = __webpack_require__(12); - exports.__esModule = true; + var _utilCamelizeStyle = __webpack_require__(8); - /** - * document.activeElement - */ - exports['default'] = activeElement; + var _utilCamelizeStyle2 = babelHelpers.interopRequireDefault(_utilCamelizeStyle); + + var rposition = /^(top|right|bottom|left)$/; + var rnumnonpx = /^([+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|))(?!px)[a-z%]+$/i; - var _ownerDocument = __webpack_require__(7); + module.exports = function _getComputedStyle(node) { + if (!node) throw new TypeError('No Element passed to `getComputedStyle()`'); + var doc = node.ownerDocument; - var _ownerDocument2 = babelHelpers.interopRequireDefault(_ownerDocument); + return 'defaultView' in doc ? doc.defaultView.opener ? node.ownerDocument.defaultView.getComputedStyle(node, null) : window.getComputedStyle(node, null) : { //ie 8 "magic" from: https://github.com/jquery/jquery/blob/1.11-stable/src/css/curCSS.js#L72 + getPropertyValue: function getPropertyValue(prop) { + var style = node.style; - function activeElement() { - var doc = arguments[0] === undefined ? document : arguments[0]; + prop = (0, _utilCamelizeStyle2['default'])(prop); - try { - return doc.activeElement; - } catch (e) {} - } + if (prop == 'float') prop = 'styleFloat'; - module.exports = exports['default']; + var current = node.currentStyle[prop] || null; + + if (current == null && style && style[prop]) current = style[prop]; + + if (rnumnonpx.test(current) && !rposition.test(prop)) { + // Remember the original values + var left = style.left; + var runStyle = node.runtimeStyle; + var rsLeft = runStyle && runStyle.left; + + // Put in the new values to get a computed value out + if (rsLeft) runStyle.left = node.currentStyle.left; + + style.left = prop === 'fontSize' ? '1em' : current; + current = style.pixelLeft + 'px'; + + // Revert the changed values + style.left = left; + if (rsLeft) runStyle.left = rsLeft; + } + + return current; + } + }; + }; /***/ }, -/* 6 */ +/* 12 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { @@ -839,894 +641,1370 @@ return /******/ (function(modules) { // webpackBootstrap }) /***/ }, -/* 7 */ +/* 13 */ /***/ function(module, exports) { - "use strict"; - - exports.__esModule = true; - exports["default"] = ownerDocument; - - function ownerDocument(node) { - return node && node.ownerDocument || document; - } + 'use strict'; - module.exports = exports["default"]; + module.exports = function removeStyle(node, key) { + return 'removeProperty' in node.style ? node.style.removeProperty(key) : node.style.removeAttribute(key); + }; /***/ }, -/* 8 */ +/* 14 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var canUseDOM = __webpack_require__(9); + var canUseDOM = __webpack_require__(15); + var on = function on() {}; - var contains = (function () { - var root = canUseDOM && document.documentElement; - - return root && root.contains ? function (context, node) { - return context.contains(node); - } : root && root.compareDocumentPosition ? function (context, node) { - return context === node || !!(context.compareDocumentPosition(node) & 16); - } : function (context, node) { - if (node) do { - if (node === context) return true; - } while (node = node.parentNode); + if (canUseDOM) { + on = (function () { - return false; - }; - })(); + if (document.addEventListener) return function (node, eventName, handler, capture) { + return node.addEventListener(eventName, handler, capture || false); + };else if (document.attachEvent) return function (node, eventName, handler) { + return node.attachEvent('on' + eventName, handler); + }; + })(); + } - module.exports = contains; + module.exports = on; /***/ }, -/* 9 */ +/* 15 */ /***/ function(module, exports) { 'use strict'; module.exports = !!(typeof window !== 'undefined' && window.document && window.document.createElement); /***/ }, -/* 10 */ +/* 16 */ /***/ function(module, exports, __webpack_require__) { - var __WEBPACK_AMD_DEFINE_RESULT__;/*! - Copyright (c) 2015 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames - */ - /* global define */ + 'use strict'; + var canUseDOM = __webpack_require__(15); + var off = function off() {}; - (function () { - 'use strict'; + if (canUseDOM) { - var hasOwn = {}.hasOwnProperty; + off = (function () { - function classNames () { - var classes = ''; + if (document.addEventListener) return function (node, eventName, handler, capture) { + return node.removeEventListener(eventName, handler, capture || false); + };else if (document.attachEvent) return function (node, eventName, handler) { + return node.detachEvent('on' + eventName, handler); + }; + })(); + } - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i]; - if (!arg) continue; + module.exports = off; - var argType = typeof arg; +/***/ }, +/* 17 */ +/***/ function(module, exports, __webpack_require__) { - if (argType === 'string' || argType === 'number') { - classes += ' ' + arg; - } else if (Array.isArray(arg)) { - classes += ' ' + classNames.apply(null, arg); - } else if (argType === 'object') { - for (var key in arg) { - if (hasOwn.call(arg, key) && arg[key]) { - classes += ' ' + key; - } - } - } - } + 'use strict'; + var canUseDOM = __webpack_require__(15); - return classes.substr(1); - } + var has = Object.prototype.hasOwnProperty, + transform = 'transform', + transition = {}, + transitionTiming, + transitionDuration, + transitionProperty, + transitionDelay; - if (typeof module !== 'undefined' && module.exports) { - module.exports = classNames; - } else if (true) { - // register as 'classnames', consistent with npm package name - !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { - return classNames; - }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else { - window.classNames = classNames; - } - }()); + if (canUseDOM) { + transition = getTransitionProperties(); + transform = transition.prefix + transform; -/***/ }, -/* 11 */ -/***/ function(module, exports) { + transitionProperty = transition.prefix + 'transition-property'; + transitionDuration = transition.prefix + 'transition-duration'; + transitionDelay = transition.prefix + 'transition-delay'; + transitionTiming = transition.prefix + 'transition-timing-function'; + } - 'use strict'; - var idCount = 0; + module.exports = { + transform: transform, + end: transition.end, + property: transitionProperty, + timing: transitionTiming, + delay: transitionDelay, + duration: transitionDuration + }; - var _ = module.exports = { + function getTransitionProperties() { + var endEvent, + prefix = '', + transitions = { + O: 'otransitionend', + Moz: 'transitionend', + Webkit: 'webkitTransitionEnd', + ms: 'MSTransitionEnd' + }; - has: has, + var element = document.createElement('div'); - result: function result(value) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; + for (var vendor in transitions) if (has.call(transitions, vendor)) { + if (element.style[vendor + 'TransitionProperty'] !== undefined) { + prefix = '-' + vendor.toLowerCase() + '-'; + endEvent = transitions[vendor]; + break; } + } - return typeof value === 'function' ? value.apply(undefined, args) : value; - }, - - isShallowEqual: function isShallowEqual(a, b) { - if (a === b) return true; - if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); - - if (typeof a !== 'object' && typeof b !== 'object') return a === b; - - if (typeof a !== typeof b) return false; + if (!endEvent && element.style.transitionProperty !== undefined) endEvent = 'transitionend'; - return shallowEqual(a, b); - }, + return { end: endEvent, prefix: prefix }; + } - transform: function transform(obj, cb, seed) { - _.each(obj, cb.bind(null, seed = seed || (Array.isArray(obj) ? [] : {}))); - return seed; - }, +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { - each: function each(obj, cb, thisArg) { - if (Array.isArray(obj)) return obj.forEach(cb, thisArg); + /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - for (var key in obj) if (has(obj, key)) cb.call(thisArg, obj[key], key, obj); - }, + var babelHelpers = __webpack_require__(2); - pick: function pick(obj, keys) { - keys = [].concat(keys); - return _.transform(obj, function (mapped, val, key) { - if (keys.indexOf(key) !== -1) mapped[key] = val; - }, {}); - }, + exports.__esModule = true; + exports.setNumber = setNumber; + exports.setDate = setDate; - omit: function omit(obj, keys) { - keys = [].concat(keys); - return _.transform(obj, function (mapped, val, key) { - if (keys.indexOf(key) === -1) mapped[key] = val; - }, {}); - }, + var _invariant = __webpack_require__(19); - find: function find(arr, cb, thisArg) { - var result; - if (Array.isArray(arr)) { - arr.every(function (val, idx) { - if (cb.call(thisArg, val, idx, arr)) return (result = val, false); - return true; - }); - return result; - } else for (var key in arr) if (has(arr, key)) if (cb.call(thisArg, arr[key], key, arr)) return arr[key]; - }, + var _invariant2 = babelHelpers.interopRequireDefault(_invariant); - chunk: function chunk(array, chunkSize) { - var index = 0, - length = array ? array.length : 0, - result = []; + var _ = __webpack_require__(20); - chunkSize = Math.max(+chunkSize || 1, 1); + var _react = __webpack_require__(21); - while (index < length) result.push(array.slice(index, index += chunkSize)); + var _react2 = babelHelpers.interopRequireDefault(_react); - return result; - }, + var localePropType = _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.string, _react2['default'].PropTypes.func]); - splat: function splat(obj) { - return obj == null ? [] : [].concat(obj); - }, + var REQUIRED_NUMBER_FORMATS = ['default']; - noop: function noop() {}, + var REQUIRED_DATE_FORMATS = ['default', 'date', 'time', 'header', 'footer', 'dayOfMonth', 'month', 'year', 'decade', 'century']; - uniqueId: function uniqueId(prefix) { - return '' + ((prefix == null ? '' : prefix) + ++idCount); - } + function _format(localizer, formatter, value, format, culture) { + var result = typeof format === 'function' ? format(value, culture, localizer) : formatter.call(localizer, value, format, culture); - }; + _invariant2['default'](result == null || typeof result === 'string', '`localizer format(..)` must return a string, null, or undefined'); - function has(o, k) { - return o ? Object.prototype.hasOwnProperty.call(o, k) : false; + return result; } - function eql(a, b) { - return a === b; + function checkFormats(requiredFormats, formats) { + if (process.env.NODE_ENV !== 'production') requiredFormats.forEach(function (f) { + return _invariant2['default'](_.has(formats, f), 'localizer missing required format: `%s`', f); + }); } - /** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - */ - function shallowEqual(objA, objB) { + var _numberLocalizer = {}; - if (objA == null || objB == null) return false; + function setNumber(_ref) { + var _format2 = _ref.format; + var _parse = _ref.parse; + var _ref$precision = _ref.precision; + var precision = _ref$precision === undefined ? function () { + return null; + } : _ref$precision; + var formats = _ref.formats; + var propType = _ref.propType; - var keysA = Object.keys(objA), - keysB = Object.keys(objB); + _invariant2['default'](typeof _format2 === 'function', 'number localizer `format(..)` must be a function'); + _invariant2['default'](typeof _parse === 'function', 'number localizer `parse(..)` must be a function'); - if (keysA.length !== keysB.length) return false; + checkFormats(REQUIRED_NUMBER_FORMATS, formats); - for (var i = 0; i < keysA.length; i++) if (!has(objB, keysA[i]) || !eql(objA[keysA[i]], objB[keysA[i]])) return false; + _numberLocalizer = { + formats: formats, + precision: precision, + propType: propType || localePropType, - return true; + format: function format(value, str, culture) { + return _format(this, _format2, value, str, culture); + }, + + parse: function parse(value, culture) { + var result = _parse.call(this, value, culture); + _invariant2['default'](result == null || typeof result === 'number', 'number localizer `parse(..)` must return a number, null, or undefined'); + return result; + } + }; } -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { + var _dateLocalizer = {}; - 'use strict'; + function setDate(spec) { + _invariant2['default'](typeof spec.format === 'function', 'date localizer `format(..)` must be a function'); + _invariant2['default'](typeof spec.parse === 'function', 'date localizer `parse(..)` must be a function'); + _invariant2['default'](typeof spec.firstOfWeek === 'function', 'date localizer `firstOfWeek(..)` must be a function'); + checkFormats(REQUIRED_DATE_FORMATS, spec.formats); - var babelHelpers = __webpack_require__(3); + _dateLocalizer = { + formats: spec.formats, + propType: spec.propType || localePropType, + startOfWeek: spec.firstOfWeek, + format: function format(value, str, culture) { + return _format(this, spec.format, value, str, culture); + }, + parse: function parse(value, culture) { + var result = spec.parse.call(this, value, culture); + _invariant2['default'](result == null || result instanceof Date && !isNaN(result.getTime()), 'date localizer `parse(..)` must return a valid Date, null, or undefined'); + return result; + } + }; + } - var React = __webpack_require__(4), - css = __webpack_require__(13), - getHeight = __webpack_require__(20), - config = __webpack_require__(23), - cn = __webpack_require__(10), - compat = __webpack_require__(28); + var number = { + propType: function propType() { + var _numberLocalizer2; - var transform = config.animate.transform; + return (_numberLocalizer2 = _numberLocalizer).propType.apply(_numberLocalizer2, arguments); + }, + getFormat: function getFormat(key, format) { + return format || _numberLocalizer.formats[key]; + }, + parse: function parse() { + var _numberLocalizer3; - function properties(prop, value) { - var _ref, _ref2; + return (_numberLocalizer3 = _numberLocalizer).parse.apply(_numberLocalizer3, arguments); + }, + format: function format() { + var _numberLocalizer4; - var TRANSLATION_MAP = config.animate.TRANSLATION_MAP; + return (_numberLocalizer4 = _numberLocalizer).format.apply(_numberLocalizer4, arguments); + }, + precision: function precision() { + var _numberLocalizer5; - if (TRANSLATION_MAP && TRANSLATION_MAP[prop]) return (_ref = {}, _ref[transform] = TRANSLATION_MAP[prop] + '(' + value + ')', _ref); + return (_numberLocalizer5 = _numberLocalizer).precision.apply(_numberLocalizer5, arguments); + } + }; - return (_ref2 = {}, _ref2[prop] = value, _ref2); - } + exports.number = number; + var date = { + propType: function propType() { + var _dateLocalizer2; - var PopupContent = React.createClass({ - displayName: 'PopupContent', + return (_dateLocalizer2 = _dateLocalizer).propType.apply(_dateLocalizer2, arguments); + }, + getFormat: function getFormat(key, format) { + return format || _dateLocalizer.formats[key]; + }, + parse: function parse() { + var _dateLocalizer3; - render: function render() { - var child = this.props.children; + return (_dateLocalizer3 = _dateLocalizer).parse.apply(_dateLocalizer3, arguments); + }, + format: function format() { + var _dateLocalizer4; - if (!child) return React.createElement('span', { className: 'rw-popup rw-widget' }); + return (_dateLocalizer4 = _dateLocalizer).format.apply(_dateLocalizer4, arguments); + }, + startOfWeek: function startOfWeek() { + var _dateLocalizer5; - child = React.Children.only(this.props.children); + return (_dateLocalizer5 = _dateLocalizer).startOfWeek.apply(_dateLocalizer5, arguments); + } + }; - return compat.cloneElement(child, { - className: cn(child.props.className, 'rw-popup rw-widget') - }); + exports.date = date; + exports['default'] = { number: number, date: date }; + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + /* WEBPACK VAR INJECTION */(function(process) {/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule invariant + */ + + 'use strict'; + + /** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + + var invariant = function(condition, format, a, b, c, d, e, f) { + if (process.env.NODE_ENV !== 'production') { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } } - }); - module.exports = React.createClass({ + if (!condition) { + var error; + if (format === undefined) { + error = new Error( + 'Minified exception occurred; use the non-minified dev environment ' + + 'for the full error message and additional helpful warnings.' + ); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error( + 'Invariant Violation: ' + + format.replace(/%s/g, function() { return args[argIndex++]; }) + ); + } - displayName: 'Popup', + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } + }; - propTypes: { - open: React.PropTypes.bool, - dropUp: React.PropTypes.bool, - duration: React.PropTypes.number, + module.exports = invariant; + + /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) + +/***/ }, +/* 20 */ +/***/ function(module, exports) { + + 'use strict'; + var idCount = 0; + + var _ = module.exports = { + + has: has, + + result: function result(value) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } - onRequestClose: React.PropTypes.func.isRequired, - onClosing: React.PropTypes.func, - onOpening: React.PropTypes.func, - onClose: React.PropTypes.func, - onOpen: React.PropTypes.func + return typeof value === 'function' ? value.apply(undefined, args) : value; }, - getInitialState: function getInitialState() { - return {}; + isShallowEqual: function isShallowEqual(a, b) { + if (a === b) return true; + if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); + + if (typeof a !== 'object' && typeof b !== 'object') return a === b; + + if (typeof a !== typeof b) return false; + + return shallowEqual(a, b); }, - getDefaultProps: function getDefaultProps() { - return { - duration: 200, - open: false, - onClosing: function onClosing() {}, - onOpening: function onOpening() {}, - onClose: function onClose() {}, - onOpen: function onOpen() {} - }; + transform: function transform(obj, cb, seed) { + _.each(obj, cb.bind(null, seed = seed || (Array.isArray(obj) ? [] : {}))); + return seed; }, - // componentDidMount(){ - // !this.props.open && this.close(0) - // }, - componentWillMount: function componentWillMount() { - !this.props.open && (this._initialPosition = true); + each: function each(obj, cb, thisArg) { + if (Array.isArray(obj)) return obj.forEach(cb, thisArg); + + for (var key in obj) if (has(obj, key)) cb.call(thisArg, obj[key], key, obj); }, - componentWillReceiveProps: function componentWillReceiveProps(nextProps) { - this.setState({ - contentChanged: childKey(nextProps.children) !== childKey(this.props.children) - }); + pick: function pick(obj, keys) { + keys = [].concat(keys); + return _.transform(obj, function (mapped, val, key) { + if (keys.indexOf(key) !== -1) mapped[key] = val; + }, {}); }, - componentDidUpdate: function componentDidUpdate(pvProps) { - var closing = pvProps.open && !this.props.open, - opening = !pvProps.open && this.props.open, - open = this.props.open; + omit: function omit(obj, keys) { + keys = [].concat(keys); + return _.transform(obj, function (mapped, val, key) { + if (keys.indexOf(key) === -1) mapped[key] = val; + }, {}); + }, - if (opening) this.open();else if (closing) this.close();else if (open) this.height(); + find: function find(arr, cb, thisArg) { + var result; + if (Array.isArray(arr)) { + arr.every(function (val, idx) { + if (cb.call(thisArg, val, idx, arr)) return (result = val, false); + return true; + }); + return result; + } else for (var key in arr) if (has(arr, key)) if (cb.call(thisArg, arr[key], key, arr)) return arr[key]; }, - render: function render() { - var _props = this.props; - var className = _props.className; - var open = _props.open; - var dropUp = _props.dropUp; - var props = babelHelpers.objectWithoutProperties(_props, ['className', 'open', 'dropUp']); - var display = open ? 'block' : void 0; + chunk: function chunk(array, chunkSize) { + var index = 0, + length = array ? array.length : 0, + result = []; - if (this._initialPosition) { - display = 'none'; - } + chunkSize = Math.max(+chunkSize || 1, 1); - return React.createElement( - 'div', - babelHelpers._extends({}, props, { - style: babelHelpers._extends({ - display: display, - height: this.state.height - }, props.style), - className: cn(className, 'rw-popup-container', { 'rw-dropup': dropUp }) - }), - React.createElement( - PopupContent, - { ref: 'content' }, - this.props.children - ) - ); - }, + while (index < length) result.push(array.slice(index, index += chunkSize)); - reset: function reset() { - var container = compat.findDOMNode(this), - content = compat.findDOMNode(this.refs.content), - style = { display: 'block', overflow: 'hidden' }; + return result; + }, - css(container, style); - this.height(); - css(content, properties('top', this.props.dropUp ? '100%' : '-100%')); + splat: function splat(obj) { + return obj == null ? [] : [].concat(obj); }, - height: function height() { - var el = compat.findDOMNode(this), - content = compat.findDOMNode(this.refs.content), - margin = parseInt(css(content, 'margin-top'), 10) + parseInt(css(content, 'margin-bottom'), 10); + noop: function noop() {}, - var height = getHeight(content) + (isNaN(margin) ? 0 : margin); + uniqueId: function uniqueId(prefix) { + return '' + ((prefix == null ? '' : prefix) + ++idCount); + } + }; - if (this.state.height !== height) { - el.style.height = height + 'px'; - this.setState({ height: height }); - } - }, + function has(o, k) { + return o ? Object.prototype.hasOwnProperty.call(o, k) : false; + } - open: function open() { - var self = this, - anim = compat.findDOMNode(this), - el = compat.findDOMNode(this.refs.content); + function eql(a, b) { + return a === b; + } - this.ORGINAL_POSITION = css(el, 'position'); - this._isOpening = true; + /** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + */ + function shallowEqual(objA, objB) { - if (this._initialPosition) { - this._initialPosition = false; - this.reset(); - } else this.height(); + if (objA == null || objB == null) return false; - this.props.onOpening(); + var keysA = Object.keys(objA), + keysB = Object.keys(objB); - anim.className += ' rw-popup-animating'; - el.style.position = 'absolute'; + if (keysA.length !== keysB.length) return false; - config.animate(el, { top: 0 }, self.props.duration, 'ease', function () { - if (!self._isOpening) return; + for (var i = 0; i < keysA.length; i++) if (!has(objB, keysA[i]) || !eql(objA[keysA[i]], objB[keysA[i]])) return false; - anim.className = anim.className.replace(/ ?rw-popup-animating/g, ''); + return true; + } - el.style.position = self.ORGINAL_POSITION; - anim.style.overflow = 'visible'; - self.ORGINAL_POSITION = null; +/***/ }, +/* 21 */ +/***/ function(module, exports) { - self.props.onOpen(); - }); - }, + module.exports = __WEBPACK_EXTERNAL_MODULE_21__; - close: function close(dur) { - var self = this, - el = compat.findDOMNode(this.refs.content), - anim = compat.findDOMNode(this); +/***/ }, +/* 22 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var babelHelpers = __webpack_require__(2); + + exports.__esModule = true; + + var _react = __webpack_require__(21); + + var _react2 = babelHelpers.interopRequireDefault(_react); + + var _domHelpersActiveElement = __webpack_require__(23); + + var _domHelpersActiveElement2 = babelHelpers.interopRequireDefault(_domHelpersActiveElement); + + var _domHelpersQueryContains = __webpack_require__(25); + + var _domHelpersQueryContains2 = babelHelpers.interopRequireDefault(_domHelpersQueryContains); + + var _classnames = __webpack_require__(26); + + var _classnames2 = babelHelpers.interopRequireDefault(_classnames); + + var _util_ = __webpack_require__(20); - this.ORGINAL_POSITION = css(el, 'position'); + var _util_2 = babelHelpers.interopRequireDefault(_util_); + + var _Popup = __webpack_require__(27); + + var _Popup2 = babelHelpers.interopRequireDefault(_Popup); + + var _utilCompat = __webpack_require__(31); + + var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); + + var _utilPropTypes = __webpack_require__(33); + + var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); + + var _List = __webpack_require__(35); + + var _List2 = babelHelpers.interopRequireDefault(_List); + + var _ListGroupable = __webpack_require__(41); + + var _ListGroupable2 = babelHelpers.interopRequireDefault(_ListGroupable); + + var _utilValidateListInterface = __webpack_require__(43); + + var _utilValidateListInterface2 = babelHelpers.interopRequireDefault(_utilValidateListInterface); + + var _uncontrollable = __webpack_require__(44); + + var _uncontrollable2 = babelHelpers.interopRequireDefault(_uncontrollable); + + var _utilDataHelpers = __webpack_require__(37); + + var _utilInteraction = __webpack_require__(47); + + var _utilWidgetHelpers = __webpack_require__(38); + + var omit = _util_2['default'].omit; + var pick = _util_2['default'].pick; + var result = _util_2['default'].result; + + var propTypes = { + //-- controlled props ----------- + value: _react2['default'].PropTypes.any, + onChange: _react2['default'].PropTypes.func, + open: _react2['default'].PropTypes.bool, + onToggle: _react2['default'].PropTypes.func, + //------------------------------------ + + data: _react2['default'].PropTypes.array, + valueField: _react2['default'].PropTypes.string, + textField: _utilPropTypes2['default'].accessor, + + valueComponent: _utilPropTypes2['default'].elementType, + itemComponent: _utilPropTypes2['default'].elementType, + listComponent: _utilPropTypes2['default'].elementType, + + groupComponent: _utilPropTypes2['default'].elementType, + groupBy: _utilPropTypes2['default'].accessor, + + onSelect: _react2['default'].PropTypes.func, + + searchTerm: _react2['default'].PropTypes.string, + onSearch: _react2['default'].PropTypes.func, + + busy: _react2['default'].PropTypes.bool, + + delay: _react2['default'].PropTypes.number, + + dropUp: _react2['default'].PropTypes.bool, + duration: _react2['default'].PropTypes.number, //popup + + disabled: _utilPropTypes2['default'].disabled, + + readOnly: _utilPropTypes2['default'].readOnly, + + messages: _react2['default'].PropTypes.shape({ + open: _utilPropTypes2['default'].message, + emptyList: _utilPropTypes2['default'].message, + emptyFilter: _utilPropTypes2['default'].message, + filterPlaceholder: _utilPropTypes2['default'].message + }) + }; + + var DropdownList = _react2['default'].createClass(babelHelpers.createDecoratedObject([{ + key: 'displayName', + initializer: function initializer() { + return 'DropdownList'; + } + }, { + key: 'mixins', + initializer: function initializer() { + return [__webpack_require__(48), __webpack_require__(49), __webpack_require__(50), __webpack_require__(51), __webpack_require__(56), __webpack_require__(40)()]; + } + }, { + key: 'propTypes', + initializer: function initializer() { + return propTypes; + } + }, { + key: 'getDefaultProps', + value: function getDefaultProps() { + return { + delay: 500, + value: '', + open: false, + data: [], + searchTerm: '', + messages: msgs(), + ariaActiveDescendantKey: 'dropdownlist' + }; + } + }, { + key: 'getInitialState', + value: function getInitialState() { + var _props = this.props; + var open = _props.open; + var filter = _props.filter; + var value = _props.value; + var data = _props.data; + var searchTerm = _props.searchTerm; + var valueField = _props.valueField; + + var processed = filter ? this.filter(data, searchTerm) : data, + initialIdx = _utilDataHelpers.dataIndexOf(data, value, valueField); + + return { + filteredData: open && filter ? processed : null, + selectedItem: processed[initialIdx], + focusedItem: processed[initialIdx] || data[0] + }; + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate() { + this.refs.list && _utilValidateListInterface2['default'](this.refs.list); + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(props) { + var open = props.open; + var filter = props.filter; + var value = props.value; + var data = props.data; + var searchTerm = props.searchTerm; + var valueField = props.valueField; + + var processed = filter ? this.filter(data, searchTerm) : data, + idx = _utilDataHelpers.dataIndexOf(data, value, valueField); + + this.setState({ + filteredData: open && filter ? processed : null, + selectedItem: processed[idx], + focusedItem: processed[! ~idx ? 0 : idx] + }); + } + }, { + key: 'render', + value: function render() { + var _cx, + _this = this; + + var _props2 = this.props; + var className = _props2.className; + var tabIndex = _props2.tabIndex; + var filter = _props2.filter; + var valueField = _props2.valueField; + var textField = _props2.textField; + var groupBy = _props2.groupBy; + var messages = _props2.messages; + var data = _props2.data; + var busy = _props2.busy; + var dropUp = _props2.dropUp; + var placeholder = _props2.placeholder; + var value = _props2.value; + var open = _props2.open; + var disabled = _props2.disabled; + var readOnly = _props2.readOnly; + var ValueComponent = _props2.valueComponent; + var List = _props2.listComponent; + + List = List || groupBy && _ListGroupable2['default'] || _List2['default']; + + var elementProps = omit(this.props, Object.keys(propTypes)); + var listProps = pick(this.props, Object.keys(List.propTypes)); + var popupProps = pick(this.props, Object.keys(_Popup2['default'].propTypes)); + + var _state = this.state; + var focusedItem = _state.focusedItem; + var selectedItem = _state.selectedItem; + var focused = _state.focused; + + var items = this._data(), + valueItem = _utilDataHelpers.dataItem(data, value, valueField), + // take value from the raw data + listID = _utilWidgetHelpers.instanceId(this, '__listbox'); + + var shouldRenderList = _utilWidgetHelpers.isFirstFocusedRender(this) || open; + + messages = msgs(messages); + + return _react2['default'].createElement( + 'div', + babelHelpers._extends({}, elementProps, { + ref: 'input', + role: 'combobox', + tabIndex: tabIndex || '0', + 'aria-expanded': open, + 'aria-haspopup': true, + 'aria-owns': listID, + 'aria-busy': !!busy, + 'aria-live': !open && 'polite', + //aria-activedescendant={activeID} + 'aria-autocomplete': 'list', + 'aria-disabled': disabled, + 'aria-readonly': readOnly, + onKeyDown: this._keyDown, + onClick: this._click, + onFocus: this._focus.bind(null, true), + onBlur: this._focus.bind(null, false), + className: _classnames2['default'](className, 'rw-dropdownlist', 'rw-widget', (_cx = { + 'rw-state-disabled': disabled, + 'rw-state-readonly': readOnly, + 'rw-state-focus': focused, + 'rw-rtl': this.isRtl() + + }, _cx['rw-open' + (dropUp ? '-up' : '')] = open, _cx)) }), + _react2['default'].createElement( + 'span', + { className: 'rw-dropdownlist-picker rw-select rw-btn' }, + _react2['default'].createElement( + 'i', + { className: 'rw-i rw-i-caret-down' + (busy ? ' rw-loading' : '') }, + _react2['default'].createElement( + 'span', + { className: 'rw-sr' }, + result(messages.open, this.props) + ) + ) + ), + _react2['default'].createElement( + 'div', + { + className: 'rw-input' + }, + !valueItem && placeholder ? _react2['default'].createElement( + 'span', + { className: 'rw-placeholder' }, + placeholder + ) : this.props.valueComponent ? _react2['default'].createElement(ValueComponent, { item: valueItem }) : _utilDataHelpers.dataText(valueItem, textField) + ), + _react2['default'].createElement( + _Popup2['default'], + babelHelpers._extends({}, popupProps, { + onOpen: function () { + return _this.focus(); + }, + onOpening: function () { + return _this.refs.list.forceUpdate(); + }, + onRequestClose: this.close + }), + _react2['default'].createElement( + 'div', + null, + filter && this._renderFilter(messages), + shouldRenderList && _react2['default'].createElement(List, babelHelpers._extends({ ref: 'list' + }, listProps, { + data: items, + id: listID, + 'aria-live': open && 'polite', + 'aria-labelledby': _utilWidgetHelpers.instanceId(this), + 'aria-hidden': !this.props.open, + selected: selectedItem, + focused: open ? focusedItem : null, + onSelect: this._onSelect, + onMove: this._scrollTo, + messages: { + emptyList: data.length ? messages.emptyFilter : messages.emptyList + } })) + ) + ) + ); + } + }, { + key: '_renderFilter', + value: function _renderFilter(messages) { + var _this2 = this; + + return _react2['default'].createElement( + 'div', + { ref: 'filterWrapper', className: 'rw-filter-input' }, + _react2['default'].createElement( + 'span', + { className: 'rw-select rw-btn' }, + _react2['default'].createElement('i', { className: 'rw-i rw-i-search' }) + ), + _react2['default'].createElement('input', { ref: 'filter', className: 'rw-input', + placeholder: _util_2['default'].result(messages.filterPlaceholder, this.props), + value: this.props.searchTerm, + onChange: function (e) { + return _utilWidgetHelpers.notify(_this2.props.onSearch, e.target.value); + } }) + ); + } + }, { + key: '_focus', + decorators: [_utilInteraction.widgetEnabled], + value: function _focus(focused, e) { + var _this3 = this; + + this.setTimeout('focus', function () { + if (!focused) _this3.close(); + + if (focused !== _this3.state.focused) { + _utilWidgetHelpers.notify(_this3.props[focused ? 'onFocus' : 'onBlur'], e); + _this3.setState({ focused: focused }); + } + }); + } + }, { + key: '_onSelect', + decorators: [_utilInteraction.widgetEditable], + value: function _onSelect(data) { + this.close(); + _utilWidgetHelpers.notify(this.props.onSelect, data); + this.change(data); + this.focus(this); + } + }, { + key: '_click', + decorators: [_utilInteraction.widgetEditable], + value: function _click(e) { + var wrapper = this.refs.filterWrapper; + + if (!this.props.filter || !this.props.open) this.toggle();else if (!_domHelpersQueryContains2['default'](_utilCompat2['default'].findDOMNode(wrapper), e.target)) this.close(); + + _utilWidgetHelpers.notify(this.props.onClick, e); + } + }, { + key: '_keyDown', + decorators: [_utilInteraction.widgetEditable], + value: function _keyDown(e) { + var _this4 = this; + + var self = this, + key = e.key, + alt = e.altKey, + list = this.refs.list, + filtering = this.props.filter, + focusedItem = this.state.focusedItem, + selectedItem = this.state.selectedItem, + isOpen = this.props.open, + closeWithFocus = function closeWithFocus() { + _this4.close(), _utilCompat2['default'].findDOMNode(_this4).focus(); + }; + + if (key === 'End') { + if (isOpen) this.setState({ focusedItem: list.last() });else change(list.last()); + e.preventDefault(); + } else if (key === 'Home') { + if (isOpen) this.setState({ focusedItem: list.first() });else change(list.first()); + e.preventDefault(); + } else if (key === 'Escape' && isOpen) { + closeWithFocus(); + } else if ((key === 'Enter' || key === ' ' && !filtering) && isOpen) { + change(this.state.focusedItem, true); + } else if (key === 'ArrowDown') { + if (alt) this.open();else if (isOpen) this.setState({ focusedItem: list.next(focusedItem) });else change(list.next(selectedItem)); + e.preventDefault(); + } else if (key === 'ArrowUp') { + if (alt) closeWithFocus();else if (isOpen) this.setState({ focusedItem: list.prev(focusedItem) });else change(list.prev(selectedItem)); + e.preventDefault(); + } else if (!(this.props.filter && isOpen)) this.search(String.fromCharCode(e.keyCode), function (item) { + isOpen ? _this4.setState({ focusedItem: item }) : change(item); + }); + + _utilWidgetHelpers.notify(this.props.onKeyDown, [e]); + + function change(item, fromList) { + if (!item) return; + fromList ? self._onSelect(item) : self.change(item); + } + } + }, { + key: 'change', + value: function change(data) { + if (!_util_2['default'].isShallowEqual(data, this.props.value)) { + _utilWidgetHelpers.notify(this.props.onChange, data); + _utilWidgetHelpers.notify(this.props.onSearch, ''); + this.close(); + } + } + }, { + key: 'focus', + value: function focus(target) { + var inst = target || (this.props.filter && this.props.open ? this.refs.filter : this.refs.input); - this._isOpening = false; - this.height(); - this.props.onClosing(); + if (_domHelpersActiveElement2['default']() !== _utilCompat2['default'].findDOMNode(inst)) _utilCompat2['default'].findDOMNode(inst).focus(); + } + }, { + key: '_data', + value: function _data() { + return this.state.filteredData || this.props.data.concat(); + } + }, { + key: 'search', + value: function search(character, cb) { + var _this5 = this; - anim.style.overflow = 'hidden'; - anim.className += ' rw-popup-animating'; - el.style.position = 'absolute'; + var word = ((this._searchTerm || '') + character).toLowerCase(); - config.animate(el, { top: this.props.dropUp ? '100%' : '-100%' }, dur === undefined ? this.props.duration : dur, 'ease', function () { - if (self._isOpening) return; + this._searchTerm = word; - el.style.position = self.ORGINAL_POSITION; - anim.className = anim.className.replace(/ ?rw-popup-animating/g, ''); + this.setTimeout('search', function () { + var list = _this5.refs.list, + key = _this5.props.open ? 'focusedItem' : 'selectedItem', + item = list.next(_this5.state[key], word); - anim.style.display = 'none'; - self.ORGINAL_POSITION = null; - self.props.onClose(); - }); + _this5._searchTerm = ''; + if (item) cb(item); + }, this.props.delay); } + }, { + key: 'open', + value: function open() { + _utilWidgetHelpers.notify(this.props.onToggle, true); + } + }, { + key: 'close', + value: function close() { + _utilWidgetHelpers.notify(this.props.onToggle, false); + } + }, { + key: 'toggle', + value: function toggle() { + this.props.open ? this.close() : this.open(); + } + }])); - }); - - function childKey(children) { - var nextChildMapping = React.Children.map(children, function (c) { - return c; - }); - for (var key in nextChildMapping) return key; + function msgs(msgs) { + return babelHelpers._extends({ + open: 'open dropdown', + filterPlaceholder: '', + emptyList: 'There are no items in this list', + emptyFilter: 'The filter returned no results' + }, msgs); } + exports['default'] = _uncontrollable2['default'](DropdownList, { open: 'onToggle', value: 'onChange', searchTerm: 'onSearch' }); + module.exports = exports['default']; + /***/ }, -/* 13 */ +/* 23 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var camelize = __webpack_require__(14), - hyphenate = __webpack_require__(16), - _getComputedStyle = __webpack_require__(18), - removeStyle = __webpack_require__(19); - - var has = Object.prototype.hasOwnProperty; - - module.exports = function style(node, property, value) { - var css = '', - props = property; - - if (typeof property === 'string') { + var babelHelpers = __webpack_require__(12); - if (value === undefined) return node.style[camelize(property)] || _getComputedStyle(node).getPropertyValue(hyphenate(property));else (props = {})[property] = value; - } + exports.__esModule = true; - for (var key in props) if (has.call(props, key)) { - !props[key] && props[key] !== 0 ? removeStyle(node, hyphenate(key)) : css += hyphenate(key) + ':' + props[key] + ';'; - } + /** + * document.activeElement + */ + exports['default'] = activeElement; - node.style.cssText += ';' + css; - }; + var _ownerDocument = __webpack_require__(24); -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { + var _ownerDocument2 = babelHelpers.interopRequireDefault(_ownerDocument); - /** - * Copyright 2014-2015, Facebook, Inc. - * All rights reserved. - * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/camelizeStyleName.js - */ + function activeElement() { + var doc = arguments[0] === undefined ? document : arguments[0]; - 'use strict'; - var camelize = __webpack_require__(15); - var msPattern = /^-ms-/; + try { + return doc.activeElement; + } catch (e) {} + } - module.exports = function camelizeStyleName(string) { - return camelize(string.replace(msPattern, 'ms-')); - }; + module.exports = exports['default']; /***/ }, -/* 15 */ +/* 24 */ /***/ function(module, exports) { "use strict"; - var rHyphen = /-(.)/g; + exports.__esModule = true; + exports["default"] = ownerDocument; - module.exports = function camelize(string) { - return string.replace(rHyphen, function (_, chr) { - return chr.toUpperCase(); - }); - }; + function ownerDocument(node) { + return node && node.ownerDocument || document; + } + + module.exports = exports["default"]; /***/ }, -/* 16 */ +/* 25 */ /***/ function(module, exports, __webpack_require__) { - /** - * Copyright 2013-2014, Facebook, Inc. - * All rights reserved. - * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/hyphenateStyleName.js - */ + 'use strict'; + var canUseDOM = __webpack_require__(15); - "use strict"; + var contains = (function () { + var root = canUseDOM && document.documentElement; - var hyphenate = __webpack_require__(17); - var msPattern = /^ms-/; + return root && root.contains ? function (context, node) { + return context.contains(node); + } : root && root.compareDocumentPosition ? function (context, node) { + return context === node || !!(context.compareDocumentPosition(node) & 16); + } : function (context, node) { + if (node) do { + if (node === context) return true; + } while (node = node.parentNode); - module.exports = function hyphenateStyleName(string) { - return hyphenate(string).replace(msPattern, "-ms-"); - }; + return false; + }; + })(); + + module.exports = contains; /***/ }, -/* 17 */ -/***/ function(module, exports) { +/* 26 */ +/***/ function(module, exports, __webpack_require__) { - 'use strict'; + var __WEBPACK_AMD_DEFINE_RESULT__;/*! + Copyright (c) 2015 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames + */ + /* global define */ - var rUpper = /([A-Z])/g; + (function () { + 'use strict'; - module.exports = function hyphenate(string) { - return string.replace(rUpper, '-$1').toLowerCase(); - }; + var hasOwn = {}.hasOwnProperty; -/***/ }, -/* 18 */ -/***/ function(module, exports, __webpack_require__) { + function classNames () { + var classes = ''; - 'use strict'; + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + if (!arg) continue; - var babelHelpers = __webpack_require__(6); + var argType = typeof arg; - var _utilCamelizeStyle = __webpack_require__(14); + if (argType === 'string' || argType === 'number') { + classes += ' ' + arg; + } else if (Array.isArray(arg)) { + classes += ' ' + classNames.apply(null, arg); + } else if (argType === 'object') { + for (var key in arg) { + if (hasOwn.call(arg, key) && arg[key]) { + classes += ' ' + key; + } + } + } + } - var _utilCamelizeStyle2 = babelHelpers.interopRequireDefault(_utilCamelizeStyle); + return classes.substr(1); + } - var rposition = /^(top|right|bottom|left)$/; - var rnumnonpx = /^([+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|))(?!px)[a-z%]+$/i; + if (typeof module !== 'undefined' && module.exports) { + module.exports = classNames; + } else if (true) { + // register as 'classnames', consistent with npm package name + !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { + return classNames; + }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else { + window.classNames = classNames; + } + }()); - module.exports = function _getComputedStyle(node) { - if (!node) throw new TypeError('No Element passed to `getComputedStyle()`'); - var doc = node.ownerDocument; - return 'defaultView' in doc ? doc.defaultView.opener ? node.ownerDocument.defaultView.getComputedStyle(node, null) : window.getComputedStyle(node, null) : { //ie 8 "magic" from: https://github.com/jquery/jquery/blob/1.11-stable/src/css/curCSS.js#L72 - getPropertyValue: function getPropertyValue(prop) { - var style = node.style; +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { - prop = (0, _utilCamelizeStyle2['default'])(prop); + 'use strict'; - if (prop == 'float') prop = 'styleFloat'; + var babelHelpers = __webpack_require__(2); - var current = node.currentStyle[prop] || null; + var _react = __webpack_require__(21); - if (current == null && style && style[prop]) current = style[prop]; + var _react2 = babelHelpers.interopRequireDefault(_react); - if (rnumnonpx.test(current) && !rposition.test(prop)) { - // Remember the original values - var left = style.left; - var runStyle = node.runtimeStyle; - var rsLeft = runStyle && runStyle.left; + var _domHelpersStyle = __webpack_require__(7); - // Put in the new values to get a computed value out - if (rsLeft) runStyle.left = node.currentStyle.left; + var _domHelpersStyle2 = babelHelpers.interopRequireDefault(_domHelpersStyle); - style.left = prop === 'fontSize' ? '1em' : current; - current = style.pixelLeft + 'px'; + var _domHelpersQueryHeight = __webpack_require__(28); - // Revert the changed values - style.left = left; - if (rsLeft) runStyle.left = rsLeft; - } + var _domHelpersQueryHeight2 = babelHelpers.interopRequireDefault(_domHelpersQueryHeight); - return current; - } - }; - }; + var _utilConfiguration = __webpack_require__(4); -/***/ }, -/* 19 */ -/***/ function(module, exports) { + var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); - 'use strict'; + var _classnames = __webpack_require__(26); - module.exports = function removeStyle(node, key) { - return 'removeProperty' in node.style ? node.style.removeProperty(key) : node.style.removeAttribute(key); - }; + var _classnames2 = babelHelpers.interopRequireDefault(_classnames); -/***/ }, -/* 20 */ -/***/ function(module, exports, __webpack_require__) { + var _utilCompat = __webpack_require__(31); - 'use strict'; + var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var offset = __webpack_require__(21), - getWindow = __webpack_require__(22); + var transform = _utilConfiguration2['default'].animate.transform; - module.exports = function height(node, client) { - var win = getWindow(node); - return win ? win.innerHeight : client ? node.clientHeight : offset(node).height; - }; + function properties(prop, value) { + var _ref, _ref2; -/***/ }, -/* 21 */ -/***/ function(module, exports, __webpack_require__) { + var TRANSLATION_MAP = _utilConfiguration2['default'].animate.TRANSLATION_MAP; - 'use strict'; - var contains = __webpack_require__(8), - getWindow = __webpack_require__(22), - ownerDocument = __webpack_require__(7); + if (TRANSLATION_MAP && TRANSLATION_MAP[prop]) return (_ref = {}, _ref[transform] = TRANSLATION_MAP[prop] + '(' + value + ')', _ref); - module.exports = function offset(node) { - var doc = ownerDocument(node), - win = getWindow(doc), - docElem = doc && doc.documentElement, - box = { top: 0, left: 0, height: 0, width: 0 }; + return (_ref2 = {}, _ref2[prop] = value, _ref2); + } - if (!doc) return; + var PopupContent = _react2['default'].createClass({ + displayName: 'PopupContent', - // Make sure it's not a disconnected DOM node - if (!contains(docElem, node)) return box; + render: function render() { + var child = this.props.children; - if (node.getBoundingClientRect !== undefined) box = node.getBoundingClientRect(); + if (!child) return _react2['default'].createElement('span', { className: 'rw-popup rw-widget' }); - if (box.width || box.height) { + child = _react2['default'].Children.only(this.props.children); - box = { - top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0), - left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0), - width: (box.width == null ? node.offsetWidth : box.width) || 0, - height: (box.height == null ? node.offsetHeight : box.height) || 0 - }; + return _react.cloneElement(child, { + className: _classnames2['default'](child.props.className, 'rw-popup rw-widget') + }); } + }); - return box; - }; - -/***/ }, -/* 22 */ -/***/ function(module, exports) { + module.exports = _react2['default'].createClass({ - 'use strict'; + displayName: 'Popup', - module.exports = function getWindow(node) { - return node === node.window ? node : node.nodeType === 9 ? node.defaultView || node.parentWindow : false; - }; + propTypes: { + open: _react2['default'].PropTypes.bool, + dropUp: _react2['default'].PropTypes.bool, + duration: _react2['default'].PropTypes.number, -/***/ }, -/* 23 */ -/***/ function(module, exports, __webpack_require__) { + onRequestClose: _react2['default'].PropTypes.func.isRequired, + onClosing: _react2['default'].PropTypes.func, + onOpening: _react2['default'].PropTypes.func, + onClose: _react2['default'].PropTypes.func, + onOpen: _react2['default'].PropTypes.func + }, - 'use strict'; + getInitialState: function getInitialState() { + return {}; + }, - var babelHelpers = __webpack_require__(3); + getDefaultProps: function getDefaultProps() { + return { + duration: 200, + open: false, + onClosing: function onClosing() {}, + onOpening: function onOpening() {}, + onClose: function onClose() {}, + onOpen: function onOpen() {} + }; + }, - exports.__esModule = true; + // componentDidMount(){ + // !this.props.open && this.close(0) + // }, + componentWillMount: function componentWillMount() { + !this.props.open && (this._initialPosition = true); + }, - var _domAnimate = __webpack_require__(24); + componentWillReceiveProps: function componentWillReceiveProps(nextProps) { + this.setState({ + contentChanged: childKey(nextProps.children) !== childKey(this.props.children) + }); + }, - var _domAnimate2 = babelHelpers.interopRequireDefault(_domAnimate); + componentDidUpdate: function componentDidUpdate(pvProps) { + var closing = pvProps.open && !this.props.open, + opening = !pvProps.open && this.props.open, + open = this.props.open; - function error() { - throw new Error('[React Widgets] You are attempting to use a widget that requires localization (DateTimePicker, NumberPicker)' + 'but there is no localizer set. In order to use these widgets please install a localizer'); - } + if (opening) this.open();else if (closing) this.close();else if (open) this.height(); + }, - var dummy = { - formats: error, - parse: error, - format: error, - firstOfWeek: error - }; + render: function render() { + var _props = this.props; + var className = _props.className; + var open = _props.open; + var dropUp = _props.dropUp; + var props = babelHelpers.objectWithoutProperties(_props, ['className', 'open', 'dropUp']); + var display = open ? 'block' : void 0; - exports['default'] = { + if (this._initialPosition) { + display = 'none'; + } - animate: _domAnimate2['default'], + return _react2['default'].createElement( + 'div', + babelHelpers._extends({}, props, { + style: babelHelpers._extends({ + display: display, + height: this.state.height + }, props.style), + className: _classnames2['default'](className, 'rw-popup-container', { 'rw-dropup': dropUp }) + }), + _react2['default'].createElement( + PopupContent, + { ref: 'content' }, + this.props.children + ) + ); + }, - locale: { - date: dummy, - number: dummy - } - }; - module.exports = exports['default']; + reset: function reset() { + var container = _utilCompat2['default'].findDOMNode(this), + content = _utilCompat2['default'].findDOMNode(this.refs.content), + style = { display: 'block', overflow: 'hidden' }; -/***/ }, -/* 24 */ -/***/ function(module, exports, __webpack_require__) { + _domHelpersStyle2['default'](container, style); + this.height(); + _domHelpersStyle2['default'](content, properties('top', this.props.dropUp ? '100%' : '-100%')); + }, - 'use strict'; - var hyphenate = __webpack_require__(17), - css = __webpack_require__(13), - on = __webpack_require__(25), - off = __webpack_require__(26), - transitionProps = __webpack_require__(27); + height: function height() { + var el = _utilCompat2['default'].findDOMNode(this), + content = _utilCompat2['default'].findDOMNode(this.refs.content), + margin = parseInt(_domHelpersStyle2['default'](content, 'margin-top'), 10) + parseInt(_domHelpersStyle2['default'](content, 'margin-bottom'), 10); - var has = Object.prototype.hasOwnProperty, - reset = {}, - TRANSLATION_MAP = { - left: 'translateX', - right: 'translateX', - top: 'translateY', - bottom: 'translateY' - }; + var height = _domHelpersQueryHeight2['default'](content) + (isNaN(margin) ? 0 : margin); - reset[transitionProps.property] = reset[transitionProps.duration] = reset[transitionProps.delay] = reset[transitionProps.timing] = ''; + if (this.state.height !== height) { + el.style.height = height + 'px'; + this.setState({ height: height }); + } + }, - animate.endEvent = transitionProps.end; - animate.transform = transitionProps.transform; - animate.TRANSLATION_MAP = TRANSLATION_MAP; + open: function open() { + var self = this, + anim = _utilCompat2['default'].findDOMNode(this), + el = _utilCompat2['default'].findDOMNode(this.refs.content); - module.exports = animate; + this.ORGINAL_POSITION = _domHelpersStyle2['default'](el, 'position'); + this._isOpening = true; - // super lean animate function for transitions - // doesn't support all translations to keep it matching the jquery API - /** - * code in part from: Zepto 1.1.4 | zeptojs.com/license - */ - function animate(node, properties, duration, easing, callback) { - var cssProperties = [], - fakeEvent = { target: node, currentTarget: node }, - cssValues = {}, - transforms = '', - fired; + if (this._initialPosition) { + this._initialPosition = false; + this.reset(); + } else this.height(); - if (typeof easing === 'function') callback = easing, easing = null; + this.props.onOpening(); - if (!transitionProps.end) duration = 0; - if (duration === undefined) duration = 200; + anim.className += ' rw-popup-animating'; + el.style.position = 'absolute'; - for (var key in properties) if (has.call(properties, key)) { - if (/(top|bottom)/.test(key)) transforms += TRANSLATION_MAP[key] + '(' + properties[key] + ') ';else { - cssValues[key] = properties[key]; - cssProperties.push(hyphenate(key)); - } - } + _utilConfiguration2['default'].animate(el, { top: 0 }, self.props.duration, 'ease', function () { + if (!self._isOpening) return; - if (transforms) { - cssValues[transitionProps.transform] = transforms; - cssProperties.push(transitionProps.transform); - } + anim.className = anim.className.replace(/ ?rw-popup-animating/g, ''); - if (duration > 0) { - cssValues[transitionProps.property] = cssProperties.join(', '); - cssValues[transitionProps.duration] = duration / 1000 + 's'; - cssValues[transitionProps.delay] = 0 + 's'; - cssValues[transitionProps.timing] = easing || 'linear'; + el.style.position = self.ORGINAL_POSITION; + anim.style.overflow = 'visible'; + self.ORGINAL_POSITION = null; - on(node, transitionProps.end, done); + self.props.onOpen(); + }); + }, - setTimeout(function () { - if (!fired) done(fakeEvent); - }, duration + 500); - } + close: function close(dur) { + var self = this, + el = _utilCompat2['default'].findDOMNode(this.refs.content), + anim = _utilCompat2['default'].findDOMNode(this); - node.clientLeft; // trigger page reflow - css(node, cssValues); + this.ORGINAL_POSITION = _domHelpersStyle2['default'](el, 'position'); - if (duration <= 0) setTimeout(done.bind(null, fakeEvent), 0); + this._isOpening = false; + this.height(); + this.props.onClosing(); - function done(event) { - if (event.target !== event.currentTarget) return; + anim.style.overflow = 'hidden'; + anim.className += ' rw-popup-animating'; + el.style.position = 'absolute'; - fired = true; - off(event.target, transitionProps.end, done); - css(node, reset); - callback && callback.call(this); - } - } + _utilConfiguration2['default'].animate(el, { top: this.props.dropUp ? '100%' : '-100%' }, dur === undefined ? this.props.duration : dur, 'ease', function () { + if (self._isOpening) return; -/***/ }, -/* 25 */ -/***/ function(module, exports, __webpack_require__) { + el.style.position = self.ORGINAL_POSITION; + anim.className = anim.className.replace(/ ?rw-popup-animating/g, ''); - 'use strict'; - var canUseDOM = __webpack_require__(9); - var on = function on() {}; + anim.style.display = 'none'; + self.ORGINAL_POSITION = null; + self.props.onClose(); + }); + } - if (canUseDOM) { - on = (function () { + }); - if (document.addEventListener) return function (node, eventName, handler, capture) { - return node.addEventListener(eventName, handler, capture || false); - };else if (document.attachEvent) return function (node, eventName, handler) { - return node.attachEvent('on' + eventName, handler); - }; - })(); + function childKey(children) { + var nextChildMapping = _react2['default'].Children.map(children, function (c) { + return c; + }); + for (var key in nextChildMapping) return key; } - module.exports = on; - /***/ }, -/* 26 */ +/* 28 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var canUseDOM = __webpack_require__(9); - var off = function off() {}; - - if (canUseDOM) { - - off = (function () { - if (document.addEventListener) return function (node, eventName, handler, capture) { - return node.removeEventListener(eventName, handler, capture || false); - };else if (document.attachEvent) return function (node, eventName, handler) { - return node.detachEvent('on' + eventName, handler); - }; - })(); - } + var offset = __webpack_require__(29), + getWindow = __webpack_require__(30); - module.exports = off; + module.exports = function height(node, client) { + var win = getWindow(node); + return win ? win.innerHeight : client ? node.clientHeight : offset(node).height; + }; /***/ }, -/* 27 */ +/* 29 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var canUseDOM = __webpack_require__(9); + var contains = __webpack_require__(25), + getWindow = __webpack_require__(30), + ownerDocument = __webpack_require__(24); - var has = Object.prototype.hasOwnProperty, - transform = 'transform', - transition = {}, - transitionTiming, - transitionDuration, - transitionProperty, - transitionDelay; + module.exports = function offset(node) { + var doc = ownerDocument(node), + win = getWindow(doc), + docElem = doc && doc.documentElement, + box = { top: 0, left: 0, height: 0, width: 0 }; - if (canUseDOM) { - transition = getTransitionProperties(); + if (!doc) return; - transform = transition.prefix + transform; + // Make sure it's not a disconnected DOM node + if (!contains(docElem, node)) return box; - transitionProperty = transition.prefix + 'transition-property'; - transitionDuration = transition.prefix + 'transition-duration'; - transitionDelay = transition.prefix + 'transition-delay'; - transitionTiming = transition.prefix + 'transition-timing-function'; - } + if (node.getBoundingClientRect !== undefined) box = node.getBoundingClientRect(); - module.exports = { - transform: transform, - end: transition.end, - property: transitionProperty, - timing: transitionTiming, - delay: transitionDelay, - duration: transitionDuration - }; + if (box.width || box.height) { - function getTransitionProperties() { - var endEvent, - prefix = '', - transitions = { - O: 'otransitionend', - Moz: 'transitionend', - Webkit: 'webkitTransitionEnd', - ms: 'MSTransitionEnd' - }; + box = { + top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0), + left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0), + width: (box.width == null ? node.offsetWidth : box.width) || 0, + height: (box.height == null ? node.offsetHeight : box.height) || 0 + }; + } - var element = document.createElement('div'); + return box; + }; - for (var vendor in transitions) if (has.call(transitions, vendor)) { - if (element.style[vendor + 'TransitionProperty'] !== undefined) { - prefix = '-' + vendor.toLowerCase() + '-'; - endEvent = transitions[vendor]; - break; - } - } +/***/ }, +/* 30 */ +/***/ function(module, exports) { - if (!endEvent && element.style.transitionProperty !== undefined) endEvent = 'transitionend'; + 'use strict'; - return { end: endEvent, prefix: prefix }; - } + module.exports = function getWindow(node) { + return node === node.window ? node : node.nodeType === 9 ? node.defaultView || node.parentWindow : false; + }; /***/ }, -/* 28 */ +/* 31 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _reactDom = __webpack_require__(29); + var _reactDom = __webpack_require__(32); var _reactDom2 = babelHelpers.interopRequireDefault(_reactDom); - var _2 = __webpack_require__(11); - - var _3 = babelHelpers.interopRequireDefault(_2); - var _version = _react2['default'].version.split('.').map(parseFloat); module.exports = { @@ -1735,55 +2013,38 @@ return /******/ (function(modules) { // webpackBootstrap return _version; }, - type: function type(component) { - if (_version[0] === 0 && _version[1] >= 13) return component; - - return component.type; - }, - findDOMNode: function findDOMNode(component) { return _reactDom2['default'].findDOMNode(component); - }, - - cloneElement: function cloneElement(child, props) { - if (_react2['default'].cloneElement) return _react2['default'].cloneElement(child, props); - - //just mutate if pre 0.13 - _3['default'].each(props, function (value, prop) { - return child.props[prop] = value; - }); - - return child; } + }; /***/ }, -/* 29 */ +/* 32 */ /***/ function(module, exports) { - module.exports = __WEBPACK_EXTERNAL_MODULE_29__; + module.exports = __WEBPACK_EXTERNAL_MODULE_32__; /***/ }, -/* 30 */ +/* 33 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _configuration = __webpack_require__(23); + var _localizers = __webpack_require__(18); - var _configuration2 = babelHelpers.interopRequireDefault(_configuration); + var _localizers2 = babelHelpers.interopRequireDefault(_localizers); - var _filter = __webpack_require__(31); + var _filter = __webpack_require__(34); var _filter2 = babelHelpers.interopRequireDefault(_filter); - var localizers = _configuration2['default'].locale; var filterTypes = Object.keys(_filter2['default']).filter(function (i) { return i !== 'filter'; }); @@ -1812,13 +2073,13 @@ return /******/ (function(modules) { // webpackBootstrap numberFormat: createChainableTypeChecker(function () { var _localizers$number; - return (_localizers$number = localizers.number).propType.apply(_localizers$number, arguments); + return (_localizers$number = _localizers2['default'].number).propType.apply(_localizers$number, arguments); }), dateFormat: createChainableTypeChecker(function () { var _localizers$date; - return (_localizers$date = localizers.date).propType.apply(_localizers$date, arguments); + return (_localizers$date = _localizers2['default'].date).propType.apply(_localizers$date, arguments); }), disabled: getInteractionPropType('disabled'), @@ -1849,10 +2110,12 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 31 */ +/* 34 */ /***/ function(module, exports) { - 'use strict'; + "use strict"; + + exports.__esModule = true; var common = { eq: function eq(a, b) { return a === b; @@ -1889,45 +2152,46 @@ return /******/ (function(modules) { // webpackBootstrap } }; - module.exports = common; + exports["default"] = common; + module.exports = exports["default"]; /***/ }, -/* 32 */ +/* 35 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _ListOption = __webpack_require__(33); + var _ListOption = __webpack_require__(36); var _ListOption2 = babelHelpers.interopRequireDefault(_ListOption); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _utilDataHelpers = __webpack_require__(34); + var _utilDataHelpers = __webpack_require__(37); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); var optionId = function optionId(id, idx) { return id + '__option__' + idx; @@ -1937,7 +2201,7 @@ return /******/ (function(modules) { // webpackBootstrap displayName: 'List', - mixins: [__webpack_require__(36), __webpack_require__(37)()], + mixins: [__webpack_require__(39), __webpack_require__(40)()], propTypes: { data: _react2['default'].PropTypes.array, @@ -2019,7 +2283,7 @@ return /******/ (function(modules) { // webpackBootstrap key: 'item_' + idx, id: currentId, dataItem: item, - focused: focused === item, z: true, + focused: focused === item, selected: selected === item, onClick: onSelect.bind(null, item) }, @@ -2061,20 +2325,20 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 33 */ +/* 36 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); @@ -2117,7 +2381,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 34 */ +/* 37 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -2129,7 +2393,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.valueMatcher = valueMatcher; exports.dataItem = dataItem; - var _ = __webpack_require__(11); + var _ = __webpack_require__(20); function accessor(data, field) { var value = data; @@ -2181,7 +2445,7 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 35 */ +/* 38 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -2191,7 +2455,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.instanceId = instanceId; exports.isFirstFocusedRender = isFirstFocusedRender; - var _ = __webpack_require__(11); + var _ = __webpack_require__(20); function notify(handler, args) { handler && handler.apply(null, [].concat(args)); @@ -2209,22 +2473,22 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 36 */ +/* 39 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _utilFilter = __webpack_require__(31); + var _utilFilter = __webpack_require__(34); var _utilFilter2 = babelHelpers.interopRequireDefault(_utilFilter); - var _utilDataHelpers = __webpack_require__(34); + var _utilDataHelpers = __webpack_require__(37); module.exports = { @@ -2295,20 +2559,20 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 37 */ +/* 40 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); @@ -2380,46 +2644,46 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 38 */ +/* 41 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _ListOption = __webpack_require__(33); + var _ListOption = __webpack_require__(36); var _ListOption2 = babelHelpers.interopRequireDefault(_ListOption); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _warning = __webpack_require__(39); + var _warning = __webpack_require__(42); var _warning2 = babelHelpers.interopRequireDefault(_warning); - var _utilDataHelpers = __webpack_require__(34); + var _utilDataHelpers = __webpack_require__(37); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); var optionId = function optionId(id, idx) { return id + '__option__' + idx; @@ -2429,7 +2693,7 @@ return /******/ (function(modules) { // webpackBootstrap displayName: 'List', - mixins: [__webpack_require__(36), __webpack_require__(37)()], + mixins: [__webpack_require__(39), __webpack_require__(40)()], propTypes: { data: _react2['default'].PropTypes.array, @@ -2658,7 +2922,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 39 */ +/* 42 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** @@ -2725,34 +2989,35 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }, -/* 40 */ +/* 43 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - var METHODS = ['next', 'prev', 'first', 'last']; - module.exports = function validateListComponent(list) { + var babelHelpers = __webpack_require__(2); + + exports.__esModule = true; + exports['default'] = validateListComponent; + + var _invariant = __webpack_require__(19); + + var _invariant2 = babelHelpers.interopRequireDefault(_invariant); + var METHODS = ['next', 'prev', 'first', 'last']; + + function validateListComponent(list) { if (process.env.NODE_ENV !== 'production') { METHODS.forEach(function (method) { - return assert(typeof list[method] === 'function', 'List components must implement a `' + method + '()` method'); + return _invariant2['default'](typeof list[method] === 'function', 'List components must implement a `' + method + '()` method'); }); } - }; - - function assert(condition, msg) { - var error; - - if (!condition) { - error = new Error(msg); - error.framesToPop = 1; - throw error; - } } + + module.exports = exports['default']; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }, -/* 41 */ +/* 44 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -2761,7 +3026,7 @@ return /******/ (function(modules) { // webpackBootstrap function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _createUncontrollable = __webpack_require__(42); + var _createUncontrollable = __webpack_require__(45); var _createUncontrollable2 = _interopRequireDefault(_createUncontrollable); @@ -2787,7 +3052,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 42 */ +/* 45 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -2804,11 +3069,11 @@ return /******/ (function(modules) { // webpackBootstrap function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = _interopRequireDefault(_react); - var _utils = __webpack_require__(43); + var _utils = __webpack_require__(46); var utils = _interopRequireWildcard(_utils); @@ -2909,7 +3174,7 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 43 */ +/* 46 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {'use strict'; @@ -2927,11 +3192,11 @@ return /******/ (function(modules) { // webpackBootstrap function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = _interopRequireDefault(_react); - var _invariant = __webpack_require__(44); + var _invariant = __webpack_require__(19); var _invariant2 = _interopRequireDefault(_invariant); @@ -3013,67 +3278,7 @@ return /******/ (function(modules) { // webpackBootstrap /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) /***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule invariant - */ - - 'use strict'; - - /** - * Use invariant() to assert state which your program assumes to be true. - * - * Provide sprintf-style format (only %s is supported) and arguments - * to provide information about what broke and what you were - * expecting. - * - * The invariant message will be stripped in production, but the invariant - * will remain to ensure logic does not differ in production. - */ - - var invariant = function(condition, format, a, b, c, d, e, f) { - if (process.env.NODE_ENV !== 'production') { - if (format === undefined) { - throw new Error('invariant requires an error message argument'); - } - } - - if (!condition) { - var error; - if (format === undefined) { - error = new Error( - 'Minified exception occurred; use the non-minified dev environment ' + - 'for the full error message and additional helpful warnings.' - ); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error( - 'Invariant Violation: ' + - format.replace(/%s/g, function() { return args[argIndex++]; }) - ); - } - - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; - } - }; - - module.exports = invariant; - - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) - -/***/ }, -/* 45 */ +/* 47 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -3086,7 +3291,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.contains = contains; exports.move = move; - var _dataHelpers = __webpack_require__(34); + var _dataHelpers = __webpack_require__(37); function isDisabled(props) { return props.disabled === true || props.disabled === 'disabled'; @@ -3153,12 +3358,12 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 46 */ +/* 48 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var _require = __webpack_require__(11); + var _require = __webpack_require__(20); var has = _require.has; @@ -3184,11 +3389,11 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 47 */ +/* 49 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var _ = __webpack_require__(11); + var _ = __webpack_require__(20); //backport PureRenderEqual module.exports = { @@ -3199,26 +3404,26 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 48 */ +/* 50 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _utilFilter = __webpack_require__(31); + var _utilFilter = __webpack_require__(34); var _utilFilter2 = babelHelpers.interopRequireDefault(_utilFilter); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _utilDataHelpers = __webpack_require__(34); + var _utilDataHelpers = __webpack_require__(37); var dflt = function dflt(f) { return f === true ? 'startsWith' : f ? f : 'eq'; @@ -3280,16 +3485,16 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 49 */ +/* 51 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _domHelpersUtilScrollTo = __webpack_require__(50); + var _domHelpersUtilScrollTo = __webpack_require__(52); var _domHelpersUtilScrollTo2 = babelHelpers.interopRequireDefault(_domHelpersUtilScrollTo); @@ -3320,16 +3525,16 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 50 */ +/* 52 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var getOffset = __webpack_require__(21), - height = __webpack_require__(20), - getScrollParent = __webpack_require__(51), - scrollTop = __webpack_require__(52), - raf = __webpack_require__(53), - getWindow = __webpack_require__(22); + var getOffset = __webpack_require__(29), + height = __webpack_require__(28), + getScrollParent = __webpack_require__(53), + scrollTop = __webpack_require__(54), + raf = __webpack_require__(55), + getWindow = __webpack_require__(30); module.exports = function scrollTo(selected, scrollParent) { var offset = getOffset(selected), @@ -3376,13 +3581,13 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 51 */ +/* 53 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var css = __webpack_require__(13), - height = __webpack_require__(20); + var css = __webpack_require__(7), + height = __webpack_require__(28); module.exports = function scrollPrarent(node) { var position = css(node, 'position'), @@ -3405,11 +3610,11 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 52 */ +/* 54 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var getWindow = __webpack_require__(22); + var getWindow = __webpack_require__(30); module.exports = function scrollTop(node, val) { var win = getWindow(node); @@ -3420,12 +3625,12 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 53 */ +/* 55 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var canUseDOM = __webpack_require__(9); + var canUseDOM = __webpack_require__(15); var vendors = ['', 'webkit', 'moz', 'o', 'ms'], cancel = 'clearTimeout', @@ -3471,11 +3676,11 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = compatRaf; /***/ }, -/* 54 */ +/* 56 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var React = __webpack_require__(4); + var React = __webpack_require__(21); module.exports = { @@ -3504,72 +3709,72 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 55 */ +/* 57 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _utilFilter = __webpack_require__(31); + var _utilFilter = __webpack_require__(34); var _utilFilter2 = babelHelpers.interopRequireDefault(_utilFilter); - var _Popup = __webpack_require__(12); + var _Popup = __webpack_require__(27); var _Popup2 = babelHelpers.interopRequireDefault(_Popup); - var _WidgetButton = __webpack_require__(56); + var _WidgetButton = __webpack_require__(58); var _WidgetButton2 = babelHelpers.interopRequireDefault(_WidgetButton); - var _ComboboxInput = __webpack_require__(57); + var _ComboboxInput = __webpack_require__(59); var _ComboboxInput2 = babelHelpers.interopRequireDefault(_ComboboxInput); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _List = __webpack_require__(32); + var _List = __webpack_require__(35); var _List2 = babelHelpers.interopRequireDefault(_List); - var _ListGroupable = __webpack_require__(38); + var _ListGroupable = __webpack_require__(41); var _ListGroupable2 = babelHelpers.interopRequireDefault(_ListGroupable); - var _utilValidateListInterface = __webpack_require__(40); + var _utilValidateListInterface = __webpack_require__(43); var _utilValidateListInterface2 = babelHelpers.interopRequireDefault(_utilValidateListInterface); - var _uncontrollable = __webpack_require__(41); + var _uncontrollable = __webpack_require__(44); var _uncontrollable2 = babelHelpers.interopRequireDefault(_uncontrollable); - var _utilDataHelpers = __webpack_require__(34); + var _utilDataHelpers = __webpack_require__(37); - var _utilInteraction = __webpack_require__(45); + var _utilInteraction = __webpack_require__(47); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); var defaultSuggest = function defaultSuggest(f) { return f === true ? 'startsWith' : f ? f : 'eq'; @@ -3602,7 +3807,6 @@ return /******/ (function(modules) { // webpackBootstrap autoFocus: _react2['default'].PropTypes.bool, disabled: _utilPropTypes2['default'].disabled, readOnly: _utilPropTypes2['default'].readOnly, - autoFocus: _react2['default'].PropTypes.bool, suggest: _utilPropTypes2['default'].filter, filter: _utilPropTypes2['default'].filter, @@ -3629,7 +3833,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'mixins', initializer: function initializer() { - return [__webpack_require__(46), __webpack_require__(48), __webpack_require__(49), __webpack_require__(54), __webpack_require__(37)('input')]; + return [__webpack_require__(48), __webpack_require__(50), __webpack_require__(51), __webpack_require__(56), __webpack_require__(40)('input')]; } }, { key: 'propTypes', @@ -3736,8 +3940,8 @@ return /******/ (function(modules) { // webpackBootstrap List = List || groupBy && _ListGroupable2['default'] || _List2['default']; var elementProps = omit(this.props, Object.keys(propTypes)); - var listProps = pick(this.props, Object.keys(_utilCompat2['default'].type(List).propTypes)); - var popupProps = pick(this.props, Object.keys(_utilCompat2['default'].type(_Popup2['default']).propTypes)); + var listProps = pick(this.props, Object.keys(List.propTypes)); + var popupProps = pick(this.props, Object.keys(_Popup2['default'].propTypes)); var _state = this.state; var focusedItem = _state.focusedItem; @@ -4016,20 +4220,20 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 56 */ +/* 58 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); @@ -4052,24 +4256,24 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 57 */ +/* 59 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _utilCaret = __webpack_require__(58); + var _utilCaret = __webpack_require__(60); var _utilCaret2 = babelHelpers.interopRequireDefault(_utilCaret); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); @@ -4148,17 +4352,20 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 58 */ +/* 60 */ /***/ function(module, exports) { /*eslint-disable no-empty */ 'use strict'; - module.exports = function caret(el, start, end) { + exports.__esModule = true; + exports['default'] = caret; + + function caret(el, start, end) { if (start === undefined) return get(el); set(el, start, end); - }; + } function get(el) { var start, end, rangeEl, clone; @@ -4200,88 +4407,87 @@ return /******/ (function(modules) { // webpackBootstrap } } catch (e) {/* not focused or not visible */} } + module.exports = exports['default']; /***/ }, -/* 59 */ +/* 61 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; var _VIEW, _OPPOSITE_DIRECTION, _MULTIPLIER; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _Header = __webpack_require__(60); + var _Header = __webpack_require__(62); var _Header2 = babelHelpers.interopRequireDefault(_Header); - var _Footer = __webpack_require__(62); + var _Footer = __webpack_require__(64); var _Footer2 = babelHelpers.interopRequireDefault(_Footer); - var _Month = __webpack_require__(63); + var _Month = __webpack_require__(65); var _Month2 = babelHelpers.interopRequireDefault(_Month); - var _Year = __webpack_require__(67); + var _Year = __webpack_require__(69); var _Year2 = babelHelpers.interopRequireDefault(_Year); - var _Decade = __webpack_require__(68); + var _Decade = __webpack_require__(70); var _Decade2 = babelHelpers.interopRequireDefault(_Decade); - var _Century = __webpack_require__(69); + var _Century = __webpack_require__(71); var _Century2 = babelHelpers.interopRequireDefault(_Century); - var _utilConfiguration = __webpack_require__(23); + var _utilLocalizers = __webpack_require__(18); - var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); - - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _uncontrollable = __webpack_require__(41); + var _uncontrollable = __webpack_require__(44); var _uncontrollable2 = babelHelpers.interopRequireDefault(_uncontrollable); - var _SlideTransition = __webpack_require__(70); + var _SlideTransition = __webpack_require__(72); var _SlideTransition2 = babelHelpers.interopRequireDefault(_SlideTransition); - var _utilDates = __webpack_require__(64); + var _utilDates = __webpack_require__(66); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); - var _utilConstants = __webpack_require__(66); + var _utilConstants = __webpack_require__(68); var _utilConstants2 = babelHelpers.interopRequireDefault(_utilConstants); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); //values, omit - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); - var _utilInteraction = __webpack_require__(45); + var _utilInteraction = __webpack_require__(47); var dir = _utilConstants2['default'].directions, values = function values(obj) { @@ -4295,8 +4501,7 @@ return /******/ (function(modules) { // webpackBootstrap }, {}); }; - var localizers = _utilConfiguration2['default'].locale, - views = _utilConstants2['default'].calendarViews, + var views = _utilConstants2['default'].calendarViews, VIEW_OPTIONS = values(views), ALT_VIEW = invert(_utilConstants2['default'].calendarViewHierarchy), NEXT_VIEW = _utilConstants2['default'].calendarViewHierarchy, @@ -4315,7 +4520,7 @@ return /******/ (function(modules) { // webpackBootstrap var MULTIPLIER = (_MULTIPLIER = {}, _MULTIPLIER[views.YEAR] = 1, _MULTIPLIER[views.DECADE] = 10, _MULTIPLIER[views.CENTURY] = 100, _MULTIPLIER); var format = function format(props, f) { - return props[f + 'Format'] || localizers.date.formats[f]; + return _utilLocalizers.date.getFormat(f, props[f + 'Format']); }; var propTypes = { @@ -4367,7 +4572,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'mixins', initializer: function initializer() { - return [__webpack_require__(46), __webpack_require__(47), __webpack_require__(54), __webpack_require__(37)()]; + return [__webpack_require__(48), __webpack_require__(49), __webpack_require__(56), __webpack_require__(40)()]; } }, { key: 'propTypes', @@ -4456,7 +4661,7 @@ return /******/ (function(modules) { // webpackBootstrap key = view + '_' + _utilDates2['default'][view](currentDate); var elementProps = _util_2['default'].omit(this.props, Object.keys(propTypes)), - viewProps = _util_2['default'].pick(this.props, Object.keys(_utilCompat2['default'].type(View).propTypes)); + viewProps = _util_2['default'].pick(this.props, Object.keys(View.propTypes)); var isDisabled = disabled || readOnly; @@ -4654,7 +4859,7 @@ return /******/ (function(modules) { // webpackBootstrap var view = this.state.view; var dt = this.state.currentDate; - if (view === 'month') return localizers.date.format(dt, format(props, 'header'), culture);else if (view === 'year') return localizers.date.format(dt, format(props, 'year'), culture);else if (view === 'decade') return localizers.date.format(_utilDates2['default'].startOf(dt, 'decade'), format(props, 'decade'), culture);else if (view === 'century') return localizers.date.format(_utilDates2['default'].startOf(dt, 'century'), format(props, 'century'), culture); + if (view === 'month') return _utilLocalizers.date.format(dt, format(props, 'header'), culture);else if (view === 'year') return _utilLocalizers.date.format(dt, format(props, 'year'), culture);else if (view === 'decade') return _utilLocalizers.date.format(_utilDates2['default'].startOf(dt, 'decade'), format(props, 'decade'), culture);else if (view === 'century') return _utilLocalizers.date.format(_utilDates2['default'].startOf(dt, 'century'), format(props, 'century'), culture); } }, { key: 'inRangeValue', @@ -4692,34 +4897,43 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 60 */ +/* 62 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var React = __webpack_require__(4), - Btn = __webpack_require__(56); - module.exports = React.createClass({ - displayName: 'exports', + var babelHelpers = __webpack_require__(2); + + exports.__esModule = true; + + var _react = __webpack_require__(21); + + var _react2 = babelHelpers.interopRequireDefault(_react); + + var _WidgetButton = __webpack_require__(58); + var _WidgetButton2 = babelHelpers.interopRequireDefault(_WidgetButton); + + exports['default'] = _react2['default'].createClass({ + displayName: 'Header', propTypes: { - label: React.PropTypes.string.isRequired, - labelId: React.PropTypes.string, - - upDisabled: React.PropTypes.bool.isRequired, - prevDisabled: React.PropTypes.bool.isRequired, - nextDisabled: React.PropTypes.bool.isRequired, - onViewChange: React.PropTypes.func.isRequired, - onMoveLeft: React.PropTypes.func.isRequired, - onMoveRight: React.PropTypes.func.isRequired, - - messages: React.PropTypes.shape({ - moveBack: React.PropTypes.string, - moveForward: React.PropTypes.string + label: _react2['default'].PropTypes.string.isRequired, + labelId: _react2['default'].PropTypes.string, + + upDisabled: _react2['default'].PropTypes.bool.isRequired, + prevDisabled: _react2['default'].PropTypes.bool.isRequired, + nextDisabled: _react2['default'].PropTypes.bool.isRequired, + onViewChange: _react2['default'].PropTypes.func.isRequired, + onMoveLeft: _react2['default'].PropTypes.func.isRequired, + onMoveRight: _react2['default'].PropTypes.func.isRequired, + + messages: _react2['default'].PropTypes.shape({ + moveBack: _react2['default'].PropTypes.string, + moveForward: _react2['default'].PropTypes.string }) }, - mixins: [__webpack_require__(47), __webpack_require__(61)], + mixins: [__webpack_require__(49), __webpack_require__(63)], getDefaultProps: function getDefaultProps() { return { @@ -4744,11 +4958,11 @@ return /******/ (function(modules) { // webpackBootstrap var rtl = this.isRtl(); - return React.createElement( + return _react2['default'].createElement( 'div', { className: 'rw-header' }, - React.createElement( - Btn, + _react2['default'].createElement( + _WidgetButton2['default'], { className: 'rw-btn-left', tabIndex: '-1', onClick: onMoveLeft, @@ -4757,12 +4971,12 @@ return /******/ (function(modules) { // webpackBootstrap 'aria-label': messages.moveBack, title: messages.moveBack }, - React.createElement('i', { 'aria-hidden': 'false', + _react2['default'].createElement('i', { 'aria-hidden': 'false', className: 'rw-i rw-i-caret-' + (rtl ? 'right' : 'left') }) ), - React.createElement( - Btn, + _react2['default'].createElement( + _WidgetButton2['default'], { id: labelId, tabIndex: '-1', @@ -4775,8 +4989,8 @@ return /******/ (function(modules) { // webpackBootstrap }, label ), - React.createElement( - Btn, + _react2['default'].createElement( + _WidgetButton2['default'], { className: 'rw-btn-right', tabIndex: '-1', onClick: onMoveRight, @@ -4785,25 +4999,26 @@ return /******/ (function(modules) { // webpackBootstrap 'aria-label': messages.moveForward, 'aria-disabled': nextDisabled }, - React.createElement('i', { 'aria-hidden': 'false', + _react2['default'].createElement('i', { 'aria-hidden': 'false', className: 'rw-i rw-i-caret-' + (rtl ? 'left' : 'right') }) ) ); } }); + module.exports = exports['default']; /***/ }, -/* 61 */ +/* 63 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); @@ -4821,32 +5036,40 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 62 */ +/* 64 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var React = __webpack_require__(4), - Btn = __webpack_require__(56), - localizers = __webpack_require__(23).locale; + var babelHelpers = __webpack_require__(2); + + var _react = __webpack_require__(21); + + var _react2 = babelHelpers.interopRequireDefault(_react); + + var _WidgetButton = __webpack_require__(58); + + var _WidgetButton2 = babelHelpers.interopRequireDefault(_WidgetButton); + + var _utilLocalizers = __webpack_require__(18); var format = function format(props) { - return props.format || localizers.date.formats.footer; + return _utilLocalizers.date.getFormat('footer', props.format); }; - module.exports = React.createClass({ + module.exports = _react2['default'].createClass({ displayName: 'Footer', render: function render() { var now = this.props.value, - formatted = localizers.date.format(now, format(this.props), this.props.culture); + formatted = _utilLocalizers.date.format(now, format(this.props), this.props.culture); - return React.createElement( + return _react2['default'].createElement( 'div', { className: 'rw-footer' }, - React.createElement( - Btn, + _react2['default'].createElement( + _WidgetButton2['default'], { tabIndex: '-1', 'aria-disabled': !!this.props.disabled, 'aria-readonly': !!this.props.readOnly, @@ -4862,47 +5085,44 @@ return /******/ (function(modules) { // webpackBootstrap }); /***/ }, -/* 63 */ +/* 65 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _utilDates = __webpack_require__(64); + var _utilDates = __webpack_require__(66); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); - var _utilConfiguration = __webpack_require__(23); - - var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); + var _utilLocalizers = __webpack_require__(18); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); - var localizers = _utilConfiguration2['default'].locale, - dayFormat = function dayFormat(props) { - return props.dayFormat || localizers.date.formats.weekday; + var dayFormat = function dayFormat(props) { + return _utilLocalizers.date.getFormat('weekday', props.dayFormat); }, dateFormat = function dateFormat(props) { - return props.dateFormat || localizers.date.formats.dayOfMonth; + return _utilLocalizers.date.getFormat('dayOfMonth', props.dateFormat); }; var optionId = function optionId(id, date) { @@ -4939,7 +5159,7 @@ return /******/ (function(modules) { // webpackBootstrap isEqual: isEqual }, - mixins: [__webpack_require__(61), __webpack_require__(37)()], + mixins: [__webpack_require__(63), __webpack_require__(40)()], propTypes: propTypes, @@ -4968,7 +5188,7 @@ return /******/ (function(modules) { // webpackBootstrap _react2['default'].createElement( 'tr', null, - this._headers(dayFormat(this.props), culture) + this._headers(rows[0], dayFormat(this.props), culture) ) ), _react2['default'].createElement( @@ -4993,7 +5213,7 @@ return /******/ (function(modules) { // webpackBootstrap var max = _props2.max; var Day = _props2.dayComponent; var id = _utilWidgetHelpers.instanceId(this); - var labelFormat = localizers.date.formats.footer; + var labelFormat = _utilLocalizers.date.getFormat('footer'); return _react2['default'].createElement( 'tr', @@ -5003,8 +5223,8 @@ return /******/ (function(modules) { // webpackBootstrap var isFocused = isEqual(day, focused), isSelected = isEqual(day, value), isToday = isEqual(day, today), - date = localizers.date.format(day, dateFormat(_this.props), culture), - label = localizers.date.format(day, labelFormat, culture); + date = _utilLocalizers.date.format(day, dateFormat(_this.props), culture), + label = _utilLocalizers.date.format(day, labelFormat, culture); var currentID = optionId(id, day); @@ -5042,12 +5262,12 @@ return /******/ (function(modules) { // webpackBootstrap ); }, - _headers: function _headers(format, culture) { - return [0, 1, 2, 3, 4, 5, 6].map(function (day) { + _headers: function _headers(week, format, culture) { + return week.map(function (date) { return _react2['default'].createElement( 'th', - { key: 'header_' + day }, - localizers.date.format(day, format, culture) + { key: 'header_' + _utilDates2['default'].weekday(date) }, + _utilLocalizers.date.format(date, format, culture) ); }); } @@ -5058,29 +5278,36 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 64 */ +/* 66 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); + + exports.__esModule = true; + + var _dateArithmetic = __webpack_require__(67); - var dateMath = __webpack_require__(65); + var _dateArithmetic2 = babelHelpers.interopRequireDefault(_dateArithmetic); - var _require = __webpack_require__(66); + var _constants = __webpack_require__(68); - var directions = _require.directions; - var calendarViewUnits = _require.calendarViewUnits; - var locale = __webpack_require__(23).locale; + var _constants2 = babelHelpers.interopRequireDefault(_constants); - var dates = module.exports = babelHelpers._extends(dateMath, { + var _localizers = __webpack_require__(18); + + var directions = _constants2['default'].directions; + var calendarViewUnits = _constants2['default'].calendarViewUnits; + + var dates = babelHelpers._extends(_dateArithmetic2['default'], { parse: function parse(date, format, culture) { - return locale.date.parse(date, format, culture); + return _localizers.date.parse(date, format, culture); }, format: function format(date, _format, culture) { - return locale.date.format(date, _format, culture); + return _localizers.date.format(date, _format, culture); }, monthsInYear: function monthsInYear(year) { @@ -5094,14 +5321,13 @@ return /******/ (function(modules) { // webpackBootstrap firstVisibleDay: function firstVisibleDay(date, culture) { var firstOfMonth = dates.startOf(date, 'month'); - - return dates.startOf(firstOfMonth, 'week', locale.date.startOfWeek(culture)); + return dates.startOf(firstOfMonth, 'week', _localizers.date.startOfWeek(culture)); }, lastVisibleDay: function lastVisibleDay(date, culture) { var endOfMonth = dates.endOf(date, 'month'); - return dates.endOf(endOfMonth, 'week', locale.date.startOfWeek(culture)); + return dates.endOf(endOfMonth, 'week', _localizers.date.startOfWeek(culture)); }, visibleDays: function visibleDays(date, culture) { @@ -5162,8 +5388,11 @@ return /******/ (function(modules) { // webpackBootstrap } }); + exports['default'] = dates; + module.exports = exports['default']; + /***/ }, -/* 65 */ +/* 67 */ /***/ function(module, exports) { var MILI = 'milliseconds' @@ -5336,7 +5565,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 66 */ +/* 68 */ /***/ function(module, exports) { 'use strict'; @@ -5372,44 +5601,41 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 67 */ +/* 69 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _utilDates = __webpack_require__(64); + var _utilDates = __webpack_require__(66); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); - var _utilConfiguration = __webpack_require__(23); - - var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); + var _utilLocalizers = __webpack_require__(18); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); - var localizers = _utilConfiguration2['default'].locale; var format = function format(props) { - return props.monthFormat || localizers.date.formats.month; + return _utilLocalizers.date.getFormat('month', props.monthFormat); }; var propTypes = { @@ -5435,7 +5661,7 @@ return /******/ (function(modules) { // webpackBootstrap displayName: 'YearView', - mixins: [__webpack_require__(61), __webpack_require__(37)()], + mixins: [__webpack_require__(63), __webpack_require__(40)()], propTypes: propTypes, @@ -5480,7 +5706,7 @@ return /******/ (function(modules) { // webpackBootstrap var min = _props2.min; var max = _props2.max; var id = _utilWidgetHelpers.instanceId(this); - var labelFormat = localizers.date.formats.header; + var labelFormat = _utilLocalizers.date.getFormat('header'); return _react2['default'].createElement( 'tr', @@ -5489,7 +5715,7 @@ return /******/ (function(modules) { // webpackBootstrap var isFocused = isEqual(date, focused), isSelected = isEqual(date, value), currentMonth = isEqual(date, today), - label = localizers.date.format(date, labelFormat, culture); + label = _utilLocalizers.date.format(date, labelFormat, culture); var currentID = optionId(id, date); @@ -5515,7 +5741,7 @@ return /******/ (function(modules) { // webpackBootstrap 'rw-now': currentMonth }) }, - localizers.date.format(date, format(_this.props), culture) + _utilLocalizers.date.format(date, format(_this.props), culture) ) ) : _react2['default'].createElement( 'td', @@ -5532,46 +5758,38 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 68 */ +/* 70 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _utilDates = __webpack_require__(64); + var _utilDates = __webpack_require__(66); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); - var _utilConfiguration = __webpack_require__(23); - - var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); + var _utilLocalizers = __webpack_require__(18); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _utilWidgetHelpers = __webpack_require__(35); - - var localizers = _utilConfiguration2['default'].locale; - - var format = function format(props) { - return props.yearFormat || localizers.date.formats.year; - }; + var _utilWidgetHelpers = __webpack_require__(38); var propTypes = { optionID: _react2['default'].PropTypes.func, @@ -5597,7 +5815,7 @@ return /******/ (function(modules) { // webpackBootstrap displayName: 'DecadeView', - mixins: [__webpack_require__(47), __webpack_require__(61), __webpack_require__(37)()], + mixins: [__webpack_require__(49), __webpack_require__(63), __webpack_require__(40)()], propTypes: propTypes, @@ -5650,7 +5868,7 @@ return /******/ (function(modules) { // webpackBootstrap var isFocused = isEqual(date, focused), isSelected = isEqual(date, value), currentYear = isEqual(date, today), - label = localizers.date.format(date, format(_this.props), culture); + label = _utilLocalizers.date.format(date, _utilLocalizers.date.getFormat('year', _this.props.yearFormat), culture); var currentID = optionId(id, date); @@ -5704,44 +5922,41 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 69 */ +/* 71 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _utilDates = __webpack_require__(64); + var _utilDates = __webpack_require__(66); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); - var _utilConfiguration = __webpack_require__(23); - - var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); + var _utilLocalizers = __webpack_require__(18); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); - var localizers = _utilConfiguration2['default'].locale; var format = function format(props) { - return props.decadeFormat || localizers.date.formats.decade; + return _utilLocalizers.date.getFormat('decade', props.decadeFormat); }; var isEqual = function isEqual(dateA, dateB) { @@ -5766,7 +5981,7 @@ return /******/ (function(modules) { // webpackBootstrap displayName: 'CenturyView', - mixins: [__webpack_require__(47), __webpack_require__(61), __webpack_require__(37)()], + mixins: [__webpack_require__(49), __webpack_require__(63), __webpack_require__(40)()], propTypes: propTypes, @@ -5819,7 +6034,7 @@ return /******/ (function(modules) { // webpackBootstrap var isFocused = isEqual(date, focused), isSelected = isEqual(date, value), currentDecade = isEqual(date, today), - label = localizers.date.format(_utilDates2['default'].startOf(date, 'decade'), format(_this.props), culture); + label = _utilLocalizers.date.format(_utilDates2['default'].startOf(date, 'decade'), format(_this.props), culture); var currentID = optionId(id, date); @@ -5882,19 +6097,19 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 70 */ +/* 72 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); - var React = __webpack_require__(4), - ReplaceTransitionGroup = __webpack_require__(71), - compat = __webpack_require__(28), - css = __webpack_require__(13), - getWidth = __webpack_require__(72), - config = __webpack_require__(23); + var React = __webpack_require__(21), + ReplaceTransitionGroup = __webpack_require__(73), + compat = __webpack_require__(31), + css = __webpack_require__(7), + getWidth = __webpack_require__(74), + config = __webpack_require__(4); var SlideChildGroup = React.createClass({ displayName: 'SlideChildGroup', @@ -6009,7 +6224,7 @@ return /******/ (function(modules) { // webpackBootstrap }); /***/ }, -/* 71 */ +/* 73 */ /***/ function(module, exports, __webpack_require__) { /** @@ -6020,12 +6235,12 @@ return /******/ (function(modules) { // webpackBootstrap */ 'use strict'; - var React = __webpack_require__(4), - css = __webpack_require__(13), - height = __webpack_require__(20), - width = __webpack_require__(72), - compat = __webpack_require__(28), - _ = __webpack_require__(11); + var React = __webpack_require__(21), + css = __webpack_require__(7), + height = __webpack_require__(28), + width = __webpack_require__(74), + compat = __webpack_require__(31), + _ = __webpack_require__(20); module.exports = React.createClass({ @@ -6203,13 +6418,13 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }, -/* 72 */ +/* 74 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var offset = __webpack_require__(21), - getWindow = __webpack_require__(22); + var offset = __webpack_require__(29), + getWindow = __webpack_require__(30); module.exports = function width(node, client) { var win = getWindow(node); @@ -6217,90 +6432,87 @@ return /******/ (function(modules) { // webpackBootstrap }; /***/ }, -/* 73 */ +/* 75 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _invariant = __webpack_require__(44); + var _invariant = __webpack_require__(19); var _invariant2 = babelHelpers.interopRequireDefault(_invariant); - var _domHelpersActiveElement = __webpack_require__(5); + var _domHelpersActiveElement = __webpack_require__(23); var _domHelpersActiveElement2 = babelHelpers.interopRequireDefault(_domHelpersActiveElement); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); //pick, omit, has - var _utilDates = __webpack_require__(64); + var _utilDates = __webpack_require__(66); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); - var _utilConfiguration = __webpack_require__(23); - - var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); + var _utilLocalizers = __webpack_require__(18); - var _utilConstants = __webpack_require__(66); + var _utilConstants = __webpack_require__(68); var _utilConstants2 = babelHelpers.interopRequireDefault(_utilConstants); - var _Popup = __webpack_require__(12); + var _Popup = __webpack_require__(27); var _Popup2 = babelHelpers.interopRequireDefault(_Popup); - var _Calendar2 = __webpack_require__(59); + var _Calendar2 = __webpack_require__(61); var _Calendar3 = babelHelpers.interopRequireDefault(_Calendar2); - var _TimeList = __webpack_require__(74); + var _TimeList = __webpack_require__(76); var _TimeList2 = babelHelpers.interopRequireDefault(_TimeList); - var _DateInput = __webpack_require__(75); + var _DateInput = __webpack_require__(77); var _DateInput2 = babelHelpers.interopRequireDefault(_DateInput); - var _WidgetButton = __webpack_require__(56); + var _WidgetButton = __webpack_require__(58); var _WidgetButton2 = babelHelpers.interopRequireDefault(_WidgetButton); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _uncontrollable = __webpack_require__(41); + var _uncontrollable = __webpack_require__(44); var _uncontrollable2 = babelHelpers.interopRequireDefault(_uncontrollable); - var _utilInteraction = __webpack_require__(45); + var _utilInteraction = __webpack_require__(47); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); var views = _utilConstants2['default'].calendarViews; var popups = _utilConstants2['default'].datePopups; var Calendar = _Calendar3['default'].ControlledComponent; - var localizers = _utilConfiguration2['default'].locale; var viewEnum = Object.keys(views).map(function (k) { return views[k]; }); @@ -6308,7 +6520,7 @@ return /******/ (function(modules) { // webpackBootstrap var omit = _util_2['default'].omit; var pick = _util_2['default'].pick; - var propTypes = babelHelpers._extends({}, _utilCompat2['default'].type(Calendar).propTypes, { + var propTypes = babelHelpers._extends({}, Calendar.propTypes, { //-- controlled props ----------- value: _react2['default'].PropTypes.instanceOf(Date), @@ -6346,7 +6558,6 @@ return /******/ (function(modules) { // webpackBootstrap autoFocus: _react2['default'].PropTypes.bool, disabled: _utilPropTypes2['default'].disabled, readOnly: _utilPropTypes2['default'].readOnly, - autoFocus: _react2['default'].PropTypes.bool, parse: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), _react2['default'].PropTypes.string, _react2['default'].PropTypes.func]), @@ -6366,7 +6577,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'mixins', initializer: function initializer() { - return [__webpack_require__(46), __webpack_require__(47), __webpack_require__(49), __webpack_require__(54), __webpack_require__(37)('valueInput', function (key, id) { + return [__webpack_require__(48), __webpack_require__(49), __webpack_require__(51), __webpack_require__(56), __webpack_require__(40)('valueInput', function (key, id) { var open = this.props.open; var current = this.ariaActiveDescendant(); var calIsActive = open === popups.CALENDAR && key === 'calendar'; @@ -6450,7 +6661,7 @@ return /******/ (function(modules) { // webpackBootstrap owns = ''; var elementProps = omit(this.props, Object.keys(propTypes)), - calProps = pick(this.props, Object.keys(_utilCompat2['default'].type(Calendar).propTypes)); + calProps = pick(this.props, Object.keys(Calendar.propTypes)); var shouldRenderList = _utilWidgetHelpers.isFirstFocusedRender(this) || open, disabledOrReadonly = disabled || readOnly, @@ -6738,13 +6949,13 @@ return /******/ (function(modules) { // webpackBootstrap var cal = props[popups.CALENDAR] != null ? props.calendar : true, time = props[popups.TIME] != null ? props.time : true; - return props.format ? props.format : cal && time || !cal && !time ? localizers.date.formats['default'] : localizers.date.formats[cal ? 'date' : 'time']; + return props.format ? props.format : cal && time || !cal && !time ? _utilLocalizers.date.getFormat('default') : _utilLocalizers.date.getFormat(cal ? 'date' : 'time'); } function formatDate(date, format, culture) { var val = ''; - if (date instanceof Date && !isNaN(date.getTime())) val = localizers.date.format(date, format, culture); + if (date instanceof Date && !isNaN(date.getTime())) val = _utilLocalizers.date.format(date, format, culture); return val; } @@ -6753,7 +6964,7 @@ return /******/ (function(modules) { // webpackBootstrap var date; for (var i = 0; i < formats.length; i++) { - date = localizers.date.parse(str, formats[i], culture); + date = _utilLocalizers.date.parse(str, formats[i], culture); if (date) return date; } return null; @@ -6766,40 +6977,54 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 74 */ +/* 76 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); + + exports.__esModule = true; + + var _react = __webpack_require__(21); + + var _react2 = babelHelpers.interopRequireDefault(_react); + + var _utilDates = __webpack_require__(66); + + var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); + + var _List = __webpack_require__(35); + + var _List2 = babelHelpers.interopRequireDefault(_List); + + var _utilLocalizers = __webpack_require__(18); - var React = __webpack_require__(4), - dates = __webpack_require__(64), - List = __webpack_require__(32), - localizers = __webpack_require__(23).locale, - CustomPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); + + var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); var format = function format(props) { - return props.format || localizers.date.formats.time; + return _utilLocalizers.date.getFormat('time', props.format); }; - module.exports = React.createClass({ + exports['default'] = _react2['default'].createClass({ displayName: 'TimeList', propTypes: { - value: React.PropTypes.instanceOf(Date), - min: React.PropTypes.instanceOf(Date), - max: React.PropTypes.instanceOf(Date), - step: React.PropTypes.number, - itemComponent: CustomPropTypes.elementType, - format: CustomPropTypes.dateFormat, - onSelect: React.PropTypes.func, - preserveDate: React.PropTypes.bool, - culture: React.PropTypes.string + value: _react2['default'].PropTypes.instanceOf(Date), + min: _react2['default'].PropTypes.instanceOf(Date), + max: _react2['default'].PropTypes.instanceOf(Date), + step: _react2['default'].PropTypes.number, + itemComponent: _utilPropTypes2['default'].elementType, + format: _utilPropTypes2['default'].dateFormat, + onSelect: _react2['default'].PropTypes.func, + preserveDate: _react2['default'].PropTypes.bool, + culture: _react2['default'].PropTypes.string }, - mixins: [__webpack_require__(46)], + mixins: [__webpack_require__(48)], getDefaultProps: function getDefaultProps() { return { @@ -6825,9 +7050,9 @@ return /******/ (function(modules) { // webpackBootstrap componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var data = this._dates(nextProps), focusedItem = this._closestDate(data, nextProps.value), - valChanged = !dates.eq(nextProps.value, this.props.value, 'minutes'), - minChanged = !dates.eq(nextProps.min, this.props.min, 'minutes'), - maxChanged = !dates.eq(nextProps.max, this.props.max, 'minutes'); + valChanged = !_utilDates2['default'].eq(nextProps.value, this.props.value, 'minutes'), + minChanged = !_utilDates2['default'].eq(nextProps.min, this.props.min, 'minutes'), + maxChanged = !_utilDates2['default'].eq(nextProps.max, this.props.max, 'minutes'); if (valChanged || minChanged || maxChanged) { this.setState({ @@ -6848,7 +7073,7 @@ return /******/ (function(modules) { // webpackBootstrap var times = this.state.dates, date = this._closestDate(times, value); - return React.createElement(List, babelHelpers._extends({}, props, { + return _react2['default'].createElement(_List2['default'], babelHelpers._extends({}, props, { ref: 'list', data: times, textField: 'label', @@ -6866,7 +7091,7 @@ return /******/ (function(modules) { // webpackBootstrap if (!date) return null; date = new Date(Math.floor(date.getTime() / roundTo) * roundTo); - label = localizers.date.format(date, format(this.props), this.props.culture); + label = _utilLocalizers.date.format(date, format(this.props), this.props.culture); times.some(function (time) { if (time.label === label) return inst = time; @@ -6884,18 +7109,18 @@ return /******/ (function(modules) { // webpackBootstrap i = 0, values = this._dateValues(props), start = values.min, - startDay = dates.date(start); + startDay = _utilDates2['default'].date(start); - while (dates.date(start) === startDay && dates.lte(start, values.max)) { + while (_utilDates2['default'].date(start) === startDay && _utilDates2['default'].lte(start, values.max)) { i++; - times.push({ date: start, label: localizers.date.format(start, format(props), props.culture) }); - start = dates.add(start, props.step || 30, 'minutes'); + times.push({ date: start, label: _utilLocalizers.date.format(start, format(props), props.culture) }); + start = _utilDates2['default'].add(start, props.step || 30, 'minutes'); } return times; }, _dateValues: function _dateValues(props) { - var value = props.value || dates.today(), + var value = props.value || _utilDates2['default'].today(), useDate = props.preserveDate, min = props.min, max = props.max, @@ -6904,10 +7129,10 @@ return /******/ (function(modules) { // webpackBootstrap //compare just the time regradless of whether they fall on the same day if (!useDate) { - start = dates.startOf(dates.merge(new Date(), min), 'minutes'); - end = dates.startOf(dates.merge(new Date(), max), 'minutes'); + start = _utilDates2['default'].startOf(_utilDates2['default'].merge(new Date(), min), 'minutes'); + end = _utilDates2['default'].startOf(_utilDates2['default'].merge(new Date(), max), 'minutes'); - if (dates.lte(end, start) && dates.gt(max, min, 'day')) end = dates.tomorrow(); + if (_utilDates2['default'].lte(end, start) && _utilDates2['default'].gt(max, min, 'day')) end = _utilDates2['default'].tomorrow(); return { min: start, @@ -6915,12 +7140,12 @@ return /******/ (function(modules) { // webpackBootstrap }; } - start = dates.today(); - end = dates.tomorrow(); + start = _utilDates2['default'].today(); + end = _utilDates2['default'].tomorrow(); //date parts are equal return { - min: dates.eq(value, min, 'day') ? dates.merge(start, min) : start, - max: dates.eq(value, max, 'day') ? dates.merge(start, max) : end + min: _utilDates2['default'].eq(value, min, 'day') ? _utilDates2['default'].merge(start, min) : start, + max: _utilDates2['default'].eq(value, max, 'day') ? _utilDates2['default'].merge(start, max) : end }; }, @@ -6968,33 +7193,48 @@ return /******/ (function(modules) { // webpackBootstrap } }); + module.exports = exports['default']; /***/ }, -/* 75 */ +/* 77 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); + + exports.__esModule = true; - var React = __webpack_require__(4), - cx = __webpack_require__(10), - compat = __webpack_require__(28), - localizers = __webpack_require__(23).locale, - CustomPropTypes = __webpack_require__(30); + var _react = __webpack_require__(21); - module.exports = React.createClass({ + var _react2 = babelHelpers.interopRequireDefault(_react); + + var _classnames = __webpack_require__(26); + + var _classnames2 = babelHelpers.interopRequireDefault(_classnames); + + var _utilCompat = __webpack_require__(31); + + var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); + + var _utilLocalizers = __webpack_require__(18); + + var _utilPropTypes = __webpack_require__(33); + + var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); + + exports['default'] = _react2['default'].createClass({ displayName: 'DatePickerInput', propTypes: { - format: CustomPropTypes.dateFormat.isRequired, - editFormat: CustomPropTypes.dateFormat, - parse: React.PropTypes.func.isRequired, + format: _utilPropTypes2['default'].dateFormat.isRequired, + editFormat: _utilPropTypes2['default'].dateFormat, + parse: _react2['default'].PropTypes.func.isRequired, - value: React.PropTypes.instanceOf(Date), - onChange: React.PropTypes.func.isRequired, - culture: React.PropTypes.string + value: _react2['default'].PropTypes.instanceOf(Date), + onChange: _react2['default'].PropTypes.func.isRequired, + culture: _react2['default'].PropTypes.string }, getDefaultProps: function getDefaultProps() { @@ -7026,9 +7266,9 @@ return /******/ (function(modules) { // webpackBootstrap render: function render() { var value = this.state.textValue; - return React.createElement('input', babelHelpers._extends({}, this.props, { + return _react2['default'].createElement('input', babelHelpers._extends({}, this.props, { type: 'text', - className: cx({ 'rw-input': true }), + className: _classnames2['default']({ 'rw-input': true }), value: value, 'aria-disabled': this.props.disabled, 'aria-readonly': this.props.readOnly, @@ -7056,7 +7296,7 @@ return /******/ (function(modules) { // webpackBootstrap }, focus: function focus() { - compat.findDOMNode(this).focus(); + _utilCompat2['default'].findDOMNode(this).focus(); } }); @@ -7068,7 +7308,7 @@ return /******/ (function(modules) { // webpackBootstrap function formatDate(date, format, culture) { var val = ''; - if (date instanceof Date && isValid(date)) val = localizers.date.format(date, format, culture); + if (date instanceof Date && isValid(date)) val = _utilLocalizers.date.format(date, format, culture); return val; } @@ -7079,71 +7319,68 @@ return /******/ (function(modules) { // webpackBootstrap b && b.apply(thisArg, arguments); }; } + module.exports = exports['default']; /***/ }, -/* 76 */ +/* 78 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _uncontrollable = __webpack_require__(41); + var _uncontrollable = __webpack_require__(44); var _uncontrollable2 = babelHelpers.interopRequireDefault(_uncontrollable); - var _utilConstants = __webpack_require__(66); + var _utilConstants = __webpack_require__(68); var _utilConstants2 = babelHelpers.interopRequireDefault(_utilConstants); - var _utilRepeater = __webpack_require__(77); + var _utilRepeater = __webpack_require__(79); var _utilRepeater2 = babelHelpers.interopRequireDefault(_utilRepeater); - var _utilConfiguration = __webpack_require__(23); - - var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); + var _utilLocalizers = __webpack_require__(18); - var _NumberInput = __webpack_require__(78); + var _NumberInput = __webpack_require__(80); var _NumberInput2 = babelHelpers.interopRequireDefault(_NumberInput); - var _WidgetButton = __webpack_require__(56); + var _WidgetButton = __webpack_require__(58); var _WidgetButton2 = babelHelpers.interopRequireDefault(_WidgetButton); - var _utilInteraction = __webpack_require__(45); + var _utilInteraction = __webpack_require__(47); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); var directions = _utilConstants2['default'].directions; - var localizers = _utilConfiguration2['default'].locale; - var format = function format(props) { - return props.format || localizers.number.formats['default']; + return _utilLocalizers.number.getFormat('default', props.format); }; var propTypes = { @@ -7170,7 +7407,6 @@ return /******/ (function(modules) { // webpackBootstrap autoFocus: _react2['default'].PropTypes.bool, disabled: _utilPropTypes2['default'].disabled, readOnly: _utilPropTypes2['default'].readOnly, - autoFocus: _react2['default'].PropTypes.bool, messages: _react2['default'].PropTypes.shape({ increment: _react2['default'].PropTypes.string, @@ -7188,7 +7424,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'mixins', initializer: function initializer() { - return [__webpack_require__(46), __webpack_require__(47), __webpack_require__(54)]; + return [__webpack_require__(48), __webpack_require__(49), __webpack_require__(56)]; } }, { key: 'propTypes', @@ -7385,7 +7621,7 @@ return /******/ (function(modules) { // webpackBootstrap value: function step(amount) { var value = (this.props.value || 0) + amount; - var decimals = this.props.precision != null ? this.props.precision : localizers.number.precision(format(this.props)); + var decimals = this.props.precision != null ? this.props.precision : _utilLocalizers.number.precision(format(this.props)); this.change(decimals != null ? round(value, decimals) : value); @@ -7430,13 +7666,16 @@ return /******/ (function(modules) { // webpackBootstrap //allow for styling, focus stealing keeping me from the normal what have you /***/ }, -/* 77 */ +/* 79 */ /***/ function(module, exports) { // my tests in ie11/chrome/FF indicate that keyDown repeats // at about 35ms+/- 5ms after an initial 500ms delay. callback fires on the leading edge "use strict"; + exports.__esModule = true; + exports["default"] = Repeater; + function Repeater(callback) { var id, cancel = function cancel() { @@ -7452,40 +7691,48 @@ return /******/ (function(modules) { // webpackBootstrap return cancel; } - module.exports = Repeater; + module.exports = exports["default"]; /***/ }, -/* 78 */ +/* 80 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); + + exports.__esModule = true; + + var _react = __webpack_require__(21); + + var _react2 = babelHelpers.interopRequireDefault(_react); + + var _utilPropTypes = __webpack_require__(33); + + var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var React = __webpack_require__(4), - CustomPropTypes = __webpack_require__(30), - localizers = __webpack_require__(23).locale; + var _utilLocalizers = __webpack_require__(18); var format = function format(props) { - return props.format || localizers.number.formats['default']; + return _utilLocalizers.number.getFormat('default', props.format); }; - module.exports = React.createClass({ + exports['default'] = _react2['default'].createClass({ displayName: 'NumberPickerInput', propTypes: { - value: React.PropTypes.number, - placeholder: React.PropTypes.string, + value: _react2['default'].PropTypes.number, + placeholder: _react2['default'].PropTypes.string, - format: CustomPropTypes.numberFormat, - parse: React.PropTypes.func.isRequired, - culture: React.PropTypes.string, + format: _utilPropTypes2['default'].numberFormat, + parse: _react2['default'].PropTypes.func.isRequired, + culture: _react2['default'].PropTypes.string, - min: React.PropTypes.number, + min: _react2['default'].PropTypes.number, - onChange: React.PropTypes.func.isRequired, - onKeyDown: React.PropTypes.func + onChange: _react2['default'].PropTypes.func.isRequired, + onKeyDown: _react2['default'].PropTypes.func }, getDefaultProps: function getDefaultProps() { @@ -7493,7 +7740,7 @@ return /******/ (function(modules) { // webpackBootstrap value: null, editing: false, parse: function parse(number, culture) { - return localizers.number.parse(number, culture); + return _utilLocalizers.number.parse(number, culture); } }; }, @@ -7519,7 +7766,7 @@ return /******/ (function(modules) { // webpackBootstrap render: function render() { var value = this.state.stringValue; - return React.createElement('input', babelHelpers._extends({}, this.props, { + return _react2['default'].createElement('input', babelHelpers._extends({}, this.props, { type: 'text', className: 'rw-input', onChange: this._change, @@ -7586,76 +7833,69 @@ return /******/ (function(modules) { // webpackBootstrap // } function formatNumber(number, format, culture) { - return localizers.number.format(number, format, culture); + return _utilLocalizers.number.format(number, format, culture); } + module.exports = exports['default']; /***/ }, -/* 79 */ +/* 81 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _Popup = __webpack_require__(12); + var _Popup = __webpack_require__(27); var _Popup2 = babelHelpers.interopRequireDefault(_Popup); - var _utilDomSupport = __webpack_require__(80); - - var _utilDomSupport2 = babelHelpers.interopRequireDefault(_utilDomSupport); - - var _MultiselectInput = __webpack_require__(81); + var _MultiselectInput = __webpack_require__(82); var _MultiselectInput2 = babelHelpers.interopRequireDefault(_MultiselectInput); - var _MultiselectTagList = __webpack_require__(82); + var _MultiselectTagList = __webpack_require__(83); var _MultiselectTagList2 = babelHelpers.interopRequireDefault(_MultiselectTagList); - var _utilCompat = __webpack_require__(28); - - var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _List = __webpack_require__(32); + var _List = __webpack_require__(35); var _List2 = babelHelpers.interopRequireDefault(_List); - var _ListGroupable = __webpack_require__(38); + var _ListGroupable = __webpack_require__(41); var _ListGroupable2 = babelHelpers.interopRequireDefault(_ListGroupable); - var _utilValidateListInterface = __webpack_require__(40); + var _utilValidateListInterface = __webpack_require__(43); var _utilValidateListInterface2 = babelHelpers.interopRequireDefault(_utilValidateListInterface); - var _uncontrollable = __webpack_require__(41); + var _uncontrollable = __webpack_require__(44); var _uncontrollable2 = babelHelpers.interopRequireDefault(_uncontrollable); - var _utilDataHelpers = __webpack_require__(34); + var _utilDataHelpers = __webpack_require__(37); - var _utilInteraction = __webpack_require__(45); + var _utilInteraction = __webpack_require__(47); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); var compatCreate = function compatCreate(props, msgs) { return typeof msgs.createNew === 'function' ? msgs.createNew(props) : [_react2['default'].createElement( @@ -7665,8 +7905,6 @@ return /******/ (function(modules) { // webpackBootstrap ), ' ' + msgs.createNew]; }; - _react2['default'].initializeTouchEvents(true); - var omit = _util_2['default'].omit; var pick = _util_2['default'].pick; var splat = _util_2['default'].splat; @@ -7724,7 +7962,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'mixins', initializer: function initializer() { - return [__webpack_require__(46), __webpack_require__(48), __webpack_require__(49), __webpack_require__(54), __webpack_require__(37)('input', function (key, id) { + return [__webpack_require__(48), __webpack_require__(50), __webpack_require__(51), __webpack_require__(56), __webpack_require__(40)('input', function (key, id) { var myKey = this.props.ariaActiveDescendantKey; var createIsActive = (!this._data().length || this.state.focusedItem === null) && key === myKey; @@ -7837,8 +8075,8 @@ return /******/ (function(modules) { // webpackBootstrap var elementProps = omit(this.props, Object.keys(propTypes)); var tagsProps = pick(this.props, ['valueField', 'textField']); var inputProps = pick(this.props, ['maxLength', 'searchTerm', 'autoFocus']); - var listProps = pick(this.props, Object.keys(_utilCompat2['default'].type(List).propTypes)); - var popupProps = pick(this.props, Object.keys(_utilCompat2['default'].type(_Popup2['default']).propTypes)); + var listProps = pick(this.props, Object.keys(List.propTypes)); + var popupProps = pick(this.props, Object.keys(_Popup2['default'].propTypes)); var _state = this.state; var focusedTag = _state.focusedTag; @@ -8134,6 +8372,8 @@ return /******/ (function(modules) { // webpackBootstrap }); }); + this._lengthWithoutValues = items.length; + if (searchTerm) items = this.filter(items, searchTerm); return items; @@ -8177,34 +8417,24 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 80 */ -/***/ function(module, exports) { - - 'use strict'; - - module.exports = { - ios: typeof navigator !== 'undefined' && navigator.userAgent.match(/(iPod|iPhone|iPad)/) && navigator.userAgent.match(/AppleWebKit/) - }; - -/***/ }, -/* 81 */ +/* 82 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); @@ -8250,36 +8480,36 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 82 */ +/* 83 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); - var _utilDataHelpers = __webpack_require__(34); + var _utilDataHelpers = __webpack_require__(37); - var _utilInteraction = __webpack_require__(45); + var _utilInteraction = __webpack_require__(47); var optionId = function optionId(id, idx) { return id + '__option__' + idx; @@ -8289,7 +8519,7 @@ return /******/ (function(modules) { // webpackBootstrap displayName: 'MultiselectTagList', - mixins: [__webpack_require__(47), __webpack_require__(37)()], + mixins: [__webpack_require__(49), __webpack_require__(40)()], propTypes: { value: _react2['default'].PropTypes.array, @@ -8443,56 +8673,56 @@ return /******/ (function(modules) { // webpackBootstrap module.exports = exports['default']; /***/ }, -/* 83 */ +/* 84 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(3); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; - var _react = __webpack_require__(4); + var _react = __webpack_require__(21); var _react2 = babelHelpers.interopRequireDefault(_react); - var _util_ = __webpack_require__(11); + var _util_ = __webpack_require__(20); var _util_2 = babelHelpers.interopRequireDefault(_util_); - var _classnames = __webpack_require__(10); + var _classnames = __webpack_require__(26); var _classnames2 = babelHelpers.interopRequireDefault(_classnames); - var _uncontrollable = __webpack_require__(41); + var _uncontrollable = __webpack_require__(44); var _uncontrollable2 = babelHelpers.interopRequireDefault(_uncontrollable); - var _utilCompat = __webpack_require__(28); + var _utilCompat = __webpack_require__(31); var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _utilPropTypes = __webpack_require__(30); + var _utilPropTypes = __webpack_require__(33); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); - var _List = __webpack_require__(32); + var _List = __webpack_require__(35); var _List2 = babelHelpers.interopRequireDefault(_List); - var _utilValidateListInterface = __webpack_require__(40); + var _utilValidateListInterface = __webpack_require__(43); var _utilValidateListInterface2 = babelHelpers.interopRequireDefault(_utilValidateListInterface); - var _domHelpersUtilScrollTo = __webpack_require__(50); + var _domHelpersUtilScrollTo = __webpack_require__(52); var _domHelpersUtilScrollTo2 = babelHelpers.interopRequireDefault(_domHelpersUtilScrollTo); - var _utilDataHelpers = __webpack_require__(34); + var _utilDataHelpers = __webpack_require__(37); - var _utilInteraction = __webpack_require__(45); + var _utilInteraction = __webpack_require__(47); - var _utilWidgetHelpers = __webpack_require__(35); + var _utilWidgetHelpers = __webpack_require__(38); var omit = _util_2['default'].omit; var pick = _util_2['default'].pick; @@ -8538,7 +8768,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'mixins', initializer: function initializer() { - return [__webpack_require__(46), __webpack_require__(54), __webpack_require__(37)()]; + return [__webpack_require__(48), __webpack_require__(56), __webpack_require__(40)()]; } }, { key: 'getDefaultProps', @@ -8604,7 +8834,7 @@ return /******/ (function(modules) { // webpackBootstrap List = List || _List2['default']; var elementProps = omit(this.props, Object.keys(propTypes)); - var listProps = pick(this.props, Object.keys(_utilCompat2['default'].type(List).propTypes)); + var listProps = pick(this.props, Object.keys(List.propTypes)); var _state = this.state; var ListItem = _state.ListItem; @@ -8864,152 +9094,6 @@ return /******/ (function(modules) { // webpackBootstrap exports['default'] = _uncontrollable2['default'](SelectList, { value: 'onChange' }); module.exports = exports['default']; -/***/ }, -/* 84 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var babelHelpers = __webpack_require__(3); - - exports.__esModule = true; - - var _utilConfiguration = __webpack_require__(23); - - var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); - - var _utilLocalizers = __webpack_require__(85); - - var _utilLocalizers2 = babelHelpers.interopRequireDefault(_utilLocalizers); - - var NumberLocalizer = _utilLocalizers2['default'].NumberLocalizer; - var DateLocalizer = _utilLocalizers2['default'].DateLocalizer; - exports['default'] = { - - setAnimate: function setAnimate(animatefn) { - _utilConfiguration2['default'].animate = animatefn; - }, - - setLocalizers: function setLocalizers(_ref) { - var date = _ref.date; - var number = _ref.number; - - this.setDateLocalizer(date); - this.setNumberLocalizer(number); - }, - - setDateLocalizer: function setDateLocalizer(spec) { - _utilConfiguration2['default'].locale.date = new DateLocalizer(spec); - }, - - setNumberLocalizer: function setNumberLocalizer(spec) { - _utilConfiguration2['default'].locale.number = new NumberLocalizer(spec); - } - }; - module.exports = exports['default']; - -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { - - /* WEBPACK VAR INJECTION */(function(process) {'use strict'; - - var babelHelpers = __webpack_require__(3); - - var invariant = __webpack_require__(44); - - var _require = __webpack_require__(11); - - var has = _require.has; - - var React = __webpack_require__(4); - - var REQUIRED_NUMBER_FORMATS = ['default']; - - var localePropType = React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.func]); - - var REQUIRED_DATE_FORMATS = ['default', 'date', 'time', 'header', 'footer', 'dayOfMonth', 'month', 'year', 'decade', 'century']; - - function _format(localizer, formatter, value, format, culture) { - var result = typeof format === 'function' ? format(value, culture, localizer) : formatter.call(localizer, value, format, culture); - - invariant(result == null || typeof result === 'string', '`localizer format(..)` must return a string, null, or undefined'); - - return result; - } - - function checkFormats(requiredFormats, formats) { - if (process.env.NODE_ENV !== 'production') requiredFormats.forEach(function (f) { - return invariant(has(formats, f), 'localizer missing required format: `%s`', f); - }); - } - - var NumberLocalizer = function NumberLocalizer(_ref) { - var _this = this; - - var format = _ref.format; - var parse = _ref.parse; - var precision = _ref.precision; - var formats = _ref.formats; - var propType = _ref.propType; - babelHelpers.classCallCheck(this, NumberLocalizer); - - invariant(typeof format === 'function', 'number localizer `format(..)` must be a function'); - invariant(typeof parse === 'function', 'number localizer `parse(..)` must be a function'); - - checkFormats(REQUIRED_NUMBER_FORMATS, formats); - - this.propType = propType || localePropType; - this.formats = formats; - this.precision = precision || function () { - return null; - }; - - this.format = function (value, str, culture) { - return _format(_this, format, value, str, culture); - }; - - this.parse = function (value, culture) { - var result = parse.call(_this, value, culture); - - invariant(result == null || typeof result === 'number', 'number localizer `parse(..)` must return a number, null, or undefined'); - - return result; - }; - }; - - var DateLocalizer = function DateLocalizer(spec) { - var _this2 = this; - - babelHelpers.classCallCheck(this, DateLocalizer); - - invariant(typeof spec.format === 'function', 'date localizer `format(..)` must be a function'); - invariant(typeof spec.parse === 'function', 'date localizer `parse(..)` must be a function'); - invariant(typeof spec.firstOfWeek === 'function', 'date localizer `firstOfWeek(..)` must be a function'); - checkFormats(REQUIRED_DATE_FORMATS, spec.formats); - - this.propType = spec.propType || localePropType; - this.formats = spec.formats; - this.startOfWeek = spec.firstOfWeek; - - this.format = function (value, format, culture) { - return _format(_this2, spec.format, value, format, culture); - }; - - this.parse = function (value, format, culture) { - var result = spec.parse.call(_this2, value, format, culture); - - invariant(result == null || result instanceof Date && !isNaN(result.getTime()), 'date localizer `parse(..)` must return a valid Date, null, or undefined'); - - return result; - }; - }; - - module.exports = { - NumberLocalizer: NumberLocalizer, DateLocalizer: DateLocalizer - }; - /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1))) - /***/ } /******/ ]) }); diff --git a/docs/components/docs.jsx b/docs/components/docs.jsx index 189b78120..f5dcd4104 100644 --- a/docs/components/docs.jsx +++ b/docs/components/docs.jsx @@ -31,12 +31,11 @@ require('../vendor/styles.css') require('react-widgets/less/react-widgets.less') require('../docs.css') -var configure = require('../../src/configure') -var localizers = require('../../src/globalize-localizers') -configure.setLocalizers( - localizers(require('globalize')) -) +var localizers = require('../../src/localizers/globalize') + +localizers(require('globalize')) + var locations = [ 'getting-started', 'dropdown-list', 'combobox', @@ -51,7 +50,7 @@ var Docs = React.createClass({ getInitialState: function () { return { - sideHref: '#intro', + sideHref: '#intro' } }, diff --git a/docs/components/pages/Calendar.api.md b/docs/components/pages/Calendar.api.md index 070fc6705..597844afb 100644 --- a/docs/components/pages/Calendar.api.md +++ b/docs/components/pages/Calendar.api.md @@ -52,50 +52,50 @@ Acceptable values are: `"month"` `"year"` `"decade"` `"century"` -### headerFormat?{ type: 'String | Function(Date? date)', default: "'MMMM yyyy'" } +### headerFormat?{ localizable: true } A formatter for the header button of the month view -### footerFormat?{ type: 'String | Function(Date? date)', default: "'D'" } +### footerFormat?{ localizable: true } A formatter for the Calendar footer, formats Today's Date as a string. -### dayFormat?{ type: 'String | Function(Number dayOfTheWeek)', default: "Function()" } +### dayFormat?{ localizable: true } A formatter calendar days of the week, the default formats each day as a Narrow name: "Mo", "Tu", etc. ['M', 'T','W','Th', 'F', '!', '!'][day]" })}/> +widgetName, { dayFormat: "day => ['M', 'T','W','Th', 'F', '!', '!'][day.getDay()]" })}/> -### dateFormat?{ type: 'String | Function(Date? date)', default: "'dd'" } +### dateFormat?{ localizable: true } A formatter for day of the month dt.getDate()", footer: true })}/> -### monthFormat?{ type: 'String | Function(Date? date)', default: "'MMM'" } +### monthFormat?{ localizable: true } A formatter for month name. -### yearFormat?{ type: 'String | Function(Date? date)', default: "'YYYY'" } +### yearFormat?{ localizable: true } A formatter for the year. -### decadeFormat?{ type: 'String | Function(Date? date)', default: "Function()" } +### decadeFormat?{ localizable: true } A formatter for decade, the default formats the first and last year of the decade like: 2000 - 2009. -### centuryFormat?{ type: 'String | Function(Date? date)', default: "Function()" } +### centuryFormat?{ localizable: true } A formatter for century, the default formats the first and last year of the century like: 1900 - 1999. diff --git a/docs/components/pages/DateTimePicker.api.md b/docs/components/pages/DateTimePicker.api.md index a8ae99faf..e906ba286 100644 --- a/docs/components/pages/DateTimePicker.api.md +++ b/docs/components/pages/DateTimePicker.api.md @@ -1,6 +1,11 @@ -Manipulate different parts of a JavaScript `Date` object with ease. Date formats are highly localized, and localization is hard, rather than provide a half baked solution react-widgets includes a default strategy for that via [Globalize.js](https://github.com/jquery/globalize/tree/79ae658b842f75f58199d6e9074e01f7ce207468). You can pass in a `culture` string to the widgets, but you are responsible for loading the globalize culture file yourself. You can also completely replace globalize by providing format and parsing props. +Manipulate different parts of a JavaScript `Date` object with ease. +Date formats are highly localized, and localization is hard, rather than provide a half baked +solution react-widgets requires that you specify a __localizer__ in order for the widget to work. You can read more +about localizers here: [localization](i18n). -Dates are never mutated but always return and operate on a new Date instance. When the `date` prop is used the ${widgetName} will pass through the relevant props to the Calendar Widget and Calendar keyboard navigation keys will also work. +Dates are never mutated but always return and operate on a new Date instance. +When the `date` prop is used the ${widgetName} will pass through the relevant +props to the Calendar Widget and Calendar keyboard navigation keys will also work. <---------------> @@ -52,22 +57,22 @@ the `onChange` handler. -### format?{ type: 'String', default: '"fdt"' } +### format?{ localizable: true } A string format used to display the date value. For more information on prefined and custom formats visit the [Globalize.js documentation](https://github.com/jquery/globalize/tree/79ae658b842f75f58199d6e9074e01f7ce207468#dates) -### editFormat?{ type: 'String' } +### editFormat?{ localizable: true } -A string format to be used while the date input has focus. Useful for showing a simpler format for inputing. -For more information on prefined and custom formats visit +A string format to be used while the date input has focus. Useful for showing a simpler format for inputing. +For more information on prefined and custom formats visit the [Globalize.js documentation](https://github.com/jquery/globalize/tree/79ae658b842f75f58199d6e9074e01f7ce207468#dates) -### timeFormat?{ type: 'String' } +### timeFormat?{ localizable: true } A string format used by the time dropdown to render times. For more information on prefined and custom formats visit the [Globalize.js documentation](https://github.com/jquery/globalize/tree/79ae658b842f75f58199d6e9074e01f7ce207468#dates) @@ -81,7 +86,7 @@ The amount of minutes between each entry in the time list. ### parse?{ type: '[Function(String str), Array]' } Determines how the widget parses the typed date string into a Date object. You can provide an array of formats to try, -or provide a function that returns a date to handle parsing yourself. When `parse` is unspecified and +or provide a function that returns a date to handle parsing yourself. When `parse` is unspecified and the `format` prop is a `String` parse will automatically use that format as its default @@ -151,4 +156,4 @@ title and screen reader text for the right arrow button. - home move focus to first time - end move focus to last time - enter select focused item -- any key search list for time starting with key \ No newline at end of file +- any key search list for time starting with key diff --git a/docs/components/pages/GettingStarted.md b/docs/components/pages/GettingStarted.md index 4b9b91a81..b862f689f 100644 --- a/docs/components/pages/GettingStarted.md +++ b/docs/components/pages/GettingStarted.md @@ -1,62 +1,66 @@ # Getting Started current version {\_\_VERSION\_\_} -React-widgets offers a set of html form inputs, built from scratch with React. The suite is based on the excellent -work done by Kendo UI Core, and jQuery UI, but built as true components, and not library wrappers. By -building each widget entirely in React, it can leverage all of the benefits of the React ecosystem +React-widgets offers a set of html form inputs, built from scratch with React. The suite is based on the excellent +work done by Kendo UI Core, and jQuery UI, but built as true components, and not library wrappers. By +building each widget entirely in React, it can leverage all of the benefits of the React ecosystem and [philosophy](http://facebook.github.io/react/blog/2013/11/05/thinking-in-react.html). A big thanks to both of these libraries for solving most of the difficult problems already. -In keeping with the [React approach](http://facebook.github.io/react/docs/forms.html#controlled-components) to form input components, each widget can be controlled or uncontrolled. If a `value` prop -is set the widget's value is said to be controlled, meaning the parent is responsible for managing its -state. If the widget does not provide a `value` prop, the widget becomes uncontrolled or responsible for managing its own value with no other input, you can set a starting value for an uncontrolled widget with the `defaultValue` prop. In addition to the `value` prop, widgets may allow other props (such as `open` or `search`) to be controlled as well. +In keeping with the [React approach](http://facebook.github.io/react/docs/forms.html#controlled-components) to +form input components, each widget can be controlled or uncontrolled. If a `value` prop +is set the widget's value is said to be controlled, meaning the parent is responsible for managing its +state. If the widget does not provide a `value` prop, the widget becomes uncontrolled or responsible for +managing its own value with no other input, you can set a starting value for an uncontrolled widget +with the `defaultValue` prop. In addition to the `value` prop, widgets may allow other +props (such as `open` or `search`) to be controlled as well. -Some widgets can also be "bound" to a set of data (traditionally an array of models) through a `data` prop. While they work just as well with data primitives such as strings, numbers, and arrays, they really shine through the use of the -`valueField` and `textField` props, which offer a quick way to display complex data structures. +Some widgets can also be "bound" to a set of data (traditionally an array of models) through a `data` prop. +While they work just as well with data primitives such as strings, numbers, and arrays, they really shine +through the use of the `valueField` and `textField` props, which offer a quick way to display complex data structures. ## Install -##### npm (recommended) -```sh + + +npm (recommended) + npm install react-widgets --save -``` - -##### Bower -```sh + + + +bower + bower install react-widgets --save -``` + + + -##### Script Tag -```html - - - -``` +The npm build offers an additional advantage of allowing you to only require the individual widgets allowing frontend +bundlers like Webpack and Browserify to only package up the pieces you use saving you bytes. -The npm build offers an additional advantage of allowing you to only require the individual widgets allowing front end bundlers like Webpack -and Browserify to only package up the pieces you use saving you bytes. The global browser build will also need to -include [Globalize.js](https://github.com/jquery/globalize/tree/79ae658b842f75f58199d6e9074e01f7ce207468), a library for handling number and date localization (see the [Localization page](i18n) for more info on Globalize, or using other libraries). +## Setup Stylesheets, images, and fonts are found in the `dist` directory. You can use Webpack to `require()` the styles, or include the css normally. The included icons are provided by - Font Awesome by Dave Gandy +The global browser has some additional steps for including, a library for handling number and date localization (see the for more info on Globalize, or using other libraries). -##### Browser -```html - -``` - -##### Webpack +#### Webpack ```js - // css - require('react-widgets/dist/css/react-widgets.css') - // or using less - require('react-widgets/lib/less/react-widgets.less') + import { render } from 'react-dom'; + + import 'react-widgets/lib/less/react-widgets.less'; + + import DropdownList from 'react-widgets/lib/DropdownList'; + + render(, document.getElementById('app-root')) ``` -If are using Webpack to handle styles in your application you are probably already configured to load the `react-widgets` styles without any additional work. If not you will have to use the `css-loader`, `style-loader`, `file-loader`, `url-loader` and, optionally, the `less-loader`. Below is a common configuration: +If are using Webpack to handle styles in your application you are probably already configured to load +the `react-widgets` styles without any additional work. If not you will have to use +the `css-loader`, `style-loader`, `file-loader`, `url-loader` and, optionally, the `less-loader`. +Below is a common configuration: ```js loaders: [ @@ -68,6 +72,25 @@ If are using Webpack to handle styles in your application you are probably alrea ] ``` +#### Global Build + +```html + + + + + +``` + +### I18n and Localization + +If you want to use the `DateTimePicker` or `NumberPicker` widgets, you will also need to set up a *Localizer* to handle +date and number localization. Check out the [Localization page](i18n) for more information. + ## Accessibility and Read Direction React-widgets tries to be as inclusive and wide reaching as possible. Along with an included solution for @@ -77,14 +100,18 @@ right to left (with the `isRtl` prop). Each widget also has appropriate ARIA roles and attributes for the benefit of screen readers and visually impaired users. Keyboard only navigation of widgets is also supported, for those who prefer to not, or cannot use a mouse. to help ensure maximum accessibility, every widget should have -an `id` attribute. If you do not wish to provide an id attrbute, the widget will generate +an `id` attribute. If you do not wish to provide an id attribute, the widget will generate the necessary id's to properly label and annotate the widget ARIA. ## Older Browser Support -Rather than including an entire utility library, like underscore, react widgets takes a hint from React itself, -and instead relies on es5 (and transpiled es6) functionality. For most browsers this is will not be an issue, as es5 -is [very well supported](http://kangax.github.io/compat-table/es5/) by modern browsers. However older browsers will need the required functionality polyfilled. In most cases React already requires most of the needed shims ([see here](http://facebook.github.io/react/docs/working-with-the-browser.html#polyfills-needed-to-support-older-browsers)). If you are already including [kriskowal's es5-shim](https://github.com/es-shims/es5-shim') then react-widgets propbably has everything it needs. +Rather than including an entire utility library, like underscore, react widgets takes a hint from React itself, +and instead relies on es5 (and transpiled es6) functionality. For most browsers this is will not be an issue, as es5 +is [very well supported](http://kangax.github.io/compat-table/es5/) by modern browsers. +However older browsers will need the required functionality polyfilled. +In most cases React already requires most of the needed shims ([see here](http://facebook.github.io/react/docs/working-with-the-browser.html#polyfills-needed-to-support-older-browsers)). +If you are already including [kriskowal's es5-shim](https://github.com/es-shims/es5-shim') +then react-widgets probably has everything it needs. For those interested in the specific additions needed by react-widgets they are: @@ -93,7 +120,9 @@ For those interested in the specific additions needed by react-widgets they are: - `Array.prototype.reduce` #### Animation -react-widgets uses CSS animations which are not supported in older IE. If you want to replace the default the animation method for these cases you can. The built in method follows the jQuery `$.animate()` API closely so you can use it as a dropin replacement. +react-widgets uses CSS animations which are not supported in older IE. If you want to replace the +default the animation method for these cases you can. The built in method follows the +jQuery `$.animate()` API closely so you can use it as a drop in replacement. ##### With the Configure module ```js @@ -102,7 +131,7 @@ require('react-widgets/lib/configure') ``` ##### From the main export ```js -require('react-widgets').configure +require('react-widgets') .setAnimate((element, props, duration, ease, callback) => $(element).animate(props, duration, callback)) ``` diff --git a/docs/components/pages/NumberPicker.api.md b/docs/components/pages/NumberPicker.api.md index 4d4acd35a..e371df2a1 100644 --- a/docs/components/pages/NumberPicker.api.md +++ b/docs/components/pages/NumberPicker.api.md @@ -1,5 +1,6 @@ -Spinner for selecting numbers. Supports multiple formats for display and editing through [Globalize.js](https://github.com/jquery/globalize/tree/79ae658b842f75f58199d6e9074e01f7ce207468). +Spinner for selecting numbers. The NumberPicker is a _localized_ widget and so __requires__ a localizer to +be specified. You can read more about localizers here: [localization](i18n). <---------------> @@ -16,13 +17,14 @@ current numeric value or null. -### format?{ type: 'Function(String str) | String', default: 'd' } +### format?{ localizable: true } -A format string used to display the number value. For more information on prefined and custom number and currency formats visit the [Globalize.js documentation](https://github.com/jquery/globalize/tree/79ae658b842f75f58199d6e9074e01f7ce207468#number-formatting') You provide a `Function` as a format if you wish to not use Globalize, or just want to provide some custom behavior. +A format string used to display the number value. Localizer dependent, read [localization](i18n) for more info. ### parse?{ type: 'Function(String str, String culture) | Array' } -Determines how the {widgetName} parses a number from the localized string representation. You can also provide a parser `Function` to pair with a custom `format`. +Determines how the {widgetName} parses a number from the localized string representation. +You can also provide a parser `Function` to pair with a custom `format`. ### min?{ type: 'Number', default: '-Infinity' } @@ -44,7 +46,7 @@ Amount to increase or decrease value when using the spinner buttons. ### precision?{ type: 'Number' } -Specify how precise the `value` should be when typing, incrementing, or decrementing the value. When empty, precision +Specify how precise the `value` should be when typing, incrementing, or decrementing the value. When empty, precision is parsed from the current `format` and culture. ### isRtl?{ type: 'Boolean', default: 'false' } @@ -62,7 +64,7 @@ localize widget text and increase accessibility. Number picker spinner up button text for screen readers ### messages.decrement?{ type: 'String', default: '"decrement value"' } -Number picker spinner down button text for screen readers +Number picker spinner down button text for screen readers ## Keyboard Navigation diff --git a/docs/components/pages/i18n.md b/docs/components/pages/i18n.md index 83132c5ee..b485db86e 100644 --- a/docs/components/pages/i18n.md +++ b/docs/components/pages/i18n.md @@ -1,46 +1,104 @@ # Localization -In order to handle the international differences in number and date formats `react-widgets` uses Globalize.js as the default localization strategy. Globalize handles both numbers and dates making it a great fit for a library offering both number and date pickers. Of course not everyone needs as robust localization support, so you are free to swap out Globalize for whatever tool you wish. +In order to handle the complex international differences in number and date formats `react-widgets` relies on third party +parsing and formatting libraries through the use of specific "localizers". `react-widgets` comes with +built-in localizers for __Globalize.js__, __Moment.js__ and a simple number localizer, but you can easily write +your own for whatever library you are using. -## Use with multiple locales +Localization sensitive widgets have `format` props that passed directly to your chosen localizer. The type and shape +of these format props is determined by the api of the backing I18n strategy. Moment.js, for instance, +uses string based date formats like: `MMM dd YYYY` whereas the newer Globalize.js may take an object like: +`{ skeleton: GyMMMd }`. Regardless of the localizer, formats always accept `function` values for doing on-the-fly custom +formatting. -Globalize comes with the 'en' culture loaded by default, but provides many many others as well. To load additional culture files just require them via `require('globalize/lib/cultures/globalize.culture.[culture string]')`. If you are using Globalize as an external module, simply load the files you want in a `` tag. -You can load multiple culture files at once and switch between them by passing the culture string (e.g. 'ar-ZA') to individual widgets or set the culture globally for all widgets with `globalize.culture('ar-ZA')`. +### Globalize.js (recommended) date, number -#### Bundling Caveats +Globalize can be a bit of a challenge to set up correctly so please consult the [globalize docs](https://github.com/jquery/globalize#getting-started) for a lot of info on setting up +Globalize and integrating into lots of different app environments. -Loading globalize cultures mutates the "Globalize" object, this means you need to ensure that only one instance of Globalize included in your app at a time. If you are using Browserify or Webpack, -you can make use of their configuration options to ensure this. You can also use `npm dedupe` to ensure only one copy is included. If all else fails you can explicitly pass the correct Globalize instance to `react-widgets` with the included Globalize Localizers. +The globalize localizer handles both __number__ and __date__ localization so there is no need for any additional +localizers. + +__NOTE: If you like the pre `1.0.0` globalize api, the localizer still supports that version, just be sure +to install it, and follow the old docs for setup__ ```js -var { - globalizeNumberLocalizer - , globalizeDateLocalizer } = require('react-widgets/lib/globalize-localizers') -configure.setNumberLocalizer(globalizeNumberLocalizer(globalize)) -configure.setDateLocalizer(globalizeDateLocalizer(globalize)) +var Globalize = require('globalize') +var globalizeLocalizer = require('../lib/localizers/globalize') + +Globalize.load(/* load the date and number modules */) +Globalize.locale('en-GB') + +globalizeLocalizer(Globalize); + ``` -## Localizers +Globalize [formats](https://github.com/jquery/globalize/blob/master/doc/api/date/date-formatter.md#parameters) can +be either `string`s, or `object`s. Date `string` formats are automatically considered `raw` patterns, +and are equivalent to `globalize.formatDate(date, { raw: format })`. Number formats accept any of +the [Globalize number options](https://github.com/jquery/globalize/blob/master/doc/api/number/number-formatter.md#parameters). +In addition you can specify _currencies_ by adding the `currency` key like: `{ currency: "USD", style: 'decimal' }`. -All localization functionality is contained in "Localizers", making it easy to swap out -different localization strategies. There are two types of -localizers: `DateLocalizer` and `NumberLocalizer`. Localizers are used to handle -the _parsing_, converting a string into a proper type, and _formatting_, converting a type -to a string representation. Localizers also provide a way to set all localization specific widget props at once, -through "formats". +```js + + -## Creating a Localizer + + +``` -Creating a localizer is as easy as providing `react-widgets` an localizer options object. -Localizers must provide `parse()` and `format()` functions as well as provide default values for all the -required formats the widgets need. +### Moment.js date + +Again see the official [Moment docs](http://momentjs.com/) for information on integrating Moment into your build +pipeline effectively. + +Moment only provides __date__ localization, if you also need Number localization consider +the __simple-number__ localizer below, or Globalize.js. + +```js +var Moment = require('moment') +var momentLocalizer = require('../lib/localizers/moment') + +momentLocalizer(Moment); +``` -Formats can be whatever type your localization strategy requires (strings, objects, etc), however functions are always valid. The default formats, for example, can be strings or functions. If you wanted to use the builtin `Intl` apis for formating, formats might be an options object to pass to `Intl.DateTimeFormat()`. Function formats are called automatically by the localizer with the `value`, the `culture` string and the localizer instance. +Moment [format](http://momentjs.com/docs/#/displaying/format/) props accept `string`s -__For a practical example of creating a Localizer check out [this MomentJs Localizer](https://github.com/jquense/react-widgets-localizer-moment)__ +```js + +``` + +### Simple Number number + +The `simple-number` localizer provides a minimal number formatting and parsing strategy. Its best when you don't need +robust locale support for currencies, and numbers; + +```js +var numberLocalizer = require('../lib/localizers/simple-number') + +numberLocalizer(); +``` +Check out the documentation for [format-number-with-string](https://www.npmjs.com/package/format-number-with-string) for +a complete guide to its format syntax. + +```js + +``` + +## Creating a Localizer + +Creating a localizer is as easy as providing `react-widgets` an localizer options object. +Localizers must provide `parse()` and `format()` functions as well as provide default values for all the +required formats the widgets need. + +Formats can be whatever type your localization strategy requires (strings, objects, etc), however functions are +always valid. The default formats, for example, can be strings or functions. +If you wanted to use the built-in `Intl` api's for formatting, formats might be an options object to +pass to `Intl.DateTimeFormat()`. Function formats are called automatically by the localizer with the `value`, +the `culture` string and the localizer instance. ```js var localizer = { @@ -48,8 +106,8 @@ var localizer = { formats: { day: 'DD', month: 'mmm', - // we always pass a function for more advanced formats such as returning a year 'range' - // to represent a decade e.g "2000 - 2009". Notice the localizer instance is the third argument, + // we always pass a function for more advanced formats such as returning a year 'range' + // to represent a decade e.g "2000 - 2009". Notice the localizer instance is the third argument, // which can be used to format or parse as needed. decade: (date, culture, localizer) => { return localizer.format(date, 'YYYY') + ' - ' + localizer.format(lastYearOfDecade(date), 'YYYY') @@ -64,55 +122,8 @@ var localizer = { return formattedDateString } } -``` - -## Using Localizers - -`react-widgets` provides a `setDateLocalizer` and `setNumberLocalizer` functions for swapping localizers. Depending on if you are consuming widgets via the main module export (`require('react-widgets')`), or requiring each widget individually, you can get access to this API in two ways. Each method will validate your localizer object to make sure it conforms to the expected api. - -```js -// From the main export -var configure = require('react-widgets').configure - -// Alternatively -configure = require('react-widgets/lib/configure') - -var myDateLocalizer = {...} -var myNumberLocalizer = {...} - -// Pass the Localizer options object -configure.setDateLocalizer(myDateLocalizer) - -configure.setNumberLocalizer(myNumberLocalizer) -``` - -### Bundling Caveats - -Handling optional frontend dependancies is hard, and unfortunately there isn't a good way for library authors to make it easier. Because we want to make sure the there is a robust localization strategy included in react-widgets, Globalize is included as a direct dependancy. Practically this means that if you want to replace it you should also take care to exclude it from your builds, when using a frontend bundling tool. - -#### Webpack - -If you are using webpack you can ignore Globalize using the `IgnorePlugin`. - -```js -// in your webpack config -{ - plugins: [ - new webpack.IgnorePlugin(/globalize$/) - ] -} -``` - -#### Browserify -You can make use of the `ignore` option to exclude globalize from builds. -```jsbrowserify --ignore globalize --ignore-missing``` - -```js -{ - //... - ignore: ['globalize'] -} +ReactWidgets.setDateLocalizer(localizer) ``` ## Localizer Api @@ -232,4 +243,4 @@ function( format: String|Object, culture: String? ) -> Number -``` \ No newline at end of file +``` diff --git a/docs/docs.css b/docs/docs.css index b06fc1b85..ef78f4140 100644 --- a/docs/docs.css +++ b/docs/docs.css @@ -1,13 +1,17 @@ body { - font-size: 14px; + font-size: 16px; } -h4 { - margin-top: 20px; +h1, h2, h3, h4 { + margin-top: 25px; + margin-bottom: 15px; } - +.example, +.editable-rendered { + font-size: 14px; +} /*h3 { color: #284C6D; @@ -391,4 +395,4 @@ pre { .token.comment { color: #75787b; -} \ No newline at end of file +} diff --git a/docs/templates/doc-page b/docs/templates/doc-page index 25e3c056d..c54b3a900 100644 --- a/docs/templates/doc-page +++ b/docs/templates/doc-page @@ -3,7 +3,8 @@ var React = require('react') , DDButton = require('../../bootstrap').DropdownButton , MenuItem = require('../ApiMenuItem') , PropHeader = require('../PropHeader') - , WidgetDemo = require('../demos/${widgetName}'); + , WidgetDemo = require('../demos/${widgetName}') + , { Link } = require('react-router'); var widgetName = '${widgetName}'; @@ -35,4 +36,4 @@ module.exports = React.createClass({ ) } -}) \ No newline at end of file +}) diff --git a/docs/vendor/apiLoader.js b/docs/vendor/apiLoader.js index 566865dba..d6997315b 100644 --- a/docs/vendor/apiLoader.js +++ b/docs/vendor/apiLoader.js @@ -29,8 +29,7 @@ var renderer = new Renderer() , props; renderer.heading = function (text, level, raw) { - var parts = parsePropHeader(text) - , valid = true; + var parts = parsePropHeader(text); if ( level === 3 && parts.props ){ if ( parts.text ) diff --git a/lib/Calendar.js b/lib/Calendar.js index 75521d446..a97ec5d9a 100644 --- a/lib/Calendar.js +++ b/lib/Calendar.js @@ -42,9 +42,7 @@ var _Century = require('./Century'); var _Century2 = babelHelpers.interopRequireDefault(_Century); -var _utilConfiguration = require('./util/configuration'); - -var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); +var _utilLocalizers = require('./util/localizers'); var _utilPropTypes = require('./util/propTypes'); @@ -88,8 +86,7 @@ var dir = _utilConstants2['default'].directions, }, {}); }; -var localizers = _utilConfiguration2['default'].locale, - views = _utilConstants2['default'].calendarViews, +var views = _utilConstants2['default'].calendarViews, VIEW_OPTIONS = values(views), ALT_VIEW = invert(_utilConstants2['default'].calendarViewHierarchy), NEXT_VIEW = _utilConstants2['default'].calendarViewHierarchy, @@ -108,7 +105,7 @@ var OPPOSITE_DIRECTION = (_OPPOSITE_DIRECTION = {}, _OPPOSITE_DIRECTION[dir.LEFT var MULTIPLIER = (_MULTIPLIER = {}, _MULTIPLIER[views.YEAR] = 1, _MULTIPLIER[views.DECADE] = 10, _MULTIPLIER[views.CENTURY] = 100, _MULTIPLIER); var format = function format(props, f) { - return props[f + 'Format'] || localizers.date.formats[f]; + return _utilLocalizers.date.getFormat(f, props[f + 'Format']); }; var propTypes = { @@ -249,7 +246,7 @@ var Calendar = _react2['default'].createClass(babelHelpers.createDecoratedObject key = view + '_' + _utilDates2['default'][view](currentDate); var elementProps = _util_2['default'].omit(this.props, Object.keys(propTypes)), - viewProps = _util_2['default'].pick(this.props, Object.keys(_utilCompat2['default'].type(View).propTypes)); + viewProps = _util_2['default'].pick(this.props, Object.keys(View.propTypes)); var isDisabled = disabled || readOnly; @@ -447,7 +444,7 @@ var Calendar = _react2['default'].createClass(babelHelpers.createDecoratedObject var view = this.state.view; var dt = this.state.currentDate; - if (view === 'month') return localizers.date.format(dt, format(props, 'header'), culture);else if (view === 'year') return localizers.date.format(dt, format(props, 'year'), culture);else if (view === 'decade') return localizers.date.format(_utilDates2['default'].startOf(dt, 'decade'), format(props, 'decade'), culture);else if (view === 'century') return localizers.date.format(_utilDates2['default'].startOf(dt, 'century'), format(props, 'century'), culture); + if (view === 'month') return _utilLocalizers.date.format(dt, format(props, 'header'), culture);else if (view === 'year') return _utilLocalizers.date.format(dt, format(props, 'year'), culture);else if (view === 'decade') return _utilLocalizers.date.format(_utilDates2['default'].startOf(dt, 'decade'), format(props, 'decade'), culture);else if (view === 'century') return _utilLocalizers.date.format(_utilDates2['default'].startOf(dt, 'century'), format(props, 'century'), culture); } }, { key: 'inRangeValue', diff --git a/lib/Century.js b/lib/Century.js index fd30768ef..cf14a4d39 100644 --- a/lib/Century.js +++ b/lib/Century.js @@ -16,9 +16,7 @@ var _utilDates = require('./util/dates'); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); -var _utilConfiguration = require('./util/configuration'); - -var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); +var _utilLocalizers = require('./util/localizers'); var _util_ = require('./util/_'); @@ -30,9 +28,8 @@ var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); var _utilWidgetHelpers = require('./util/widgetHelpers'); -var localizers = _utilConfiguration2['default'].locale; var format = function format(props) { - return props.decadeFormat || localizers.date.formats.decade; + return _utilLocalizers.date.getFormat('decade', props.decadeFormat); }; var isEqual = function isEqual(dateA, dateB) { @@ -110,7 +107,7 @@ exports['default'] = _react2['default'].createClass({ var isFocused = isEqual(date, focused), isSelected = isEqual(date, value), currentDecade = isEqual(date, today), - label = localizers.date.format(_utilDates2['default'].startOf(date, 'decade'), format(_this.props), culture); + label = _utilLocalizers.date.format(_utilDates2['default'].startOf(date, 'decade'), format(_this.props), culture); var currentID = optionId(id, date); diff --git a/lib/Combobox.js b/lib/Combobox.js index f09185342..8f81f908a 100644 --- a/lib/Combobox.js +++ b/lib/Combobox.js @@ -93,7 +93,6 @@ var propTypes = { autoFocus: _react2['default'].PropTypes.bool, disabled: _utilPropTypes2['default'].disabled, readOnly: _utilPropTypes2['default'].readOnly, - autoFocus: _react2['default'].PropTypes.bool, suggest: _utilPropTypes2['default'].filter, filter: _utilPropTypes2['default'].filter, @@ -227,8 +226,8 @@ var ComboBox = _react2['default'].createClass(babelHelpers.createDecoratedObject List = List || groupBy && _ListGroupable2['default'] || _List2['default']; var elementProps = omit(this.props, Object.keys(propTypes)); - var listProps = pick(this.props, Object.keys(_utilCompat2['default'].type(List).propTypes)); - var popupProps = pick(this.props, Object.keys(_utilCompat2['default'].type(_Popup2['default']).propTypes)); + var listProps = pick(this.props, Object.keys(List.propTypes)); + var popupProps = pick(this.props, Object.keys(_Popup2['default'].propTypes)); var _state = this.state; var focusedItem = _state.focusedItem; diff --git a/lib/DateInput.js b/lib/DateInput.js index 2705e50c0..e9fa834c3 100644 --- a/lib/DateInput.js +++ b/lib/DateInput.js @@ -2,24 +2,38 @@ var babelHelpers = require('./util/babelHelpers.js'); -var React = require('react'), - cx = require('classnames'), - compat = require('./util/compat'), - localizers = require('./util/configuration').locale, - CustomPropTypes = require('./util/propTypes'); +exports.__esModule = true; -module.exports = React.createClass({ +var _react = require('react'); + +var _react2 = babelHelpers.interopRequireDefault(_react); + +var _classnames = require('classnames'); + +var _classnames2 = babelHelpers.interopRequireDefault(_classnames); + +var _utilCompat = require('./util/compat'); + +var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); + +var _utilLocalizers = require('./util/localizers'); + +var _utilPropTypes = require('./util/propTypes'); + +var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); + +exports['default'] = _react2['default'].createClass({ displayName: 'DatePickerInput', propTypes: { - format: CustomPropTypes.dateFormat.isRequired, - editFormat: CustomPropTypes.dateFormat, - parse: React.PropTypes.func.isRequired, + format: _utilPropTypes2['default'].dateFormat.isRequired, + editFormat: _utilPropTypes2['default'].dateFormat, + parse: _react2['default'].PropTypes.func.isRequired, - value: React.PropTypes.instanceOf(Date), - onChange: React.PropTypes.func.isRequired, - culture: React.PropTypes.string + value: _react2['default'].PropTypes.instanceOf(Date), + onChange: _react2['default'].PropTypes.func.isRequired, + culture: _react2['default'].PropTypes.string }, getDefaultProps: function getDefaultProps() { @@ -51,9 +65,9 @@ module.exports = React.createClass({ render: function render() { var value = this.state.textValue; - return React.createElement('input', babelHelpers._extends({}, this.props, { + return _react2['default'].createElement('input', babelHelpers._extends({}, this.props, { type: 'text', - className: cx({ 'rw-input': true }), + className: _classnames2['default']({ 'rw-input': true }), value: value, 'aria-disabled': this.props.disabled, 'aria-readonly': this.props.readOnly, @@ -81,7 +95,7 @@ module.exports = React.createClass({ }, focus: function focus() { - compat.findDOMNode(this).focus(); + _utilCompat2['default'].findDOMNode(this).focus(); } }); @@ -93,7 +107,7 @@ function isValid(d) { function formatDate(date, format, culture) { var val = ''; - if (date instanceof Date && isValid(date)) val = localizers.date.format(date, format, culture); + if (date instanceof Date && isValid(date)) val = _utilLocalizers.date.format(date, format, culture); return val; } @@ -103,4 +117,5 @@ function chain(a, b, thisArg) { a && a.apply(thisArg, arguments); b && b.apply(thisArg, arguments); }; -} \ No newline at end of file +} +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/DateTimePicker.js b/lib/DateTimePicker.js index d24467ade..f35682684 100644 --- a/lib/DateTimePicker.js +++ b/lib/DateTimePicker.js @@ -34,9 +34,7 @@ var _utilDates = require('./util/dates'); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); -var _utilConfiguration = require('./util/configuration'); - -var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); +var _utilLocalizers = require('./util/localizers'); var _utilConstants = require('./util/constants'); @@ -78,7 +76,6 @@ var views = _utilConstants2['default'].calendarViews; var popups = _utilConstants2['default'].datePopups; var Calendar = _Calendar3['default'].ControlledComponent; -var localizers = _utilConfiguration2['default'].locale; var viewEnum = Object.keys(views).map(function (k) { return views[k]; }); @@ -86,7 +83,7 @@ var viewEnum = Object.keys(views).map(function (k) { var omit = _util_2['default'].omit; var pick = _util_2['default'].pick; -var propTypes = babelHelpers._extends({}, _utilCompat2['default'].type(Calendar).propTypes, { +var propTypes = babelHelpers._extends({}, Calendar.propTypes, { //-- controlled props ----------- value: _react2['default'].PropTypes.instanceOf(Date), @@ -124,7 +121,6 @@ var propTypes = babelHelpers._extends({}, _utilCompat2['default'].type(Calendar) autoFocus: _react2['default'].PropTypes.bool, disabled: _utilPropTypes2['default'].disabled, readOnly: _utilPropTypes2['default'].readOnly, - autoFocus: _react2['default'].PropTypes.bool, parse: _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.arrayOf(_react2['default'].PropTypes.string), _react2['default'].PropTypes.string, _react2['default'].PropTypes.func]), @@ -228,7 +224,7 @@ var DateTimePicker = _react2['default'].createClass(babelHelpers.createDecorated owns = ''; var elementProps = omit(this.props, Object.keys(propTypes)), - calProps = pick(this.props, Object.keys(_utilCompat2['default'].type(Calendar).propTypes)); + calProps = pick(this.props, Object.keys(Calendar.propTypes)); var shouldRenderList = _utilWidgetHelpers.isFirstFocusedRender(this) || open, disabledOrReadonly = disabled || readOnly, @@ -516,13 +512,13 @@ function getFormat(props) { var cal = props[popups.CALENDAR] != null ? props.calendar : true, time = props[popups.TIME] != null ? props.time : true; - return props.format ? props.format : cal && time || !cal && !time ? localizers.date.formats['default'] : localizers.date.formats[cal ? 'date' : 'time']; + return props.format ? props.format : cal && time || !cal && !time ? _utilLocalizers.date.getFormat('default') : _utilLocalizers.date.getFormat(cal ? 'date' : 'time'); } function formatDate(date, format, culture) { var val = ''; - if (date instanceof Date && !isNaN(date.getTime())) val = localizers.date.format(date, format, culture); + if (date instanceof Date && !isNaN(date.getTime())) val = _utilLocalizers.date.format(date, format, culture); return val; } @@ -531,7 +527,7 @@ function formatsParser(formats, culture, str) { var date; for (var i = 0; i < formats.length; i++) { - date = localizers.date.parse(str, formats[i], culture); + date = _utilLocalizers.date.parse(str, formats[i], culture); if (date) return date; } return null; diff --git a/lib/Decade.js b/lib/Decade.js index 125869483..0da7bf429 100644 --- a/lib/Decade.js +++ b/lib/Decade.js @@ -16,9 +16,7 @@ var _utilDates = require('./util/dates'); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); -var _utilConfiguration = require('./util/configuration'); - -var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); +var _utilLocalizers = require('./util/localizers'); var _util_ = require('./util/_'); @@ -30,12 +28,6 @@ var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); var _utilWidgetHelpers = require('./util/widgetHelpers'); -var localizers = _utilConfiguration2['default'].locale; - -var format = function format(props) { - return props.yearFormat || localizers.date.formats.year; -}; - var propTypes = { optionID: _react2['default'].PropTypes.func, culture: _react2['default'].PropTypes.string, @@ -113,7 +105,7 @@ exports['default'] = _react2['default'].createClass({ var isFocused = isEqual(date, focused), isSelected = isEqual(date, value), currentYear = isEqual(date, today), - label = localizers.date.format(date, format(_this.props), culture); + label = _utilLocalizers.date.format(date, _utilLocalizers.date.getFormat('year', _this.props.yearFormat), culture); var currentID = optionId(id, date); diff --git a/lib/DropdownList.js b/lib/DropdownList.js index c847f056f..b7e9eecac 100644 --- a/lib/DropdownList.js +++ b/lib/DropdownList.js @@ -205,8 +205,8 @@ var DropdownList = _react2['default'].createClass(babelHelpers.createDecoratedOb List = List || groupBy && _ListGroupable2['default'] || _List2['default']; var elementProps = omit(this.props, Object.keys(propTypes)); - var listProps = pick(this.props, Object.keys(_utilCompat2['default'].type(List).propTypes)); - var popupProps = pick(this.props, Object.keys(_utilCompat2['default'].type(_Popup2['default']).propTypes)); + var listProps = pick(this.props, Object.keys(List.propTypes)); + var popupProps = pick(this.props, Object.keys(_Popup2['default'].propTypes)); var _state = this.state; var focusedItem = _state.focusedItem; diff --git a/lib/Footer.js b/lib/Footer.js index 53d0a903e..d2f3dde60 100644 --- a/lib/Footer.js +++ b/lib/Footer.js @@ -1,26 +1,34 @@ 'use strict'; -var React = require('react'), - Btn = require('./WidgetButton'), - localizers = require('./util/configuration').locale; +var babelHelpers = require('./util/babelHelpers.js'); + +var _react = require('react'); + +var _react2 = babelHelpers.interopRequireDefault(_react); + +var _WidgetButton = require('./WidgetButton'); + +var _WidgetButton2 = babelHelpers.interopRequireDefault(_WidgetButton); + +var _utilLocalizers = require('./util/localizers'); var format = function format(props) { - return props.format || localizers.date.formats.footer; + return _utilLocalizers.date.getFormat('footer', props.format); }; -module.exports = React.createClass({ +module.exports = _react2['default'].createClass({ displayName: 'Footer', render: function render() { var now = this.props.value, - formatted = localizers.date.format(now, format(this.props), this.props.culture); + formatted = _utilLocalizers.date.format(now, format(this.props), this.props.culture); - return React.createElement( + return _react2['default'].createElement( 'div', { className: 'rw-footer' }, - React.createElement( - Btn, + _react2['default'].createElement( + _WidgetButton2['default'], { tabIndex: '-1', 'aria-disabled': !!this.props.disabled, 'aria-readonly': !!this.props.readOnly, diff --git a/lib/Header.js b/lib/Header.js index 42e31d4ed..cab08d382 100644 --- a/lib/Header.js +++ b/lib/Header.js @@ -1,24 +1,33 @@ 'use strict'; -var React = require('react'), - Btn = require('./WidgetButton'); -module.exports = React.createClass({ - displayName: 'exports', +var babelHelpers = require('./util/babelHelpers.js'); +exports.__esModule = true; + +var _react = require('react'); + +var _react2 = babelHelpers.interopRequireDefault(_react); + +var _WidgetButton = require('./WidgetButton'); + +var _WidgetButton2 = babelHelpers.interopRequireDefault(_WidgetButton); + +exports['default'] = _react2['default'].createClass({ + displayName: 'Header', propTypes: { - label: React.PropTypes.string.isRequired, - labelId: React.PropTypes.string, + label: _react2['default'].PropTypes.string.isRequired, + labelId: _react2['default'].PropTypes.string, - upDisabled: React.PropTypes.bool.isRequired, - prevDisabled: React.PropTypes.bool.isRequired, - nextDisabled: React.PropTypes.bool.isRequired, - onViewChange: React.PropTypes.func.isRequired, - onMoveLeft: React.PropTypes.func.isRequired, - onMoveRight: React.PropTypes.func.isRequired, + upDisabled: _react2['default'].PropTypes.bool.isRequired, + prevDisabled: _react2['default'].PropTypes.bool.isRequired, + nextDisabled: _react2['default'].PropTypes.bool.isRequired, + onViewChange: _react2['default'].PropTypes.func.isRequired, + onMoveLeft: _react2['default'].PropTypes.func.isRequired, + onMoveRight: _react2['default'].PropTypes.func.isRequired, - messages: React.PropTypes.shape({ - moveBack: React.PropTypes.string, - moveForward: React.PropTypes.string + messages: _react2['default'].PropTypes.shape({ + moveBack: _react2['default'].PropTypes.string, + moveForward: _react2['default'].PropTypes.string }) }, @@ -47,11 +56,11 @@ module.exports = React.createClass({ var rtl = this.isRtl(); - return React.createElement( + return _react2['default'].createElement( 'div', { className: 'rw-header' }, - React.createElement( - Btn, + _react2['default'].createElement( + _WidgetButton2['default'], { className: 'rw-btn-left', tabIndex: '-1', onClick: onMoveLeft, @@ -60,12 +69,12 @@ module.exports = React.createClass({ 'aria-label': messages.moveBack, title: messages.moveBack }, - React.createElement('i', { 'aria-hidden': 'false', + _react2['default'].createElement('i', { 'aria-hidden': 'false', className: 'rw-i rw-i-caret-' + (rtl ? 'right' : 'left') }) ), - React.createElement( - Btn, + _react2['default'].createElement( + _WidgetButton2['default'], { id: labelId, tabIndex: '-1', @@ -78,8 +87,8 @@ module.exports = React.createClass({ }, label ), - React.createElement( - Btn, + _react2['default'].createElement( + _WidgetButton2['default'], { className: 'rw-btn-right', tabIndex: '-1', onClick: onMoveRight, @@ -88,10 +97,11 @@ module.exports = React.createClass({ 'aria-label': messages.moveForward, 'aria-disabled': nextDisabled }, - React.createElement('i', { 'aria-hidden': 'false', + _react2['default'].createElement('i', { 'aria-hidden': 'false', className: 'rw-i rw-i-caret-' + (rtl ? 'left' : 'right') }) ) ); } -}); \ No newline at end of file +}); +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/List.js b/lib/List.js index 80b218cd1..6a1ad6378 100644 --- a/lib/List.js +++ b/lib/List.js @@ -122,7 +122,7 @@ exports['default'] = _react2['default'].createClass({ key: 'item_' + idx, id: currentId, dataItem: item, - focused: focused === item, z: true, + focused: focused === item, selected: selected === item, onClick: onSelect.bind(null, item) }, diff --git a/lib/Month.js b/lib/Month.js index 09e596d55..90182e09f 100644 --- a/lib/Month.js +++ b/lib/Month.js @@ -16,9 +16,7 @@ var _utilDates = require('./util/dates'); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); -var _utilConfiguration = require('./util/configuration'); - -var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); +var _utilLocalizers = require('./util/localizers'); var _utilPropTypes = require('./util/propTypes'); @@ -30,12 +28,11 @@ var _util_2 = babelHelpers.interopRequireDefault(_util_); var _utilWidgetHelpers = require('./util/widgetHelpers'); -var localizers = _utilConfiguration2['default'].locale, - dayFormat = function dayFormat(props) { - return props.dayFormat || localizers.date.formats.weekday; +var dayFormat = function dayFormat(props) { + return _utilLocalizers.date.getFormat('weekday', props.dayFormat); }, dateFormat = function dateFormat(props) { - return props.dateFormat || localizers.date.formats.dayOfMonth; + return _utilLocalizers.date.getFormat('dayOfMonth', props.dateFormat); }; var optionId = function optionId(id, date) { @@ -101,7 +98,7 @@ var MonthView = _react2['default'].createClass({ _react2['default'].createElement( 'tr', null, - this._headers(dayFormat(this.props), culture) + this._headers(rows[0], dayFormat(this.props), culture) ) ), _react2['default'].createElement( @@ -126,7 +123,7 @@ var MonthView = _react2['default'].createClass({ var max = _props2.max; var Day = _props2.dayComponent; var id = _utilWidgetHelpers.instanceId(this); - var labelFormat = localizers.date.formats.footer; + var labelFormat = _utilLocalizers.date.getFormat('footer'); return _react2['default'].createElement( 'tr', @@ -136,8 +133,8 @@ var MonthView = _react2['default'].createClass({ var isFocused = isEqual(day, focused), isSelected = isEqual(day, value), isToday = isEqual(day, today), - date = localizers.date.format(day, dateFormat(_this.props), culture), - label = localizers.date.format(day, labelFormat, culture); + date = _utilLocalizers.date.format(day, dateFormat(_this.props), culture), + label = _utilLocalizers.date.format(day, labelFormat, culture); var currentID = optionId(id, day); @@ -175,12 +172,12 @@ var MonthView = _react2['default'].createClass({ ); }, - _headers: function _headers(format, culture) { - return [0, 1, 2, 3, 4, 5, 6].map(function (day) { + _headers: function _headers(week, format, culture) { + return week.map(function (date) { return _react2['default'].createElement( 'th', - { key: 'header_' + day }, - localizers.date.format(day, format, culture) + { key: 'header_' + _utilDates2['default'].weekday(date) }, + _utilLocalizers.date.format(date, format, culture) ); }); } diff --git a/lib/Multiselect.js b/lib/Multiselect.js index 9b8a32965..ed23309fb 100644 --- a/lib/Multiselect.js +++ b/lib/Multiselect.js @@ -20,10 +20,6 @@ var _Popup = require('./Popup'); var _Popup2 = babelHelpers.interopRequireDefault(_Popup); -var _utilDomSupport = require('./util/dom/support'); - -var _utilDomSupport2 = babelHelpers.interopRequireDefault(_utilDomSupport); - var _MultiselectInput = require('./MultiselectInput'); var _MultiselectInput2 = babelHelpers.interopRequireDefault(_MultiselectInput); @@ -32,10 +28,6 @@ var _MultiselectTagList = require('./MultiselectTagList'); var _MultiselectTagList2 = babelHelpers.interopRequireDefault(_MultiselectTagList); -var _utilCompat = require('./util/compat'); - -var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); - var _utilPropTypes = require('./util/propTypes'); var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); @@ -70,8 +62,6 @@ var compatCreate = function compatCreate(props, msgs) { ), ' ' + msgs.createNew]; }; -_react2['default'].initializeTouchEvents(true); - var omit = _util_2['default'].omit; var pick = _util_2['default'].pick; var splat = _util_2['default'].splat; @@ -242,8 +232,8 @@ var Multiselect = _react2['default'].createClass(babelHelpers.createDecoratedObj var elementProps = omit(this.props, Object.keys(propTypes)); var tagsProps = pick(this.props, ['valueField', 'textField']); var inputProps = pick(this.props, ['maxLength', 'searchTerm', 'autoFocus']); - var listProps = pick(this.props, Object.keys(_utilCompat2['default'].type(List).propTypes)); - var popupProps = pick(this.props, Object.keys(_utilCompat2['default'].type(_Popup2['default']).propTypes)); + var listProps = pick(this.props, Object.keys(List.propTypes)); + var popupProps = pick(this.props, Object.keys(_Popup2['default'].propTypes)); var _state = this.state; var focusedTag = _state.focusedTag; @@ -539,6 +529,8 @@ var Multiselect = _react2['default'].createClass(babelHelpers.createDecoratedObj }); }); + this._lengthWithoutValues = items.length; + if (searchTerm) items = this.filter(items, searchTerm); return items; diff --git a/lib/NumberInput.js b/lib/NumberInput.js index 0b58dee31..8e456c368 100644 --- a/lib/NumberInput.js +++ b/lib/NumberInput.js @@ -2,30 +2,38 @@ var babelHelpers = require('./util/babelHelpers.js'); -var React = require('react'), - CustomPropTypes = require('./util/propTypes'), - localizers = require('./util/configuration').locale; +exports.__esModule = true; + +var _react = require('react'); + +var _react2 = babelHelpers.interopRequireDefault(_react); + +var _utilPropTypes = require('./util/propTypes'); + +var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); + +var _utilLocalizers = require('./util/localizers'); var format = function format(props) { - return props.format || localizers.number.formats['default']; + return _utilLocalizers.number.getFormat('default', props.format); }; -module.exports = React.createClass({ +exports['default'] = _react2['default'].createClass({ displayName: 'NumberPickerInput', propTypes: { - value: React.PropTypes.number, - placeholder: React.PropTypes.string, + value: _react2['default'].PropTypes.number, + placeholder: _react2['default'].PropTypes.string, - format: CustomPropTypes.numberFormat, - parse: React.PropTypes.func.isRequired, - culture: React.PropTypes.string, + format: _utilPropTypes2['default'].numberFormat, + parse: _react2['default'].PropTypes.func.isRequired, + culture: _react2['default'].PropTypes.string, - min: React.PropTypes.number, + min: _react2['default'].PropTypes.number, - onChange: React.PropTypes.func.isRequired, - onKeyDown: React.PropTypes.func + onChange: _react2['default'].PropTypes.func.isRequired, + onKeyDown: _react2['default'].PropTypes.func }, getDefaultProps: function getDefaultProps() { @@ -33,7 +41,7 @@ module.exports = React.createClass({ value: null, editing: false, parse: function parse(number, culture) { - return localizers.number.parse(number, culture); + return _utilLocalizers.number.parse(number, culture); } }; }, @@ -59,7 +67,7 @@ module.exports = React.createClass({ render: function render() { var value = this.state.stringValue; - return React.createElement('input', babelHelpers._extends({}, this.props, { + return _react2['default'].createElement('input', babelHelpers._extends({}, this.props, { type: 'text', className: 'rw-input', onChange: this._change, @@ -126,5 +134,6 @@ module.exports = React.createClass({ // } function formatNumber(number, format, culture) { - return localizers.number.format(number, format, culture); -} \ No newline at end of file + return _utilLocalizers.number.format(number, format, culture); +} +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/NumberPicker.js b/lib/NumberPicker.js index 953600670..5a6ea37ee 100644 --- a/lib/NumberPicker.js +++ b/lib/NumberPicker.js @@ -36,9 +36,7 @@ var _utilRepeater = require('./util/repeater'); var _utilRepeater2 = babelHelpers.interopRequireDefault(_utilRepeater); -var _utilConfiguration = require('./util/configuration'); - -var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); +var _utilLocalizers = require('./util/localizers'); var _NumberInput = require('./NumberInput'); @@ -54,10 +52,8 @@ var _utilWidgetHelpers = require('./util/widgetHelpers'); var directions = _utilConstants2['default'].directions; -var localizers = _utilConfiguration2['default'].locale; - var format = function format(props) { - return props.format || localizers.number.formats['default']; + return _utilLocalizers.number.getFormat('default', props.format); }; var propTypes = { @@ -84,7 +80,6 @@ var propTypes = { autoFocus: _react2['default'].PropTypes.bool, disabled: _utilPropTypes2['default'].disabled, readOnly: _utilPropTypes2['default'].readOnly, - autoFocus: _react2['default'].PropTypes.bool, messages: _react2['default'].PropTypes.shape({ increment: _react2['default'].PropTypes.string, @@ -299,7 +294,7 @@ var NumberPicker = _react2['default'].createClass(babelHelpers.createDecoratedOb value: function step(amount) { var value = (this.props.value || 0) + amount; - var decimals = this.props.precision != null ? this.props.precision : localizers.number.precision(format(this.props)); + var decimals = this.props.precision != null ? this.props.precision : _utilLocalizers.number.precision(format(this.props)); this.change(decimals != null ? round(value, decimals) : value); diff --git a/lib/Popup.js b/lib/Popup.js index 438c404b5..35661d0cd 100644 --- a/lib/Popup.js +++ b/lib/Popup.js @@ -2,55 +2,72 @@ var babelHelpers = require('./util/babelHelpers.js'); -var React = require('react'), - css = require('dom-helpers/style'), - getHeight = require('dom-helpers/query/height'), - config = require('./util/configuration'), - cn = require('classnames'), - compat = require('./util/compat'); +var _react = require('react'); -var transform = config.animate.transform; +var _react2 = babelHelpers.interopRequireDefault(_react); + +var _domHelpersStyle = require('dom-helpers/style'); + +var _domHelpersStyle2 = babelHelpers.interopRequireDefault(_domHelpersStyle); + +var _domHelpersQueryHeight = require('dom-helpers/query/height'); + +var _domHelpersQueryHeight2 = babelHelpers.interopRequireDefault(_domHelpersQueryHeight); + +var _utilConfiguration = require('./util/configuration'); + +var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); + +var _classnames = require('classnames'); + +var _classnames2 = babelHelpers.interopRequireDefault(_classnames); + +var _utilCompat = require('./util/compat'); + +var _utilCompat2 = babelHelpers.interopRequireDefault(_utilCompat); + +var transform = _utilConfiguration2['default'].animate.transform; function properties(prop, value) { var _ref, _ref2; - var TRANSLATION_MAP = config.animate.TRANSLATION_MAP; + var TRANSLATION_MAP = _utilConfiguration2['default'].animate.TRANSLATION_MAP; if (TRANSLATION_MAP && TRANSLATION_MAP[prop]) return (_ref = {}, _ref[transform] = TRANSLATION_MAP[prop] + '(' + value + ')', _ref); return (_ref2 = {}, _ref2[prop] = value, _ref2); } -var PopupContent = React.createClass({ +var PopupContent = _react2['default'].createClass({ displayName: 'PopupContent', render: function render() { var child = this.props.children; - if (!child) return React.createElement('span', { className: 'rw-popup rw-widget' }); + if (!child) return _react2['default'].createElement('span', { className: 'rw-popup rw-widget' }); - child = React.Children.only(this.props.children); + child = _react2['default'].Children.only(this.props.children); - return compat.cloneElement(child, { - className: cn(child.props.className, 'rw-popup rw-widget') + return _react.cloneElement(child, { + className: _classnames2['default'](child.props.className, 'rw-popup rw-widget') }); } }); -module.exports = React.createClass({ +module.exports = _react2['default'].createClass({ displayName: 'Popup', propTypes: { - open: React.PropTypes.bool, - dropUp: React.PropTypes.bool, - duration: React.PropTypes.number, - - onRequestClose: React.PropTypes.func.isRequired, - onClosing: React.PropTypes.func, - onOpening: React.PropTypes.func, - onClose: React.PropTypes.func, - onOpen: React.PropTypes.func + open: _react2['default'].PropTypes.bool, + dropUp: _react2['default'].PropTypes.bool, + duration: _react2['default'].PropTypes.number, + + onRequestClose: _react2['default'].PropTypes.func.isRequired, + onClosing: _react2['default'].PropTypes.func, + onOpening: _react2['default'].PropTypes.func, + onClose: _react2['default'].PropTypes.func, + onOpen: _react2['default'].PropTypes.func }, getInitialState: function getInitialState() { @@ -101,16 +118,16 @@ module.exports = React.createClass({ display = 'none'; } - return React.createElement( + return _react2['default'].createElement( 'div', babelHelpers._extends({}, props, { style: babelHelpers._extends({ display: display, height: this.state.height }, props.style), - className: cn(className, 'rw-popup-container', { 'rw-dropup': dropUp }) + className: _classnames2['default'](className, 'rw-popup-container', { 'rw-dropup': dropUp }) }), - React.createElement( + _react2['default'].createElement( PopupContent, { ref: 'content' }, this.props.children @@ -119,21 +136,21 @@ module.exports = React.createClass({ }, reset: function reset() { - var container = compat.findDOMNode(this), - content = compat.findDOMNode(this.refs.content), + var container = _utilCompat2['default'].findDOMNode(this), + content = _utilCompat2['default'].findDOMNode(this.refs.content), style = { display: 'block', overflow: 'hidden' }; - css(container, style); + _domHelpersStyle2['default'](container, style); this.height(); - css(content, properties('top', this.props.dropUp ? '100%' : '-100%')); + _domHelpersStyle2['default'](content, properties('top', this.props.dropUp ? '100%' : '-100%')); }, height: function height() { - var el = compat.findDOMNode(this), - content = compat.findDOMNode(this.refs.content), - margin = parseInt(css(content, 'margin-top'), 10) + parseInt(css(content, 'margin-bottom'), 10); + var el = _utilCompat2['default'].findDOMNode(this), + content = _utilCompat2['default'].findDOMNode(this.refs.content), + margin = parseInt(_domHelpersStyle2['default'](content, 'margin-top'), 10) + parseInt(_domHelpersStyle2['default'](content, 'margin-bottom'), 10); - var height = getHeight(content) + (isNaN(margin) ? 0 : margin); + var height = _domHelpersQueryHeight2['default'](content) + (isNaN(margin) ? 0 : margin); if (this.state.height !== height) { el.style.height = height + 'px'; @@ -143,10 +160,10 @@ module.exports = React.createClass({ open: function open() { var self = this, - anim = compat.findDOMNode(this), - el = compat.findDOMNode(this.refs.content); + anim = _utilCompat2['default'].findDOMNode(this), + el = _utilCompat2['default'].findDOMNode(this.refs.content); - this.ORGINAL_POSITION = css(el, 'position'); + this.ORGINAL_POSITION = _domHelpersStyle2['default'](el, 'position'); this._isOpening = true; if (this._initialPosition) { @@ -159,7 +176,7 @@ module.exports = React.createClass({ anim.className += ' rw-popup-animating'; el.style.position = 'absolute'; - config.animate(el, { top: 0 }, self.props.duration, 'ease', function () { + _utilConfiguration2['default'].animate(el, { top: 0 }, self.props.duration, 'ease', function () { if (!self._isOpening) return; anim.className = anim.className.replace(/ ?rw-popup-animating/g, ''); @@ -174,10 +191,10 @@ module.exports = React.createClass({ close: function close(dur) { var self = this, - el = compat.findDOMNode(this.refs.content), - anim = compat.findDOMNode(this); + el = _utilCompat2['default'].findDOMNode(this.refs.content), + anim = _utilCompat2['default'].findDOMNode(this); - this.ORGINAL_POSITION = css(el, 'position'); + this.ORGINAL_POSITION = _domHelpersStyle2['default'](el, 'position'); this._isOpening = false; this.height(); @@ -187,7 +204,7 @@ module.exports = React.createClass({ anim.className += ' rw-popup-animating'; el.style.position = 'absolute'; - config.animate(el, { top: this.props.dropUp ? '100%' : '-100%' }, dur === undefined ? this.props.duration : dur, 'ease', function () { + _utilConfiguration2['default'].animate(el, { top: this.props.dropUp ? '100%' : '-100%' }, dur === undefined ? this.props.duration : dur, 'ease', function () { if (self._isOpening) return; el.style.position = self.ORGINAL_POSITION; @@ -202,7 +219,7 @@ module.exports = React.createClass({ }); function childKey(children) { - var nextChildMapping = React.Children.map(children, function (c) { + var nextChildMapping = _react2['default'].Children.map(children, function (c) { return c; }); for (var key in nextChildMapping) return key; diff --git a/lib/SelectList.js b/lib/SelectList.js index 86c29213b..045c8f007 100644 --- a/lib/SelectList.js +++ b/lib/SelectList.js @@ -156,7 +156,7 @@ var SelectList = _react2['default'].createClass(babelHelpers.createDecoratedObje List = List || _List2['default']; var elementProps = omit(this.props, Object.keys(propTypes)); - var listProps = pick(this.props, Object.keys(_utilCompat2['default'].type(List).propTypes)); + var listProps = pick(this.props, Object.keys(List.propTypes)); var _state = this.state; var ListItem = _state.ListItem; diff --git a/lib/TimeList.js b/lib/TimeList.js index 38b992bb4..17fb20858 100644 --- a/lib/TimeList.js +++ b/lib/TimeList.js @@ -2,30 +2,44 @@ var babelHelpers = require('./util/babelHelpers.js'); -var React = require('react'), - dates = require('./util/dates'), - List = require('./List'), - localizers = require('./util/configuration').locale, - CustomPropTypes = require('./util/propTypes'); +exports.__esModule = true; + +var _react = require('react'); + +var _react2 = babelHelpers.interopRequireDefault(_react); + +var _utilDates = require('./util/dates'); + +var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); + +var _List = require('./List'); + +var _List2 = babelHelpers.interopRequireDefault(_List); + +var _utilLocalizers = require('./util/localizers'); + +var _utilPropTypes = require('./util/propTypes'); + +var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); var format = function format(props) { - return props.format || localizers.date.formats.time; + return _utilLocalizers.date.getFormat('time', props.format); }; -module.exports = React.createClass({ +exports['default'] = _react2['default'].createClass({ displayName: 'TimeList', propTypes: { - value: React.PropTypes.instanceOf(Date), - min: React.PropTypes.instanceOf(Date), - max: React.PropTypes.instanceOf(Date), - step: React.PropTypes.number, - itemComponent: CustomPropTypes.elementType, - format: CustomPropTypes.dateFormat, - onSelect: React.PropTypes.func, - preserveDate: React.PropTypes.bool, - culture: React.PropTypes.string + value: _react2['default'].PropTypes.instanceOf(Date), + min: _react2['default'].PropTypes.instanceOf(Date), + max: _react2['default'].PropTypes.instanceOf(Date), + step: _react2['default'].PropTypes.number, + itemComponent: _utilPropTypes2['default'].elementType, + format: _utilPropTypes2['default'].dateFormat, + onSelect: _react2['default'].PropTypes.func, + preserveDate: _react2['default'].PropTypes.bool, + culture: _react2['default'].PropTypes.string }, mixins: [require('./mixins/TimeoutMixin')], @@ -54,9 +68,9 @@ module.exports = React.createClass({ componentWillReceiveProps: function componentWillReceiveProps(nextProps) { var data = this._dates(nextProps), focusedItem = this._closestDate(data, nextProps.value), - valChanged = !dates.eq(nextProps.value, this.props.value, 'minutes'), - minChanged = !dates.eq(nextProps.min, this.props.min, 'minutes'), - maxChanged = !dates.eq(nextProps.max, this.props.max, 'minutes'); + valChanged = !_utilDates2['default'].eq(nextProps.value, this.props.value, 'minutes'), + minChanged = !_utilDates2['default'].eq(nextProps.min, this.props.min, 'minutes'), + maxChanged = !_utilDates2['default'].eq(nextProps.max, this.props.max, 'minutes'); if (valChanged || minChanged || maxChanged) { this.setState({ @@ -77,7 +91,7 @@ module.exports = React.createClass({ var times = this.state.dates, date = this._closestDate(times, value); - return React.createElement(List, babelHelpers._extends({}, props, { + return _react2['default'].createElement(_List2['default'], babelHelpers._extends({}, props, { ref: 'list', data: times, textField: 'label', @@ -95,7 +109,7 @@ module.exports = React.createClass({ if (!date) return null; date = new Date(Math.floor(date.getTime() / roundTo) * roundTo); - label = localizers.date.format(date, format(this.props), this.props.culture); + label = _utilLocalizers.date.format(date, format(this.props), this.props.culture); times.some(function (time) { if (time.label === label) return inst = time; @@ -113,18 +127,18 @@ module.exports = React.createClass({ i = 0, values = this._dateValues(props), start = values.min, - startDay = dates.date(start); + startDay = _utilDates2['default'].date(start); - while (dates.date(start) === startDay && dates.lte(start, values.max)) { + while (_utilDates2['default'].date(start) === startDay && _utilDates2['default'].lte(start, values.max)) { i++; - times.push({ date: start, label: localizers.date.format(start, format(props), props.culture) }); - start = dates.add(start, props.step || 30, 'minutes'); + times.push({ date: start, label: _utilLocalizers.date.format(start, format(props), props.culture) }); + start = _utilDates2['default'].add(start, props.step || 30, 'minutes'); } return times; }, _dateValues: function _dateValues(props) { - var value = props.value || dates.today(), + var value = props.value || _utilDates2['default'].today(), useDate = props.preserveDate, min = props.min, max = props.max, @@ -133,10 +147,10 @@ module.exports = React.createClass({ //compare just the time regradless of whether they fall on the same day if (!useDate) { - start = dates.startOf(dates.merge(new Date(), min), 'minutes'); - end = dates.startOf(dates.merge(new Date(), max), 'minutes'); + start = _utilDates2['default'].startOf(_utilDates2['default'].merge(new Date(), min), 'minutes'); + end = _utilDates2['default'].startOf(_utilDates2['default'].merge(new Date(), max), 'minutes'); - if (dates.lte(end, start) && dates.gt(max, min, 'day')) end = dates.tomorrow(); + if (_utilDates2['default'].lte(end, start) && _utilDates2['default'].gt(max, min, 'day')) end = _utilDates2['default'].tomorrow(); return { min: start, @@ -144,12 +158,12 @@ module.exports = React.createClass({ }; } - start = dates.today(); - end = dates.tomorrow(); + start = _utilDates2['default'].today(); + end = _utilDates2['default'].tomorrow(); //date parts are equal return { - min: dates.eq(value, min, 'day') ? dates.merge(start, min) : start, - max: dates.eq(value, max, 'day') ? dates.merge(start, max) : end + min: _utilDates2['default'].eq(value, min, 'day') ? _utilDates2['default'].merge(start, min) : start, + max: _utilDates2['default'].eq(value, max, 'day') ? _utilDates2['default'].merge(start, max) : end }; }, @@ -196,4 +210,5 @@ module.exports = React.createClass({ }, this.props.delay); } -}); \ No newline at end of file +}); +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/Year.js b/lib/Year.js index 8e78c7865..c86863aad 100644 --- a/lib/Year.js +++ b/lib/Year.js @@ -16,9 +16,7 @@ var _utilDates = require('./util/dates'); var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); -var _utilConfiguration = require('./util/configuration'); - -var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration); +var _utilLocalizers = require('./util/localizers'); var _util_ = require('./util/_'); @@ -30,9 +28,8 @@ var _utilPropTypes2 = babelHelpers.interopRequireDefault(_utilPropTypes); var _utilWidgetHelpers = require('./util/widgetHelpers'); -var localizers = _utilConfiguration2['default'].locale; var format = function format(props) { - return props.monthFormat || localizers.date.formats.month; + return _utilLocalizers.date.getFormat('month', props.monthFormat); }; var propTypes = { @@ -103,7 +100,7 @@ var YearView = _react2['default'].createClass({ var min = _props2.min; var max = _props2.max; var id = _utilWidgetHelpers.instanceId(this); - var labelFormat = localizers.date.formats.header; + var labelFormat = _utilLocalizers.date.getFormat('header'); return _react2['default'].createElement( 'tr', @@ -112,7 +109,7 @@ var YearView = _react2['default'].createClass({ var isFocused = isEqual(date, focused), isSelected = isEqual(date, value), currentMonth = isEqual(date, today), - label = localizers.date.format(date, labelFormat, culture); + label = _utilLocalizers.date.format(date, labelFormat, culture); var currentID = optionId(id, date); @@ -138,7 +135,7 @@ var YearView = _react2['default'].createClass({ 'rw-now': currentMonth }) }, - localizers.date.format(date, format(_this.props), culture) + _utilLocalizers.date.format(date, format(_this.props), culture) ) ) : _react2['default'].createElement( 'td', diff --git a/lib/configure.js b/lib/configure.js index 999f47f9e..be79f1e64 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -10,10 +10,7 @@ var _utilConfiguration2 = babelHelpers.interopRequireDefault(_utilConfiguration) var _utilLocalizers = require('./util/localizers'); -var _utilLocalizers2 = babelHelpers.interopRequireDefault(_utilLocalizers); - -var NumberLocalizer = _utilLocalizers2['default'].NumberLocalizer; -var DateLocalizer = _utilLocalizers2['default'].DateLocalizer; +var localizers = babelHelpers.interopRequireWildcard(_utilLocalizers); exports['default'] = { setAnimate: function setAnimate(animatefn) { @@ -24,16 +21,12 @@ exports['default'] = { var date = _ref.date; var number = _ref.number; - this.setDateLocalizer(date); - this.setNumberLocalizer(number); + date && this.setDateLocalizer(date); + number && this.setNumberLocalizer(number); }, - setDateLocalizer: function setDateLocalizer(spec) { - _utilConfiguration2['default'].locale.date = new DateLocalizer(spec); - }, + setDateLocalizer: localizers.setDate, - setNumberLocalizer: function setNumberLocalizer(spec) { - _utilConfiguration2['default'].locale.number = new NumberLocalizer(spec); - } + setNumberLocalizer: localizers.setNumber }; module.exports = exports['default']; \ No newline at end of file diff --git a/lib/globalize-localizers.js b/lib/globalize-localizers.js deleted file mode 100644 index 9ea056a8b..000000000 --- a/lib/globalize-localizers.js +++ /dev/null @@ -1,105 +0,0 @@ -'use strict'; - -var babelHelpers = require('./util/babelHelpers.js'); - -exports.__esModule = true; -exports['default'] = globalizeLocalizers; - -var _utilDates = require('./util/dates'); - -var _utilDates2 = babelHelpers.interopRequireDefault(_utilDates); - -function globalizeLocalizers(globalize) { - var shortNames = Object.create(null); - - function getCulture(culture) { - return culture ? globalize.findClosestCulture(culture) : globalize.culture(); - } - - function firstOfWeek(culture) { - culture = getCulture(culture); - return culture && culture.calendar.firstDay || 0; - } - - function shortDay(dayOfTheWeek) { - var culture = getCulture(arguments[1]), - name = culture.name, - start = firstOfWeek(culture), - days = function days() { - var days = culture.calendar.days.namesShort.slice(); - return start === 0 ? days : days.concat(days.splice(0, start)); - }; - - var names = shortNames[name] || (shortNames[name] = days()); - - return names[dayOfTheWeek]; - } - - var date = { - - formats: { - date: 'd', - time: 't', - 'default': 'f', - header: 'MMMM yyyy', - footer: 'D', - weekday: shortDay, - dayOfMonth: 'dd', - month: 'MMM', - year: 'yyyy', - - decade: function decade(dt, culture, l) { - return l.format(dt, l.formats.year, culture) + ' - ' + l.format(_utilDates2['default'].endOf(dt, 'decade'), l.formats.year, culture); - }, - - century: function century(dt, culture, l) { - return l.format(dt, l.formats.year, culture) + ' - ' + l.format(_utilDates2['default'].endOf(dt, 'century'), l.formats.year, culture); - } - }, - - firstOfWeek: firstOfWeek, - - parse: function parse(value, format, culture) { - return globalize.parseDate(value, format, culture); - }, - - format: function format(value, _format, culture) { - return globalize.format(value, _format, culture); - } - }; - - var number = { - - formats: { - 'default': 'D' - }, - - parse: function parse(value, culture) { - return globalize.parseFloat(value, 10, culture); - }, - - format: function format(value, _format2, culture) { - return globalize.format(value, _format2, culture); - }, - - precision: function precision(format, _culture) { - var culture = getCulture(_culture), - numFormat = culture.numberFormat; - - if (typeof format === 'string') { - if (format.length > 1) return parseFloat(format.substr(1)); - - if (format.indexOf('p') !== -1) numFormat = numFormat.percent; - if (format.indexOf('c') !== -1) numFormat = numFormat.curency; - - return numFormat.decimals || null; - } - - return null; - } - }; - - return { date: date, number: number }; -} - -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js index c0d868649..013b95e28 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,28 +1,26 @@ 'use strict'; +var babelHelpers = require('./util/babelHelpers.js'); + +var configure = require('./configure'); + if (process.env.NODE_ENV !== 'production') { [Array.prototype.some, Array.prototype.filter, Array.prototype.reduce].forEach(function (method) { if (!method) throw new Error('One or more ES5 features is not available to ReactWidgets: http://jquense.github.io/react-widgets/docs/#/getting-started/browser'); }); } -module.exports = { - +module.exports = babelHelpers._extends({}, configure, { DropdownList: require('./DropdownList'), Combobox: require('./Combobox'), - Calendar: require('./Calendar'), DateTimePicker: require('./DateTimePicker'), - NumberPicker: require('./NumberPicker'), - Multiselect: require('./Multiselect'), SelectList: require('./SelectList'), - configure: require('./configure'), - utils: { ReplaceTransitionGroup: require('./ReplaceTransitionGroup'), SlideTransition: require('./SlideTransition') } -}; \ No newline at end of file +}); \ No newline at end of file diff --git a/lib/localizers/globalize.js b/lib/localizers/globalize.js new file mode 100644 index 000000000..b39ae6999 --- /dev/null +++ b/lib/localizers/globalize.js @@ -0,0 +1,197 @@ +'use strict'; + +var babelHelpers = require('../util/babelHelpers.js'); + +exports.__esModule = true; +exports['default'] = globalizeLocalizers; + +var _react = require('react'); + +var _configure = require('../configure'); + +var _configure2 = babelHelpers.interopRequireDefault(_configure); + +function endOfDecade(date) { + date = new Date(date); + date.setFullYear(date.getFullYear() + 10); + date.setMilliseconds(date.getMilliseconds() - 1); + return date; +} + +function endOfCentury(date) { + date = new Date(date); + date.setFullYear(date.getFullYear() + 100); + date.setMilliseconds(date.getMilliseconds() - 1); + return date; +} + +function globalizeLocalizers(globalize) { + var localizers = globalize.load ? newGlobalize(globalize) : oldGlobalize(globalize); + + _configure2['default'].setLocalizers(localizers); + return localizers; +} + +function newGlobalize(globalize) { + var locale = function locale(culture) { + return culture ? globalize(culture) : globalize; + }; + + var date = { + + formats: { + date: { date: 'short' }, + time: { time: 'short' }, + 'default': { datetime: 'medium' }, + header: 'MMMM yyyy', + footer: { date: 'full' }, + weekday: 'eeeeee', + dayOfMonth: 'dd', + month: 'MMM', + year: 'yyyy', + + decade: function decade(dt, culture, l) { + return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfDecade(dt), l.formats.year, culture); + }, + + century: function century(dt, culture, l) { + return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfCentury(dt), l.formats.year, culture); + } + }, + + propType: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.object, _react.PropTypes.func]), + + firstOfWeek: function firstOfWeek(culture) { + var date = new Date(); + //cldr-data doesn't seem to be zero based + var localeDay = Math.max(parseInt(locale(culture).formatDate(date, { raw: 'e' }), 10) - 1, 0); + + return Math.abs(date.getDay() - localeDay); + }, + + parse: function parse(value, format, culture) { + format = typeof format === 'string' ? { raw: format } : format; + return locale(culture).parseDate(value, format); + }, + + format: function format(value, _format, culture) { + _format = typeof _format === 'string' ? { raw: _format } : _format; + return locale(culture).formatDate(value, _format); + } + }; + + var number = { + formats: { + 'default': { maximumFractionDigits: 0 } + }, + + propType: _react.PropTypes.oneOfType([_react.PropTypes.object, _react.PropTypes.func]), + + parse: function parse(value, format, culture) { + return locale(culture).parseNumber(value, format); + }, + + format: function format(value, _format2, culture) { + return value == null ? value : locale(culture).formatNumber(value, _format2); + }, + + precision: function precision(format) { + return !format || format.maximumFractionDigits == null ? null : format.maximumFractionDigits; + } + }; + return { date: date, number: number }; +} + +function oldGlobalize(globalize) { + var shortNames = Object.create(null); + + function getCulture(culture) { + return culture ? globalize.findClosestCulture(culture) : globalize.culture(); + } + + function firstOfWeek(culture) { + culture = getCulture(culture); + return culture && culture.calendar.firstDay || 0; + } + + function shortDay(dayOfTheWeek) { + var culture = getCulture(arguments[1]), + name = culture.name, + start = firstOfWeek(culture), + days = function days() { + var days = culture.calendar.days.namesShort.slice(); + return start === 0 ? days : days.concat(days.splice(0, start)); + }; + + var names = shortNames[name] || (shortNames[name] = days()); + + return names[dayOfTheWeek.getDay()]; + } + + var date = { + + formats: { + date: 'd', + time: 't', + 'default': 'f', + header: 'MMMM yyyy', + footer: 'D', + weekday: shortDay, + dayOfMonth: 'dd', + month: 'MMM', + year: 'yyyy', + + decade: function decade(dt, culture, l) { + return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfDecade(dt), l.formats.year, culture); + }, + + century: function century(dt, culture, l) { + return l.format(dt, l.formats.year, culture) + ' - ' + l.format(endOfCentury(dt), l.formats.year, culture); + } + }, + + firstOfWeek: firstOfWeek, + + parse: function parse(value, format, culture) { + return globalize.parseDate(value, format, culture); + }, + + format: function format(value, _format3, culture) { + return globalize.format(value, _format3, culture); + } + }; + + var number = { + + formats: { + 'default': 'D' + }, + + parse: function parse(value, culture) { + return globalize.parseFloat(value, 10, culture); + }, + + format: function format(value, _format4, culture) { + return globalize.format(value, _format4, culture); + }, + + precision: function precision(format, _culture) { + var culture = getCulture(_culture), + numFormat = culture.numberFormat; + + if (typeof format === 'string') { + if (format.length > 1) return parseFloat(format.substr(1)); + + if (format.indexOf('p') !== -1) numFormat = numFormat.percent; + if (format.indexOf('c') !== -1) numFormat = numFormat.curency; + + return numFormat.decimals || null; + } + + return null; + } + }; + + return { date: date, number: number }; +} +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/localizers/moment.js b/lib/localizers/moment.js new file mode 100644 index 000000000..fbc292823 --- /dev/null +++ b/lib/localizers/moment.js @@ -0,0 +1,76 @@ +'use strict'; + +var babelHelpers = require('../util/babelHelpers.js'); + +exports.__esModule = true; + +var _configure = require('../configure'); + +var _configure2 = babelHelpers.interopRequireDefault(_configure); + +function endOfDecade(date) { + date = new Date(date); + date.setFullYear(date.getFullYear() + 10); + date.setMilliseconds(date.getMilliseconds() - 1); + return date; +} + +function endOfCentury(date) { + date = new Date(date); + date.setFullYear(date.getFullYear() + 100); + date.setMilliseconds(date.getMilliseconds() - 1); + return date; +} + +exports['default'] = function (moment) { + if (typeof moment !== 'function') throw new TypeError('You must provide a valid moment object'); + + var localField = typeof moment().locale === 'function' ? 'locale' : 'lang', + hasLocaleData = !!moment.localeData; + + if (!hasLocaleData) throw new TypeError('The Moment localizer depends on the `localeData` api, please provide a moment object v2.2.0 or higher'); + + function getMoment(culture, value, format) { + return culture ? moment(value, format)[localField](culture) : moment(value, format); + } + + var localizer = { + formats: { + date: 'L', + time: 'LT', + 'default': 'lll', + header: 'MMMM YYYY', + footer: 'LL', + weekday: 'dd', + dayOfMonth: 'DD', + month: 'MMM', + year: 'YYYY', + + decade: function decade(date, culture, localizer) { + return localizer.format(date, 'YYYY', culture) + ' - ' + localizer.format(endOfDecade(date), 'YYYY', culture); + }, + + century: function century(date, culture, localizer) { + return localizer.format(date, 'YYYY', culture) + ' - ' + localizer.format(endOfCentury(date), 'YYYY', culture); + } + }, + + firstOfWeek: function firstOfWeek(culture) { + return moment.localeData(culture).firstDayOfWeek(); + }, + + parse: function parse(value, format, culture) { + return getMoment(culture, value, format).toDate(); + }, + + format: function format(value, _format, culture) { + return getMoment(culture, value, _format).format(_format); + } + }; + + _configure2['default'].setDateLocalizer(localizer); + + return localizer; +}; + +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/localizers/simple-number.js b/lib/localizers/simple-number.js new file mode 100644 index 000000000..ae7bdaeea --- /dev/null +++ b/lib/localizers/simple-number.js @@ -0,0 +1,64 @@ +'use strict'; + +var babelHelpers = require('../util/babelHelpers.js'); + +exports.__esModule = true; +exports['default'] = simpleNumber; + +var _configure = require('../configure'); + +var _configure2 = babelHelpers.interopRequireDefault(_configure); + +var _formatNumberWithString = require('format-number-with-string'); + +var _formatNumberWithString2 = babelHelpers.interopRequireDefault(_formatNumberWithString); + +var _deconstructNumberFormat = require('deconstruct-number-format'); + +var _deconstructNumberFormat2 = babelHelpers.interopRequireDefault(_deconstructNumberFormat); + +function simpleNumber() { + + var localizer = { + formats: { + 'default': '-#,##0.' + }, + + parse: function parse(value, format) { + if (format) { + var data = _deconstructNumberFormat2['default'](format); + + if (data.negativeLeftPos !== -1) value = value.substr(data.negativeLeftPos + 1); + + if (data.negativeRightPos !== -1) value = value.substring(0, data.negativeRightPos); + + value = value.replace(data.prefix, '').replace(data.suffix, ''); + + var halves = value.split(data.decimalChar); + + if (data.integerSeperator) halves[0] = halves[0].replace(new RegExp('\\' + data.integerSeperator, 'g')); + + if (data.decimalsSeparator) halves[1] = halves[1].replace(new RegExp('\\' + data.decimalsSeparator, 'g')); + + value = halves.join(data.decimalChar); + } + var number = parseFloat(value); + + return number; + }, + + format: function format(value, _format) { + return _formatNumberWithString2['default'](value, _format); + }, + + precision: function precision(format) { + var data = _deconstructNumberFormat2['default'](format); + return data.maxRight !== -1 ? data.maxRight : null; + } + }; + + _configure2['default'].setNumberLocalizer(localizer); + return localizer; +} + +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/util/_.js b/lib/util/_.js index 9463fb7c5..932cf2d83 100644 --- a/lib/util/_.js +++ b/lib/util/_.js @@ -81,7 +81,6 @@ var _ = module.exports = { uniqueId: function uniqueId(prefix) { return '' + ((prefix == null ? '' : prefix) + ++idCount); } - }; function has(o, k) { diff --git a/lib/util/babelHelpers.js b/lib/util/babelHelpers.js index 06f4eb23a..b5db5a412 100644 --- a/lib/util/babelHelpers.js +++ b/lib/util/babelHelpers.js @@ -92,10 +92,4 @@ return target; }; - - babelHelpers.classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } - }; }) \ No newline at end of file diff --git a/lib/util/caret.js b/lib/util/caret.js index b63daec00..b4c7de4e9 100644 --- a/lib/util/caret.js +++ b/lib/util/caret.js @@ -1,11 +1,14 @@ /*eslint-disable no-empty */ 'use strict'; -module.exports = function caret(el, start, end) { +exports.__esModule = true; +exports['default'] = caret; + +function caret(el, start, end) { if (start === undefined) return get(el); set(el, start, end); -}; +} function get(el) { var start, end, rangeEl, clone; @@ -46,4 +49,5 @@ function set(el, start, end) { rangeEl.select(); } } catch (e) {/* not focused or not visible */} -} \ No newline at end of file +} +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/util/compat.js b/lib/util/compat.js index ced28cfd8..50c99858f 100644 --- a/lib/util/compat.js +++ b/lib/util/compat.js @@ -10,10 +10,6 @@ var _reactDom = require('react-dom'); var _reactDom2 = babelHelpers.interopRequireDefault(_reactDom); -var _2 = require('./_'); - -var _3 = babelHelpers.interopRequireDefault(_2); - var _version = _react2['default'].version.split('.').map(parseFloat); module.exports = { @@ -22,24 +18,8 @@ module.exports = { return _version; }, - type: function type(component) { - if (_version[0] === 0 && _version[1] >= 13) return component; - - return component.type; - }, - findDOMNode: function findDOMNode(component) { return _reactDom2['default'].findDOMNode(component); - }, - - cloneElement: function cloneElement(child, props) { - if (_react2['default'].cloneElement) return _react2['default'].cloneElement(child, props); - - //just mutate if pre 0.13 - _3['default'].each(props, function (value, prop) { - return child.props[prop] = value; - }); - - return child; } + }; \ No newline at end of file diff --git a/lib/util/dates.js b/lib/util/dates.js index 7328c9da0..3fb83aace 100644 --- a/lib/util/dates.js +++ b/lib/util/dates.js @@ -2,22 +2,29 @@ var babelHelpers = require('./babelHelpers.js'); -var dateMath = require('date-arithmetic'); +exports.__esModule = true; -var _require = require('./constants'); +var _dateArithmetic = require('date-arithmetic'); -var directions = _require.directions; -var calendarViewUnits = _require.calendarViewUnits; -var locale = require('./configuration').locale; +var _dateArithmetic2 = babelHelpers.interopRequireDefault(_dateArithmetic); -var dates = module.exports = babelHelpers._extends(dateMath, { +var _constants = require('./constants'); + +var _constants2 = babelHelpers.interopRequireDefault(_constants); + +var _localizers = require('./localizers'); + +var directions = _constants2['default'].directions; +var calendarViewUnits = _constants2['default'].calendarViewUnits; + +var dates = babelHelpers._extends(_dateArithmetic2['default'], { parse: function parse(date, format, culture) { - return locale.date.parse(date, format, culture); + return _localizers.date.parse(date, format, culture); }, format: function format(date, _format, culture) { - return locale.date.format(date, _format, culture); + return _localizers.date.format(date, _format, culture); }, monthsInYear: function monthsInYear(year) { @@ -31,14 +38,13 @@ var dates = module.exports = babelHelpers._extends(dateMath, { firstVisibleDay: function firstVisibleDay(date, culture) { var firstOfMonth = dates.startOf(date, 'month'); - - return dates.startOf(firstOfMonth, 'week', locale.date.startOfWeek(culture)); + return dates.startOf(firstOfMonth, 'week', _localizers.date.startOfWeek(culture)); }, lastVisibleDay: function lastVisibleDay(date, culture) { var endOfMonth = dates.endOf(date, 'month'); - return dates.endOf(endOfMonth, 'week', locale.date.startOfWeek(culture)); + return dates.endOf(endOfMonth, 'week', _localizers.date.startOfWeek(culture)); }, visibleDays: function visibleDays(date, culture) { @@ -97,4 +103,7 @@ var dates = module.exports = babelHelpers._extends(dateMath, { tomorrow: function tomorrow() { return this.add(this.startOf(new Date(), 'day'), 1, 'day'); } -}); \ No newline at end of file +}); + +exports['default'] = dates; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/util/dom/animate.js b/lib/util/dom/animate.js index b36f6a1f0..f3fa4deda 100644 --- a/lib/util/dom/animate.js +++ b/lib/util/dom/animate.js @@ -1,9 +1,29 @@ 'use strict'; -var hyphenate = require('dom-helpers/util/hyphenate'), - css = require('dom-helpers/style'), - on = require('dom-helpers/events/on'), - off = require('dom-helpers/events/off'), - transitionProps = require('dom-helpers/transition/properties'); + +var babelHelpers = require('../babelHelpers.js'); + +exports.__esModule = true; +exports['default'] = animate; + +var _domHelpersUtilHyphenate = require('dom-helpers/util/hyphenate'); + +var _domHelpersUtilHyphenate2 = babelHelpers.interopRequireDefault(_domHelpersUtilHyphenate); + +var _domHelpersStyle = require('dom-helpers/style'); + +var _domHelpersStyle2 = babelHelpers.interopRequireDefault(_domHelpersStyle); + +var _domHelpersEventsOn = require('dom-helpers/events/on'); + +var _domHelpersEventsOn2 = babelHelpers.interopRequireDefault(_domHelpersEventsOn); + +var _domHelpersEventsOff = require('dom-helpers/events/off'); + +var _domHelpersEventsOff2 = babelHelpers.interopRequireDefault(_domHelpersEventsOff); + +var _domHelpersTransitionProperties = require('dom-helpers/transition/properties'); + +var _domHelpersTransitionProperties2 = babelHelpers.interopRequireDefault(_domHelpersTransitionProperties); var has = Object.prototype.hasOwnProperty, reset = {}, @@ -14,19 +34,18 @@ var has = Object.prototype.hasOwnProperty, bottom: 'translateY' }; -reset[transitionProps.property] = reset[transitionProps.duration] = reset[transitionProps.delay] = reset[transitionProps.timing] = ''; +reset[_domHelpersTransitionProperties2['default'].property] = reset[_domHelpersTransitionProperties2['default'].duration] = reset[_domHelpersTransitionProperties2['default'].delay] = reset[_domHelpersTransitionProperties2['default'].timing] = ''; -animate.endEvent = transitionProps.end; -animate.transform = transitionProps.transform; +animate.endEvent = _domHelpersTransitionProperties2['default'].end; +animate.transform = _domHelpersTransitionProperties2['default'].transform; animate.TRANSLATION_MAP = TRANSLATION_MAP; -module.exports = animate; - // super lean animate function for transitions // doesn't support all translations to keep it matching the jquery API /** * code in part from: Zepto 1.1.4 | zeptojs.com/license */ + function animate(node, properties, duration, easing, callback) { var cssProperties = [], fakeEvent = { target: node, currentTarget: node }, @@ -36,28 +55,28 @@ function animate(node, properties, duration, easing, callback) { if (typeof easing === 'function') callback = easing, easing = null; - if (!transitionProps.end) duration = 0; + if (!_domHelpersTransitionProperties2['default'].end) duration = 0; if (duration === undefined) duration = 200; for (var key in properties) if (has.call(properties, key)) { if (/(top|bottom)/.test(key)) transforms += TRANSLATION_MAP[key] + '(' + properties[key] + ') ';else { cssValues[key] = properties[key]; - cssProperties.push(hyphenate(key)); + cssProperties.push(_domHelpersUtilHyphenate2['default'](key)); } } if (transforms) { - cssValues[transitionProps.transform] = transforms; - cssProperties.push(transitionProps.transform); + cssValues[_domHelpersTransitionProperties2['default'].transform] = transforms; + cssProperties.push(_domHelpersTransitionProperties2['default'].transform); } if (duration > 0) { - cssValues[transitionProps.property] = cssProperties.join(', '); - cssValues[transitionProps.duration] = duration / 1000 + 's'; - cssValues[transitionProps.delay] = 0 + 's'; - cssValues[transitionProps.timing] = easing || 'linear'; + cssValues[_domHelpersTransitionProperties2['default'].property] = cssProperties.join(', '); + cssValues[_domHelpersTransitionProperties2['default'].duration] = duration / 1000 + 's'; + cssValues[_domHelpersTransitionProperties2['default'].delay] = 0 + 's'; + cssValues[_domHelpersTransitionProperties2['default'].timing] = easing || 'linear'; - on(node, transitionProps.end, done); + _domHelpersEventsOn2['default'](node, _domHelpersTransitionProperties2['default'].end, done); setTimeout(function () { if (!fired) done(fakeEvent); @@ -65,7 +84,7 @@ function animate(node, properties, duration, easing, callback) { } node.clientLeft; // trigger page reflow - css(node, cssValues); + _domHelpersStyle2['default'](node, cssValues); if (duration <= 0) setTimeout(done.bind(null, fakeEvent), 0); @@ -73,8 +92,10 @@ function animate(node, properties, duration, easing, callback) { if (event.target !== event.currentTarget) return; fired = true; - off(event.target, transitionProps.end, done); - css(node, reset); + _domHelpersEventsOff2['default'](event.target, _domHelpersTransitionProperties2['default'].end, done); + _domHelpersStyle2['default'](node, reset); callback && callback.call(this); } -} \ No newline at end of file +} + +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/util/dom/support.js b/lib/util/dom/support.js index 4ac8fc200..8260e195e 100644 --- a/lib/util/dom/support.js +++ b/lib/util/dom/support.js @@ -1,5 +1,7 @@ 'use strict'; -module.exports = { +exports.__esModule = true; +exports['default'] = { ios: typeof navigator !== 'undefined' && navigator.userAgent.match(/(iPod|iPhone|iPad)/) && navigator.userAgent.match(/AppleWebKit/) -}; \ No newline at end of file +}; +module.exports = exports['default']; \ No newline at end of file diff --git a/lib/util/filter.js b/lib/util/filter.js index 255c2974c..f3652ffaf 100644 --- a/lib/util/filter.js +++ b/lib/util/filter.js @@ -1,4 +1,6 @@ -'use strict'; +"use strict"; + +exports.__esModule = true; var common = { eq: function eq(a, b) { return a === b; @@ -35,4 +37,5 @@ var common = { } }; -module.exports = common; \ No newline at end of file +exports["default"] = common; +module.exports = exports["default"]; \ No newline at end of file diff --git a/lib/util/localizers.js b/lib/util/localizers.js index ea17833fa..a7df3e3e8 100644 --- a/lib/util/localizers.js +++ b/lib/util/localizers.js @@ -2,95 +2,149 @@ var babelHelpers = require('./babelHelpers.js'); -var invariant = require('invariant'); +exports.__esModule = true; +exports.setNumber = setNumber; +exports.setDate = setDate; -var _require = require('./_'); +var _invariant = require('invariant'); -var has = _require.has; +var _invariant2 = babelHelpers.interopRequireDefault(_invariant); -var React = require('react'); +var _ = require('./_'); -var REQUIRED_NUMBER_FORMATS = ['default']; +var _react = require('react'); + +var _react2 = babelHelpers.interopRequireDefault(_react); -var localePropType = React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.func]); +var localePropType = _react2['default'].PropTypes.oneOfType([_react2['default'].PropTypes.string, _react2['default'].PropTypes.func]); + +var REQUIRED_NUMBER_FORMATS = ['default']; var REQUIRED_DATE_FORMATS = ['default', 'date', 'time', 'header', 'footer', 'dayOfMonth', 'month', 'year', 'decade', 'century']; function _format(localizer, formatter, value, format, culture) { var result = typeof format === 'function' ? format(value, culture, localizer) : formatter.call(localizer, value, format, culture); - invariant(result == null || typeof result === 'string', '`localizer format(..)` must return a string, null, or undefined'); + _invariant2['default'](result == null || typeof result === 'string', '`localizer format(..)` must return a string, null, or undefined'); return result; } function checkFormats(requiredFormats, formats) { if (process.env.NODE_ENV !== 'production') requiredFormats.forEach(function (f) { - return invariant(has(formats, f), 'localizer missing required format: `%s`', f); + return _invariant2['default'](_.has(formats, f), 'localizer missing required format: `%s`', f); }); } -var NumberLocalizer = function NumberLocalizer(_ref) { - var _this = this; +var _numberLocalizer = {}; - var format = _ref.format; - var parse = _ref.parse; - var precision = _ref.precision; +function setNumber(_ref) { + var _format2 = _ref.format; + var _parse = _ref.parse; + var _ref$precision = _ref.precision; + var precision = _ref$precision === undefined ? function () { + return null; + } : _ref$precision; var formats = _ref.formats; var propType = _ref.propType; - babelHelpers.classCallCheck(this, NumberLocalizer); - invariant(typeof format === 'function', 'number localizer `format(..)` must be a function'); - invariant(typeof parse === 'function', 'number localizer `parse(..)` must be a function'); + _invariant2['default'](typeof _format2 === 'function', 'number localizer `format(..)` must be a function'); + _invariant2['default'](typeof _parse === 'function', 'number localizer `parse(..)` must be a function'); checkFormats(REQUIRED_NUMBER_FORMATS, formats); - this.propType = propType || localePropType; - this.formats = formats; - this.precision = precision || function () { - return null; - }; - - this.format = function (value, str, culture) { - return _format(_this, format, value, str, culture); - }; - - this.parse = function (value, culture) { - var result = parse.call(_this, value, culture); + _numberLocalizer = { + formats: formats, + precision: precision, + propType: propType || localePropType, - invariant(result == null || typeof result === 'number', 'number localizer `parse(..)` must return a number, null, or undefined'); + format: function format(value, str, culture) { + return _format(this, _format2, value, str, culture); + }, - return result; + parse: function parse(value, culture) { + var result = _parse.call(this, value, culture); + _invariant2['default'](result == null || typeof result === 'number', 'number localizer `parse(..)` must return a number, null, or undefined'); + return result; + } }; -}; - -var DateLocalizer = function DateLocalizer(spec) { - var _this2 = this; +} - babelHelpers.classCallCheck(this, DateLocalizer); +var _dateLocalizer = {}; - invariant(typeof spec.format === 'function', 'date localizer `format(..)` must be a function'); - invariant(typeof spec.parse === 'function', 'date localizer `parse(..)` must be a function'); - invariant(typeof spec.firstOfWeek === 'function', 'date localizer `firstOfWeek(..)` must be a function'); +function setDate(spec) { + _invariant2['default'](typeof spec.format === 'function', 'date localizer `format(..)` must be a function'); + _invariant2['default'](typeof spec.parse === 'function', 'date localizer `parse(..)` must be a function'); + _invariant2['default'](typeof spec.firstOfWeek === 'function', 'date localizer `firstOfWeek(..)` must be a function'); checkFormats(REQUIRED_DATE_FORMATS, spec.formats); - this.propType = spec.propType || localePropType; - this.formats = spec.formats; - this.startOfWeek = spec.firstOfWeek; - - this.format = function (value, format, culture) { - return _format(_this2, spec.format, value, format, culture); + _dateLocalizer = { + formats: spec.formats, + propType: spec.propType || localePropType, + startOfWeek: spec.firstOfWeek, + format: function format(value, str, culture) { + return _format(this, spec.format, value, str, culture); + }, + parse: function parse(value, culture) { + var result = spec.parse.call(this, value, culture); + _invariant2['default'](result == null || result instanceof Date && !isNaN(result.getTime()), 'date localizer `parse(..)` must return a valid Date, null, or undefined'); + return result; + } }; +} - this.parse = function (value, format, culture) { - var result = spec.parse.call(_this2, value, format, culture); - - invariant(result == null || result instanceof Date && !isNaN(result.getTime()), 'date localizer `parse(..)` must return a valid Date, null, or undefined'); +var number = { + propType: function propType() { + var _numberLocalizer2; + + return (_numberLocalizer2 = _numberLocalizer).propType.apply(_numberLocalizer2, arguments); + }, + getFormat: function getFormat(key, format) { + return format || _numberLocalizer.formats[key]; + }, + parse: function parse() { + var _numberLocalizer3; + + return (_numberLocalizer3 = _numberLocalizer).parse.apply(_numberLocalizer3, arguments); + }, + format: function format() { + var _numberLocalizer4; + + return (_numberLocalizer4 = _numberLocalizer).format.apply(_numberLocalizer4, arguments); + }, + precision: function precision() { + var _numberLocalizer5; + + return (_numberLocalizer5 = _numberLocalizer).precision.apply(_numberLocalizer5, arguments); + } +}; - return result; - }; +exports.number = number; +var date = { + propType: function propType() { + var _dateLocalizer2; + + return (_dateLocalizer2 = _dateLocalizer).propType.apply(_dateLocalizer2, arguments); + }, + getFormat: function getFormat(key, format) { + return format || _dateLocalizer.formats[key]; + }, + parse: function parse() { + var _dateLocalizer3; + + return (_dateLocalizer3 = _dateLocalizer).parse.apply(_dateLocalizer3, arguments); + }, + format: function format() { + var _dateLocalizer4; + + return (_dateLocalizer4 = _dateLocalizer).format.apply(_dateLocalizer4, arguments); + }, + startOfWeek: function startOfWeek() { + var _dateLocalizer5; + + return (_dateLocalizer5 = _dateLocalizer).startOfWeek.apply(_dateLocalizer5, arguments); + } }; -module.exports = { - NumberLocalizer: NumberLocalizer, DateLocalizer: DateLocalizer -}; \ No newline at end of file +exports.date = date; +exports['default'] = { number: number, date: date }; \ No newline at end of file diff --git a/lib/util/propTypes.js b/lib/util/propTypes.js index 346f7bbe0..1352d6042 100644 --- a/lib/util/propTypes.js +++ b/lib/util/propTypes.js @@ -6,15 +6,14 @@ var _react = require('react'); var _react2 = babelHelpers.interopRequireDefault(_react); -var _configuration = require('./configuration'); +var _localizers = require('./localizers'); -var _configuration2 = babelHelpers.interopRequireDefault(_configuration); +var _localizers2 = babelHelpers.interopRequireDefault(_localizers); var _filter = require('./filter'); var _filter2 = babelHelpers.interopRequireDefault(_filter); -var localizers = _configuration2['default'].locale; var filterTypes = Object.keys(_filter2['default']).filter(function (i) { return i !== 'filter'; }); @@ -43,13 +42,13 @@ module.exports = { numberFormat: createChainableTypeChecker(function () { var _localizers$number; - return (_localizers$number = localizers.number).propType.apply(_localizers$number, arguments); + return (_localizers$number = _localizers2['default'].number).propType.apply(_localizers$number, arguments); }), dateFormat: createChainableTypeChecker(function () { var _localizers$date; - return (_localizers$date = localizers.date).propType.apply(_localizers$date, arguments); + return (_localizers$date = _localizers2['default'].date).propType.apply(_localizers$date, arguments); }), disabled: getInteractionPropType('disabled'), diff --git a/lib/util/repeater.js b/lib/util/repeater.js index 84d367e8b..92d9b5105 100644 --- a/lib/util/repeater.js +++ b/lib/util/repeater.js @@ -2,6 +2,9 @@ // at about 35ms+/- 5ms after an initial 500ms delay. callback fires on the leading edge "use strict"; +exports.__esModule = true; +exports["default"] = Repeater; + function Repeater(callback) { var id, cancel = function cancel() { @@ -17,4 +20,4 @@ function Repeater(callback) { return cancel; } -module.exports = Repeater; \ No newline at end of file +module.exports = exports["default"]; \ No newline at end of file diff --git a/lib/util/validateListInterface.js b/lib/util/validateListInterface.js index 9297f9441..938bc46b5 100644 --- a/lib/util/validateListInterface.js +++ b/lib/util/validateListInterface.js @@ -1,21 +1,22 @@ 'use strict'; -var METHODS = ['next', 'prev', 'first', 'last']; -module.exports = function validateListComponent(list) { +var babelHelpers = require('./babelHelpers.js'); + +exports.__esModule = true; +exports['default'] = validateListComponent; + +var _invariant = require('invariant'); + +var _invariant2 = babelHelpers.interopRequireDefault(_invariant); +var METHODS = ['next', 'prev', 'first', 'last']; + +function validateListComponent(list) { if (process.env.NODE_ENV !== 'production') { METHODS.forEach(function (method) { - return assert(typeof list[method] === 'function', 'List components must implement a `' + method + '()` method'); + return _invariant2['default'](typeof list[method] === 'function', 'List components must implement a `' + method + '()` method'); }); } -}; +} -function assert(condition, msg) { - var error; - - if (!condition) { - error = new Error(msg); - error.framesToPop = 1; - throw error; - } -} \ No newline at end of file +module.exports = exports['default']; \ No newline at end of file diff --git a/package.json b/package.json index 8f74729a2..dec03893c 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,11 @@ "compile:lib": "node build/babel src --out-dir lib", "compile:docs": "webpack --config build/docs.config.js --production", "compile:dist": "webpack --config build/browser.config.js", + "compile:locale": "webpack --config build/localizers.config.js", "build:lib": "npm run clean:lib && npm run compile:lib && npm run assets:lib", "build:docs": "npm run clean:docs && npm run compile:docs && npm run assets:docs", - "build:dist": "npm run clean:dist && npm run compile:dist && npm run less && npm run assets:dist", + "build:dist": "npm run clean:dist && npm run compile:dist & npm run compile:locale && npm run less && npm run assets:dist", + "build": "npm run build:lib && npm run build:dist & npm run build:docs", "docs": "npm run clean:docs && webpack-dev-server --config ./build/docs.config.js --hot", "dev": "webpack-dev-server --config ./build/dev.config.js --hot", @@ -70,6 +72,10 @@ "uncontrollable": "^3.0.2", "warning": "^2.0.0" }, + "optionalDependencies": { + "format-number-with-string": "0.0.1", + "deconstruct-number-format": "0.0.1" + }, "devDependencies": { "babel-core": "^5.8.21", "babel-eslint": "^3.1.30", @@ -77,6 +83,7 @@ "babel-plugin-external-helpers": "^1.1.1", "babel-plugin-object-assign": "^1.2.1", "chance": "^0.7.6", + "cldr-data": "^28.0.2", "cpy": "^3.4.0", "css-loader": "^0.15.6", "eslint": "^0.24.1", @@ -85,8 +92,8 @@ "file-loader": "^0.8.1", "glob": "^5.0.14", "globalize": "^0.1.1", - "imports-loader": "^0.6.3", - "json-loader": "^0.5.2", + "imports-loader": "^0.6.4", + "json-loader": "^0.5.3", "karma": "^0.13.3", "karma-chrome-launcher": "^0.2.0", "karma-expect": "~1.1.0", diff --git a/src/Calendar.jsx b/src/Calendar.jsx index 722b427b0..ca42f697b 100644 --- a/src/Calendar.jsx +++ b/src/Calendar.jsx @@ -7,7 +7,7 @@ import Month from './Month'; import Year from './Year'; import Decade from './Decade'; import Century from './Century'; -import config from './util/configuration'; +import { date as dateLocalizer } from './util/localizers'; import CustomPropTypes from './util/propTypes'; import createUncontrolledWidget from 'uncontrollable'; import SlideTransition from './SlideTransition'; @@ -21,8 +21,7 @@ let dir = constants.directions , values = obj => Object.keys(obj).map( k => obj[k] ) , invert = obj => _.transform(obj, (o, val, key) => { o[val] = key }, {}); -let localizers = config.locale - , views = constants.calendarViews +let views = constants.calendarViews , VIEW_OPTIONS = values(views) , ALT_VIEW = invert(constants.calendarViewHierarchy) , NEXT_VIEW = constants.calendarViewHierarchy @@ -52,7 +51,7 @@ let MULTIPLIER = { [views.CENTURY]: 100 }; -let format = (props, f) => props[f + 'Format'] || localizers.date.formats[f] +let format = (props, f) => dateLocalizer.getFormat(f, props[f + 'Format']) let propTypes = { @@ -385,16 +384,16 @@ let Calendar = React.createClass({ , dt = this.state.currentDate; if ( view === 'month') - return localizers.date.format(dt, format(props, 'header'), culture) + return dateLocalizer.format(dt, format(props, 'header'), culture) else if ( view === 'year') - return localizers.date.format(dt, format(props, 'year'), culture) + return dateLocalizer.format(dt, format(props, 'year'), culture) else if ( view === 'decade') - return localizers.date.format(dates.startOf(dt, 'decade'), format(props, 'decade'), culture) + return dateLocalizer.format(dates.startOf(dt, 'decade'), format(props, 'decade'), culture) else if ( view === 'century') - return localizers.date.format(dates.startOf(dt, 'century'), format(props, 'century'), culture) + return dateLocalizer.format(dates.startOf(dt, 'century'), format(props, 'century'), culture) }, inRangeValue(_value){ diff --git a/src/Century.jsx b/src/Century.jsx index 9842a7f13..a85343ec7 100644 --- a/src/Century.jsx +++ b/src/Century.jsx @@ -1,12 +1,12 @@ import React from 'react'; import cn from 'classnames'; import dates from './util/dates'; -import config from './util/configuration';import _ from './util/_'; +import { date as dateLocalizer } from './util/localizers'; +import _ from './util/_'; import CustomPropTypes from './util/propTypes'; import { instanceId } from './util/widgetHelpers'; -let localizers = config.locale; -let format = props => props.decadeFormat || localizers.date.formats.decade +let format = props => dateLocalizer.getFormat('decade', props.decadeFormat) let isEqual = (dateA, dateB) => dates.eq(dateA, dateB, 'decade') let optionId = (id, date) => `${id}__century_${dates.year(date)}`; @@ -70,7 +70,7 @@ export default React.createClass({ var isFocused = isEqual(date, focused) , isSelected = isEqual(date, value) , currentDecade = isEqual(date, today) - , label = localizers.date.format( + , label = dateLocalizer.format( dates.startOf(date, 'decade'), format(this.props), culture); var currentID = optionId(id, date); diff --git a/src/Combobox.jsx b/src/Combobox.jsx index dae894ba0..b7eed65b6 100644 --- a/src/Combobox.jsx +++ b/src/Combobox.jsx @@ -204,7 +204,6 @@ var ComboBox = React.createClass({ suggest={suggest} name={name} role='combobox' - autoFocus={this.props.autoFocus} aria-owns={listID} aria-busy={!!busy} aria-autocomplete={completeType} diff --git a/src/DateInput.jsx b/src/DateInput.jsx index ccfd381c4..442804621 100644 --- a/src/DateInput.jsx +++ b/src/DateInput.jsx @@ -1,11 +1,9 @@ import React from 'react'; import cx from 'classnames'; import compat from './util/compat'; -import config from './util/configuration'; +import { date as dateLocalizer } from './util/localizers'; import CustomPropTypes from './util/propTypes'; -let localizers = config.locale; - export default React.createClass({ displayName: 'DatePickerInput', @@ -106,7 +104,7 @@ function formatDate(date, format, culture){ var val = '' if ( (date instanceof Date) && isValid(date) ) - val = localizers.date.format(date, format, culture) + val = dateLocalizer.format(date, format, culture) return val; } diff --git a/src/DateTimePicker.jsx b/src/DateTimePicker.jsx index c86361aa3..c9e46a335 100644 --- a/src/DateTimePicker.jsx +++ b/src/DateTimePicker.jsx @@ -6,7 +6,7 @@ import compat from './util/compat'; import _ from './util/_'; //pick, omit, has import dates from './util/dates'; -import config from './util/configuration'; +import { date as dateLocalizer } from './util/localizers'; import constants from './util/constants'; import Popup from './Popup'; @@ -21,7 +21,6 @@ import { instanceId, notify, isFirstFocusedRender } from './util/widgetHelpers'; let { calendarViews: views, datePopups: popups } = constants; let Calendar = _Calendar.ControlledComponent; -let localizers = config.locale; let viewEnum = Object.keys(views).map( k => views[k] ); let { omit, pick } = _; @@ -461,15 +460,15 @@ function getFormat(props){ return props.format ? props.format : (cal && time) || (!cal && !time) - ? localizers.date.formats.default - : localizers.date.formats[cal ? 'date' : 'time'] + ? dateLocalizer.getFormat('default') + : dateLocalizer.getFormat(cal ? 'date' : 'time') } function formatDate(date, format, culture){ var val = '' if ((date instanceof Date) && !isNaN(date.getTime())) - val = localizers.date.format(date, format, culture) + val = dateLocalizer.format(date, format, culture) return val; } @@ -478,7 +477,7 @@ function formatsParser(formats, culture, str){ var date; for (var i = 0; i < formats.length; i++ ){ - date = localizers.date.parse(str, formats[i], culture) + date = dateLocalizer.parse(str, formats[i], culture) if (date) return date } return null diff --git a/src/Decade.jsx b/src/Decade.jsx index d65c6d4f3..b63264d88 100644 --- a/src/Decade.jsx +++ b/src/Decade.jsx @@ -1,15 +1,11 @@ import React from 'react'; import cn from 'classnames'; import dates from './util/dates'; -import config from './util/configuration'; +import { date as dateLocalizer } from './util/localizers'; import _ from './util/_'; import CustomPropTypes from './util/propTypes'; import { instanceId } from './util/widgetHelpers'; -var localizers = config.locale - -var format = props => props.yearFormat || localizers.date.formats.year - let propTypes = { optionID: React.PropTypes.func, culture: React.PropTypes.string, @@ -75,7 +71,9 @@ export default React.createClass({ var isFocused = isEqual(date, focused) , isSelected = isEqual(date, value) , currentYear = isEqual(date, today) - , label = localizers.date.format(date, format(this.props), culture); + , label = dateLocalizer.format(date, + dateLocalizer.getFormat('year', this.props.yearFormat) + , culture); var currentID = optionId(id, date); diff --git a/src/Footer.jsx b/src/Footer.jsx index 07852e3a2..42cacb030 100644 --- a/src/Footer.jsx +++ b/src/Footer.jsx @@ -1,8 +1,8 @@ -var React = require('react') - , Btn = require('./WidgetButton') - , localizers = require('./util/configuration').locale; +import React from 'react'; +import Btn from './WidgetButton'; +import { date as dateLocalizer } from './util/localizers'; -var format = props => props.format || localizers.date.formats.footer +var format = props => dateLocalizer.getFormat('footer', props.format) module.exports = React.createClass({ @@ -10,7 +10,7 @@ module.exports = React.createClass({ render() { var now = this.props.value - , formatted = localizers.date.format( + , formatted = dateLocalizer.format( now , format(this.props) , this.props.culture); diff --git a/src/Header.jsx b/src/Header.jsx index faddf460a..e2f8a1317 100644 --- a/src/Header.jsx +++ b/src/Header.jsx @@ -1,9 +1,8 @@ -'use strict'; -var React = require('react') - , Btn = require('./WidgetButton'); - -module.exports = React.createClass({ +import React from 'react'; +import Btn from './WidgetButton'; +export default React.createClass({ + displayName: 'Header', propTypes: { label: React.PropTypes.string.isRequired, labelId: React.PropTypes.string, @@ -26,7 +25,7 @@ module.exports = React.createClass({ require('./mixins/RtlChildContextMixin') ], - getDefaultProps: function(){ + getDefaultProps(){ return { messages: { moveBack: 'navigate back', @@ -35,7 +34,7 @@ module.exports = React.createClass({ } }, - render: function(){ + render(){ let { messages, label, labelId , onMoveRight, onMoveLeft, onViewChange diff --git a/src/Month.jsx b/src/Month.jsx index a61c3b56c..145365460 100644 --- a/src/Month.jsx +++ b/src/Month.jsx @@ -1,14 +1,13 @@ import React from 'react'; import cn from 'classnames'; import dates from './util/dates'; -import config from './util/configuration' +import { date as dateLocalizer } from './util/localizers'; import CustomPropTypes from './util/propTypes'; import _ from './util/_'; import { instanceId } from './util/widgetHelpers'; -var localizers = config.locale - , dayFormat = props => props.dayFormat || localizers.date.formats.weekday - , dateFormat = props => props.dateFormat || localizers.date.formats.dayOfMonth +var dayFormat = props => dateLocalizer.getFormat('weekday', props.dayFormat) + , dateFormat = props => dateLocalizer.getFormat('dayOfMonth', props.dateFormat) let optionId = (id, date) => `${id}__month_${dates.month(date)}-${dates.date(date)}`; @@ -64,7 +63,7 @@ let MonthView = React.createClass({ role='grid' > - {this._headers(dayFormat(this.props), culture)} + {this._headers(rows[0], dayFormat(this.props), culture)} {rows.map(this._row)} @@ -79,7 +78,7 @@ let MonthView = React.createClass({ , value, culture, min, max , dayComponent: Day } = this.props , id = instanceId(this) - , labelFormat = localizers.date.formats.footer; + , labelFormat = dateLocalizer.getFormat('footer'); return ( @@ -88,8 +87,8 @@ let MonthView = React.createClass({ var isFocused = isEqual(day, focused) , isSelected = isEqual(day, value) , isToday = isEqual(day, today) - , date = localizers.date.format(day, dateFormat(this.props), culture) - , label = localizers.date.format(day, labelFormat, culture); + , date = dateLocalizer.format(day, dateFormat(this.props), culture) + , label = dateLocalizer.format(day, labelFormat, culture); var currentID = optionId(id, day); @@ -128,9 +127,14 @@ let MonthView = React.createClass({ ) }, - _headers(format, culture){ - return [0, 1, 2, 3, 4, 5, 6].map( (day) => - { localizers.date.format(day, format, culture) }) + _headers(week, format, culture){ + return week.map(date => { + return ( + + { dateLocalizer.format(date, format, culture) } + + ) + }) } }); diff --git a/src/NumberInput.jsx b/src/NumberInput.jsx index e2b962f70..a0121a6e1 100644 --- a/src/NumberInput.jsx +++ b/src/NumberInput.jsx @@ -1,11 +1,10 @@ -'use strict'; -var React = require('react') - , CustomPropTypes = require('./util/propTypes') - , localizers = require('./util/configuration').locale; +import React from 'react'; +import CustomPropTypes from './util/propTypes'; +import { number as numberLocalizer } from './util/localizers'; -var format = props => props.format || localizers.number.formats.default +var format = props => numberLocalizer.getFormat('default', props.format) -module.exports = React.createClass({ +export default React.createClass({ displayName: 'NumberPickerInput', @@ -27,7 +26,7 @@ module.exports = React.createClass({ return { value: null, editing: false, - parse: (number, culture) => localizers.number.parse(number, culture) + parse: (number, culture) => numberLocalizer.parse(number, culture) } }, @@ -133,5 +132,5 @@ module.exports = React.createClass({ // } function formatNumber(number, format, culture){ - return localizers.number.format(number, format, culture) + return numberLocalizer.format(number, format, culture) } diff --git a/src/NumberPicker.jsx b/src/NumberPicker.jsx index 4fc4e9f86..397c8c100 100644 --- a/src/NumberPicker.jsx +++ b/src/NumberPicker.jsx @@ -6,7 +6,7 @@ import CustomPropTypes from './util/propTypes'; import createUncontrolledWidget from 'uncontrollable'; import constants from './util/constants'; import repeater from './util/repeater'; -import config from './util/configuration'; +import { number as numberLocalizer } from './util/localizers'; import Input from './NumberInput'; import Btn from './WidgetButton'; @@ -14,9 +14,8 @@ import { widgetEditable, widgetEnabled } from './util/interaction'; import { notify } from './util/widgetHelpers'; let { directions } = constants; -let localizers = config.locale -let format = props => props.format || localizers.number.formats.default +var format = props => numberLocalizer.getFormat('default', props.format) let propTypes = { @@ -153,7 +152,6 @@ let NumberPicker = React.createClass({ name={this.props.name} role='spinbutton' min={this.props.min} - autoFocus={this.props.autoFocus} aria-valuenow={val} aria-valuemin={isFinite(this.props.min) ? this.props.min : null } aria-valuemax={isFinite(this.props.max) ? this.props.max : null } @@ -245,7 +243,7 @@ let NumberPicker = React.createClass({ var decimals = this.props.precision != null ? this.props.precision - : localizers.number.precision(format(this.props)) + : numberLocalizer.precision(format(this.props)) this.change( decimals != null ? round(value, decimals) : value) diff --git a/src/TimeList.jsx b/src/TimeList.jsx index 9f74cdfe2..79d729f79 100644 --- a/src/TimeList.jsx +++ b/src/TimeList.jsx @@ -1,14 +1,13 @@ 'use strict'; -var React = require('react') - , dates = require('./util/dates') - , List = require('./List') - , localizers = require('./util/configuration').locale - , CustomPropTypes = require('./util/propTypes'); +import React from 'react'; +import dates from './util/dates'; +import List from './List'; +import { date as dateLocalizer } from './util/localizers'; +import CustomPropTypes from './util/propTypes'; -var format = props => props.format || localizers.date.formats.time +var format = props => dateLocalizer.getFormat('time', props.format) - -module.exports = React.createClass({ +export default React.createClass({ displayName: 'TimeList', @@ -90,7 +89,7 @@ module.exports = React.createClass({ if( !date) return null date = new Date(Math.floor(date.getTime() / roundTo) * roundTo) - label = localizers.date.format(date, format(this.props), this.props.culture) + label = dateLocalizer.format(date, format(this.props), this.props.culture) times.some( time => { if( time.label === label ) @@ -112,7 +111,7 @@ module.exports = React.createClass({ while (dates.date(start) === startDay && dates.lte(start, values.max)) { i++ - times.push({ date: start, label: localizers.date.format(start, format(props), props.culture) }) + times.push({ date: start, label: dateLocalizer.format(start, format(props), props.culture) }) start = dates.add(start, props.step || 30, 'minutes') } return times diff --git a/src/Year.jsx b/src/Year.jsx index 4ab69cd3a..f088bfece 100644 --- a/src/Year.jsx +++ b/src/Year.jsx @@ -1,13 +1,12 @@ import React from 'react'; import cn from 'classnames'; import dates from './util/dates'; -import config from './util/configuration'; +import { date as dateLocalizer } from './util/localizers'; import _ from './util/_'; import CustomPropTypes from './util/propTypes'; import { instanceId } from './util/widgetHelpers'; -var localizers = config.locale -var format = props => props.monthFormat || localizers.date.formats.month +var format = props => dateLocalizer.getFormat('month', props.monthFormat) let propTypes = { optionID: React.PropTypes.func, @@ -64,7 +63,7 @@ let YearView = React.createClass({ focused, disabled, onChange , value, today, culture, min, max } = this.props , id = instanceId(this) - , labelFormat = localizers.date.formats.header; + , labelFormat = dateLocalizer.getFormat('header'); return ( @@ -72,7 +71,7 @@ let YearView = React.createClass({ var isFocused = isEqual(date, focused) , isSelected = isEqual(date, value) , currentMonth = isEqual(date, today) - , label = localizers.date.format(date, labelFormat, culture); + , label = dateLocalizer.format(date, labelFormat, culture); var currentID = optionId(id, date); @@ -96,7 +95,7 @@ let YearView = React.createClass({ 'rw-now': currentMonth })} > - {localizers.date.format(date, format(this.props), culture) } + {dateLocalizer.format(date, format(this.props), culture) } ) diff --git a/src/configure.js b/src/configure.js index 981651d48..6ced9717f 100644 --- a/src/configure.js +++ b/src/configure.js @@ -1,9 +1,6 @@ import configuration from './util/configuration'; -import localizers from './util/localizers'; +import * as localizers from './util/localizers'; -let { - NumberLocalizer - , DateLocalizer } = localizers export default { @@ -12,15 +9,11 @@ export default { }, setLocalizers({ date, number }) { - this.setDateLocalizer(date) - this.setNumberLocalizer(number) + date && this.setDateLocalizer(date) + number && this.setNumberLocalizer(number) }, - setDateLocalizer(spec) { - configuration.locale.date = new DateLocalizer(spec) - }, + setDateLocalizer: localizers.setDate, - setNumberLocalizer(spec) { - configuration.locale.number = new NumberLocalizer(spec) - } + setNumberLocalizer: localizers.setNumber } diff --git a/src/globalize-localizers.js b/src/globalize-localizers.js deleted file mode 100644 index 8ee98e0bd..000000000 --- a/src/globalize-localizers.js +++ /dev/null @@ -1,95 +0,0 @@ -import dates from './util/dates'; - -export default function globalizeLocalizers(globalize) { - const shortNames = Object.create(null); - - function getCulture(culture){ - return culture - ? globalize.findClosestCulture(culture) - : globalize.culture() - } - - function firstOfWeek(culture) { - culture = getCulture(culture) - return (culture && culture.calendar.firstDay) || 0 - } - - function shortDay(dayOfTheWeek){ - var culture = getCulture(arguments[1]) - , name = culture.name - , start = firstOfWeek(culture) - , days = () => { - let days = culture.calendar.days.namesShort.slice() - return start === 0 ? days : days.concat(days.splice(0, start)) - }; - - var names = shortNames[name] || (shortNames[name] = days()); - - return names[dayOfTheWeek]; - } - - var date = { - - formats: { - date: 'd', - time: 't', - default: 'f', - header: 'MMMM yyyy', - footer: 'D', - weekday: shortDay, - dayOfMonth: 'dd', - month: 'MMM', - year: 'yyyy', - - decade: (dt, culture, l) => - `${l.format(dt, l.formats.year, culture)} - ${l.format(dates.endOf(dt, 'decade'), l.formats.year, culture)}`, - - century: (dt, culture, l) => - `${l.format(dt, l.formats.year, culture)} - ${l.format(dates.endOf(dt, 'century'), l.formats.year, culture)}` - }, - - firstOfWeek, - - parse(value, format, culture){ - return globalize.parseDate(value, format, culture) - }, - - format(value, format, culture){ - return globalize.format(value, format, culture) - } - } - - var number = { - - formats: { - default: 'D' - }, - - parse(value, culture){ - return globalize.parseFloat(value, 10, culture) - }, - - format(value, format, culture){ - return globalize.format(value, format, culture) - }, - - precision(format, _culture){ - var culture = getCulture(_culture) - , numFormat = culture.numberFormat - - if (typeof format === 'string') { - if (format.length > 1) - return parseFloat(format.substr(1)) - - if (format.indexOf('p') !== -1) numFormat = numFormat.percent - if (format.indexOf('c') !== -1) numFormat = numFormat.curency - - return numFormat.decimals || null - } - - return null - } - } - - return { date, number } -} diff --git a/src/index.js b/src/index.js index e2f16f78f..cffec9a89 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,4 @@ +let configure = require('./configure'); if (process.env.NODE_ENV !== 'production' ) { [ @@ -5,26 +6,21 @@ if (process.env.NODE_ENV !== 'production' ) { Array.prototype.filter, Array.prototype.reduce ].forEach(method => { - if ( !method ) throw new Error( + if (!method) throw new Error( 'One or more ES5 features is not available to ReactWidgets: http://jquense.github.io/react-widgets/docs/#/getting-started/browser' ) }) } module.exports = { - + ...configure, DropdownList: require('./DropdownList'), Combobox: require('./Combobox'), - Calendar: require('./Calendar'), DateTimePicker: require('./DateTimePicker'), - NumberPicker: require('./NumberPicker'), - Multiselect: require('./Multiselect'), SelectList: require('./SelectList'), - configure: require('./configure'), - utils: { ReplaceTransitionGroup: require('./ReplaceTransitionGroup'), SlideTransition: require('./SlideTransition') diff --git a/src/localizers/globalize.js b/src/localizers/globalize.js new file mode 100644 index 000000000..2552ccd63 --- /dev/null +++ b/src/localizers/globalize.js @@ -0,0 +1,190 @@ +import { PropTypes } from 'react'; +import configure from '../configure' + +function endOfDecade(date) { + date = new Date(date) + date.setFullYear(date.getFullYear() + 10) + date.setMilliseconds(date.getMilliseconds() - 1) + return date +} + +function endOfCentury(date) { + date = new Date(date) + date.setFullYear(date.getFullYear() + 100) + date.setMilliseconds(date.getMilliseconds() - 1) + return date +} + + +export default function globalizeLocalizers(globalize) { + let localizers = globalize.load + ? newGlobalize(globalize) + : oldGlobalize(globalize) + + configure.setLocalizers(localizers) + return localizers; +} + +function newGlobalize(globalize){ + let locale = culture => culture ? globalize(culture) : globalize; + + var date = { + + formats: { + date: { date: 'short' }, + time: { time: 'short' }, + default: { datetime: 'medium' }, + header: 'MMMM yyyy', + footer: { date: 'full' }, + weekday: 'eeeeee', + dayOfMonth: 'dd', + month: 'MMM', + year: 'yyyy', + + decade: (dt, culture, l) => + `${l.format(dt, l.formats.year, culture)} - ${l.format(endOfDecade(dt), l.formats.year, culture)}`, + + century: (dt, culture, l) => + `${l.format(dt, l.formats.year, culture)} - ${l.format(endOfCentury(dt), l.formats.year, culture)}` + }, + + propType: PropTypes.oneOfType([ + PropTypes.string, PropTypes.object, PropTypes.func]), + + firstOfWeek(culture){ + let date = new Date(); + //cldr-data doesn't seem to be zero based + let localeDay = Math.max(parseInt(locale(culture).formatDate(date, { raw: 'e' }), 10) - 1, 0) + + return Math.abs(date.getDay() - localeDay) + }, + + parse(value, format, culture){ + format = typeof format === 'string' ? { raw: format } : format; + return locale(culture).parseDate(value, format) + }, + + format(value, format, culture){ + format = typeof format === 'string' ? { raw: format } : format; + return locale(culture).formatDate(value, format) + } + } + + let number = { + formats: { + default: { maximumFractionDigits: 0 } + }, + + propType: PropTypes.oneOfType([PropTypes.object, PropTypes.func]), + + parse(value, format, culture){ + return locale(culture).parseNumber(value, format) + }, + + format(value, format, culture){ + if (value == null) + return value + + if (format && format.currency) + return locale(culture).formatCurrency(value, format.currency, format) + + return locale(culture).formatNumber(value, format) + }, + + precision(format){ + return !format || format.maximumFractionDigits == null + ? null : format.maximumFractionDigits + } + } + return { date, number } +} + +function oldGlobalize(globalize){ + const shortNames = Object.create(null); + + function getCulture(culture){ + return culture + ? globalize.findClosestCulture(culture) + : globalize.culture() + } + + function firstOfWeek(culture) { + culture = getCulture(culture) + return (culture && culture.calendar.firstDay) || 0 + } + + function shortDay(dayOfTheWeek){ + var culture = getCulture(arguments[1]) + , name = culture.name + , days = () => culture.calendar.days.namesShort.slice(); + + var names = shortNames[name] || (shortNames[name] = days()); + + return names[dayOfTheWeek.getDay()]; + } + + var date = { + + formats: { + date: 'd', + time: 't', + default: 'f', + header: 'MMMM yyyy', + footer: 'D', + weekday: shortDay, + dayOfMonth: 'dd', + month: 'MMM', + year: 'yyyy', + + decade: (dt, culture, l) => + `${l.format(dt, l.formats.year, culture)} - ${l.format(endOfDecade(dt), l.formats.year, culture)}`, + + century: (dt, culture, l) => + `${l.format(dt, l.formats.year, culture)} - ${l.format(endOfCentury(dt), l.formats.year, culture)}` + }, + + firstOfWeek, + + parse(value, format, culture){ + return globalize.parseDate(value, format, culture) + }, + + format(value, format, culture){ + return globalize.format(value, format, culture) + } + } + + var number = { + + formats: { + default: 'D' + }, + + parse(value, culture){ + return globalize.parseFloat(value, 10, culture) + }, + + format(value, format, culture){ + return globalize.format(value, format, culture) + }, + + precision(format, _culture){ + var culture = getCulture(_culture) + , numFormat = culture.numberFormat + + if (typeof format === 'string') { + if (format.length > 1) + return parseFloat(format.substr(1)) + + if (format.indexOf('p') !== -1) numFormat = numFormat.percent + if (format.indexOf('c') !== -1) numFormat = numFormat.curency + + return numFormat.decimals || null + } + + return null + } + } + + return { date, number } +} diff --git a/src/localizers/moment.js b/src/localizers/moment.js new file mode 100644 index 000000000..414a31ea3 --- /dev/null +++ b/src/localizers/moment.js @@ -0,0 +1,71 @@ +import configure from '../configure' + +function endOfDecade(date) { + date = new Date(date) + date.setFullYear(date.getFullYear() + 10) + date.setMilliseconds(date.getMilliseconds() - 1) + return date +} + +function endOfCentury(date) { + date = new Date(date) + date.setFullYear(date.getFullYear() + 100) + date.setMilliseconds(date.getMilliseconds() - 1) + return date +} + +export default function(moment){ + if (typeof moment !== 'function') + throw new TypeError('You must provide a valid moment object') + + var localField = typeof moment().locale === 'function' ? 'locale' : 'lang' + , hasLocaleData = !!moment.localeData; + + if (!hasLocaleData) + throw new TypeError( + 'The Moment localizer depends on the `localeData` api, please provide a moment object v2.2.0 or higher') + + function getMoment(culture, value, format){ + return culture ? moment(value, format)[localField](culture) : moment(value, format) + } + + let localizer = { + formats: { + date: 'L', + time: 'LT', + default: 'lll', + header: 'MMMM YYYY', + footer: 'LL', + weekday: 'dd', + dayOfMonth: 'DD', + month: 'MMM', + year: 'YYYY', + + decade(date, culture, localizer) { + return localizer.format(date, 'YYYY', culture) + + ' - ' + localizer.format(endOfDecade(date), 'YYYY', culture) + }, + + century(date, culture, localizer) { + return localizer.format(date, 'YYYY', culture) + + ' - ' + localizer.format(endOfCentury(date), 'YYYY', culture) + } + }, + + firstOfWeek(culture) { + return moment.localeData(culture).firstDayOfWeek() + }, + + parse(value, format, culture) { + return getMoment(culture, value, format).toDate() + }, + + format(value, format, culture) { + return getMoment(culture, value, format).format(format) + } + } + + configure.setDateLocalizer(localizer) + + return localizer; +} diff --git a/src/localizers/simple-number.js b/src/localizers/simple-number.js new file mode 100644 index 000000000..5a5e5a274 --- /dev/null +++ b/src/localizers/simple-number.js @@ -0,0 +1,53 @@ +import configure from '../configure' +import formatNumber from 'format-number-with-string'; +import deconstruct from 'deconstruct-number-format'; + +export default function simpleNumber(){ + + let localizer = { + formats: { + default: '-#,##0.' + }, + + parse(value, format){ + if (format) { + let data = deconstruct(format) + + if (data.negativeLeftPos !== -1) + value = value.substr(data.negativeLeftPos + 1) + + if (data.negativeRightPos !== -1) + value = value.substring(0, data.negativeRightPos) + + value = value + .replace(data.prefix, '') + .replace(data.suffix, '') + + let halves = value.split(data.decimalChar) + + if (data.integerSeperator) + halves[0] = halves[0].replace(new RegExp('\\' + data.integerSeperator, 'g')) + + if (data.decimalsSeparator) + halves[1] = halves[1].replace(new RegExp('\\' + data.decimalsSeparator, 'g')) + + value = halves.join(data.decimalChar) + } + let number = parseFloat(value) + + return number + }, + + format(value, format){ + return formatNumber(value, format) + }, + + precision(format){ + let data = deconstruct(format) + return data.maxRight !== -1 ? data.maxRight : null + } + } + + configure.setNumberLocalizer(localizer) + return localizer +} diff --git a/src/util/configuration.js b/src/util/configuration.js index a2399a293..2ca4d7ca5 100644 --- a/src/util/configuration.js +++ b/src/util/configuration.js @@ -1,24 +1,3 @@ import animate from './dom/animate'; -function error(){ - throw new Error( - '[React Widgets] You are attempting to use a widget that requires localization (DateTimePicker, NumberPicker)' + - 'but there is no localizer set. In order to use these widgets please install a localizer') -} - -let dummy = { - formats: error, - parse: error, - format:error, - firstOfWeek: error -} - -export default { - - animate, - - locale: { - date: dummy, - number: dummy - } -} +export default { animate } diff --git a/src/util/dates.js b/src/util/dates.js index 34dc36224..481ae2073 100644 --- a/src/util/dates.js +++ b/src/util/dates.js @@ -1,38 +1,36 @@ -'use strict'; -var dateMath = require('date-arithmetic') - , { - directions - , calendarViewUnits } = require('./constants') - , locale = require('./configuration').locale +import dateMath from 'date-arithmetic'; +import constants from './constants'; +import { date as dateLocalizer } from './localizers'; + +let { directions, calendarViewUnits } = constants var dates = Object.assign(dateMath, { parse(date, format, culture) { - return locale.date.parse(date, format, culture) + return dateLocalizer.parse(date, format, culture) }, format(date, format, culture){ - return locale.date.format(date, format, culture) + return dateLocalizer.format(date, format, culture) }, monthsInYear(year){ var months = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] , date = new Date(year, 0, 1) - return months.map( i => dates.month(date, i)) + return months.map(i => dates.month(date, i)) }, firstVisibleDay(date, culture){ var firstOfMonth = dates.startOf(date, 'month') - - return dates.startOf(firstOfMonth, 'week', locale.date.startOfWeek(culture)); + return dates.startOf(firstOfMonth, 'week', dateLocalizer.startOfWeek(culture)); }, lastVisibleDay(date, culture){ var endOfMonth = dates.endOf(date, 'month') - return dates.endOf(endOfMonth, 'week', locale.date.startOfWeek(culture)); + return dates.endOf(endOfMonth, 'week', dateLocalizer.startOfWeek(culture)); }, visibleDays(date, culture){ diff --git a/src/util/localizers.js b/src/util/localizers.js index fad1cf5b2..a3049b039 100644 --- a/src/util/localizers.js +++ b/src/util/localizers.js @@ -2,13 +2,13 @@ import invariant from 'invariant'; import { has } from './_'; import React from 'react'; -const REQUIRED_NUMBER_FORMATS = [ 'default' ] - const localePropType = React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.func ]) +const REQUIRED_NUMBER_FORMATS = [ 'default' ]; + const REQUIRED_DATE_FORMATS = [ 'default', 'date', @@ -19,7 +19,8 @@ const REQUIRED_DATE_FORMATS = [ 'month', 'year', 'decade', - 'century'] + 'century' + ]; function _format(localizer, formatter, value, format, culture) { let result = typeof format === 'function' @@ -38,63 +39,111 @@ function checkFormats(requiredFormats, formats){ f => invariant(has(formats, f), 'localizer missing required format: `%s`', f )) } -class NumberLocalizer { - constructor({ format, parse, precision, formats, propType }){ - invariant(typeof format === 'function' - , 'number localizer `format(..)` must be a function') - invariant(typeof parse === 'function' - , 'number localizer `parse(..)` must be a function') +let _numberLocalizer = createWrapper('NumberPicker') - checkFormats(REQUIRED_NUMBER_FORMATS, formats) +export function setNumber({ format, parse, precision = () => null, formats, propType }) { + invariant(typeof format === 'function' + , 'number localizer `format(..)` must be a function') + invariant(typeof parse === 'function' + , 'number localizer `parse(..)` must be a function') - this.propType = propType || localePropType - this.formats = formats - this.precision = precision || (() => null) + checkFormats(REQUIRED_NUMBER_FORMATS, formats) - this.format = (value, str, culture) => _format(this, format, value, str, culture) + _numberLocalizer = { + formats, + precision, + propType: propType || localePropType, - this.parse = (value, culture) => { - let result = parse.call(this, value, culture) + format(value, str, culture){ + return _format(this, format, value, str, culture) + }, + parse(value, culture) { + let result = parse.call(this, value, culture) invariant(result == null || typeof result === 'number' , 'number localizer `parse(..)` must return a number, null, or undefined') - return result } } } -class DateLocalizer { - - constructor(spec) { - invariant(typeof spec.format === 'function' - , 'date localizer `format(..)` must be a function') - invariant(typeof spec.parse === 'function' - , 'date localizer `parse(..)` must be a function') - invariant(typeof spec.firstOfWeek === 'function' - , 'date localizer `firstOfWeek(..)` must be a function') - checkFormats(REQUIRED_DATE_FORMATS, spec.formats) - - this.propType = spec.propType || localePropType - this.formats = spec.formats - this.startOfWeek = spec.firstOfWeek - - this.format = (value, format, culture) => _format(this, spec.format, value, format, culture) - - this.parse = (value, format, culture) => { - let result = spec.parse.call(this, value, format, culture) - +let _dateLocalizer = createWrapper('DateTimePicker') + +export function setDate(spec) { + invariant(typeof spec.format === 'function' + , 'date localizer `format(..)` must be a function') + invariant(typeof spec.parse === 'function' + , 'date localizer `parse(..)` must be a function') + invariant(typeof spec.firstOfWeek === 'function' + , 'date localizer `firstOfWeek(..)` must be a function') + checkFormats(REQUIRED_DATE_FORMATS, spec.formats) + + _dateLocalizer = { + formats: spec.formats, + propType: spec.propType || localePropType, + startOfWeek: spec.firstOfWeek, + format(value, str, culture){ + return _format(this, spec.format, value, str, culture) + }, + parse(value, culture) { + let result = spec.parse.call(this, value, culture) invariant(result == null || (result instanceof Date && !isNaN(result.getTime())) , 'date localizer `parse(..)` must return a valid Date, null, or undefined') - return result } } } +export let number = { + propType(...args){ return _numberLocalizer.propType(...args) }, + getFormat(key, format){ + return format || _numberLocalizer.formats[key] + }, + parse(...args){ + return _numberLocalizer.parse(...args) + }, + format(...args){ + return _numberLocalizer.format(...args) + }, + precision(...args){ + return _numberLocalizer.precision(...args) + } +} + +export let date = { + propType(...args){ return _dateLocalizer.propType(...args) }, + getFormat(key, format){ + return format || _dateLocalizer.formats[key] + }, + parse(...args){ + return _dateLocalizer.parse(...args) + }, + format(...args){ + return _dateLocalizer.format(...args) + }, + startOfWeek(...args){ + return _dateLocalizer.startOfWeek(...args) + } +} + +export default { number, date } + + +function createWrapper(){ + let dummy = {}; -module.exports = { - NumberLocalizer, DateLocalizer + ['formats', 'parse', 'format', 'firstOfWeek', 'precision'] + .forEach(name => Object.defineProperty(dummy, name, { + enumerable: true, + get(){ + throw new Error( + '[React Widgets] You are attempting to use a widget that requires localization ' + + '(Calendar, DateTimePicker, NumberPicker). ' + + 'However there is no localizer set. Please configure a localizer. \n\n' + + 'see http://jquense.github.io/react-widgets/docs/#/i18n for more info.') + } + })) + return dummy } diff --git a/src/util/propTypes.js b/src/util/propTypes.js index 71b81fe12..b5b39ff11 100644 --- a/src/util/propTypes.js +++ b/src/util/propTypes.js @@ -1,8 +1,7 @@ import React, { PropTypes } from 'react'; -import config from'./configuration'; +import localizers from './localizers'; import filters from'./filter'; -let localizers = config.locale var filterTypes = Object.keys(filters).filter( i => i !== 'filter') function getInteractionPropType(key){ diff --git a/test/index.js b/test/index.js index c5c5f41e6..c16528b76 100644 --- a/test/index.js +++ b/test/index.js @@ -2,10 +2,8 @@ var React = require('react'); var widgetHelpers = require('../src/util/widgetHelpers') var globalize = require('globalize') -var configure = require('../src/configure') -var localizers = require('../src/globalize-localizers') -configure.setLocalizers(localizers(globalize)) +require('../src/localizers/globalize')(globalize) //disable this particular optimization sinon.stub(widgetHelpers, 'isFirstFocusedRender', ()=> true) diff --git a/test/server.js b/test/server.js index ace4920aa..ada4a50a7 100644 --- a/test/server.js +++ b/test/server.js @@ -8,10 +8,8 @@ var assert = require('assert') var React = require('react'); var renderToString = require('react-dom/server').renderToString var globalize = require('globalize') -var configure = require('../src/configure') -var localizers = require('../src/globalize-localizers') -configure.setLocalizers(localizers(globalize)) +require('../src/localizers/globalize')(globalize) var components = [ 'Calendar',
npm install react-widgets --save -``` - -##### Bower -```sh +
bower install react-widgets --save -``` +