react-time-picker
Advanced tools
Comparing version 0.1.1 to 0.1.2
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
module.exports = factory(require("React")); | ||
else if(typeof define === 'function' && define.amd) | ||
define(factory); | ||
define(["React"], factory); | ||
else if(typeof exports === 'object') | ||
exports["ReactTimePicker"] = factory(); | ||
exports["ReactTimePicker"] = factory(require("React")); | ||
else | ||
root["ReactTimePicker"] = factory(); | ||
})(this, function() { | ||
root["ReactTimePicker"] = factory(root["React"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
@@ -57,6 +57,1742 @@ /******/ // The module cache | ||
/** @jsx React.DOM */ | ||
/** @jsx React.DOM */'use strict'; | ||
var React = __webpack_require__(1) | ||
var assign = __webpack_require__(6) | ||
var normalize = __webpack_require__(9) | ||
var parseTime = __webpack_require__(2) | ||
var updateTime = __webpack_require__(3) | ||
var toUpperFirst = __webpack_require__(4) | ||
var timeToString = __webpack_require__(5) | ||
var hasTouch = __webpack_require__(8) | ||
var EVENT_NAMES = __webpack_require__(7) | ||
var WHITESPACE = '\u00a0' | ||
function twoDigits(value){ | ||
return value < 10? | ||
'0' + value: | ||
value | ||
} | ||
function emptyFn(){} | ||
module.exports = React.createClass({ | ||
displayName: 'ReactTimePicker', | ||
componentWillUnmount: function(){ | ||
this.stopInterval() | ||
}, | ||
getInitialState: function(){ | ||
return { | ||
defaultValue: this.props.defaultValue, | ||
focused: { | ||
hour : null, | ||
minute : null, | ||
second : null, | ||
meridian: null | ||
} | ||
} | ||
}, | ||
getDefaultProps: function() { | ||
return { | ||
stopChangePropagation: true, | ||
//makes 15:78 be converted to 15:00, and not to 16:18 | ||
strict: true, | ||
overflowHourToMeridian: true, | ||
step: 1, | ||
hourStep: null, | ||
minuteStep: 10, | ||
secondStep: 30, | ||
stepDelay:60, | ||
showArrows: true, | ||
// showMinute: true, | ||
// showSecond: true, | ||
defaultStyle: { | ||
border: '1px solid gray', | ||
padding: 20, | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
boxSizing: 'border-box', | ||
flexFlow: 'row', | ||
width: 200 | ||
}, | ||
defaultArrowStyle: { | ||
cursor: 'pointer', | ||
userSelect: 'none' | ||
}, | ||
defaultBoxStyle: { | ||
boxSizing: 'border-box', | ||
display: 'flex', | ||
flexFlow: 'column', | ||
alignItems: 'center' | ||
}, | ||
defaultInputStyle: { | ||
boxSizing: 'border-box', | ||
width: '100%', | ||
textAlign: 'center' | ||
}, | ||
defaultSeparatorStyle: { | ||
flex: 'none' | ||
}, | ||
defaultMeridianInputStyle: { | ||
cursor: 'pointer' | ||
}, | ||
defaultMeridianInputProps: { | ||
readOnly: true | ||
}, | ||
format: twoDigits, | ||
formatHour: null, | ||
formatMinute: null, | ||
formatSecond: null, | ||
formatMeridian: null, | ||
defaultArrowFactory: React.DOM.span, | ||
arrowFactory: null, | ||
arrowUpFactory: null, | ||
arrowDownFactory: null, | ||
defaultInputFactory: React.DOM.input, | ||
inputFactory: null, | ||
hourInputFactory: null, | ||
minuteInputFactory: null, | ||
secondInputFactory: null, | ||
meridianInputFactory: null, | ||
timeToString: timeToString | ||
} | ||
}, | ||
render: function(){ | ||
var props = this.prepareProps(this.props, this.state) | ||
var hour = this.renderHour(props) | ||
var minute = this.renderMinute(props) | ||
var second = this.renderSecond(props) | ||
var meridian = this.renderMeridian(props) | ||
var separator = props.separator || React.createElement("span", {style: props.separatorStyle}, WHITESPACE + ':' + WHITESPACE) | ||
var hourSeparator = props.hourSeparator || separator | ||
var minuteSeparator = minute && (second || meridian)? props.minuteSeparator || separator: null | ||
var secondSeparator = (second && meridian)? props.secondSeparator || separator: null | ||
return React.createElement("div", React.__spread({}, props), | ||
hour, | ||
hourSeparator, | ||
minute, | ||
minuteSeparator, | ||
second, | ||
secondSeparator, | ||
meridian | ||
) | ||
}, | ||
onArrowMouseDown: function(props, dir, name, event){ | ||
if (name == 'meridian'){ | ||
this.onArrowMeridianAction(props, dir, name) | ||
return | ||
} | ||
var target = hasTouch? | ||
event.target: | ||
window | ||
var eventName = hasTouch? 'touchend': 'click' | ||
target.addEventListener(eventName, this.onWindowClick) | ||
this.startInterval(props, dir, name) | ||
}, | ||
onWindowClick: function(){ | ||
this.stopInterval() | ||
}, | ||
stopInterval: function(){ | ||
clearInterval(this.intervalId) | ||
}, | ||
startInterval: function(props, dir, name){ | ||
this.intervalId = setInterval(function(){ | ||
this.onArrowAction(props, dir, name) | ||
}.bind(this), props.stepDelay) | ||
}, | ||
onMeridianInputMouseDown: function(props, event){ | ||
event.preventDefault() | ||
this.onArrowMeridianAction(props, 1, 'meridian') | ||
}, | ||
onArrowMeridianAction: function(props, dir, name){ | ||
this.updateValue(name, this.time.meridian == 'AM'? 'PM': 'AM') | ||
}, | ||
onArrowAction: function(props, dir, name) { | ||
var dirName = dir == 1? 'Up': 'Down' | ||
var methodName = 'onArrow' + dirName + toUpperFirst(name) + 'Action' | ||
if (typeof this[methodName] == 'function'){ | ||
this[methodName](props) | ||
} | ||
methodName = 'onArrow' + toUpperFirst(name) + 'Action' | ||
if (typeof this[methodName] == 'function'){ | ||
this[methodName](props, dir) | ||
} | ||
this.incValue(props, name, dir) | ||
}, | ||
incValue: function(props, name, dir){ | ||
dir = dir || 0 | ||
var step = props[name + 'Step'] || props.step | ||
var amount = dir * step | ||
var time = this.time | ||
var oldValue = time[name] | ||
var newValue = oldValue + amount | ||
this.setValue(time) | ||
this.updateValue(name, newValue) | ||
}, | ||
updateValue: function(name, newValue, config){ | ||
this.setValue(this.updateTime(name, newValue, config)) | ||
}, | ||
updateTime: function(name, newValue, config){ | ||
config = config || {} | ||
config.overflowHourToMeridian = this.props.overflowHourToMeridian | ||
var time = this.time | ||
time = updateTime(time, name, newValue, config) | ||
return this.time = time | ||
}, | ||
setValue: function(time){ | ||
if (this.props.value == null){ | ||
this.setState({ | ||
defaultValue: time | ||
}) | ||
} | ||
;(this.props.onChange || emptyFn)(this.props.timeToString(time), assign({}, time)) | ||
}, | ||
format: function(props, name, value){ | ||
var formatFn | ||
if (arguments.length < 3){ | ||
value = props.time[name] | ||
} | ||
if (name != 'meridian'){ | ||
formatFn = props['format' + toUpperFirst(name)] || props.format | ||
} else { | ||
formatFn = props.formatMeridian | ||
} | ||
if (typeof formatFn == 'function'){ | ||
value = formatFn(value) | ||
} | ||
return value | ||
}, | ||
renderBox: function(props, name){ | ||
var state = this.state | ||
var style = props[name + 'Style'] | ||
var inputStyle = props[name + 'InputStyle'] | ||
var upperName = toUpperFirst(name) | ||
var value | ||
if (!state.focused[name]){ | ||
value = this.format(props, name) | ||
} else { | ||
value = state.focused[name].value | ||
} | ||
var arrowUp | ||
var arrowDown | ||
if (props.showArrows){ | ||
var arrowUpProps = { | ||
style : props.arrowUpStyle, | ||
children : '▴' | ||
} | ||
arrowUpProps[EVENT_NAMES.onMouseDown] = this.onArrowMouseDown.bind(this, props, 1, name) | ||
var arrowDownProps = { | ||
style : props.arrowDownStyle, | ||
children : '▾' | ||
} | ||
arrowDownProps[EVENT_NAMES.onMouseDown] = this.onArrowMouseDown.bind(this, props, -1, name) | ||
var defaultArrowFactory = props.defaultArrowFactory | ||
var arrowUpFactory = props.arrowUpFactory || props.arrowFactory || defaultArrowFactory | ||
var arrowDownFactory = props.arrowDownFactory || props.arrowFactory || defaultArrowFactory | ||
arrowUp = arrowUpFactory(arrowUpProps) | ||
if (arrowUp === undefined){ | ||
arrowUp = defaultArrowFactory(arrowUpProps) | ||
} | ||
arrowDown = arrowDownFactory(arrowDownProps) | ||
if (arrowDown === undefined){ | ||
arrowDown = defaultArrowFactory(arrowDownProps) | ||
} | ||
} | ||
var defaultInputFactory = props.defaultInputFactory | ||
var inputFactory = props[name + 'InputFactory'] || props.inputFactory || defaultInputFactory | ||
var defaultInputProps = props['default' + upperName + 'InputProps'] | ||
var inputProps = assign({}, defaultInputProps, { | ||
style : inputStyle, | ||
value : value, | ||
onFocus : this.handleInputFocus.bind(this, props, name), | ||
onBlur : this.handleInputBlur.bind(this, props, name), | ||
onChange: this.handleInputChange.bind(this, props, name) | ||
}) | ||
if (name == 'meridian'){ | ||
inputProps.onMouseDown = this.onMeridianInputMouseDown.bind(this, props) | ||
} | ||
var input = inputFactory(inputProps) | ||
if (input === undefined){ | ||
input = defaultInputFactory(inputProps) | ||
} | ||
return React.createElement("div", {style: style}, | ||
arrowUp, | ||
input, | ||
arrowDown | ||
) | ||
}, | ||
handleInputFocus: function(props, name, event){ | ||
var focused = this.state.focused | ||
focused[name] = { | ||
value: this.format(props, name) | ||
} | ||
this.setState({}) | ||
}, | ||
handleInputBlur: function(props, name, event){ | ||
this.state.focused[name] = null | ||
this.setState({}) | ||
var time | ||
var value = event.target.value * 1 | ||
this.updateValue(name, value, { | ||
clamp: props.clamp | ||
}) | ||
}, | ||
handleInputChange: function(props, name, event){ | ||
if (this.state.focused[name]){ | ||
this.state.focused[name].value = event.target.value | ||
} | ||
this.setState({}) | ||
props.stopChangePropagation && event.stopPropagation() | ||
}, | ||
getTime: function(){ | ||
return parseTime(this.getValue(), { | ||
strict: this.props.strict | ||
}) | ||
}, | ||
prepareTime: function(props, state) { | ||
var timeValue = this.getTime() | ||
props.showSecond = timeValue.second !== undefined | ||
props.showMinute = timeValue.minute !== undefined | ||
props.withMeridian = timeValue.meridian != null | ||
return timeValue | ||
}, | ||
getValue: function() { | ||
var value = this.props.value == null? | ||
this.state.defaultValue: | ||
this.props.value | ||
return value | ||
}, | ||
renderHour: function(props) { | ||
return this.renderBox(props, 'hour') | ||
}, | ||
renderMinute: function(props) { | ||
if (props.showMinute){ | ||
return this.renderBox(props, 'minute') | ||
} | ||
}, | ||
renderSecond: function(props) { | ||
if (props.showSecond){ | ||
return this.renderBox(props, 'second') | ||
} | ||
}, | ||
renderMeridian: function(props) { | ||
if (props.withMeridian){ | ||
return this.renderBox(props, 'meridian') | ||
} | ||
}, | ||
prepareProps: function(thisProps, state) { | ||
var props = assign({}, thisProps) | ||
this.time = props.time = this.prepareTime(props, state) | ||
this.prepareStyles(props, state) | ||
return props | ||
}, | ||
prepareStyles: function(props, state) { | ||
props.style = this.prepareStyle(props, state) | ||
props.separatorStyle = this.prepareSeparatorStyle(props, state) | ||
this.prepareArrowStyles(props, state) | ||
this.prepareHourStyles(props, state) | ||
this.prepareMinuteStyles(props, state) | ||
this.prepareSecondStyles(props, state) | ||
this.prepareMeridianStyles(props, state) | ||
}, | ||
prepareStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultStyle, props.style)) | ||
}, | ||
prepareSeparatorStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultSeparatorStyle, props.separatorStyle)) | ||
}, | ||
prepareArrowStyles: function(props, state) { | ||
props.arrowUpStyle = normalize(assign({}, props.defaultArrowStyle, props.defaultArrowUpStyle, props.arrowUpStyle)) | ||
props.arrowDownStyle = normalize(assign({}, props.defaultArrowStyle, props.defaultArrowDownStyle, props.arrowDownStyle)) | ||
}, | ||
prepareHourStyles: function(props, state) { | ||
props.hourStyle = this.prepareHourStyle(props, state) | ||
props.hourInputStyle = this.prepareHourInputStyle(props, state) | ||
}, | ||
prepareHourStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultBoxStyle, props.defaultHourStyle, props.hourStyle)) | ||
}, | ||
prepareHourInputStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultInputStyle, props.defaultHourInputStyle, props.hourInputStyle)) | ||
}, | ||
prepareMinuteStyles: function(props, state) { | ||
props.minuteStyle = this.prepareMinuteStyle(props, state) | ||
props.minuteInputStyle = this.prepareMinuteInputStyle(props, state) | ||
}, | ||
prepareMinuteStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultBoxStyle, props.defaultMinuteStyle, props.minuteStyle)) | ||
}, | ||
prepareMinuteInputStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultInputStyle, props.defaultMinuteInputStyle, props.minuteInputStyle)) | ||
}, | ||
prepareSecondStyles: function(props, state) { | ||
if (props.showSecond){ | ||
props.secondStyle = this.prepareSecondStyle(props, state) | ||
props.secondInputStyle = this.prepareSecondInputStyle(props, state) | ||
} | ||
}, | ||
prepareSecondStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultBoxStyle, props.defaultSecondStyle, props.secondStyle)) | ||
}, | ||
prepareSecondInputStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultInputStyle, props.defaultSecondInputStyle, props.secondInputStyle)) | ||
}, | ||
prepareMeridianStyles: function(props, state){ | ||
if (props.withMeridian){ | ||
props.meridianStyle = this.prepareMeridianStyle(props, state) | ||
props.meridianInputStyle = this.prepareMeridianInputStyle(props, state) | ||
} | ||
}, | ||
prepareMeridianStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultBoxStyle, props.defaultMeridianStyle, props.meridianStyle)) | ||
}, | ||
prepareMeridianInputStyle: function(props, state) { | ||
return normalize(assign({}, props.defaultInputStyle, props.defaultMeridianInputStyle, props.meridianInputStyle)) | ||
} | ||
}) | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_1__; | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var parseTime = __webpack_require__(14) | ||
var adjustOverflow = parseTime.adjustOverflow | ||
var defaults = {} | ||
function onInvalid(timeValue, config){ | ||
timeValue.invalid.forEach(function(info){ | ||
var name = info.name | ||
var value = info.value * 1 | ||
if (!isNaN(value)){ | ||
timeValue[name] = value | ||
} | ||
}) | ||
return adjustOverflow(timeValue, config) | ||
} | ||
module.exports = function(value, config){ | ||
config = config || defaults | ||
value = value || '' | ||
if (typeof value == 'string'){ | ||
value = parseTime(value) | ||
} | ||
var definedParts = {} | ||
if (value){ | ||
config.withMeridian = value.meridian != null | ||
if (value.invalid){ | ||
value.invalid.forEach(function(info){ | ||
definedParts[info.name] = true | ||
}) | ||
} | ||
if (!config.strict && value.invalid){ | ||
value = onInvalid(value, config) | ||
} | ||
if (definedParts.hour){ | ||
value.hour = value.hour || 0 | ||
} | ||
if (definedParts.minute){ | ||
value.minute = value.minute || 0 | ||
} | ||
if (definedParts.second){ | ||
value.second = value.second || 0 | ||
} | ||
// value.hour = value.hour || 0 | ||
// value.minute = value.minute || 0 | ||
// value.second = value.second || 0 | ||
if (config.strict && value.meridian && value.hour === 12){ | ||
if (value.minute !== undefined){ | ||
value.minute = 0 | ||
} | ||
if (value.second !== undefined){ | ||
value.second = 0 | ||
} | ||
} | ||
} | ||
var result = { | ||
hour : value.hour | ||
} | ||
if (value.minute !== undefined){ | ||
result.minute = value.minute | ||
} | ||
if (value.second !== undefined){ | ||
result.second = value.second | ||
} | ||
if (config.withMeridian){ | ||
result.meridian = value.meridian | ||
} | ||
return result | ||
} | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var update = __webpack_require__(14).updateTime | ||
module.exports = function(time, name, value, config){ | ||
time = update(time, name, value, config) | ||
return time | ||
} | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = function(str){ | ||
return str? | ||
str.charAt(0).toUpperCase() + str.slice(1): | ||
'' | ||
} | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
function twoDigits(value){ | ||
return value < 10? | ||
'0' + value: | ||
value | ||
} | ||
module.exports = function(time){ | ||
var str = twoDigits(time.hour) | ||
if (time.minute != null){ | ||
str += ':' + twoDigits(time.minute) | ||
} | ||
if (time.second != null){ | ||
str += ':' + twoDigits(time.second) | ||
} | ||
if (time.meridian){ | ||
str += ' ' + time.meridian | ||
} | ||
return str | ||
} | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
function ToObject(val) { | ||
if (val == null) { | ||
throw new TypeError('Object.assign cannot be called with null or undefined'); | ||
} | ||
return Object(val); | ||
} | ||
module.exports = Object.assign || function (target, source) { | ||
var from; | ||
var keys; | ||
var to = ToObject(target); | ||
for (var s = 1; s < arguments.length; s++) { | ||
from = arguments[s]; | ||
keys = Object.keys(Object(from)); | ||
for (var i = 0; i < keys.length; i++) { | ||
to[keys[i]] = from[keys[i]]; | ||
} | ||
} | ||
return to; | ||
}; | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = __webpack_require__(8)? | ||
{ | ||
onMouseDown: 'onTouchStart', | ||
onMouseUp : 'onTouchEnd', | ||
onMouseMove: 'onTouchMove' | ||
}: | ||
{ | ||
onMouseDown: 'onMouseDown', | ||
onMouseUp : 'onMouseUp', | ||
onMouseMove: 'onMouseMove' | ||
} | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {module.exports = 'ontouchstart' in global || (global.DocumentTouch && document instanceof DocumentTouch) | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ }, | ||
/* 9 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var hasOwn = __webpack_require__(10) | ||
var getPrefixed = __webpack_require__(11) | ||
var map = __webpack_require__(12) | ||
var plugable = __webpack_require__(13) | ||
function plugins(key, value){ | ||
var result = { | ||
key : key, | ||
value: value | ||
} | ||
;(RESULT.plugins || []).forEach(function(fn){ | ||
var tmp = map(function(res){ | ||
return fn(key, value, res) | ||
}, result) | ||
if (tmp){ | ||
result = tmp | ||
} | ||
}) | ||
return result | ||
} | ||
function normalize(key, value){ | ||
var result = plugins(key, value) | ||
return map(function(result){ | ||
return { | ||
key : getPrefixed(result.key, result.value), | ||
value: result.value | ||
} | ||
}, result) | ||
return result | ||
} | ||
var RESULT = function(style){ | ||
var k | ||
var item | ||
var result = {} | ||
for (k in style) if (hasOwn(style, k)){ | ||
item = normalize(k, style[k]) | ||
if (!item){ | ||
continue | ||
} | ||
map(function(item){ | ||
result[item.key] = item.value | ||
}, item) | ||
} | ||
return result | ||
} | ||
module.exports = plugable(RESULT) | ||
/***/ }, | ||
/* 10 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = function(obj, prop){ | ||
return Object.prototype.hasOwnProperty.call(obj, prop) | ||
} | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var getStylePrefixed = __webpack_require__(16) | ||
var properties = __webpack_require__(17) | ||
module.exports = function(key, value){ | ||
if (!properties[key]){ | ||
return key | ||
} | ||
return getStylePrefixed(key, value) | ||
} | ||
/***/ }, | ||
/* 12 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = function(fn, item){ | ||
if (!item){ | ||
return | ||
} | ||
if (Array.isArray(item)){ | ||
return item.map(fn).filter(function(x){ | ||
return !!x | ||
}) | ||
} else { | ||
return fn(item) | ||
} | ||
} | ||
/***/ }, | ||
/* 13 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var getCssPrefixedValue = __webpack_require__(15) | ||
module.exports = function(target){ | ||
target.plugins = target.plugins || [ | ||
(function(){ | ||
var values = { | ||
'flex':1, | ||
'inline-flex':1 | ||
} | ||
return function(key, value){ | ||
if (key === 'display' && value in values){ | ||
return { | ||
key : key, | ||
value: getCssPrefixedValue(key, value) | ||
} | ||
} | ||
} | ||
})() | ||
] | ||
target.plugin = function(fn){ | ||
target.plugins = target.plugins || [] | ||
target.plugins.push(fn) | ||
} | ||
return target | ||
} | ||
/***/ }, | ||
/* 14 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var assign = __webpack_require__(30) | ||
var defaults = __webpack_require__(18) | ||
function trim(str){ | ||
return str.trim() | ||
} | ||
var validHour = __webpack_require__(19) | ||
var validMinute = __webpack_require__(20) | ||
var validSecond = __webpack_require__(21) | ||
var validMeridian = __webpack_require__(22) | ||
function getHour(value, config){ | ||
if (validHour(value, config)){ | ||
return value * 1 | ||
} | ||
} | ||
function getMinute(value){ | ||
if (validMinute(value)){ | ||
return value * 1 | ||
} | ||
} | ||
function getSecond(value){ | ||
if (validSecond(value)){ | ||
return value * 1 | ||
} | ||
} | ||
function getMeridian(value){ | ||
if (validMeridian(value)){ | ||
return value | ||
} | ||
} | ||
function hasMeridian(str){ | ||
var parts = str.split(' ') | ||
return parts.length > 1 | ||
} | ||
var GET_MAP = { | ||
hour : getHour, | ||
minute : getMinute, | ||
second : getSecond, | ||
meridian: getMeridian | ||
} | ||
function get(name){ | ||
return GET_MAP[name] | ||
} | ||
function parseLast(str, partName, config){ | ||
var withMeridian = config && config.meridian | ||
var parts = str.split(' ').map(trim) | ||
var getFn = get(partName) | ||
var result = { | ||
invalid: [] | ||
} | ||
var partValue | ||
var meridian | ||
if (isValidPart(partName, parts[0], config)){ | ||
if (getFn){ | ||
partValue = getFn(parts[0], config) | ||
} | ||
} else { | ||
result.invalid.push({ | ||
name: partName, | ||
value: parts[0] | ||
}) | ||
} | ||
if (withMeridian){ | ||
meridian = getMeridian(parts[1]) | ||
if (meridian === undefined){ | ||
result.invalid.push({ | ||
name: 'meridian', | ||
value: parts[1] | ||
}) | ||
} | ||
} | ||
if (meridian !== undefined){ | ||
result.meridian = meridian | ||
} | ||
if (partValue !== undefined){ | ||
result[partName] = partValue | ||
} | ||
return result | ||
} | ||
function PARSE(time, config){ | ||
config = assign({}, defaults, config) | ||
var parts = time.split(config.separator).map(trim) | ||
var withMeridian = hasMeridian(parts[parts.length - 1]) | ||
config.meridian = withMeridian | ||
var invalids = [] | ||
var result = {} | ||
var hour | ||
var minute | ||
if (parts.length > 3){ | ||
return | ||
} | ||
if (parts.length == 1){ | ||
//hh am | ||
assign(result, parseLast(parts[0], 'hour', config)) | ||
} | ||
if (parts.length == 2){ | ||
//hh:mm am | ||
hour = getHour(parts[0], config) | ||
if (hour === undefined){ | ||
invalids.push({ | ||
name: 'hour', | ||
value: parts[0] | ||
}) | ||
} | ||
assign(result, parseLast(parts[1], 'minute', config)) | ||
} | ||
if (parts.length == 3){ | ||
//hh:mm:ss am | ||
hour = getHour(parts[0], config) | ||
minute = getMinute(parts[1]) | ||
if (hour === undefined){ | ||
invalids.push({ | ||
name: 'hour', | ||
value: parts[0] | ||
}) | ||
} | ||
if (minute === undefined){ | ||
invalids.push({ | ||
name: 'minute', | ||
value: parts[1] | ||
}) | ||
} | ||
assign(result, parseLast(parts[2], 'second', config)) | ||
} | ||
if (result.invalid){ | ||
invalids.push.apply(invalids, result.invalid) | ||
result.invalid = invalids | ||
} | ||
if (hour !== undefined){ | ||
result.hour = hour | ||
} | ||
if (minute !== undefined){ | ||
result.minute = minute | ||
} | ||
if (!result.invalid.length){ | ||
delete result.invalid | ||
} | ||
return result | ||
} | ||
var isValidPart = __webpack_require__(23) | ||
var isValidTime = __webpack_require__(24) | ||
var updateTime = __webpack_require__(25) | ||
var adjustOverflow = __webpack_require__(26) | ||
PARSE.isValidPart = isValidPart | ||
PARSE.isValidTime = isValidTime | ||
PARSE.updateTime = updateTime | ||
PARSE.adjustOverflow = adjustOverflow | ||
module.exports = PARSE | ||
/***/ }, | ||
/* 15 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var getPrefix = __webpack_require__(27) | ||
var forcePrefixed = __webpack_require__(28) | ||
var el = __webpack_require__(29) | ||
var MEMORY = {} | ||
var STYLE = el.style | ||
module.exports = function(key, value){ | ||
var k = key + ': ' + value | ||
if (MEMORY[k]){ | ||
return MEMORY[k] | ||
} | ||
var prefix | ||
var prefixed | ||
var prefixedValue | ||
if (!(key in STYLE)){ | ||
prefix = getPrefix('appearance') | ||
if (prefix){ | ||
prefixed = forcePrefixed(key, value) | ||
prefixedValue = '-' + prefix.toLowerCase() + '-' + value | ||
if (prefixed in STYLE){ | ||
el.style[prefixed] = '' | ||
el.style[prefixed] = prefixedValue | ||
if (el.style[prefixed] !== ''){ | ||
value = prefixedValue | ||
} | ||
} | ||
} | ||
} | ||
MEMORY[k] = value | ||
return value | ||
} | ||
/***/ }, | ||
/* 16 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var toUpperFirst = __webpack_require__(31) | ||
var getPrefix = __webpack_require__(27) | ||
var el = __webpack_require__(29) | ||
var MEMORY = {} | ||
var STYLE = el.style | ||
module.exports = function(key, value){ | ||
var k = key// + ': ' + value | ||
if (MEMORY[k]){ | ||
return MEMORY[k] | ||
} | ||
var prefix | ||
var prefixed | ||
if (!(key in STYLE)){//we have to prefix | ||
prefix = getPrefix('appearance') | ||
if (prefix){ | ||
prefixed = prefix + toUpperFirst(key) | ||
if (prefixed in STYLE){ | ||
key = prefixed | ||
} | ||
} | ||
} | ||
MEMORY[k] = key | ||
return key | ||
} | ||
/***/ }, | ||
/* 17 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = { | ||
'alignItems': 1, | ||
'justifyContent': 1, | ||
'flex': 1, | ||
'flexFlow': 1, | ||
'userSelect': 1, | ||
'transform': 1, | ||
'transition': 1, | ||
'transformOrigin': 1, | ||
'transformStyle': 1, | ||
'transitionProperty': 1, | ||
'transitionDuration': 1, | ||
'transitionTimingFunction': 1, | ||
'transitionDelay': 1, | ||
'borderImage': 1, | ||
'borderImageSlice': 1, | ||
'boxShadow': 1, | ||
'backgroundClip': 1, | ||
'backfaceVisibility': 1, | ||
'perspective': 1, | ||
'perspectiveOrigin': 1, | ||
'animation': 1, | ||
'animationDuration': 1, | ||
'animationName': 1, | ||
'animationDelay': 1, | ||
'animationDirection': 1, | ||
'animationIterationCount': 1, | ||
'animationTimingFunction': 1, | ||
'animationPlayState': 1, | ||
'animationFillMode': 1, | ||
'appearance': 1 | ||
} | ||
/***/ }, | ||
/* 18 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = { | ||
separator: ':', | ||
twoDigits: true | ||
} | ||
/***/ }, | ||
/* 19 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var validNumber = __webpack_require__(32) | ||
module.exports = function validHour(value, config){ | ||
var meridian = config && config.meridian | ||
if (validNumber(value, config)){ | ||
value *= 1 | ||
if (meridian){ | ||
return 0 <= value && value <= 12 | ||
} | ||
return 0 <= value && value < 24 | ||
} | ||
return false | ||
} | ||
/***/ }, | ||
/* 20 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var validNumber = __webpack_require__(32) | ||
module.exports = function validMinute(value, config){ | ||
if (validNumber(value, config)){ | ||
value *= 1 | ||
return 0 <= value && value < 60 | ||
} | ||
return false | ||
} | ||
/***/ }, | ||
/* 21 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var validMinute = __webpack_require__(20) | ||
module.exports = function validSecond(value, config){ | ||
return validMinute(value, config) | ||
} | ||
/***/ }, | ||
/* 22 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = function validMeridian(value){ | ||
if (!value){ | ||
return false | ||
} | ||
value = value.toUpperCase() | ||
return value == 'AM' || value == 'PM' | ||
} | ||
/***/ }, | ||
/* 23 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var validHour = __webpack_require__(19) | ||
var validMinute = __webpack_require__(20) | ||
var validSecond = __webpack_require__(21) | ||
var validMeridian = __webpack_require__(22) | ||
var VALIDATION_MAP = { | ||
hour : validHour, | ||
minute : validMinute, | ||
second : validSecond, | ||
meridian: validMeridian | ||
} | ||
/** | ||
* VALIDATES TIME PART [name, value] eg ['hour', '15'] | ||
* | ||
* Returns whether the given value is valid for the given time part. | ||
* | ||
* EG: | ||
* name: 'hour', value: 15 => true | ||
* name: 'hour', value: '07' => true | ||
* name: 'hour', value: 15, config={meridian: true} => false | ||
* | ||
* name: 'minute', value: '05' => true | ||
* | ||
* name: 'second', value: 55 => true | ||
* name: 'second', value: 5 => true | ||
* name: 'second', value: '5' => false (string without two digits) | ||
* name: 'second', value: '5', {twoDigits: false} => true | ||
* name: 'meridian', value: 'PM' => true | ||
* name: 'meridian', value: 'am' => true | ||
* name: 'meridian', value: 'apm' => false | ||
* | ||
* @param {String} name | ||
* @param {Number/String} value | ||
* @param {Object} config | ||
* @param {Boolean} config.meridian | ||
* @param {Boolean} config.twoDigits | ||
* | ||
* @return {Boolean} | ||
*/ | ||
module.exports = function isValidPart(name, value, config){ | ||
var fn = VALIDATION_MAP[name] | ||
return !!(fn && fn(value, config)) | ||
} | ||
/***/ }, | ||
/* 24 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var isValidPart = __webpack_require__(23) | ||
var assign = __webpack_require__(30) | ||
module.exports = function isValidTime(time, config){ | ||
var validSecond = time.second === undefined || isValidPart('second', time.second, config) | ||
var validMinute = validSecond && (time.minute === undefined || isValidPart('minute', time.minute, config)) | ||
var validHour = validMinute && isValidPart('hour', time.hour, assign({meridian: time.meridian}, config)) | ||
var meridian = time.meridian | ||
var validMeridian = validHour && (meridian? isValidPart('meridian', meridian, config): true) | ||
var valid = validMeridian | ||
if (valid && meridian){ | ||
//for 24 hour clock, we're done | ||
//BUT there is a special case when we have meridian specified: | ||
//12:00:00 am/pm is ok, but >= 12:00:01 is not | ||
var hour = time.hour * 1 | ||
if (hour === 12){ | ||
valid = time.minute * 1 === 0 && time.second * 1 === 0 | ||
} | ||
} | ||
return valid | ||
} | ||
/***/ }, | ||
/* 25 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var assign = __webpack_require__(30) | ||
var isValidNumber = __webpack_require__(32) | ||
var isValidPart = __webpack_require__(23) | ||
var isValidTime = __webpack_require__(24) | ||
var adjustOverflow = __webpack_require__(26) | ||
var clamp = __webpack_require__(33) | ||
/** | ||
* @param {Object} time | ||
* @param {String} name | ||
* @param {String/Number} value | ||
* @param {Object} [config] | ||
* @param {Boolean} [config.clamp=false] | ||
* @param {Boolean} [config.overflow=true] | ||
* @param {Boolean} [config.rejectInvalid=false] | ||
* | ||
* @return {Object} time | ||
*/ | ||
module.exports = function update(time, name, value, config){ | ||
var initial = time | ||
var touched | ||
var validNumber = isValidNumber(value, config) | ||
var validPart = isValidPart(name, value, config) | ||
time = assign({}, time) | ||
config = config || {} | ||
if (validNumber){ | ||
value *= 1 | ||
} | ||
if (validPart || validNumber){ | ||
time[name] = value | ||
} | ||
if (!isValidTime(time, config) && config.clamp){ | ||
time[name] = clamp(time, name, time[name]) | ||
} | ||
if (!isValidTime(time, config)){ | ||
if (config.rejectInvalid){ | ||
return initial | ||
} | ||
if (config.overflow !== false){ | ||
time = adjustOverflow(time, config) | ||
} | ||
} | ||
return time | ||
} | ||
/***/ }, | ||
/* 26 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
/** | ||
* See documentation below | ||
*/ | ||
var defaults = {} | ||
var MAP = { | ||
hour: overflowHour, | ||
minute: overflowMinute, | ||
second: overflowSecond | ||
} | ||
function overflowHour(values, name, value, config){ | ||
if (values.hour === undefined){ | ||
return | ||
} | ||
var overflowHourToMeridian = !config || config.overflowHourToMeridian !== false | ||
var meridian = values.meridian || config && config.meridian | ||
var limit = meridian? 12: 23 | ||
var plusOne = meridian? 12: 24 | ||
var extra = 0 | ||
if (value > limit){ | ||
extra += Math.floor(value / limit) | ||
value = value % plusOne | ||
} | ||
if (value < 0){ | ||
extra = Math.ceil(-value / limit) | ||
value = plusOne + value | ||
} | ||
if (meridian && value === limit && (values.minute > 0 || values.second > 0)){ | ||
extra += 1 | ||
value = 0 | ||
} | ||
if (meridian && extra % 2 == 1 && overflowHourToMeridian){ | ||
if (typeof meridian == 'string'){ | ||
meridian = meridian.toUpperCase() | ||
} | ||
//change meridian | ||
values.meridian = meridian == 'PM'? 'AM': 'PM' | ||
} | ||
values.hour = value | ||
} | ||
function overflowMinuteOrSecond(values, name, value, config, nextName){ | ||
if (values[name] === undefined){ | ||
return | ||
} | ||
var extra = 0 | ||
if (value > 59){ | ||
extra += Math.floor(value / 60) | ||
value = value % 60 | ||
} | ||
if (value < 0){ | ||
extra -= Math.ceil(-value / 60) | ||
value = 60 + value | ||
} | ||
values[name || 'minute'] = value | ||
if (extra){ | ||
values[nextName || 'hour'] += extra | ||
} | ||
} | ||
function overflowMinute(values, name, value, config){ | ||
overflowMinuteOrSecond(values, 'minute', values.minute, config) // minute -> hour | ||
overflowHour(values, 'hour', values.hour, config) //overflow hour | ||
} | ||
function overflowSecond(values, name, value, config){ | ||
overflowMinuteOrSecond(values, 'second', values.second, config, 'minute') //second -> minute | ||
overflowMinute(values, 'minute', values.minute, config) //minute -> hour | ||
} | ||
/** | ||
* | ||
* This method receives an object with hour, minute and second properties. | ||
* It adjusts any overflowing values and moves the overflow to the next value: | ||
* | ||
* EG: extra seconds go to minute; extra minutes go to hour; | ||
* hours beyond 23 (in 24 hour format, so without values.meridian specified) restart from 0, | ||
* or beyond 12:00:00 (when meridian is specified) restart from 0 | ||
* | ||
* @param {Object} values [description] | ||
* @param {Number} values.hour | ||
* @param {Number} values.minute | ||
* @param {Number} values.second | ||
* @param {Number} values.meridian | ||
* | ||
* @param {String} [name="second"] "hour"|"minute"|"second" | ||
* @param {Number} [value] | ||
* @param {Object} config | ||
* | ||
* Both {name} and {value} are optional. If not given, they default to "second" and value for second. | ||
* | ||
* @return {Object} | ||
*/ | ||
module.exports = function(values, name, value, config){ | ||
if (arguments.length == 2){ | ||
config = name | ||
name = 'second' | ||
value = values[name] | ||
} | ||
MAP[name](values, name, value, config || defaults) | ||
return values | ||
} | ||
/***/ }, | ||
/* 27 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var toUpperFirst = __webpack_require__(31) | ||
var prefixes = ["ms", "Moz", "Webkit", "O"] | ||
var el = __webpack_require__(29) | ||
var PREFIX | ||
module.exports = function(key){ | ||
if (PREFIX){ | ||
return PREFIX | ||
} | ||
var i = 0 | ||
var len = prefixes.length | ||
var tmp | ||
var prefix | ||
for (; i < len; i++){ | ||
prefix = prefixes[i] | ||
tmp = prefix + toUpperFirst(key) | ||
if (typeof el.style[tmp] != 'undefined'){ | ||
return PREFIX = prefix | ||
} | ||
} | ||
} | ||
/***/ }, | ||
/* 28 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var toUpperFirst = __webpack_require__(31) | ||
var getPrefix = __webpack_require__(27) | ||
var properties = __webpack_require__(17) | ||
/** | ||
* Returns the given key prefixed, if the property is found in the prefixProps map. | ||
* | ||
* Does not test if the property supports the given value unprefixed. | ||
* If you need this, use './getPrefixed' instead | ||
*/ | ||
module.exports = function(key, value){ | ||
if (!properties[key]){ | ||
return key | ||
} | ||
var prefix = getPrefix(key) | ||
return prefix? | ||
prefix + toUpperFirst(key): | ||
key | ||
} | ||
/***/ }, | ||
/* 29 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {'use strict'; | ||
var el | ||
if(!!global.document){ | ||
el = global.document.createElement('div') | ||
} | ||
module.exports = el | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ }, | ||
/* 30 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
function ToObject(val) { | ||
if (val == null) { | ||
throw new TypeError('Object.assign cannot be called with null or undefined'); | ||
} | ||
return Object(val); | ||
} | ||
module.exports = Object.assign || function (target, source) { | ||
var from; | ||
var keys; | ||
var to = ToObject(target); | ||
for (var s = 1; s < arguments.length; s++) { | ||
from = arguments[s]; | ||
keys = Object.keys(Object(from)); | ||
for (var i = 0; i < keys.length; i++) { | ||
to[keys[i]] = from[keys[i]]; | ||
} | ||
} | ||
return to; | ||
}; | ||
/***/ }, | ||
/* 31 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = function(str){ | ||
return str? | ||
str.charAt(0).toUpperCase() + str.slice(1): | ||
'' | ||
} | ||
/***/ }, | ||
/* 32 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
var assign = __webpack_require__(30) | ||
var defaults = __webpack_require__(18) | ||
module.exports = function validNumber(n, config){ | ||
var valid = !isNaN(n * 1) | ||
if (config){ | ||
config = assign({}, defaults, config) | ||
} else { | ||
config = defaults | ||
} | ||
if (valid && typeof n == 'string' && config.twoDigits){ | ||
valid = n.length == 2 | ||
} | ||
if (valid){ | ||
n = n * 1 | ||
valid = parseInt(n) === n | ||
} | ||
return valid | ||
} | ||
/***/ }, | ||
/* 33 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
module.exports = function clamp(time, name, value){ | ||
if (name == 'meridian'){ | ||
return value | ||
} | ||
if (name == 'hour'){ | ||
var limit = 24 | ||
if (time.meridian){ | ||
limit = (time.hour || time.minute)? 11: 12 | ||
} | ||
return value < 0? | ||
0: | ||
value > limit? | ||
limit: | ||
value | ||
} | ||
return value < 0? | ||
0: | ||
value > 59? | ||
59: | ||
value | ||
} | ||
/***/ } | ||
/******/ ]) | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.ReactTimePicker=t():e.ReactTimePicker=t()}(this,function(){return function(e){function t(r){if(o[r])return o[r].exports;var n=o[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}([function(){}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React")):"function"==typeof define&&define.amd?define(["React"],e):"object"==typeof exports?exports.ReactTimePicker=e(require("React")):t.ReactTimePicker=e(t.React)}(this,function(t){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}(function(t){for(var e in t)switch(typeof t[e]){case"number":t[e]=t[t[e]];break;case"object":t[e]=function(e){var n=e.slice(1),r=t[e[0]];return function(t,e,i){r.apply(null,[t,e,i].concat(n))}}(t[e])}return t}([function(t,e,n){"use strict";function r(t){return 10>t?"0"+t:t}function i(){}var o=n(33),u=n(19),a=n(26),s=n(29),l=n(32),c=n(31),p=n(30),d=n(15),f=n(20),h=" ";t.exports=o.createClass({displayName:"ReactTimePicker",componentWillUnmount:function(){this.stopInterval()},getInitialState:function(){return{defaultValue:this.props.defaultValue,focused:{hour:null,minute:null,second:null,meridian:null}}},getDefaultProps:function(){return{stopChangePropagation:!0,strict:!0,overflowHourToMeridian:!0,step:1,hourStep:null,minuteStep:10,secondStep:30,stepDelay:60,showArrows:!0,defaultStyle:{border:"1px solid gray",padding:20,display:"inline-flex",alignItems:"center",boxSizing:"border-box",flexFlow:"row",width:200},defaultArrowStyle:{cursor:"pointer",userSelect:"none"},defaultBoxStyle:{boxSizing:"border-box",display:"flex",flexFlow:"column",alignItems:"center"},defaultInputStyle:{boxSizing:"border-box",width:"100%",textAlign:"center"},defaultSeparatorStyle:{flex:"none"},defaultMeridianInputStyle:{cursor:"pointer"},defaultMeridianInputProps:{readOnly:!0},format:r,formatHour:null,formatMinute:null,formatSecond:null,formatMeridian:null,defaultArrowFactory:o.DOM.span,arrowFactory:null,arrowUpFactory:null,arrowDownFactory:null,defaultInputFactory:o.DOM.input,inputFactory:null,hourInputFactory:null,minuteInputFactory:null,secondInputFactory:null,meridianInputFactory:null,timeToString:p}},render:function(){var t=this.prepareProps(this.props,this.state),e=this.renderHour(t),n=this.renderMinute(t),r=this.renderSecond(t),i=this.renderMeridian(t),u=t.separator||o.createElement("span",{style:t.separatorStyle},h+":"+h),a=t.hourSeparator||u,s=n&&(r||i)?t.minuteSeparator||u:null,l=r&&i?t.secondSeparator||u:null;return o.createElement("div",o.__spread({},t),e,a,n,s,r,l,i)},onArrowMouseDown:function(t,e,n,r){if("meridian"==n)return void this.onArrowMeridianAction(t,e,n);var i=d?r.target:window,o=d?"touchend":"click";i.addEventListener(o,this.onWindowClick),this.startInterval(t,e,n)},onWindowClick:function(){this.stopInterval()},stopInterval:function(){clearInterval(this.intervalId)},startInterval:function(t,e,n){this.intervalId=setInterval(function(){this.onArrowAction(t,e,n)}.bind(this),t.stepDelay)},onMeridianInputMouseDown:function(t,e){e.preventDefault(),this.onArrowMeridianAction(t,1,"meridian")},onArrowMeridianAction:function(t,e,n){this.updateValue(n,"AM"==this.time.meridian?"PM":"AM")},onArrowAction:function(t,e,n){var r=1==e?"Up":"Down",i="onArrow"+r+c(n)+"Action";"function"==typeof this[i]&&this[i](t),i="onArrow"+c(n)+"Action","function"==typeof this[i]&&this[i](t,e),this.incValue(t,n,e)},incValue:function(t,e,n){n=n||0;var r=t[e+"Step"]||t.step,i=n*r,o=this.time,u=o[e],a=u+i;this.setValue(o),this.updateValue(e,a)},updateValue:function(t,e,n){this.setValue(this.updateTime(t,e,n))},updateTime:function(t,e,n){n=n||{},n.overflowHourToMeridian=this.props.overflowHourToMeridian;var r=this.time;return r=l(r,t,e,n),this.time=r},setValue:function(t){null==this.props.value&&this.setState({defaultValue:t}),(this.props.onChange||i)(this.props.timeToString(t),u({},t))},format:function(t,e,n){var r;return arguments.length<3&&(n=t.time[e]),r="meridian"!=e?t["format"+c(e)]||t.format:t.formatMeridian,"function"==typeof r&&(n=r(n)),n},renderBox:function(t,e){var n,r=this.state,i=t[e+"Style"],a=t[e+"InputStyle"],s=c(e);n=r.focused[e]?r.focused[e].value:this.format(t,e);var l,p;if(t.showArrows){var d={style:t.arrowUpStyle,children:"▴"};d[f.onMouseDown]=this.onArrowMouseDown.bind(this,t,1,e);var h={style:t.arrowDownStyle,children:"▾"};h[f.onMouseDown]=this.onArrowMouseDown.bind(this,t,-1,e);var v=t.defaultArrowFactory,m=t.arrowUpFactory||t.arrowFactory||v,y=t.arrowDownFactory||t.arrowFactory||v;l=m(d),void 0===l&&(l=v(d)),p=y(h),void 0===p&&(p=v(h))}var S=t.defaultInputFactory,w=t[e+"InputFactory"]||t.inputFactory||S,M=t["default"+s+"InputProps"],x=u({},M,{style:a,value:n,onFocus:this.handleInputFocus.bind(this,t,e),onBlur:this.handleInputBlur.bind(this,t,e),onChange:this.handleInputChange.bind(this,t,e)});"meridian"==e&&(x.onMouseDown=this.onMeridianInputMouseDown.bind(this,t));var g=w(x);return void 0===g&&(g=S(x)),o.createElement("div",{style:i},l,g,p)},handleInputFocus:function(t,e){var n=this.state.focused;n[e]={value:this.format(t,e)},this.setState({})},handleInputBlur:function(t,e,n){this.state.focused[e]=null,this.setState({});var r=1*n.target.value;this.updateValue(e,r,{clamp:t.clamp})},handleInputChange:function(t,e,n){this.state.focused[e]&&(this.state.focused[e].value=n.target.value),this.setState({}),t.stopChangePropagation&&n.stopPropagation()},getTime:function(){return s(this.getValue(),{strict:this.props.strict})},prepareTime:function(t){var e=this.getTime();return t.showSecond=void 0!==e.second,t.showMinute=void 0!==e.minute,t.withMeridian=null!=e.meridian,e},getValue:function(){var t=null==this.props.value?this.state.defaultValue:this.props.value;return t},renderHour:function(t){return this.renderBox(t,"hour")},renderMinute:function(t){return t.showMinute?this.renderBox(t,"minute"):void 0},renderSecond:function(t){return t.showSecond?this.renderBox(t,"second"):void 0},renderMeridian:function(t){return t.withMeridian?this.renderBox(t,"meridian"):void 0},prepareProps:function(t,e){var n=u({},t);return this.time=n.time=this.prepareTime(n,e),this.prepareStyles(n,e),n},prepareStyles:function(t,e){t.style=this.prepareStyle(t,e),t.separatorStyle=this.prepareSeparatorStyle(t,e),this.prepareArrowStyles(t,e),this.prepareHourStyles(t,e),this.prepareMinuteStyles(t,e),this.prepareSecondStyles(t,e),this.prepareMeridianStyles(t,e)},prepareStyle:function(t){return a(u({},t.defaultStyle,t.style))},prepareSeparatorStyle:function(t){return a(u({},t.defaultSeparatorStyle,t.separatorStyle))},prepareArrowStyles:function(t){t.arrowUpStyle=a(u({},t.defaultArrowStyle,t.defaultArrowUpStyle,t.arrowUpStyle)),t.arrowDownStyle=a(u({},t.defaultArrowStyle,t.defaultArrowDownStyle,t.arrowDownStyle))},prepareHourStyles:function(t,e){t.hourStyle=this.prepareHourStyle(t,e),t.hourInputStyle=this.prepareHourInputStyle(t,e)},prepareHourStyle:function(t){return a(u({},t.defaultBoxStyle,t.defaultHourStyle,t.hourStyle))},prepareHourInputStyle:function(t){return a(u({},t.defaultInputStyle,t.defaultHourInputStyle,t.hourInputStyle))},prepareMinuteStyles:function(t,e){t.minuteStyle=this.prepareMinuteStyle(t,e),t.minuteInputStyle=this.prepareMinuteInputStyle(t,e)},prepareMinuteStyle:function(t){return a(u({},t.defaultBoxStyle,t.defaultMinuteStyle,t.minuteStyle))},prepareMinuteInputStyle:function(t){return a(u({},t.defaultInputStyle,t.defaultMinuteInputStyle,t.minuteInputStyle))},prepareSecondStyles:function(t,e){t.showSecond&&(t.secondStyle=this.prepareSecondStyle(t,e),t.secondInputStyle=this.prepareSecondInputStyle(t,e))},prepareSecondStyle:function(t){return a(u({},t.defaultBoxStyle,t.defaultSecondStyle,t.secondStyle))},prepareSecondInputStyle:function(t){return a(u({},t.defaultInputStyle,t.defaultSecondInputStyle,t.secondInputStyle))},prepareMeridianStyles:function(t,e){t.withMeridian&&(t.meridianStyle=this.prepareMeridianStyle(t,e),t.meridianInputStyle=this.prepareMeridianInputStyle(t,e))},prepareMeridianStyle:function(t){return a(u({},t.defaultBoxStyle,t.defaultMeridianStyle,t.meridianStyle))},prepareMeridianInputStyle:function(t){return a(u({},t.defaultInputStyle,t.defaultMeridianInputStyle,t.meridianInputStyle))}})},function(t){"use strict";function e(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=Object.assign||function(t){for(var n,r,i=e(t),o=1;o<arguments.length;o++){n=arguments[o],r=Object.keys(Object(n));for(var u=0;u<r.length;u++)i[r[u]]=n[r[u]]}return i}},function(t,e,n){"use strict";var r=n(12),i=n(3),o=n(14),u=n(13),a={hour:r,minute:i,second:o,meridian:u};t.exports=function(t,e,n){var r=a[t];return!(!r||!r(e,n))}},function(t,e,n){"use strict";var r=n(4);t.exports=function(t,e){return r(t,e)?(t*=1,t>=0&&60>t):!1}},function(t,e,n){"use strict";var r=n(1),i=n(9);t.exports=function(t,e){var n=!isNaN(1*t);return e=e?r({},i,e):i,n&&"string"==typeof t&&e.twoDigits&&(n=2==t.length),n&&(t=1*t,n=parseInt(t)===t),n}},function(t,e){(function(e){"use strict";var n;e.document&&(n=e.document.createElement("div")),t.exports=n}).call(e,function(){return this}())},function(t,e,n){"use strict";var r,i=n(7),o=["ms","Moz","Webkit","O"],u=n(5);t.exports=function(t){if(r)return r;for(var e,n,a=0,s=o.length;s>a;a++)if(n=o[a],e=n+i(t),"undefined"!=typeof u.style[e])return r=n}},function(t){"use strict";t.exports=function(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}},function(t){"use strict";function e(t,e,n,r){if(void 0!==t.hour){var i=!r||r.overflowHourToMeridian!==!1,o=t.meridian||r&&r.meridian,u=o?12:23,a=o?12:24,s=0;n>u&&(s+=Math.floor(n/u),n%=a),0>n&&(s=Math.ceil(-n/u),n=a+n),o&&n===u&&(t.minute>0||t.second>0)&&(s+=1,n=0),o&&s%2==1&&i&&("string"==typeof o&&(o=o.toUpperCase()),t.meridian="PM"==o?"AM":"PM"),t.hour=n}}function n(t,e,n,r,i){if(void 0!==t[e]){var o=0;n>59&&(o+=Math.floor(n/60),n%=60),0>n&&(o-=Math.ceil(-n/60),n=60+n),t[e||"minute"]=n,o&&(t[i||"hour"]+=o)}}function r(t,r,i,o){n(t,"minute",t.minute,o),e(t,"hour",t.hour,o)}function i(t,e,i,o){n(t,"second",t.second,o,"minute"),r(t,"minute",t.minute,o)}var o={},u={hour:e,minute:r,second:i};t.exports=function(t,e,n,r){return 2==arguments.length&&(r=e,e="second",n=t[e]),u[e](t,e,n,r||o),t}},function(t){"use strict";t.exports={separator:":",twoDigits:!0}},function(t,e,n){"use strict";function r(t){return t.trim()}function i(t,e){return h(t,e)?1*t:void 0}function o(t){return v(t)?1*t:void 0}function u(t){return m(t)?1*t:void 0}function a(t){return y(t)?t:void 0}function s(t){var e=t.split(" ");return e.length>1}function l(t){return S[t]}function c(t,e,n){var i,o,u=n&&n.meridian,s=t.split(" ").map(r),c=l(e),p={invalid:[]};return w(e,s[0],n)?c&&(i=c(s[0],n)):p.invalid.push({name:e,value:s[0]}),u&&(o=a(s[1]),void 0===o&&p.invalid.push({name:"meridian",value:s[1]})),void 0!==o&&(p.meridian=o),void 0!==i&&(p[e]=i),p}function p(t,e){e=d({},f,e);var n=t.split(e.separator).map(r),u=s(n[n.length-1]);e.meridian=u;var a,l,p=[],h={};return n.length>3?void 0:(1==n.length&&d(h,c(n[0],"hour",e)),2==n.length&&(a=i(n[0],e),void 0===a&&p.push({name:"hour",value:n[0]}),d(h,c(n[1],"minute",e))),3==n.length&&(a=i(n[0],e),l=o(n[1]),void 0===a&&p.push({name:"hour",value:n[0]}),void 0===l&&p.push({name:"minute",value:n[1]}),d(h,c(n[2],"second",e))),h.invalid&&(p.push.apply(p,h.invalid),h.invalid=p),void 0!==a&&(h.hour=a),void 0!==l&&(h.minute=l),h.invalid.length||delete h.invalid,h)}var d=n(1),f=n(9),h=n(12),v=n(3),m=n(14),y=n(13),S={hour:i,minute:o,second:u,meridian:a},w=n(2),M=n(11),x=n(18),g=n(8);p.isValidPart=w,p.isValidTime=M,p.updateTime=x,p.adjustOverflow=g,t.exports=p},function(t,e,n){"use strict";var r=n(2),i=n(1);t.exports=function(t,e){var n=void 0===t.second||r("second",t.second,e),o=n&&(void 0===t.minute||r("minute",t.minute,e)),u=o&&r("hour",t.hour,i({meridian:t.meridian},e)),a=t.meridian,s=u&&(a?r("meridian",a,e):!0),l=s;if(l&&a){var c=1*t.hour;12===c&&(l=1*t.minute===0&&1*t.second===0)}return l}},function(t,e,n){"use strict";var r=n(4);t.exports=function(t,e){var n=e&&e.meridian;return r(t,e)?(t*=1,n?t>=0&&12>=t:t>=0&&24>t):!1}},function(t){"use strict";t.exports=function(t){return t?(t=t.toUpperCase(),"AM"==t||"PM"==t):!1}},function(t,e,n){"use strict";var r=n(3);t.exports=function(t,e){return r(t,e)}},function(t,e){(function(e){t.exports="ontouchstart"in e||e.DocumentTouch&&document instanceof DocumentTouch}).call(e,function(){return this}())},function(t){"use strict";t.exports={alignItems:1,justifyContent:1,flex:1,flexFlow:1,userSelect:1,transform:1,transition:1,transformOrigin:1,transformStyle:1,transitionProperty:1,transitionDuration:1,transitionTimingFunction:1,transitionDelay:1,borderImage:1,borderImageSlice:1,boxShadow:1,backgroundClip:1,backfaceVisibility:1,perspective:1,perspectiveOrigin:1,animation:1,animationDuration:1,animationName:1,animationDelay:1,animationDirection:1,animationIterationCount:1,animationTimingFunction:1,animationPlayState:1,animationFillMode:1,appearance:1}},function(t){"use strict";t.exports=function(t,e,n){if("meridian"==e)return n;if("hour"==e){var r=24;return t.meridian&&(r=t.hour||t.minute?11:12),0>n?0:n>r?r:n}return 0>n?0:n>59?59:n}},function(t,e,n){"use strict";var r=n(1),i=n(4),o=n(2),u=n(11),a=n(8),s=n(17);t.exports=function(t,e,n,l){var c=t,p=i(n,l),d=o(e,n,l);if(t=r({},t),l=l||{},p&&(n*=1),(d||p)&&(t[e]=n),!u(t,l)&&l.clamp&&(t[e]=s(t,e,t[e])),!u(t,l)){if(l.rejectInvalid)return c;l.overflow!==!1&&(t=a(t,l))}return t}},1,function(t,e,n){"use strict";t.exports=n(15)?{onMouseDown:"onTouchStart",onMouseUp:"onTouchEnd",onMouseMove:"onTouchMove"}:{onMouseDown:"onMouseDown",onMouseUp:"onMouseUp",onMouseMove:"onMouseMove"}},function(t,e,n){"use strict";var r=n(7),i=n(6),o=n(16);t.exports=function(t){if(!o[t])return t;var e=i(t);return e?e+r(t):t}},function(t,e,n){"use strict";var r=n(6),i=n(21),o=n(5),u={},a=o.style;t.exports=function(t,e){var n=t+": "+e;if(u[n])return u[n];var s,l,c;return t in a||(s=r("appearance"),s&&(l=i(t,e),c="-"+s.toLowerCase()+"-"+e,l in a&&(o.style[l]="",o.style[l]=c,""!==o.style[l]&&(e=c)))),u[n]=e,e}},function(t,e,n){"use strict";var r=n(24),i=n(16);t.exports=function(t,e){return i[t]?r(t,e):t}},function(t,e,n){"use strict";var r=n(7),i=n(6),o=n(5),u={},a=o.style;t.exports=function(t){var e=t;if(u[e])return u[e];var n,o;return t in a||(n=i("appearance"),n&&(o=n+r(t),o in a&&(t=o))),u[e]=t,t}},function(t){"use strict";t.exports=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},function(t,e,n){"use strict";function r(t,e){var n={key:t,value:e};return(l.plugins||[]).forEach(function(r){var i=a(function(n){return r(t,e,n)},n);i&&(n=i)}),n}function i(t,e){var n=r(t,e);return a(function(t){return{key:u(t.key,t.value),value:t.value}},n)}var o=n(25),u=n(23),a=n(27),s=n(28),l=function(t){var e,n,r={};for(e in t)if(o(t,e)){if(n=i(e,t[e]),!n)continue;a(function(t){r[t.key]=t.value},n)}return r};t.exports=s(l)},function(t){"use strict";t.exports=function(t,e){return e?Array.isArray(e)?e.map(t).filter(function(t){return!!t}):t(e):void 0}},function(t,e,n){"use strict";var r=n(22);t.exports=function(t){return t.plugins=t.plugins||[function(){var t={flex:1,"inline-flex":1};return function(e,n){return"display"===e&&n in t?{key:e,value:r(e,n)}:void 0}}()],t.plugin=function(e){t.plugins=t.plugins||[],t.plugins.push(e)},t}},function(t,e,n){"use strict";function r(t,e){return t.invalid.forEach(function(e){var n=e.name,r=1*e.value;isNaN(r)||(t[n]=r)}),o(t,e)}var i=n(10),o=i.adjustOverflow,u={};t.exports=function(t,e){e=e||u,t=t||"","string"==typeof t&&(t=i(t));var n={};t&&(e.withMeridian=null!=t.meridian,t.invalid&&t.invalid.forEach(function(t){n[t.name]=!0}),!e.strict&&t.invalid&&(t=r(t,e)),n.hour&&(t.hour=t.hour||0),n.minute&&(t.minute=t.minute||0),n.second&&(t.second=t.second||0),e.strict&&t.meridian&&12===t.hour&&(void 0!==t.minute&&(t.minute=0),void 0!==t.second&&(t.second=0)));var o={hour:t.hour};return void 0!==t.minute&&(o.minute=t.minute),void 0!==t.second&&(o.second=t.second),e.withMeridian&&(o.meridian=t.meridian),o}},function(t){"use strict";function e(t){return 10>t?"0"+t:t}t.exports=function(t){var n=e(t.hour);return null!=t.minute&&(n+=":"+e(t.minute)),null!=t.second&&(n+=":"+e(t.second)),t.meridian&&(n+=" "+t.meridian),n}},7,function(t,e,n){"use strict";var r=n(10).updateTime;t.exports=function(t,e,n,i){return t=r(t,e,n,i)}},function(e){e.exports=t}]))}); |
{ | ||
"name": "react-time-picker", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "React Time Picker", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
92698
27
2523
3