rax-countdown
Advanced tools
Comparing version 0.6.5 to 1.0.0-beta.0
@@ -85,3 +85,3 @@ module.exports = function(require, exports, module) { | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ return __webpack_require__(__webpack_require__.s = 7); | ||
/******/ }) | ||
@@ -102,240 +102,48 @@ /************************************************************************/ | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.isReactNative = exports.isWeex = exports.isNode = exports.isWeb = void 0; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} // https://www.w3.org/TR/html5/webappapis.html#dom-navigator-appcodename | ||
var isWeb = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
exports.isWeb = isWeb; | ||
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node); | ||
exports.isNode = isNode; | ||
var isWeex = typeof callNative === 'function' || (typeof WXEnvironment === "undefined" ? "undefined" : _typeof(WXEnvironment)) === 'object' && WXEnvironment.platform !== 'Web'; | ||
exports.isWeex = isWeex; | ||
var isReactNative = typeof __fbBatchedBridgeConfig !== 'undefined'; | ||
exports.isReactNative = isReactNative; | ||
exports["default"] = module.exports; | ||
var _default = module.exports; | ||
exports.default = _default; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _rax = __webpack_require__(0); | ||
var _universalEnv = __webpack_require__(1); | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
/* | ||
* Current PropTypes only export some api with react, not validate in runtime. | ||
*/ | ||
function createChainableTypeChecker(validate) { | ||
function checkType(isRequired, props, propName, componentName, location, propFullName) { | ||
return typeChecker; | ||
} | ||
return _typeof(obj); | ||
var chainedCheckType = checkType.bind(null, false); | ||
chainedCheckType.isRequired = checkType.bind(null, true); | ||
return chainedCheckType; | ||
} | ||
function _extends() { | ||
_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; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
function createTypeChecker(expectedType) { | ||
function validate(props, propName, componentName, location, propFullName) {// Noop | ||
} | ||
return target; | ||
return createChainableTypeChecker(validate); | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
var View = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(View, _Component); | ||
function View() { | ||
_classCallCheck(this, View); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(View).apply(this, arguments)); | ||
} | ||
_createClass(View, [{ | ||
key: "render", | ||
value: function render() { | ||
var props = this.props; | ||
if (_universalEnv.isWeex) { | ||
// TODO: do not pass object value in props | ||
return (0, _rax.createElement)("div", props); | ||
} else { | ||
var styleProps = _objectSpread({}, styles.initial, props.style); | ||
return (0, _rax.createElement)("div", _extends({}, props, { | ||
style: styleProps | ||
})); | ||
} | ||
} | ||
}]); | ||
return View; | ||
}(_rax.Component); | ||
_defineProperty(View, "propTypes", {}); | ||
var styles = { | ||
initial: { | ||
border: '0 solid black', | ||
position: 'relative', | ||
boxSizing: 'border-box', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignContent: 'flex-start', | ||
flexShrink: 0 | ||
} | ||
var typeChecker = createTypeChecker(); | ||
var _default = { | ||
array: typeChecker, | ||
bool: typeChecker, | ||
func: typeChecker, | ||
number: typeChecker, | ||
object: typeChecker, | ||
string: typeChecker, | ||
symbol: typeChecker, | ||
element: typeChecker, | ||
node: typeChecker, | ||
any: typeChecker, | ||
arrayOf: typeChecker, | ||
instanceOf: typeChecker, | ||
objectOf: typeChecker, | ||
oneOf: typeChecker, | ||
oneOfType: typeChecker, | ||
shape: typeChecker | ||
}; | ||
var _default = View; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 3 */ | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -353,8 +161,6 @@ | ||
var _raxText = _interopRequireDefault(__webpack_require__(4)); | ||
var _universalEnv = __webpack_require__(4); | ||
var _raxView = _interopRequireDefault(__webpack_require__(2)); | ||
var _index = _interopRequireDefault(__webpack_require__(8)); | ||
var _raxImage = _interopRequireDefault(__webpack_require__(5)); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -364,2 +170,6 @@ | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -383,399 +193,4 @@ | ||
function isFunction(functionToCheck) { | ||
return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'; | ||
} | ||
var _styleSheet = _index.default; | ||
; | ||
function addZero(num, timeWrapStyle, timeBackground, timeBackgroundStyle, timeStyle, secondStyle) { | ||
var displayNum = num < 0 ? 0 : num; | ||
var displayFirstNum = displayNum < 10 ? 0 : displayNum.toString().slice(0, 1); | ||
var displaySecondNum = displayNum < 10 ? displayNum : displayNum.toString().slice(1); | ||
return (0, _rax.createElement)(_raxView.default, { | ||
style: [timeWrapStyle, styles.item] | ||
}, timeBackground ? (0, _rax.createElement)(_raxImage.default, { | ||
source: timeBackground, | ||
style: timeBackgroundStyle | ||
}) : null, (0, _rax.createElement)(_raxText.default, { | ||
style: timeStyle | ||
}, '' + displayFirstNum), (0, _rax.createElement)(_raxText.default, { | ||
style: secondStyle | ||
}, '' + displaySecondNum)); | ||
} | ||
; | ||
var Index = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Index, _Component); | ||
function Index() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, Index); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Index)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
timeRemaining: 0 | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "timeoutId", 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "tick", function () { | ||
var _this$props = _this.props, | ||
onComplete = _this$props.onComplete, | ||
onTick = _this$props.onTick, | ||
interval = _this$props.interval; | ||
var timeRemaining = _this.state.timeRemaining; | ||
var countdownComplete = 1000 > timeRemaining; | ||
if (_this.timeoutId) { | ||
clearTimeout(_this.timeoutId); | ||
} | ||
if (countdownComplete && isFunction(onComplete)) { | ||
onComplete(); | ||
} else { | ||
_this.timeoutId = !countdownComplete ? setTimeout(function () { | ||
return _this.setState({ | ||
timeRemaining: timeRemaining - interval | ||
}, function () { | ||
return isFunction(onTick) && onTick(timeRemaining); | ||
}); | ||
}, interval) : false; | ||
} | ||
}); | ||
return _this; | ||
} | ||
_createClass(Index, [{ | ||
key: "componentWillMount", | ||
value: function componentWillMount() { | ||
var timeRemaining = this.props.timeRemaining; | ||
this.setState({ | ||
timeRemaining: timeRemaining | ||
}); | ||
} | ||
}, { | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
this.tick(); | ||
} | ||
}, { | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate() { | ||
this.tick(); | ||
} | ||
}, { | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(newProps) { | ||
if (newProps.timeRemaining !== this.props.timeRemaining) { | ||
if (this.timeoutId) { | ||
clearTimeout(this.timeoutId); | ||
} | ||
this.setState({ | ||
timeRemaining: newProps.timeRemaining | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
if (this.timeoutId) { | ||
clearTimeout(this.timeoutId); | ||
} | ||
} | ||
}, { | ||
key: "shouldComponentUpdate", | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return this.props.timeRemaining !== nextProps.timeRemaining || this.state.timeRemaining !== nextState.timeRemaining; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var timeRemaining = this.state.timeRemaining; | ||
var _this$props2 = this.props, | ||
formatFunc = _this$props2.formatFunc, | ||
timeStyle = _this$props2.timeStyle, | ||
timeBackgroundStyle = _this$props2.timeBackgroundStyle, | ||
timeWrapStyle = _this$props2.timeWrapStyle, | ||
timeBackground = _this$props2.timeBackground, | ||
secondStyle = _this$props2.secondStyle, | ||
textStyle = _this$props2.textStyle, | ||
tpl = _this$props2.tpl; | ||
if (formatFunc) { | ||
return formatFunc(timeRemaining); | ||
} | ||
var totalSeconds = Math.floor(timeRemaining / 1000); | ||
var days = parseInt(totalSeconds / 3600 / 24); | ||
var hours = parseInt(totalSeconds / 3600) % 24; | ||
var minutes = parseInt(totalSeconds / 60) % 60; | ||
var seconds = parseInt(totalSeconds % 60); | ||
var _timeBackgroundStyle = [styles.background, timeBackgroundStyle]; | ||
var timeType = { | ||
'd': days, | ||
'h': hours, | ||
'm': minutes, | ||
's': seconds | ||
}; | ||
var rule = new RegExp('\{[d,h,m,s]\}', 'g'); // used to matched all template item, which includes 'd', 'h', 'm' and 's'. | ||
var matchlist = []; | ||
var tmp = null; | ||
while ((tmp = rule.exec(tpl)) !== null) { | ||
matchlist.push(tmp.index, tmp.index); | ||
} | ||
if (matchlist.length !== 0) { | ||
// used to detect the last element | ||
matchlist.push(-1); | ||
} | ||
var lastPlaintextIndex = 0; | ||
return (0, _rax.createElement)(_raxView.default, { | ||
style: styles.main | ||
}, matchlist.map(function (val, index) { | ||
if (val === -1) { | ||
// don't forget the potential plain text after last matched item | ||
var lastPlaintext = tpl.slice(lastPlaintextIndex); | ||
return lastPlaintext ? (0, _rax.createElement)(_raxText.default, { | ||
style: textStyle | ||
}, lastPlaintext) : null; | ||
} | ||
var matchedCharacter = tpl[val + 1]; | ||
switch (matchedCharacter) { | ||
case 'd': | ||
case 'h': | ||
case 'm': | ||
case 's': | ||
if (index % 2 === 0) { | ||
// insert plain text before current matched item | ||
return (0, _rax.createElement)(_raxText.default, { | ||
style: textStyle | ||
}, tpl.slice(lastPlaintextIndex, val)); | ||
} else { | ||
// replace current matched item to realtime string | ||
lastPlaintextIndex = val + 3; | ||
return addZero(timeType[matchedCharacter], timeWrapStyle, timeBackground, _timeBackgroundStyle, timeStyle, secondStyle); | ||
} | ||
default: | ||
return null; | ||
} | ||
})); | ||
} | ||
}]); | ||
return Index; | ||
}(_rax.Component); | ||
_defineProperty(Index, "propTypes", { | ||
formatFunc: _rax.PropTypes.func, | ||
onTick: _rax.PropTypes.func, | ||
onComplete: _rax.PropTypes.func, | ||
tpl: _rax.PropTypes.string, | ||
// template (example {h}:{m}:{s}) | ||
timeRemaining: _rax.PropTypes.number, | ||
secondStyle: _rax.PropTypes.object, | ||
timeStyle: _rax.PropTypes.object, | ||
// style for num | ||
textStyle: _rax.PropTypes.object, | ||
// style for text | ||
timeWrapStyle: _rax.PropTypes.object, | ||
timeBackground: _rax.PropTypes.string, | ||
timeBackgroundStyle: _rax.PropTypes.object, | ||
interval: _rax.PropTypes.number | ||
}); | ||
_defineProperty(Index, "defaultProps", { | ||
tpl: '{d}天{h}时{m}分{s}秒', | ||
timeRemaining: 0, | ||
interval: 1000 | ||
}); | ||
var styles = { | ||
main: { | ||
flexDirection: 'row', | ||
justifyContent: 'flex-start', | ||
alignItems: 'center' | ||
}, | ||
item: { | ||
flexDirection: 'row' | ||
}, | ||
background: { | ||
position: 'absolute' | ||
} | ||
}; | ||
var _default = Index; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _rax = __webpack_require__(0); | ||
var _universalEnv = __webpack_require__(1); | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _extends() { | ||
_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; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
var Text = | ||
@@ -834,3 +249,3 @@ /*#__PURE__*/ | ||
whiteSpace: 'pre-wrap' | ||
}, styles.text, nativeProps.style); | ||
}, nativeProps.style); | ||
@@ -852,3 +267,3 @@ var numberOfLines = props.numberOfLines; | ||
return (0, _rax.createElement)("span", _extends({}, nativeProps, { | ||
style: styleProps | ||
style: [_styleSheet["text"], styleProps] | ||
}), textString); | ||
@@ -866,4 +281,2 @@ } | ||
var styleProps = _objectSpread({}, styles.richtext, nativeProps.style); | ||
if (_universalEnv.isWeex) { | ||
@@ -874,3 +287,3 @@ children = transformChildren(children, _assertThisInitialized(_assertThisInitialized(_this))); | ||
return (0, _rax.createElement)("p", _extends({}, nativeProps, { | ||
style: styleProps | ||
style: _styleSheet["richtext"] | ||
}), children); | ||
@@ -967,24 +380,49 @@ }); | ||
var _default = Text; | ||
exports.default = _default; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _rax = __webpack_require__(0); | ||
var _universalEnv = __webpack_require__(4); | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
var _default = function _default(props) { | ||
if (_universalEnv.isWeex) { | ||
// TODO: do not pass object value in props | ||
return (0, _rax.createElement)("div", props); | ||
} else { | ||
var styleProps = _extends({}, styles.initial, props.style); | ||
return (0, _rax.createElement)("div", _extends({}, props, { | ||
style: styleProps | ||
})); | ||
} | ||
}; | ||
exports.default = _default; | ||
var styles = { | ||
text: { | ||
initial: { | ||
border: '0 solid black', | ||
position: 'relative', | ||
boxSizing: 'border-box', | ||
display: 'block', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignContent: 'flex-start', | ||
flexShrink: 0, | ||
fontSize: 32 | ||
}, | ||
richtext: { | ||
marginTop: 0, | ||
marginBottom: 0 | ||
flexShrink: 0 | ||
} | ||
}; | ||
var _default = Text; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 5 */ | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -995,156 +433,70 @@ | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.default = exports.isReactNative = exports.isWeex = exports.isNode = exports.isWeb = void 0; | ||
var _rax = __webpack_require__(0); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _universalEnv = __webpack_require__(1); | ||
// https://www.w3.org/TR/html5/webappapis.html#dom-navigator-appcodename | ||
var isWeb = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
exports.isWeb = isWeb; | ||
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node); | ||
exports.isNode = isNode; | ||
var isWeex = typeof callNative === 'function' || (typeof WXEnvironment === "undefined" ? "undefined" : _typeof(WXEnvironment)) === 'object' && WXEnvironment.platform !== 'Web'; | ||
exports.isWeex = isWeex; | ||
var isReactNative = typeof __fbBatchedBridgeConfig !== 'undefined'; | ||
exports.isReactNative = isReactNative; | ||
exports["default"] = module.exports; | ||
var _default = module.exports; | ||
exports.default = _default; | ||
var _raxView = _interopRequireDefault(__webpack_require__(2)); | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
"use strict"; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
var _rax = __webpack_require__(0); | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
var _universalEnv = __webpack_require__(4); | ||
return target; | ||
}; | ||
var _raxView = _interopRequireDefault(__webpack_require__(3)); | ||
return _extends.apply(this, arguments); | ||
} | ||
var _index = _interopRequireDefault(__webpack_require__(9)); | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
return target; | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
return _setPrototypeOf(o, p); | ||
} | ||
var _styleSheet = _index.default; | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
var Image = | ||
@@ -1196,2 +548,4 @@ /*#__PURE__*/ | ||
if (fallbackSource.uri && source.uri !== fallbackSource.uri) { | ||
_this.isError = true; | ||
_this.setState({ | ||
@@ -1219,3 +573,3 @@ source: fallbackSource | ||
var source = this.state.source; // Source must a object | ||
var source = this.isError ? this.state.source : nativeProps.source; // Source must a object | ||
@@ -1270,3 +624,3 @@ if (source && source.uri) { | ||
}, nativeProps)), (0, _rax.createElement)(_raxView.default, { | ||
style: styles.absoluteImage | ||
style: _styleSheet["absoluteImage"] | ||
}, this.props.children)); | ||
@@ -1307,15 +661,268 @@ } else { | ||
var styles = { | ||
absoluteImage: { | ||
left: 0, | ||
top: 0, | ||
position: 'absolute' | ||
} | ||
}; | ||
var _default = Image; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports) { | ||
var _styles = { | ||
"main": { | ||
"flexDirection": "row", | ||
"justifyContent": "flex-start", | ||
"alignItems": "center" | ||
}, | ||
"item": { | ||
"flexDirection": "row" | ||
}, | ||
"background": { | ||
"position": "absolute" | ||
} | ||
}; | ||
module.exports = _styles; | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var rax__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); | ||
/* harmony import */ var rax__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rax__WEBPACK_IMPORTED_MODULE_0__); | ||
/* harmony import */ var rax_proptypes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1); | ||
/* harmony import */ var rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(rax_proptypes__WEBPACK_IMPORTED_MODULE_1__); | ||
/* harmony import */ var rax_text__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2); | ||
/* harmony import */ var rax_text__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(rax_text__WEBPACK_IMPORTED_MODULE_2__); | ||
/* harmony import */ var rax_view__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3); | ||
/* harmony import */ var rax_view__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(rax_view__WEBPACK_IMPORTED_MODULE_3__); | ||
/* harmony import */ var rax_image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5); | ||
/* harmony import */ var rax_image__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(rax_image__WEBPACK_IMPORTED_MODULE_4__); | ||
/* harmony import */ var _index_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6); | ||
/* harmony import */ var _index_css__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_index_css__WEBPACK_IMPORTED_MODULE_5__); | ||
var _styleSheet = _index_css__WEBPACK_IMPORTED_MODULE_5___default.a; | ||
function isFunction(functionToCheck) { | ||
return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'; | ||
} | ||
; | ||
function addZero(num, timeWrapStyle, timeBackground, timeBackgroundStyle, timeStyle, secondStyle) { | ||
var displayNum = num < 0 ? 0 : num; | ||
var displayFirstNum = displayNum < 10 ? 0 : displayNum.toString().slice(0, 1); | ||
var displaySecondNum = displayNum < 10 ? displayNum : displayNum.toString().slice(1); | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_view__WEBPACK_IMPORTED_MODULE_3___default.a, { | ||
style: [_styleSheet["item"], timeWrapStyle] | ||
}, timeBackground ? Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_image__WEBPACK_IMPORTED_MODULE_4___default.a, { | ||
source: timeBackground, | ||
style: [_styleSheet["background"], timeBackgroundStyle] | ||
}) : null, Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_text__WEBPACK_IMPORTED_MODULE_2___default.a, { | ||
style: timeStyle | ||
}, '' + displayFirstNum), Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_text__WEBPACK_IMPORTED_MODULE_2___default.a, { | ||
style: secondStyle | ||
}, '' + displaySecondNum)); | ||
} | ||
; | ||
function Countdown(props) { | ||
var _this = this; | ||
var formatFunc = props.formatFunc, | ||
timeStyle = props.timeStyle, | ||
timeBackgroundStyle = props.timeBackgroundStyle, | ||
timeWrapStyle = props.timeWrapStyle, | ||
timeBackground = props.timeBackground, | ||
secondStyle = props.secondStyle, | ||
textStyle = props.textStyle, | ||
tpl = props.tpl; | ||
var _useState = Object(rax__WEBPACK_IMPORTED_MODULE_0__["useState"])(props.timeRemaining), | ||
timeRemaining = _useState[0], | ||
setTimeRemaining = _useState[1]; | ||
var timeoutId = 0; | ||
var tick = function tick() { | ||
var onComplete = props.onComplete, | ||
onTick = props.onTick, | ||
interval = props.interval; | ||
var countdownComplete = 1000 > timeRemaining; | ||
if (_this.timeoutId) { | ||
clearTimeout(_this.timeoutId); | ||
} | ||
if (countdownComplete && isFunction(onComplete)) { | ||
onComplete(); | ||
} else { | ||
timeoutId = !countdownComplete ? setTimeout(function () { | ||
setTimeRemaining(timeRemaining - interval); | ||
isFunction(onTick) && onTick(timeRemaining); | ||
}, interval) : false; | ||
} | ||
}; | ||
Object(rax__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () { | ||
tick(); | ||
}); | ||
Object(rax__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () { | ||
clearTimeout(_this.timeoutId); | ||
}, []); | ||
Object(rax__WEBPACK_IMPORTED_MODULE_0__["useMemo"])(function () { | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
setTimeRemaining(timeRemaining); | ||
}, [props.timeRemaining, timeRemaining]); | ||
if (formatFunc) { | ||
return formatFunc(timeRemaining); | ||
} | ||
var totalSeconds = Math.floor(timeRemaining / 1000); | ||
var days = parseInt(totalSeconds / 3600 / 24); | ||
var hours = parseInt(totalSeconds / 3600) % 24; | ||
var minutes = parseInt(totalSeconds / 60) % 60; | ||
var seconds = parseInt(totalSeconds % 60); | ||
var timeType = { | ||
'd': days, | ||
'h': hours, | ||
'm': minutes, | ||
's': seconds | ||
}; | ||
var rule = new RegExp('\{[d,h,m,s]\}', 'g'); // used to matched all template item, which includes 'd', 'h', 'm' and 's'. | ||
var matchlist = []; | ||
var tmp = null; | ||
while ((tmp = rule.exec(tpl)) !== null) { | ||
matchlist.push(tmp.index, tmp.index); | ||
} | ||
if (matchlist.length !== 0) { | ||
// used to detect the last element | ||
matchlist.push(-1); | ||
} | ||
var lastPlaintextIndex = 0; | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_view__WEBPACK_IMPORTED_MODULE_3___default.a, { | ||
style: _styleSheet["main"] | ||
}, matchlist.map(function (val, index) { | ||
if (val === -1) { | ||
// don't forget the potential plain text after last matched item | ||
var lastPlaintext = tpl.slice(lastPlaintextIndex); | ||
return lastPlaintext ? Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_text__WEBPACK_IMPORTED_MODULE_2___default.a, { | ||
style: textStyle | ||
}, lastPlaintext) : null; | ||
} | ||
var matchedCharacter = tpl[val + 1]; | ||
switch (matchedCharacter) { | ||
case 'd': | ||
case 'h': | ||
case 'm': | ||
case 's': | ||
if (index % 2 === 0) { | ||
// insert plain text before current matched item | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_text__WEBPACK_IMPORTED_MODULE_2___default.a, { | ||
style: textStyle | ||
}, tpl.slice(lastPlaintextIndex, val)); | ||
} else { | ||
// replace current matched item to realtime string | ||
lastPlaintextIndex = val + 3; | ||
return addZero(timeType[matchedCharacter], timeWrapStyle, timeBackground, timeBackgroundStyle, timeStyle, secondStyle); | ||
} | ||
default: | ||
return null; | ||
} | ||
})); | ||
} | ||
Countdown.defaultProps = { | ||
tpl: '{d}天{h}时{m}分{s}秒', | ||
timeRemaining: 0, | ||
interval: 1000 | ||
}; | ||
Countdown.propTypes = { | ||
formatFunc: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.func, | ||
onTick: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.func, | ||
onComplete: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.func, | ||
tpl: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.string, | ||
// template (example {h}:{m}:{s}) | ||
timeRemaining: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.number, | ||
secondStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
timeStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
// style for num | ||
textStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
// style for text | ||
timeWrapStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
timeBackground: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.string, | ||
timeBackgroundStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
interval: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.number | ||
}; | ||
/* harmony default export */ __webpack_exports__["default"] = (Countdown); | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var _styles = { | ||
"text": { | ||
"borderWidth": "0rem", | ||
"borderStyle": "solid", | ||
"borderColor": "black", | ||
"position": "relative", | ||
"boxSizing": "border-box", | ||
"display": "block", | ||
"flexDirection": "column", | ||
"alignContent": "flex-start", | ||
"flexShrink": 0, | ||
"fontSize": 32 | ||
}, | ||
"richtext": { | ||
"marginTop": 0, | ||
"marginBottom": 0 | ||
} | ||
}; | ||
if (false) {} | ||
module.exports = _styles; | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports) { | ||
var _styles = { | ||
"absoluteImage": { | ||
"left": 0, | ||
"top": 0, | ||
"position": "absolute" | ||
} | ||
}; | ||
module.exports = _styles; | ||
/***/ }) | ||
/******/ ])}};; | ||
//# sourceMappingURL=countdown.factory.map |
@@ -107,3 +107,3 @@ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ return __webpack_require__(__webpack_require__.s = 7); | ||
/******/ }) | ||
@@ -124,240 +124,48 @@ /************************************************************************/ | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.isReactNative = exports.isWeex = exports.isNode = exports.isWeb = void 0; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} // https://www.w3.org/TR/html5/webappapis.html#dom-navigator-appcodename | ||
var isWeb = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
exports.isWeb = isWeb; | ||
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node); | ||
exports.isNode = isNode; | ||
var isWeex = typeof callNative === 'function' || (typeof WXEnvironment === "undefined" ? "undefined" : _typeof(WXEnvironment)) === 'object' && WXEnvironment.platform !== 'Web'; | ||
exports.isWeex = isWeex; | ||
var isReactNative = typeof __fbBatchedBridgeConfig !== 'undefined'; | ||
exports.isReactNative = isReactNative; | ||
exports["default"] = module.exports; | ||
var _default = module.exports; | ||
exports.default = _default; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _rax = __webpack_require__(0); | ||
var _universalEnv = __webpack_require__(1); | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
/* | ||
* Current PropTypes only export some api with react, not validate in runtime. | ||
*/ | ||
function createChainableTypeChecker(validate) { | ||
function checkType(isRequired, props, propName, componentName, location, propFullName) { | ||
return typeChecker; | ||
} | ||
return _typeof(obj); | ||
var chainedCheckType = checkType.bind(null, false); | ||
chainedCheckType.isRequired = checkType.bind(null, true); | ||
return chainedCheckType; | ||
} | ||
function _extends() { | ||
_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; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
function createTypeChecker(expectedType) { | ||
function validate(props, propName, componentName, location, propFullName) {// Noop | ||
} | ||
return target; | ||
return createChainableTypeChecker(validate); | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
var View = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(View, _Component); | ||
function View() { | ||
_classCallCheck(this, View); | ||
return _possibleConstructorReturn(this, _getPrototypeOf(View).apply(this, arguments)); | ||
} | ||
_createClass(View, [{ | ||
key: "render", | ||
value: function render() { | ||
var props = this.props; | ||
if (_universalEnv.isWeex) { | ||
// TODO: do not pass object value in props | ||
return (0, _rax.createElement)("div", props); | ||
} else { | ||
var styleProps = _objectSpread({}, styles.initial, props.style); | ||
return (0, _rax.createElement)("div", _extends({}, props, { | ||
style: styleProps | ||
})); | ||
} | ||
} | ||
}]); | ||
return View; | ||
}(_rax.Component); | ||
_defineProperty(View, "propTypes", {}); | ||
var styles = { | ||
initial: { | ||
border: '0 solid black', | ||
position: 'relative', | ||
boxSizing: 'border-box', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignContent: 'flex-start', | ||
flexShrink: 0 | ||
} | ||
var typeChecker = createTypeChecker(); | ||
var _default = { | ||
array: typeChecker, | ||
bool: typeChecker, | ||
func: typeChecker, | ||
number: typeChecker, | ||
object: typeChecker, | ||
string: typeChecker, | ||
symbol: typeChecker, | ||
element: typeChecker, | ||
node: typeChecker, | ||
any: typeChecker, | ||
arrayOf: typeChecker, | ||
instanceOf: typeChecker, | ||
objectOf: typeChecker, | ||
oneOf: typeChecker, | ||
oneOfType: typeChecker, | ||
shape: typeChecker | ||
}; | ||
var _default = View; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 3 */ | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -375,8 +183,6 @@ | ||
var _raxText = _interopRequireDefault(__webpack_require__(4)); | ||
var _universalEnv = __webpack_require__(4); | ||
var _raxView = _interopRequireDefault(__webpack_require__(2)); | ||
var _index = _interopRequireDefault(__webpack_require__(8)); | ||
var _raxImage = _interopRequireDefault(__webpack_require__(5)); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -386,2 +192,6 @@ | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -405,399 +215,4 @@ | ||
function isFunction(functionToCheck) { | ||
return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'; | ||
} | ||
var _styleSheet = _index.default; | ||
; | ||
function addZero(num, timeWrapStyle, timeBackground, timeBackgroundStyle, timeStyle, secondStyle) { | ||
var displayNum = num < 0 ? 0 : num; | ||
var displayFirstNum = displayNum < 10 ? 0 : displayNum.toString().slice(0, 1); | ||
var displaySecondNum = displayNum < 10 ? displayNum : displayNum.toString().slice(1); | ||
return (0, _rax.createElement)(_raxView.default, { | ||
style: [timeWrapStyle, styles.item] | ||
}, timeBackground ? (0, _rax.createElement)(_raxImage.default, { | ||
source: timeBackground, | ||
style: timeBackgroundStyle | ||
}) : null, (0, _rax.createElement)(_raxText.default, { | ||
style: timeStyle | ||
}, '' + displayFirstNum), (0, _rax.createElement)(_raxText.default, { | ||
style: secondStyle | ||
}, '' + displaySecondNum)); | ||
} | ||
; | ||
var Index = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Index, _Component); | ||
function Index() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
_classCallCheck(this, Index); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Index)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
timeRemaining: 0 | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "timeoutId", 0); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "tick", function () { | ||
var _this$props = _this.props, | ||
onComplete = _this$props.onComplete, | ||
onTick = _this$props.onTick, | ||
interval = _this$props.interval; | ||
var timeRemaining = _this.state.timeRemaining; | ||
var countdownComplete = 1000 > timeRemaining; | ||
if (_this.timeoutId) { | ||
clearTimeout(_this.timeoutId); | ||
} | ||
if (countdownComplete && isFunction(onComplete)) { | ||
onComplete(); | ||
} else { | ||
_this.timeoutId = !countdownComplete ? setTimeout(function () { | ||
return _this.setState({ | ||
timeRemaining: timeRemaining - interval | ||
}, function () { | ||
return isFunction(onTick) && onTick(timeRemaining); | ||
}); | ||
}, interval) : false; | ||
} | ||
}); | ||
return _this; | ||
} | ||
_createClass(Index, [{ | ||
key: "componentWillMount", | ||
value: function componentWillMount() { | ||
var timeRemaining = this.props.timeRemaining; | ||
this.setState({ | ||
timeRemaining: timeRemaining | ||
}); | ||
} | ||
}, { | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
this.tick(); | ||
} | ||
}, { | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate() { | ||
this.tick(); | ||
} | ||
}, { | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(newProps) { | ||
if (newProps.timeRemaining !== this.props.timeRemaining) { | ||
if (this.timeoutId) { | ||
clearTimeout(this.timeoutId); | ||
} | ||
this.setState({ | ||
timeRemaining: newProps.timeRemaining | ||
}); | ||
} | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
if (this.timeoutId) { | ||
clearTimeout(this.timeoutId); | ||
} | ||
} | ||
}, { | ||
key: "shouldComponentUpdate", | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return this.props.timeRemaining !== nextProps.timeRemaining || this.state.timeRemaining !== nextState.timeRemaining; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var timeRemaining = this.state.timeRemaining; | ||
var _this$props2 = this.props, | ||
formatFunc = _this$props2.formatFunc, | ||
timeStyle = _this$props2.timeStyle, | ||
timeBackgroundStyle = _this$props2.timeBackgroundStyle, | ||
timeWrapStyle = _this$props2.timeWrapStyle, | ||
timeBackground = _this$props2.timeBackground, | ||
secondStyle = _this$props2.secondStyle, | ||
textStyle = _this$props2.textStyle, | ||
tpl = _this$props2.tpl; | ||
if (formatFunc) { | ||
return formatFunc(timeRemaining); | ||
} | ||
var totalSeconds = Math.floor(timeRemaining / 1000); | ||
var days = parseInt(totalSeconds / 3600 / 24); | ||
var hours = parseInt(totalSeconds / 3600) % 24; | ||
var minutes = parseInt(totalSeconds / 60) % 60; | ||
var seconds = parseInt(totalSeconds % 60); | ||
var _timeBackgroundStyle = [styles.background, timeBackgroundStyle]; | ||
var timeType = { | ||
'd': days, | ||
'h': hours, | ||
'm': minutes, | ||
's': seconds | ||
}; | ||
var rule = new RegExp('\{[d,h,m,s]\}', 'g'); // used to matched all template item, which includes 'd', 'h', 'm' and 's'. | ||
var matchlist = []; | ||
var tmp = null; | ||
while ((tmp = rule.exec(tpl)) !== null) { | ||
matchlist.push(tmp.index, tmp.index); | ||
} | ||
if (matchlist.length !== 0) { | ||
// used to detect the last element | ||
matchlist.push(-1); | ||
} | ||
var lastPlaintextIndex = 0; | ||
return (0, _rax.createElement)(_raxView.default, { | ||
style: styles.main | ||
}, matchlist.map(function (val, index) { | ||
if (val === -1) { | ||
// don't forget the potential plain text after last matched item | ||
var lastPlaintext = tpl.slice(lastPlaintextIndex); | ||
return lastPlaintext ? (0, _rax.createElement)(_raxText.default, { | ||
style: textStyle | ||
}, lastPlaintext) : null; | ||
} | ||
var matchedCharacter = tpl[val + 1]; | ||
switch (matchedCharacter) { | ||
case 'd': | ||
case 'h': | ||
case 'm': | ||
case 's': | ||
if (index % 2 === 0) { | ||
// insert plain text before current matched item | ||
return (0, _rax.createElement)(_raxText.default, { | ||
style: textStyle | ||
}, tpl.slice(lastPlaintextIndex, val)); | ||
} else { | ||
// replace current matched item to realtime string | ||
lastPlaintextIndex = val + 3; | ||
return addZero(timeType[matchedCharacter], timeWrapStyle, timeBackground, _timeBackgroundStyle, timeStyle, secondStyle); | ||
} | ||
default: | ||
return null; | ||
} | ||
})); | ||
} | ||
}]); | ||
return Index; | ||
}(_rax.Component); | ||
_defineProperty(Index, "propTypes", { | ||
formatFunc: _rax.PropTypes.func, | ||
onTick: _rax.PropTypes.func, | ||
onComplete: _rax.PropTypes.func, | ||
tpl: _rax.PropTypes.string, | ||
// template (example {h}:{m}:{s}) | ||
timeRemaining: _rax.PropTypes.number, | ||
secondStyle: _rax.PropTypes.object, | ||
timeStyle: _rax.PropTypes.object, | ||
// style for num | ||
textStyle: _rax.PropTypes.object, | ||
// style for text | ||
timeWrapStyle: _rax.PropTypes.object, | ||
timeBackground: _rax.PropTypes.string, | ||
timeBackgroundStyle: _rax.PropTypes.object, | ||
interval: _rax.PropTypes.number | ||
}); | ||
_defineProperty(Index, "defaultProps", { | ||
tpl: '{d}天{h}时{m}分{s}秒', | ||
timeRemaining: 0, | ||
interval: 1000 | ||
}); | ||
var styles = { | ||
main: { | ||
flexDirection: 'row', | ||
justifyContent: 'flex-start', | ||
alignItems: 'center' | ||
}, | ||
item: { | ||
flexDirection: 'row' | ||
}, | ||
background: { | ||
position: 'absolute' | ||
} | ||
}; | ||
var _default = Index; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _rax = __webpack_require__(0); | ||
var _universalEnv = __webpack_require__(1); | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _extends() { | ||
_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; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
} | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
var Text = | ||
@@ -856,3 +271,3 @@ /*#__PURE__*/ | ||
whiteSpace: 'pre-wrap' | ||
}, styles.text, nativeProps.style); | ||
}, nativeProps.style); | ||
@@ -874,3 +289,3 @@ var numberOfLines = props.numberOfLines; | ||
return (0, _rax.createElement)("span", _extends({}, nativeProps, { | ||
style: styleProps | ||
style: [_styleSheet["text"], styleProps] | ||
}), textString); | ||
@@ -888,4 +303,2 @@ } | ||
var styleProps = _objectSpread({}, styles.richtext, nativeProps.style); | ||
if (_universalEnv.isWeex) { | ||
@@ -896,3 +309,3 @@ children = transformChildren(children, _assertThisInitialized(_assertThisInitialized(_this))); | ||
return (0, _rax.createElement)("p", _extends({}, nativeProps, { | ||
style: styleProps | ||
style: _styleSheet["richtext"] | ||
}), children); | ||
@@ -989,24 +402,49 @@ }); | ||
var _default = Text; | ||
exports.default = _default; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _rax = __webpack_require__(0); | ||
var _universalEnv = __webpack_require__(4); | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
var _default = function _default(props) { | ||
if (_universalEnv.isWeex) { | ||
// TODO: do not pass object value in props | ||
return (0, _rax.createElement)("div", props); | ||
} else { | ||
var styleProps = _extends({}, styles.initial, props.style); | ||
return (0, _rax.createElement)("div", _extends({}, props, { | ||
style: styleProps | ||
})); | ||
} | ||
}; | ||
exports.default = _default; | ||
var styles = { | ||
text: { | ||
initial: { | ||
border: '0 solid black', | ||
position: 'relative', | ||
boxSizing: 'border-box', | ||
display: 'block', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignContent: 'flex-start', | ||
flexShrink: 0, | ||
fontSize: 32 | ||
}, | ||
richtext: { | ||
marginTop: 0, | ||
marginBottom: 0 | ||
flexShrink: 0 | ||
} | ||
}; | ||
var _default = Text; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 5 */ | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1017,156 +455,70 @@ | ||
function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.default = exports.isReactNative = exports.isWeex = exports.isNode = exports.isWeb = void 0; | ||
var _rax = __webpack_require__(0); | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _universalEnv = __webpack_require__(1); | ||
// https://www.w3.org/TR/html5/webappapis.html#dom-navigator-appcodename | ||
var isWeb = (typeof navigator === "undefined" ? "undefined" : _typeof(navigator)) === 'object' && (navigator.appCodeName === 'Mozilla' || navigator.product === 'Gecko'); | ||
exports.isWeb = isWeb; | ||
var isNode = typeof process !== 'undefined' && !!(process.versions && process.versions.node); | ||
exports.isNode = isNode; | ||
var isWeex = typeof callNative === 'function' || (typeof WXEnvironment === "undefined" ? "undefined" : _typeof(WXEnvironment)) === 'object' && WXEnvironment.platform !== 'Web'; | ||
exports.isWeex = isWeex; | ||
var isReactNative = typeof __fbBatchedBridgeConfig !== 'undefined'; | ||
exports.isReactNative = isReactNative; | ||
exports["default"] = module.exports; | ||
var _default = module.exports; | ||
exports.default = _default; | ||
var _raxView = _interopRequireDefault(__webpack_require__(2)); | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
"use strict"; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { | ||
_typeof = function _typeof(obj) { | ||
return _typeof2(obj); | ||
}; | ||
} else { | ||
_typeof = function _typeof(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
function _extends() { | ||
_extends = Object.assign || function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
var _rax = __webpack_require__(0); | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
var _universalEnv = __webpack_require__(4); | ||
return target; | ||
}; | ||
var _raxView = _interopRequireDefault(__webpack_require__(3)); | ||
return _extends.apply(this, arguments); | ||
} | ||
var _index = _interopRequireDefault(__webpack_require__(9)); | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
if (typeof Object.getOwnPropertySymbols === 'function') { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
ownKeys.forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
function _extends() { _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; }; return _extends.apply(this, arguments); } | ||
return target; | ||
} | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
} | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
} | ||
} | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { | ||
if (call && (_typeof(call) === "object" || typeof call === "function")) { | ||
return call; | ||
} | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
return _assertThisInitialized(self); | ||
} | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
}; | ||
return _getPrototypeOf(o); | ||
} | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _inherits(subClass, superClass) { | ||
if (typeof superClass !== "function" && superClass !== null) { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
constructor: { | ||
value: subClass, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
} | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
return _setPrototypeOf(o, p); | ||
} | ||
var _styleSheet = _index.default; | ||
function _assertThisInitialized(self) { | ||
if (self === void 0) { | ||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); | ||
} | ||
return self; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
var Image = | ||
@@ -1218,2 +570,4 @@ /*#__PURE__*/ | ||
if (fallbackSource.uri && source.uri !== fallbackSource.uri) { | ||
_this.isError = true; | ||
_this.setState({ | ||
@@ -1241,3 +595,3 @@ source: fallbackSource | ||
var source = this.state.source; // Source must a object | ||
var source = this.isError ? this.state.source : nativeProps.source; // Source must a object | ||
@@ -1292,3 +646,3 @@ if (source && source.uri) { | ||
}, nativeProps)), (0, _rax.createElement)(_raxView.default, { | ||
style: styles.absoluteImage | ||
style: _styleSheet["absoluteImage"] | ||
}, this.props.children)); | ||
@@ -1329,15 +683,268 @@ } else { | ||
var styles = { | ||
absoluteImage: { | ||
left: 0, | ||
top: 0, | ||
position: 'absolute' | ||
} | ||
}; | ||
var _default = Image; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports) { | ||
var _styles = { | ||
"main": { | ||
"flexDirection": "row", | ||
"justifyContent": "flex-start", | ||
"alignItems": "center" | ||
}, | ||
"item": { | ||
"flexDirection": "row" | ||
}, | ||
"background": { | ||
"position": "absolute" | ||
} | ||
}; | ||
module.exports = _styles; | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
__webpack_require__.r(__webpack_exports__); | ||
/* harmony import */ var rax__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); | ||
/* harmony import */ var rax__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rax__WEBPACK_IMPORTED_MODULE_0__); | ||
/* harmony import */ var rax_proptypes__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1); | ||
/* harmony import */ var rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(rax_proptypes__WEBPACK_IMPORTED_MODULE_1__); | ||
/* harmony import */ var rax_text__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2); | ||
/* harmony import */ var rax_text__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(rax_text__WEBPACK_IMPORTED_MODULE_2__); | ||
/* harmony import */ var rax_view__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3); | ||
/* harmony import */ var rax_view__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(rax_view__WEBPACK_IMPORTED_MODULE_3__); | ||
/* harmony import */ var rax_image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5); | ||
/* harmony import */ var rax_image__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(rax_image__WEBPACK_IMPORTED_MODULE_4__); | ||
/* harmony import */ var _index_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6); | ||
/* harmony import */ var _index_css__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_index_css__WEBPACK_IMPORTED_MODULE_5__); | ||
var _styleSheet = _index_css__WEBPACK_IMPORTED_MODULE_5___default.a; | ||
function isFunction(functionToCheck) { | ||
return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'; | ||
} | ||
; | ||
function addZero(num, timeWrapStyle, timeBackground, timeBackgroundStyle, timeStyle, secondStyle) { | ||
var displayNum = num < 0 ? 0 : num; | ||
var displayFirstNum = displayNum < 10 ? 0 : displayNum.toString().slice(0, 1); | ||
var displaySecondNum = displayNum < 10 ? displayNum : displayNum.toString().slice(1); | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_view__WEBPACK_IMPORTED_MODULE_3___default.a, { | ||
style: [_styleSheet["item"], timeWrapStyle] | ||
}, timeBackground ? Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_image__WEBPACK_IMPORTED_MODULE_4___default.a, { | ||
source: timeBackground, | ||
style: [_styleSheet["background"], timeBackgroundStyle] | ||
}) : null, Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_text__WEBPACK_IMPORTED_MODULE_2___default.a, { | ||
style: timeStyle | ||
}, '' + displayFirstNum), Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_text__WEBPACK_IMPORTED_MODULE_2___default.a, { | ||
style: secondStyle | ||
}, '' + displaySecondNum)); | ||
} | ||
; | ||
function Countdown(props) { | ||
var _this = this; | ||
var formatFunc = props.formatFunc, | ||
timeStyle = props.timeStyle, | ||
timeBackgroundStyle = props.timeBackgroundStyle, | ||
timeWrapStyle = props.timeWrapStyle, | ||
timeBackground = props.timeBackground, | ||
secondStyle = props.secondStyle, | ||
textStyle = props.textStyle, | ||
tpl = props.tpl; | ||
var _useState = Object(rax__WEBPACK_IMPORTED_MODULE_0__["useState"])(props.timeRemaining), | ||
timeRemaining = _useState[0], | ||
setTimeRemaining = _useState[1]; | ||
var timeoutId = 0; | ||
var tick = function tick() { | ||
var onComplete = props.onComplete, | ||
onTick = props.onTick, | ||
interval = props.interval; | ||
var countdownComplete = 1000 > timeRemaining; | ||
if (_this.timeoutId) { | ||
clearTimeout(_this.timeoutId); | ||
} | ||
if (countdownComplete && isFunction(onComplete)) { | ||
onComplete(); | ||
} else { | ||
timeoutId = !countdownComplete ? setTimeout(function () { | ||
setTimeRemaining(timeRemaining - interval); | ||
isFunction(onTick) && onTick(timeRemaining); | ||
}, interval) : false; | ||
} | ||
}; | ||
Object(rax__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () { | ||
tick(); | ||
}); | ||
Object(rax__WEBPACK_IMPORTED_MODULE_0__["useEffect"])(function () { | ||
clearTimeout(_this.timeoutId); | ||
}, []); | ||
Object(rax__WEBPACK_IMPORTED_MODULE_0__["useMemo"])(function () { | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
setTimeRemaining(timeRemaining); | ||
}, [props.timeRemaining, timeRemaining]); | ||
if (formatFunc) { | ||
return formatFunc(timeRemaining); | ||
} | ||
var totalSeconds = Math.floor(timeRemaining / 1000); | ||
var days = parseInt(totalSeconds / 3600 / 24); | ||
var hours = parseInt(totalSeconds / 3600) % 24; | ||
var minutes = parseInt(totalSeconds / 60) % 60; | ||
var seconds = parseInt(totalSeconds % 60); | ||
var timeType = { | ||
'd': days, | ||
'h': hours, | ||
'm': minutes, | ||
's': seconds | ||
}; | ||
var rule = new RegExp('\{[d,h,m,s]\}', 'g'); // used to matched all template item, which includes 'd', 'h', 'm' and 's'. | ||
var matchlist = []; | ||
var tmp = null; | ||
while ((tmp = rule.exec(tpl)) !== null) { | ||
matchlist.push(tmp.index, tmp.index); | ||
} | ||
if (matchlist.length !== 0) { | ||
// used to detect the last element | ||
matchlist.push(-1); | ||
} | ||
var lastPlaintextIndex = 0; | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_view__WEBPACK_IMPORTED_MODULE_3___default.a, { | ||
style: _styleSheet["main"] | ||
}, matchlist.map(function (val, index) { | ||
if (val === -1) { | ||
// don't forget the potential plain text after last matched item | ||
var lastPlaintext = tpl.slice(lastPlaintextIndex); | ||
return lastPlaintext ? Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_text__WEBPACK_IMPORTED_MODULE_2___default.a, { | ||
style: textStyle | ||
}, lastPlaintext) : null; | ||
} | ||
var matchedCharacter = tpl[val + 1]; | ||
switch (matchedCharacter) { | ||
case 'd': | ||
case 'h': | ||
case 'm': | ||
case 's': | ||
if (index % 2 === 0) { | ||
// insert plain text before current matched item | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])(rax_text__WEBPACK_IMPORTED_MODULE_2___default.a, { | ||
style: textStyle | ||
}, tpl.slice(lastPlaintextIndex, val)); | ||
} else { | ||
// replace current matched item to realtime string | ||
lastPlaintextIndex = val + 3; | ||
return addZero(timeType[matchedCharacter], timeWrapStyle, timeBackground, timeBackgroundStyle, timeStyle, secondStyle); | ||
} | ||
default: | ||
return null; | ||
} | ||
})); | ||
} | ||
Countdown.defaultProps = { | ||
tpl: '{d}天{h}时{m}分{s}秒', | ||
timeRemaining: 0, | ||
interval: 1000 | ||
}; | ||
Countdown.propTypes = { | ||
formatFunc: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.func, | ||
onTick: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.func, | ||
onComplete: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.func, | ||
tpl: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.string, | ||
// template (example {h}:{m}:{s}) | ||
timeRemaining: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.number, | ||
secondStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
timeStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
// style for num | ||
textStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
// style for text | ||
timeWrapStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
timeBackground: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.string, | ||
timeBackgroundStyle: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.object, | ||
interval: rax_proptypes__WEBPACK_IMPORTED_MODULE_1___default.a.number | ||
}; | ||
/* harmony default export */ __webpack_exports__["default"] = (Countdown); | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var _styles = { | ||
"text": { | ||
"borderWidth": "0rem", | ||
"borderStyle": "solid", | ||
"borderColor": "black", | ||
"position": "relative", | ||
"boxSizing": "border-box", | ||
"display": "block", | ||
"flexDirection": "column", | ||
"alignContent": "flex-start", | ||
"flexShrink": 0, | ||
"fontSize": 32 | ||
}, | ||
"richtext": { | ||
"marginTop": 0, | ||
"marginBottom": 0 | ||
} | ||
}; | ||
if (false) {} | ||
module.exports = _styles; | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports) { | ||
var _styles = { | ||
"absoluteImage": { | ||
"left": 0, | ||
"top": 0, | ||
"position": "absolute" | ||
} | ||
}; | ||
module.exports = _styles; | ||
/***/ }) | ||
/******/ ])});; | ||
//# sourceMappingURL=countdown.map |
@@ -1,2 +0,2 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define)define("rax-countdown",function(t,n,r){r.exports=e()});else{("undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:this).RaxCountdown=e()}}(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=function(){var e;if(!e)try{e=require("rax")}catch(e){}return e}()},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return(o="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.isReactNative=t.isWeex=t.isNode=t.isWeb=void 0;var i="object"===("undefined"==typeof navigator?"undefined":o(navigator))&&("Mozilla"===navigator.appCodeName||"Gecko"===navigator.product);t.isWeb=i;var u="undefined"!=typeof process&&!(!process.versions||!process.versions.node);t.isNode=u;var c="function"==typeof callNative||"object"===("undefined"==typeof WXEnvironment?"undefined":o(WXEnvironment))&&"Web"!==WXEnvironment.platform;t.isWeex=c;var l="undefined"!=typeof __fbBatchedBridgeConfig;t.isReactNative=l,t.default=e.exports;var a=e.exports;t.default=a},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=n(0),i=n(1);function u(e){return(u="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)})(e)}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var y=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),a(this,f(t).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,o.Component),function(e,t,n){t&&l(e.prototype,t),n&&l(e,n)}(t,[{key:"render",value:function(){var e=this.props;if(i.isWeex)return(0,o.createElement)("div",e);var t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){p(e,t,n[t])})}return e}({},b.initial,e.style);return(0,o.createElement)("div",c({},e,{style:t}))}}]),t}();p(y,"propTypes",{});var b={initial:{border:"0 solid black",position:"relative",boxSizing:"border-box",display:"flex",flexDirection:"column",alignContent:"flex-start",flexShrink:0}},m=y;t.default=m,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(0),o=c(n(4)),i=c(n(2)),u=c(n(5));function c(e){return e&&e.__esModule?e:{default:e}}function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b(e){return e&&"[object Function]"==={}.toString.call(e)}var m=function(e){function t(){var e,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return y(p(p(n=function(e,t){return!t||"object"!==l(t)&&"function"!=typeof t?p(e):t}(this,(e=f(t)).call.apply(e,[this].concat(o))))),"state",{timeRemaining:0}),y(p(p(n)),"timeoutId",0),y(p(p(n)),"tick",function(){var e=n.props,t=e.onComplete,r=e.onTick,o=e.interval,i=n.state.timeRemaining,u=1e3>i;n.timeoutId&&clearTimeout(n.timeoutId),u&&b(t)?t():n.timeoutId=!u&&setTimeout(function(){return n.setState({timeRemaining:i-o},function(){return b(r)&&r(i)})},o)}),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,r.Component),function(e,t,n){t&&a(e.prototype,t),n&&a(e,n)}(t,[{key:"componentWillMount",value:function(){var e=this.props.timeRemaining;this.setState({timeRemaining:e})}},{key:"componentDidMount",value:function(){this.tick()}},{key:"componentDidUpdate",value:function(){this.tick()}},{key:"componentWillReceiveProps",value:function(e){e.timeRemaining!==this.props.timeRemaining&&(this.timeoutId&&clearTimeout(this.timeoutId),this.setState({timeRemaining:e.timeRemaining}))}},{key:"componentWillUnmount",value:function(){this.timeoutId&&clearTimeout(this.timeoutId)}},{key:"shouldComponentUpdate",value:function(e,t){return this.props.timeRemaining!==e.timeRemaining||this.state.timeRemaining!==t.timeRemaining}},{key:"render",value:function(){var e=this.state.timeRemaining,t=this.props,n=t.formatFunc,c=t.timeStyle,l=t.timeBackgroundStyle,a=t.timeWrapStyle,f=t.timeBackground,s=t.secondStyle,p=t.textStyle,y=t.tpl;if(n)return n(e);for(var b=Math.floor(e/1e3),m=parseInt(b/3600/24),v=parseInt(b/3600)%24,h=parseInt(b/60)%60,g=parseInt(b%60),O=[d.background,l],S={d:m,h:v,m:h,s:g},j=new RegExp("{[d,h,m,s]}","g"),x=[],w=null;null!==(w=j.exec(y));)x.push(w.index,w.index);0!==x.length&&x.push(-1);var P=0;return(0,r.createElement)(i.default,{style:d.main},x.map(function(e,t){if(-1===e){var n=y.slice(P);return n?(0,r.createElement)(o.default,{style:p},n):null}var l=y[e+1];switch(l){case"d":case"h":case"m":case"s":return t%2==0?(0,r.createElement)(o.default,{style:p},y.slice(P,e)):(P=e+3,function(e,t,n,c,l,a){var f=e<0?0:e,s=f<10?0:f.toString().slice(0,1),p=f<10?f:f.toString().slice(1);return(0,r.createElement)(i.default,{style:[t,d.item]},n?(0,r.createElement)(u.default,{source:n,style:c}):null,(0,r.createElement)(o.default,{style:l},""+s),(0,r.createElement)(o.default,{style:a},""+p))}(S[l],a,f,O,c,s));default:return null}}))}}]),t}();y(m,"propTypes",{formatFunc:r.PropTypes.func,onTick:r.PropTypes.func,onComplete:r.PropTypes.func,tpl:r.PropTypes.string,timeRemaining:r.PropTypes.number,secondStyle:r.PropTypes.object,timeStyle:r.PropTypes.object,textStyle:r.PropTypes.object,timeWrapStyle:r.PropTypes.object,timeBackground:r.PropTypes.string,timeBackgroundStyle:r.PropTypes.object,interval:r.PropTypes.number}),y(m,"defaultProps",{tpl:"{d}天{h}时{m}分{s}秒",timeRemaining:0,interval:1e3});var d={main:{flexDirection:"row",justifyContent:"flex-start",alignItems:"center"},item:{flexDirection:"row"},background:{position:"absolute"}},v=m;t.default=v,e.exports=t.default},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=n(0),i=n(1);function u(e){return(u="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)})(e)}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){y(e,t,n[t])})}return e}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var b=function(e){function t(){var e,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var r=arguments.length,a=new Array(r),s=0;s<r;s++)a[s]=arguments[s];return y(p(p(n=function(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?p(e):t}(this,(e=f(t)).call.apply(e,[this].concat(a))))),"renderText",function(){var e=n.props,t=l({},e,{style:e.style||{}}),r="";if(null!=e.children&&(r=Array.isArray(e.children)?e.children.join(""):e.children.toString()),n.context.isInAParentText)return(0,o.createElement)("span",t,r);if(e.onPress&&(t.onClick=e.onPress),i.isWeex)return e.numberOfLines&&(t.style.lines=e.numberOfLines),t.value=r,(0,o.createElement)("text",t);var u=l({whiteSpace:"pre-wrap"},v.text,t.style),a=e.numberOfLines;return a&&(1===parseInt(a)?u.whiteSpace="nowrap":(u.display="-webkit-box",u.webkitBoxOrient="vertical",u.webkitLineClamp=String(a)),u.overflow="hidden"),(0,o.createElement)("span",c({},t,{style:u}),r)}),y(p(p(n)),"renderRichText",function(){var e=n.props,t=e.children,r=l({},e,{style:e.style||{}}),u=l({},v.richtext,r.style);return i.isWeex&&(t=d(t,p(p(n)))),(0,o.createElement)("p",c({},r,{style:u}),t)}),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(t,o.Component),function(e,t,n){t&&a(e.prototype,t),n&&a(e,n)}(t,[{key:"getChildContext",value:function(){return{isInAParentText:!0}}},{key:"render",value:function(){var e=this.props.children;Array.isArray(e)||(e=[e]);for(var t=!1,n=0;n<e.length;n++){var r=e[n];if(r&&"object"===u(r)){t=!0;break}}return t?this.renderRichText():this.renderText()}}]),t}();function m(e,t){var n=e.type,r=e.props,o=r.children;if("function"==typeof n){var i=new n;return i.props=r,o&&(i.props.children=d(o,t)),i.context=t.getChildContext(),i.render()}return e}function d(e,t){var n=[];Array.isArray(e)||(e=[e]);for(var r=0;r<e.length;r++){var o=e[r];"string"==typeof o?n.push(o):"object"===u(o)&&n.push(m(o,t))}return n}y(b,"propTypes",{}),y(b,"contextTypes",{isInAParentText:o.PropTypes.bool}),y(b,"childContextTypes",{isInAParentText:o.PropTypes.bool});var v={text:{border:"0 solid black",position:"relative",boxSizing:"border-box",display:"block",flexDirection:"column",alignContent:"flex-start",flexShrink:0,fontSize:32},richtext:{marginTop:0,marginBottom:0}},h=b;t.default=h,e.exports=t.default},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=n(0),i=n(1),u=function(e){return e&&e.__esModule?e:{default:e}}(n(2));function c(e){return(c="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)})(e)}function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){b(e,t,n[t])})}return e}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=function(e){function t(){var e,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return b(y(y(n=function(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?y(e):t}(this,(e=s(t)).call.apply(e,[this].concat(o))))),"state",{source:n.props.source}),b(y(y(n)),"onLoad",function(e){var t=y(y(n)).onError,r=n.props.onLoad;void 0!==e.success?e.success?r(e):t(e):void 0!==e.currentTarget&&(e.currentTarget.naturalWidth>1&&e.currentTarget.naturalHeight>1?r(e):t(e))}),b(y(y(n)),"onError",function(e){var t=n.props,r=t.fallbackSource,o=t.onError,i=n.state.source;r.uri&&i.uri!==r.uri&&n.setState({source:r}),o(e)}),b(y(y(n)),"save",function(e){n.refs.nativeImg.save(function(t){e(t)})}),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&p(e,t)}(t,o.PureComponent),function(e,t,n){t&&f(e.prototype,t),n&&f(e,n)}(t,[{key:"render",value:function(){var e=a({},this.props),t=this.state.source;if(t&&t.uri){var n,r=e.style,c=t.width,f=t.height,s=t.uri;null==c&&null==f&&null==r.height&&null==r.width&&(c=0,f=0),e.style=a({},a({},!this.context.isInAParentText&&{display:"flex"},{width:c,height:f}),r),e.src=s,e.onLoad=this.onLoad,e.onError=this.onError,delete e.source,n=i.isWeex?"image":"img";var p=e.resizeMode||e.style.resizeMode;return p&&(i.isWeex?(e.resize=p,e.style.resizeMode=p):e.style.objectFit=p),this.props.children?(e.children=null,(0,o.createElement)(u.default,{style:e.style},(0,o.createElement)(n,l({ref:"nativeImg"},e)),(0,o.createElement)(u.default,{style:d.absoluteImage},this.props.children))):(0,o.createElement)(n,l({ref:"nativeImg"},e))}return null}}]),t}();b(m,"propTypes",{}),b(m,"resizeMode",{contain:"contain",cover:"cover",stretch:"stretch",center:"center",repeat:"repeat"}),b(m,"contextTypes",{isInAParentText:o.PropTypes.bool}),b(m,"defaultProps",{onLoad:function(){},onError:function(){},fallbackSource:{}});var d={absoluteImage:{left:0,top:0,position:"absolute"}},v=m;t.default=v,e.exports=t.default}])}); | ||
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define)define("rax-countdown",function(e,t,n){n.exports=r()});else{("undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:this).RaxCountdown=r()}}(function(){return function(n){var r={};function o(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}return o.m=n,o.c=r,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=7)}([function(e,t){e.exports=function(){var e;if(!e)try{e=require("rax")}catch(e){}return e}()},function(e,t,n){"use strict";t.__esModule=!0,t.default=void 0;var a=function(e){function t(e,t,n,r,o,i){return a}var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}(),r={array:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,element:a,node:a,any:a,arrayOf:a,instanceOf:a,objectOf:a,oneOf:a,oneOfType:a,shape:a};t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,c=n(0),l=n(4);function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function p(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(e){b(t,e,n[e])})}return t}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=((r=n(8))&&r.__esModule?r:{default:r}).default,a=function(e){function u(){var e,i,t,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return t=this,n=(e=y(u)).call.apply(e,[this].concat(o)),b(d(d(i=!n||"object"!==s(n)&&"function"!=typeof n?d(t):n)),"renderText",function(){var e=i.props,t=p({},e,{style:e.style||{}}),n="";if(null!=e.children&&(n=Array.isArray(e.children)?e.children.join(""):e.children.toString()),i.context.isInAParentText)return(0,c.createElement)("span",t,n);if(e.onPress&&(t.onClick=e.onPress),l.isWeex)return e.numberOfLines&&(t.style.lines=e.numberOfLines),t.value=n,(0,c.createElement)("text",t);var r=p({whiteSpace:"pre-wrap"},t.style),o=e.numberOfLines;return o&&(1===parseInt(o)?r.whiteSpace="nowrap":(r.display="-webkit-box",r.webkitBoxOrient="vertical",r.webkitLineClamp=String(o)),r.overflow="hidden"),(0,c.createElement)("span",f({},t,{style:[m.text,r]}),n)}),b(d(d(i)),"renderRichText",function(){var e=i.props,t=e.children,n=p({},e,{style:e.style||{}});return l.isWeex&&(t=v(t,d(d(i)))),(0,c.createElement)("p",f({},n,{style:m.richtext}),t)}),i}var t,n,r;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(u,c.Component),t=u,(n=[{key:"getChildContext",value:function(){return{isInAParentText:!0}}},{key:"render",value:function(){var e=this.props.children;Array.isArray(e)||(e=[e]);for(var t=!1,n=0;n<e.length;n++){var r=e[n];if(r&&"object"===s(r)){t=!0;break}}return t?this.renderRichText():this.renderText()}}])&&o(t.prototype,n),r&&o(t,r),u}();function u(e,t){var n=e.type,r=e.props,o=r.children;if("function"!=typeof n)return e;var i=new n;return i.props=r,o&&(i.props.children=v(o,t)),i.context=t.getChildContext(),i.render()}function v(e,t){var n=[];Array.isArray(e)||(e=[e]);for(var r=0;r<e.length;r++){var o=e[r];"string"==typeof o?n.push(o):"object"===s(o)&&n.push(u(o,t))}return n}b(a,"propTypes",{}),b(a,"contextTypes",{isInAParentText:c.PropTypes.bool}),b(a,"childContextTypes",{isInAParentText:c.PropTypes.bool});var h=a;t.default=h},function(e,t,n){"use strict";t.__esModule=!0,t.default=void 0;var r=n(0),o=n(4);function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}t.default=function(e){if(o.isWeex)return(0,r.createElement)("div",e);var t=i({},a.initial,e.style);return(0,r.createElement)("div",i({},e,{style:t}))};var a={initial:{border:"0 solid black",position:"relative",boxSizing:"border-box",display:"flex",flexDirection:"column",alignContent:"flex-start",flexShrink:0}}},function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.isReactNative=t.isWeex=t.isNode=t.isWeb=void 0;var o="object"===("undefined"==typeof navigator?"undefined":r(navigator))&&("Mozilla"===navigator.appCodeName||"Gecko"===navigator.product);t.isWeb=o;var i="undefined"!=typeof process&&!(!process.versions||!process.versions.node);t.isNode=i;var a="function"==typeof callNative||"object"===("undefined"==typeof WXEnvironment?"undefined":r(WXEnvironment))&&"Web"!==WXEnvironment.platform;t.isWeex=a;var u="undefined"!=typeof __fbBatchedBridgeConfig;t.isReactNative=u,t.default=e.exports;var c=e.exports;t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var c=n(0),l=n(4),s=r(n(3));function r(e){return e&&e.__esModule?e:{default:e}}function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function y(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(e){m(t,e,n[e])})}return t}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function b(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var v=r(n(9)).default,a=function(e){function u(){var e,i,t,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u);for(var r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return t=this,n=(e=d(u)).call.apply(e,[this].concat(o)),m(b(b(i=!n||"object"!==f(n)&&"function"!=typeof n?b(t):n)),"state",{source:i.props.source}),m(b(b(i)),"onLoad",function(e){var t=b(b(i)).onError,n=i.props.onLoad;void 0!==e.success?e.success?n(e):t(e):void 0!==e.currentTarget&&(1<e.currentTarget.naturalWidth&&1<e.currentTarget.naturalHeight?n(e):t(e))}),m(b(b(i)),"onError",function(e){var t=i.props,n=t.fallbackSource,r=t.onError,o=i.state.source;n.uri&&o.uri!==n.uri&&(i.isError=!0,i.setState({source:n})),r(e)}),m(b(b(i)),"save",function(t){i.refs.nativeImg.save(function(e){t(e)})}),i}var t,n,r;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(u,c.PureComponent),t=u,(n=[{key:"render",value:function(){var e=y({},this.props),t=this.isError?this.state.source:e.source;if(t&&t.uri){var n,r=e.style,o=t.width,i=t.height,a=t.uri;null==o&&null==i&&null==r.height&&null==r.width&&(i=o=0),e.style=y({},y({},!this.context.isInAParentText&&{display:"flex"},{width:o,height:i}),r),e.src=a,e.onLoad=this.onLoad,e.onError=this.onError,delete e.source,n=l.isWeex?"image":"img";var u=e.resizeMode||e.style.resizeMode;return u&&(l.isWeex?(e.resize=u,e.style.resizeMode=u):e.style.objectFit=u),this.props.children?(e.children=null,(0,c.createElement)(s.default,{style:e.style},(0,c.createElement)(n,p({ref:"nativeImg"},e)),(0,c.createElement)(s.default,{style:v.absoluteImage},this.props.children))):(0,c.createElement)(n,p({ref:"nativeImg"},e))}return null}}])&&o(t.prototype,n),r&&o(t,r),u}();m(a,"propTypes",{}),m(a,"resizeMode",{contain:"contain",cover:"cover",stretch:"stretch",center:"center",repeat:"repeat"}),m(a,"contextTypes",{isInAParentText:c.PropTypes.bool}),m(a,"defaultProps",{onLoad:function(){},onError:function(){},fallbackSource:{}});var u=a;t.default=u},function(e,t){e.exports={main:{flexDirection:"row",justifyContent:"flex-start",alignItems:"center"},item:{flexDirection:"row"},background:{position:"absolute"}}},function(e,t,n){"use strict";n.r(t);var j=n(0),r=n(1),o=n.n(r),i=n(2),S=n.n(i),a=n(3),w=n.n(a),u=n(5),P=n.n(u),c=n(6),E=n.n(c).a;function f(e){return e&&"[object Function]"==={}.toString.call(e)}function l(o){var i=this,e=o.formatFunc,y=o.timeStyle,d=o.timeBackgroundStyle,b=o.timeWrapStyle,m=o.timeBackground,v=o.secondStyle,h=o.textStyle,g=o.tpl,t=Object(j.useState)(o.timeRemaining),a=t[0],u=t[1],c=0;if(Object(j.useEffect)(function(){var e,t,n,r;e=o.onComplete,t=o.onTick,n=o.interval,r=a<1e3,i.timeoutId&&clearTimeout(i.timeoutId),r&&f(e)?e():c=!r&&setTimeout(function(){u(a-n),f(t)&&t(a)},n)}),Object(j.useEffect)(function(){clearTimeout(i.timeoutId)},[]),Object(j.useMemo)(function(){c&&clearTimeout(c),u(a)},[o.timeRemaining,a]),e)return e(a);for(var n=Math.floor(a/1e3),O={d:parseInt(n/3600/24),h:parseInt(n/3600)%24,m:parseInt(n/60)%60,s:parseInt(n%60)},r=new RegExp("{[d,h,m,s]}","g"),l=[],s=null;null!==(s=r.exec(g));)l.push(s.index,s.index);0!==l.length&&l.push(-1);var x=0;return Object(j.createElement)(w.a,{style:E.main},l.map(function(e,t){if(-1===e){var n=g.slice(x);return n?Object(j.createElement)(S.a,{style:h},n):null}var r,o,i,a,u,c,l,s,f,p=g[e+1];switch(p){case"d":case"h":case"m":case"s":return t%2==0?Object(j.createElement)(S.a,{style:h},g.slice(x,e)):(x=e+3,o=b,i=m,a=d,u=y,c=v,s=(l=(r=O[p])<0?0:r)<10?0:l.toString().slice(0,1),f=l<10?l:l.toString().slice(1),Object(j.createElement)(w.a,{style:[E.item,o]},i?Object(j.createElement)(P.a,{source:i,style:[E.background,a]}):null,Object(j.createElement)(S.a,{style:u},""+s),Object(j.createElement)(S.a,{style:c},""+f)));default:return null}}))}l.defaultProps={tpl:"{d}天{h}时{m}分{s}秒",timeRemaining:0,interval:1e3},l.propTypes={formatFunc:o.a.func,onTick:o.a.func,onComplete:o.a.func,tpl:o.a.string,timeRemaining:o.a.number,secondStyle:o.a.object,timeStyle:o.a.object,textStyle:o.a.object,timeWrapStyle:o.a.object,timeBackground:o.a.string,timeBackgroundStyle:o.a.object,interval:o.a.number},t.default=l},function(e,t,n){e.exports={text:{borderWidth:"0rem",borderStyle:"solid",borderColor:"black",position:"relative",boxSizing:"border-box",display:"block",flexDirection:"column",alignContent:"flex-start",flexShrink:0,fontSize:32},richtext:{marginTop:0,marginBottom:0}}},function(e,t){e.exports={absoluteImage:{left:0,top:0,position:"absolute"}}}])}); | ||
//# sourceMappingURL=countdown.min.map |
338
lib/index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
@@ -10,2 +8,4 @@ | ||
var _raxProptypes = _interopRequireDefault(require("rax-proptypes")); | ||
var _raxText = _interopRequireDefault(require("rax-text")); | ||
@@ -17,24 +17,8 @@ | ||
var _index = _interopRequireDefault(require("./index.css")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
var _styleSheet = _index.default; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function isFunction(functionToCheck) { | ||
@@ -51,6 +35,6 @@ return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'; | ||
return (0, _rax.createElement)(_raxView.default, { | ||
style: [timeWrapStyle, styles.item] | ||
style: [_styleSheet["item"], timeWrapStyle] | ||
}, timeBackground ? (0, _rax.createElement)(_raxImage.default, { | ||
source: timeBackground, | ||
style: timeBackgroundStyle | ||
style: [_styleSheet["background"], timeBackgroundStyle] | ||
}) : null, (0, _rax.createElement)(_raxText.default, { | ||
@@ -65,220 +49,142 @@ style: timeStyle | ||
var Index = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Index, _Component); | ||
function Countdown(props) { | ||
var _this = this; | ||
function Index() { | ||
var _getPrototypeOf2; | ||
var formatFunc = props.formatFunc, | ||
timeStyle = props.timeStyle, | ||
timeBackgroundStyle = props.timeBackgroundStyle, | ||
timeWrapStyle = props.timeWrapStyle, | ||
timeBackground = props.timeBackground, | ||
secondStyle = props.secondStyle, | ||
textStyle = props.textStyle, | ||
tpl = props.tpl; | ||
var _this; | ||
var _useState = (0, _rax.useState)(props.timeRemaining), | ||
timeRemaining = _useState[0], | ||
setTimeRemaining = _useState[1]; | ||
_classCallCheck(this, Index); | ||
var timeoutId = 0; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
var tick = function tick() { | ||
var onComplete = props.onComplete, | ||
onTick = props.onTick, | ||
interval = props.interval; | ||
var countdownComplete = 1000 > timeRemaining; | ||
if (_this.timeoutId) { | ||
clearTimeout(_this.timeoutId); | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Index)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
if (countdownComplete && isFunction(onComplete)) { | ||
onComplete(); | ||
} else { | ||
timeoutId = !countdownComplete ? setTimeout(function () { | ||
setTimeRemaining(timeRemaining - interval); | ||
isFunction(onTick) && onTick(timeRemaining); | ||
}, interval) : false; | ||
} | ||
}; | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", { | ||
timeRemaining: 0 | ||
}); | ||
(0, _rax.useEffect)(function () { | ||
tick(); | ||
}); | ||
(0, _rax.useEffect)(function () { | ||
clearTimeout(_this.timeoutId); | ||
}, []); | ||
(0, _rax.useMemo)(function () { | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "timeoutId", 0); | ||
setTimeRemaining(timeRemaining); | ||
}, [props.timeRemaining, timeRemaining]); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "tick", function () { | ||
var _this$props = _this.props, | ||
onComplete = _this$props.onComplete, | ||
onTick = _this$props.onTick, | ||
interval = _this$props.interval; | ||
var timeRemaining = _this.state.timeRemaining; | ||
var countdownComplete = 1000 > timeRemaining; | ||
if (formatFunc) { | ||
return formatFunc(timeRemaining); | ||
} | ||
if (_this.timeoutId) { | ||
clearTimeout(_this.timeoutId); | ||
} | ||
var totalSeconds = Math.floor(timeRemaining / 1000); | ||
var days = parseInt(totalSeconds / 3600 / 24); | ||
var hours = parseInt(totalSeconds / 3600) % 24; | ||
var minutes = parseInt(totalSeconds / 60) % 60; | ||
var seconds = parseInt(totalSeconds % 60); | ||
var timeType = { | ||
'd': days, | ||
'h': hours, | ||
'm': minutes, | ||
's': seconds | ||
}; | ||
var rule = new RegExp('\{[d,h,m,s]\}', 'g'); // used to matched all template item, which includes 'd', 'h', 'm' and 's'. | ||
if (countdownComplete && isFunction(onComplete)) { | ||
onComplete(); | ||
} else { | ||
_this.timeoutId = !countdownComplete ? setTimeout(function () { | ||
return _this.setState({ | ||
timeRemaining: timeRemaining - interval | ||
}, function () { | ||
return isFunction(onTick) && onTick(timeRemaining); | ||
}); | ||
}, interval) : false; | ||
} | ||
}); | ||
var matchlist = []; | ||
var tmp = null; | ||
return _this; | ||
while ((tmp = rule.exec(tpl)) !== null) { | ||
matchlist.push(tmp.index, tmp.index); | ||
} | ||
_createClass(Index, [{ | ||
key: "componentWillMount", | ||
value: function componentWillMount() { | ||
var timeRemaining = this.props.timeRemaining; | ||
this.setState({ | ||
timeRemaining: timeRemaining | ||
}); | ||
} | ||
}, { | ||
key: "componentDidMount", | ||
value: function componentDidMount() { | ||
this.tick(); | ||
} | ||
}, { | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate() { | ||
this.tick(); | ||
} | ||
}, { | ||
key: "componentWillReceiveProps", | ||
value: function componentWillReceiveProps(newProps) { | ||
if (newProps.timeRemaining !== this.props.timeRemaining) { | ||
if (this.timeoutId) { | ||
clearTimeout(this.timeoutId); | ||
} | ||
if (matchlist.length !== 0) { | ||
// used to detect the last element | ||
matchlist.push(-1); | ||
} | ||
this.setState({ | ||
timeRemaining: newProps.timeRemaining | ||
}); | ||
} | ||
var lastPlaintextIndex = 0; | ||
return (0, _rax.createElement)(_raxView.default, { | ||
style: _styleSheet["main"] | ||
}, matchlist.map(function (val, index) { | ||
if (val === -1) { | ||
// don't forget the potential plain text after last matched item | ||
var lastPlaintext = tpl.slice(lastPlaintextIndex); | ||
return lastPlaintext ? (0, _rax.createElement)(_raxText.default, { | ||
style: textStyle | ||
}, lastPlaintext) : null; | ||
} | ||
}, { | ||
key: "componentWillUnmount", | ||
value: function componentWillUnmount() { | ||
if (this.timeoutId) { | ||
clearTimeout(this.timeoutId); | ||
} | ||
} | ||
}, { | ||
key: "shouldComponentUpdate", | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
return this.props.timeRemaining !== nextProps.timeRemaining || this.state.timeRemaining !== nextState.timeRemaining; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var timeRemaining = this.state.timeRemaining; | ||
var _this$props2 = this.props, | ||
formatFunc = _this$props2.formatFunc, | ||
timeStyle = _this$props2.timeStyle, | ||
timeBackgroundStyle = _this$props2.timeBackgroundStyle, | ||
timeWrapStyle = _this$props2.timeWrapStyle, | ||
timeBackground = _this$props2.timeBackground, | ||
secondStyle = _this$props2.secondStyle, | ||
textStyle = _this$props2.textStyle, | ||
tpl = _this$props2.tpl; | ||
if (formatFunc) { | ||
return formatFunc(timeRemaining); | ||
} | ||
var matchedCharacter = tpl[val + 1]; | ||
var totalSeconds = Math.floor(timeRemaining / 1000); | ||
var days = parseInt(totalSeconds / 3600 / 24); | ||
var hours = parseInt(totalSeconds / 3600) % 24; | ||
var minutes = parseInt(totalSeconds / 60) % 60; | ||
var seconds = parseInt(totalSeconds % 60); | ||
var _timeBackgroundStyle = [styles.background, timeBackgroundStyle]; | ||
var timeType = { | ||
'd': days, | ||
'h': hours, | ||
'm': minutes, | ||
's': seconds | ||
}; | ||
var rule = new RegExp('\{[d,h,m,s]\}', 'g'); // used to matched all template item, which includes 'd', 'h', 'm' and 's'. | ||
var matchlist = []; | ||
var tmp = null; | ||
while ((tmp = rule.exec(tpl)) !== null) { | ||
matchlist.push(tmp.index, tmp.index); | ||
} | ||
if (matchlist.length !== 0) { | ||
// used to detect the last element | ||
matchlist.push(-1); | ||
} | ||
var lastPlaintextIndex = 0; | ||
return (0, _rax.createElement)(_raxView.default, { | ||
style: styles.main | ||
}, matchlist.map(function (val, index) { | ||
if (val === -1) { | ||
// don't forget the potential plain text after last matched item | ||
var lastPlaintext = tpl.slice(lastPlaintextIndex); | ||
return lastPlaintext ? (0, _rax.createElement)(_raxText.default, { | ||
switch (matchedCharacter) { | ||
case 'd': | ||
case 'h': | ||
case 'm': | ||
case 's': | ||
if (index % 2 === 0) { | ||
// insert plain text before current matched item | ||
return (0, _rax.createElement)(_raxText.default, { | ||
style: textStyle | ||
}, lastPlaintext) : null; | ||
}, tpl.slice(lastPlaintextIndex, val)); | ||
} else { | ||
// replace current matched item to realtime string | ||
lastPlaintextIndex = val + 3; | ||
return addZero(timeType[matchedCharacter], timeWrapStyle, timeBackground, timeBackgroundStyle, timeStyle, secondStyle); | ||
} | ||
var matchedCharacter = tpl[val + 1]; | ||
switch (matchedCharacter) { | ||
case 'd': | ||
case 'h': | ||
case 'm': | ||
case 's': | ||
if (index % 2 === 0) { | ||
// insert plain text before current matched item | ||
return (0, _rax.createElement)(_raxText.default, { | ||
style: textStyle | ||
}, tpl.slice(lastPlaintextIndex, val)); | ||
} else { | ||
// replace current matched item to realtime string | ||
lastPlaintextIndex = val + 3; | ||
return addZero(timeType[matchedCharacter], timeWrapStyle, timeBackground, _timeBackgroundStyle, timeStyle, secondStyle); | ||
} | ||
default: | ||
return null; | ||
} | ||
})); | ||
default: | ||
return null; | ||
} | ||
}]); | ||
})); | ||
} | ||
return Index; | ||
}(_rax.Component); | ||
_defineProperty(Index, "propTypes", { | ||
formatFunc: _rax.PropTypes.func, | ||
onTick: _rax.PropTypes.func, | ||
onComplete: _rax.PropTypes.func, | ||
tpl: _rax.PropTypes.string, | ||
// template (example {h}:{m}:{s}) | ||
timeRemaining: _rax.PropTypes.number, | ||
secondStyle: _rax.PropTypes.object, | ||
timeStyle: _rax.PropTypes.object, | ||
// style for num | ||
textStyle: _rax.PropTypes.object, | ||
// style for text | ||
timeWrapStyle: _rax.PropTypes.object, | ||
timeBackground: _rax.PropTypes.string, | ||
timeBackgroundStyle: _rax.PropTypes.object, | ||
interval: _rax.PropTypes.number | ||
}); | ||
_defineProperty(Index, "defaultProps", { | ||
Countdown.defaultProps = { | ||
tpl: '{d}天{h}时{m}分{s}秒', | ||
timeRemaining: 0, | ||
interval: 1000 | ||
}); | ||
var styles = { | ||
main: { | ||
flexDirection: 'row', | ||
justifyContent: 'flex-start', | ||
alignItems: 'center' | ||
}, | ||
item: { | ||
flexDirection: 'row' | ||
}, | ||
background: { | ||
position: 'absolute' | ||
} | ||
}; | ||
var _default = Index; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
Countdown.propTypes = { | ||
formatFunc: _raxProptypes.default.func, | ||
onTick: _raxProptypes.default.func, | ||
onComplete: _raxProptypes.default.func, | ||
tpl: _raxProptypes.default.string, | ||
// template (example {h}:{m}:{s}) | ||
timeRemaining: _raxProptypes.default.number, | ||
secondStyle: _raxProptypes.default.object, | ||
timeStyle: _raxProptypes.default.object, | ||
// style for num | ||
textStyle: _raxProptypes.default.object, | ||
// style for text | ||
timeWrapStyle: _raxProptypes.default.object, | ||
timeBackground: _raxProptypes.default.string, | ||
timeBackgroundStyle: _raxProptypes.default.object, | ||
interval: _raxProptypes.default.number | ||
}; | ||
var _default = Countdown; | ||
exports.default = _default; |
{ | ||
"name": "rax-countdown", | ||
"version": "0.6.5", | ||
"version": "1.0.0-beta.0", | ||
"description": "Countdown component for Rax.", | ||
"license": "BSD-3-Clause", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"start": "rax-scripts start", | ||
"build": "rax-scripts build", | ||
"test": "jest", | ||
"lint": "eslint --ext .js --ext .jsx ./src" | ||
}, | ||
"files": [ | ||
"dist", | ||
"lib" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/alibaba/rax.git" | ||
"url": "git+https://github.com/raxjs/rax-countdown.git" | ||
}, | ||
@@ -24,12 +34,33 @@ "keywords": [ | ||
"dependencies": { | ||
"rax-image": "^0.6.5", | ||
"rax-text": "^0.6.5", | ||
"rax-view": "^0.6.5" | ||
"rax-image": "^1.0.0-beta.1", | ||
"rax-proptypes": "^1.0.0", | ||
"rax-text": "^1.0.0-beta.1", | ||
"rax-view": "^1.0.0-beta.0" | ||
}, | ||
"peerDependencies": { | ||
"rax": "0.x" | ||
"rax": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"rax-test-renderer": "^0.6.5" | ||
"rax": "^1.0.0", | ||
"@babel/core": "7.2.0", | ||
"@babel/plugin-proposal-class-properties": "7.2.0", | ||
"@babel/plugin-proposal-decorators": "7.2.0", | ||
"@babel/plugin-proposal-export-default-from": "7.2.0", | ||
"@babel/plugin-transform-runtime": "^7.2.0", | ||
"babel-plugin-transform-jsx-stylesheet": "0.6.5", | ||
"@babel/preset-env": "7.2.0", | ||
"@babel/preset-flow": "7.0.0", | ||
"@babel/preset-react": "7.0.0", | ||
"rax-test-renderer": "^1.0.0", | ||
"rax-scripts": "^1.2.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-eslint": "10.0.1", | ||
"babel-jest": "23.6.0", | ||
"babel-preset-rax": "^0.6.5", | ||
"eslint": "^5.10.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-react": "~7.11.1", | ||
"jest": "^23.6.0", | ||
"jest-localstorage-mock": "^2.3.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
2
1
220519
5
21
12
1762
+ Addedrax-proptypes@^1.0.0
+ Added@babel/runtime@7.26.0(transitive)
+ Added@uni/env@1.1.1(transitive)
+ Addedclassnames@2.5.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedrax@1.2.3(transitive)
+ Addedrax-children@1.0.0(transitive)
+ Addedrax-clone-element@1.0.0(transitive)
+ Addedrax-create-factory@1.0.0(transitive)
+ Addedrax-image@1.1.3(transitive)
+ Addedrax-is-valid-element@1.0.1(transitive)
+ Addedrax-proptypes@1.0.0(transitive)
+ Addedrax-text@1.4.0(transitive)
+ Addedrax-view@1.2.0(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addeduniversal-env@1.0.73.3.3(transitive)
- Removeddriver-browser@0.6.7(transitive)
- Removeddriver-server@0.6.5(transitive)
- Removeddriver-weex@0.6.5(transitive)
- Removedrax@0.6.7(transitive)
- Removedrax-image@0.6.8(transitive)
- Removedrax-text@0.6.5(transitive)
- Removedrax-view@0.6.5(transitive)
- Removedstyle-unit@0.6.5(transitive)
- Removeduniversal-env@0.6.6(transitive)
Updatedrax-image@^1.0.0-beta.1
Updatedrax-text@^1.0.0-beta.1
Updatedrax-view@^1.0.0-beta.0