Comparing version 1.0.0-beta.0 to 1.0.0-beta.1
@@ -40,7 +40,3 @@ module.exports = function(require, exports, module) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
@@ -51,5 +47,24 @@ /******/ }; | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
@@ -124,6 +139,2 @@ /******/ __webpack_require__.n = function(module) { | ||
"fontSize": 32 | ||
}, | ||
"richtext": { | ||
"marginTop": 0, | ||
"marginBottom": 0 | ||
} | ||
@@ -151,215 +162,67 @@ }; | ||
/* harmony import */ var _index_css__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_index_css__WEBPACK_IMPORTED_MODULE_2__); | ||
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); } | ||
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 _styleSheet = _index_css__WEBPACK_IMPORTED_MODULE_2___default.a; | ||
/* harmony default export */ __webpack_exports__["default"] = (function (props) { | ||
var children = props.children; | ||
var Text = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Text, _Component); | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
function Text() { | ||
var _getPrototypeOf2; | ||
var nativeProps = _extends({}, props, { | ||
style: props.style || {} | ||
}); | ||
var _this; | ||
var textString = ''; | ||
_classCallCheck(this, Text); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
if (props.children != null) { | ||
if (!Array.isArray(props.children)) { | ||
textString = props.children.toString(); | ||
} else { | ||
textString = props.children.join(''); | ||
} | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Text)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderText", function () { | ||
var props = _this.props; | ||
var nativeProps = _objectSpread({}, props, { | ||
style: props.style || {} | ||
}); | ||
var textString = ''; | ||
if (props.children != null) { | ||
if (!Array.isArray(props.children)) { | ||
textString = props.children.toString(); | ||
} else { | ||
textString = props.children.join(''); | ||
} | ||
} | ||
if (_this.context.isInAParentText) { | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("span", nativeProps, textString); | ||
} | ||
if (props.onPress) { | ||
nativeProps.onClick = props.onPress; | ||
} | ||
if (universal_env__WEBPACK_IMPORTED_MODULE_1__["isWeex"]) { | ||
if (props.numberOfLines) { | ||
nativeProps.style.lines = props.numberOfLines; | ||
} | ||
nativeProps.value = textString; | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("text", nativeProps); | ||
} else { | ||
var styleProps = _objectSpread({ | ||
whiteSpace: 'pre-wrap' | ||
}, nativeProps.style); | ||
var numberOfLines = props.numberOfLines; | ||
if (numberOfLines) { | ||
if (parseInt(numberOfLines) === 1) { | ||
styleProps.whiteSpace = 'nowrap'; | ||
} else { | ||
styleProps.display = '-webkit-box'; | ||
styleProps.webkitBoxOrient = 'vertical'; | ||
styleProps.webkitLineClamp = String(numberOfLines); | ||
} | ||
styleProps.overflow = 'hidden'; | ||
} | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("span", _extends({}, nativeProps, { | ||
style: [_styleSheet["text"], styleProps] | ||
}), textString); | ||
} | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderRichText", function () { | ||
var props = _this.props; | ||
var children = props.children; | ||
var nativeProps = _objectSpread({}, props, { | ||
style: props.style || {} | ||
}); | ||
if (universal_env__WEBPACK_IMPORTED_MODULE_1__["isWeex"]) { | ||
children = transformChildren(children, _assertThisInitialized(_assertThisInitialized(_this))); | ||
} | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("p", _extends({}, nativeProps, { | ||
style: _styleSheet["richtext"] | ||
}), children); | ||
}); | ||
return _this; | ||
if (props.onPress) { | ||
nativeProps.onClick = props.onPress; | ||
} | ||
_createClass(Text, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
isInAParentText: true | ||
}; | ||
if (universal_env__WEBPACK_IMPORTED_MODULE_1__["isWeex"]) { | ||
if (props.numberOfLines) { | ||
nativeProps.style.lines = props.numberOfLines; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var props = this.props; | ||
var children = props.children; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
nativeProps.value = textString; | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("text", nativeProps); | ||
} else { | ||
var styleProps = _extends({ | ||
whiteSpace: 'pre-wrap' | ||
}, nativeProps.style); | ||
var nested = false; | ||
var numberOfLines = props.numberOfLines; | ||
for (var i = 0; i < children.length; i++) { | ||
var child = children[i]; | ||
if (child && _typeof(child) === 'object') { | ||
nested = true; | ||
break; | ||
} | ||
if (numberOfLines) { | ||
if (parseInt(numberOfLines) === 1) { | ||
styleProps.whiteSpace = 'nowrap'; | ||
} else { | ||
styleProps.display = '-webkit-box'; | ||
styleProps.webkitBoxOrient = 'vertical'; | ||
styleProps.webkitLineClamp = String(numberOfLines); | ||
} | ||
return nested ? this.renderRichText() : this.renderText(); | ||
styleProps.overflow = 'hidden'; | ||
} | ||
}]); | ||
return Text; | ||
}(rax__WEBPACK_IMPORTED_MODULE_0__["Component"]); | ||
_defineProperty(Text, "propTypes", {}); | ||
_defineProperty(Text, "contextTypes", { | ||
isInAParentText: rax__WEBPACK_IMPORTED_MODULE_0__["PropTypes"].bool | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("span", _extends({}, nativeProps, { | ||
style: [_styleSheet["text"], styleProps] | ||
}), textString); | ||
} | ||
}); | ||
_defineProperty(Text, "childContextTypes", { | ||
isInAParentText: rax__WEBPACK_IMPORTED_MODULE_0__["PropTypes"].bool | ||
}); | ||
function transformChild(child, instance) { | ||
var ChildComponent = child.type, | ||
props = child.props; | ||
var children = props.children; | ||
if (typeof ChildComponent === 'function') { | ||
var childInstance = new ChildComponent(); | ||
childInstance.props = props; | ||
if (children) { | ||
childInstance.props.children = transformChildren(children, instance); | ||
} | ||
childInstance.context = instance.getChildContext(); | ||
return childInstance.render(); | ||
} else { | ||
return child; | ||
} | ||
} | ||
function transformChildren(children, instance) { | ||
var elements = []; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
for (var i = 0; i < children.length; i++) { | ||
var child = children[i]; | ||
if (typeof child === 'string') { | ||
elements.push(child); | ||
} else if (_typeof(child) === 'object') { | ||
elements.push(transformChild(child, instance)); | ||
} | ||
} | ||
return elements; | ||
} | ||
/* harmony default export */ __webpack_exports__["default"] = (Text); | ||
/***/ }) | ||
/******/ ])}};; | ||
//# sourceMappingURL=text.factory.map |
255
dist/text.js
@@ -62,7 +62,3 @@ | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
@@ -73,5 +69,24 @@ /******/ }; | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
@@ -146,6 +161,2 @@ /******/ __webpack_require__.n = function(module) { | ||
"fontSize": 32 | ||
}, | ||
"richtext": { | ||
"marginTop": 0, | ||
"marginBottom": 0 | ||
} | ||
@@ -173,215 +184,67 @@ }; | ||
/* harmony import */ var _index_css__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_index_css__WEBPACK_IMPORTED_MODULE_2__); | ||
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); } | ||
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 _styleSheet = _index_css__WEBPACK_IMPORTED_MODULE_2___default.a; | ||
/* harmony default export */ __webpack_exports__["default"] = (function (props) { | ||
var children = props.children; | ||
var Text = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Text, _Component); | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
function Text() { | ||
var _getPrototypeOf2; | ||
var nativeProps = _extends({}, props, { | ||
style: props.style || {} | ||
}); | ||
var _this; | ||
var textString = ''; | ||
_classCallCheck(this, Text); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
if (props.children != null) { | ||
if (!Array.isArray(props.children)) { | ||
textString = props.children.toString(); | ||
} else { | ||
textString = props.children.join(''); | ||
} | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Text)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderText", function () { | ||
var props = _this.props; | ||
var nativeProps = _objectSpread({}, props, { | ||
style: props.style || {} | ||
}); | ||
var textString = ''; | ||
if (props.children != null) { | ||
if (!Array.isArray(props.children)) { | ||
textString = props.children.toString(); | ||
} else { | ||
textString = props.children.join(''); | ||
} | ||
} | ||
if (_this.context.isInAParentText) { | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("span", nativeProps, textString); | ||
} | ||
if (props.onPress) { | ||
nativeProps.onClick = props.onPress; | ||
} | ||
if (universal_env__WEBPACK_IMPORTED_MODULE_1__["isWeex"]) { | ||
if (props.numberOfLines) { | ||
nativeProps.style.lines = props.numberOfLines; | ||
} | ||
nativeProps.value = textString; | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("text", nativeProps); | ||
} else { | ||
var styleProps = _objectSpread({ | ||
whiteSpace: 'pre-wrap' | ||
}, nativeProps.style); | ||
var numberOfLines = props.numberOfLines; | ||
if (numberOfLines) { | ||
if (parseInt(numberOfLines) === 1) { | ||
styleProps.whiteSpace = 'nowrap'; | ||
} else { | ||
styleProps.display = '-webkit-box'; | ||
styleProps.webkitBoxOrient = 'vertical'; | ||
styleProps.webkitLineClamp = String(numberOfLines); | ||
} | ||
styleProps.overflow = 'hidden'; | ||
} | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("span", _extends({}, nativeProps, { | ||
style: [_styleSheet["text"], styleProps] | ||
}), textString); | ||
} | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderRichText", function () { | ||
var props = _this.props; | ||
var children = props.children; | ||
var nativeProps = _objectSpread({}, props, { | ||
style: props.style || {} | ||
}); | ||
if (universal_env__WEBPACK_IMPORTED_MODULE_1__["isWeex"]) { | ||
children = transformChildren(children, _assertThisInitialized(_assertThisInitialized(_this))); | ||
} | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("p", _extends({}, nativeProps, { | ||
style: _styleSheet["richtext"] | ||
}), children); | ||
}); | ||
return _this; | ||
if (props.onPress) { | ||
nativeProps.onClick = props.onPress; | ||
} | ||
_createClass(Text, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
isInAParentText: true | ||
}; | ||
if (universal_env__WEBPACK_IMPORTED_MODULE_1__["isWeex"]) { | ||
if (props.numberOfLines) { | ||
nativeProps.style.lines = props.numberOfLines; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var props = this.props; | ||
var children = props.children; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
nativeProps.value = textString; | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("text", nativeProps); | ||
} else { | ||
var styleProps = _extends({ | ||
whiteSpace: 'pre-wrap' | ||
}, nativeProps.style); | ||
var nested = false; | ||
var numberOfLines = props.numberOfLines; | ||
for (var i = 0; i < children.length; i++) { | ||
var child = children[i]; | ||
if (child && _typeof(child) === 'object') { | ||
nested = true; | ||
break; | ||
} | ||
if (numberOfLines) { | ||
if (parseInt(numberOfLines) === 1) { | ||
styleProps.whiteSpace = 'nowrap'; | ||
} else { | ||
styleProps.display = '-webkit-box'; | ||
styleProps.webkitBoxOrient = 'vertical'; | ||
styleProps.webkitLineClamp = String(numberOfLines); | ||
} | ||
return nested ? this.renderRichText() : this.renderText(); | ||
styleProps.overflow = 'hidden'; | ||
} | ||
}]); | ||
return Text; | ||
}(rax__WEBPACK_IMPORTED_MODULE_0__["Component"]); | ||
_defineProperty(Text, "propTypes", {}); | ||
_defineProperty(Text, "contextTypes", { | ||
isInAParentText: rax__WEBPACK_IMPORTED_MODULE_0__["PropTypes"].bool | ||
return Object(rax__WEBPACK_IMPORTED_MODULE_0__["createElement"])("span", _extends({}, nativeProps, { | ||
style: [_styleSheet["text"], styleProps] | ||
}), textString); | ||
} | ||
}); | ||
_defineProperty(Text, "childContextTypes", { | ||
isInAParentText: rax__WEBPACK_IMPORTED_MODULE_0__["PropTypes"].bool | ||
}); | ||
function transformChild(child, instance) { | ||
var ChildComponent = child.type, | ||
props = child.props; | ||
var children = props.children; | ||
if (typeof ChildComponent === 'function') { | ||
var childInstance = new ChildComponent(); | ||
childInstance.props = props; | ||
if (children) { | ||
childInstance.props.children = transformChildren(children, instance); | ||
} | ||
childInstance.context = instance.getChildContext(); | ||
return childInstance.render(); | ||
} else { | ||
return child; | ||
} | ||
} | ||
function transformChildren(children, instance) { | ||
var elements = []; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
for (var i = 0; i < children.length; i++) { | ||
var child = children[i]; | ||
if (typeof child === 'string') { | ||
elements.push(child); | ||
} else if (_typeof(child) === 'object') { | ||
elements.push(transformChild(child, instance)); | ||
} | ||
} | ||
return elements; | ||
} | ||
/* harmony default export */ __webpack_exports__["default"] = (Text); | ||
/***/ }) | ||
/******/ ])});; | ||
//# sourceMappingURL=text.map |
@@ -1,2 +0,2 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define)define("rax-text",function(t,n,r){r.exports=e()});else{("undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:this).RaxText=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,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},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)}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 c="function"==typeof callNative||"object"===("undefined"==typeof WXEnvironment?"undefined":r(WXEnvironment))&&"Web"!==WXEnvironment.platform;t.isWeex=c;var u="undefined"!=typeof __fbBatchedBridgeConfig;t.isReactNative=u,t.default=e.exports;var f=e.exports;t.default=f},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,n){"use strict";n.r(t);var r=n(0),o=n(1),i=n(2);function c(e){return(c="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 u(){return(u=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 f(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 l(e){return(l=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=n.n(i).a,d=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 i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return y(p(p(n=function(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?p(e):t}(this,(e=l(t)).call.apply(e,[this].concat(a))))),"renderText",function(){var e=n.props,t=f({},e,{style:e.style||{}}),i="";if(null!=e.children&&(i=Array.isArray(e.children)?e.children.join(""):e.children.toString()),n.context.isInAParentText)return Object(r.createElement)("span",t,i);if(e.onPress&&(t.onClick=e.onPress),o.isWeex)return e.numberOfLines&&(t.style.lines=e.numberOfLines),t.value=i,Object(r.createElement)("text",t);var c=f({whiteSpace:"pre-wrap"},t.style),a=e.numberOfLines;return a&&(1===parseInt(a)?c.whiteSpace="nowrap":(c.display="-webkit-box",c.webkitBoxOrient="vertical",c.webkitLineClamp=String(a)),c.overflow="hidden"),Object(r.createElement)("span",u({},t,{style:[b.text,c]}),i)}),y(p(p(n)),"renderRichText",function(){var e=n.props,t=e.children,i=f({},e,{style:e.style||{}});return o.isWeex&&(t=h(t,p(p(n)))),Object(r.createElement)("p",u({},i,{style:b.richtext}),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,r["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"===c(r)){t=!0;break}}return t?this.renderRichText():this.renderText()}}]),t}();function v(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=h(o,t)),i.context=t.getChildContext(),i.render()}return e}function h(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"===c(o)&&n.push(v(o,t))}return n}y(d,"propTypes",{}),y(d,"contextTypes",{isInAParentText:r.PropTypes.bool}),y(d,"childContextTypes",{isInAParentText:r.PropTypes.bool}),t.default=d}])}); | ||
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define)define("rax-text",function(e,t,n){n.exports=r()});else{("undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:this).RaxText=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=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)}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 f="function"==typeof callNative||"object"===("undefined"==typeof WXEnvironment?"undefined":r(WXEnvironment))&&"Web"!==WXEnvironment.platform;t.isWeex=f;var u="undefined"!=typeof __fbBatchedBridgeConfig;t.isReactNative=u,t.default=e.exports;var a=e.exports;t.default=a},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}}},function(e,t,n){"use strict";n.r(t);var f=n(0),u=n(1),r=n(2);function a(){return(a=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)}var l=n.n(r).a;t.default=function(e){var t=e.children;Array.isArray(t)||(t=[t]);var n=a({},e,{style:e.style||{}}),r="";if(null!=e.children&&(r=Array.isArray(e.children)?e.children.join(""):e.children.toString()),e.onPress&&(n.onClick=e.onPress),u.isWeex)return e.numberOfLines&&(n.style.lines=e.numberOfLines),n.value=r,Object(f.createElement)("text",n);var o=a({whiteSpace:"pre-wrap"},n.style),i=e.numberOfLines;return i&&(1===parseInt(i)?o.whiteSpace="nowrap":(o.display="-webkit-box",o.webkitBoxOrient="vertical",o.webkitLineClamp=String(i)),o.overflow="hidden"),Object(f.createElement)("span",a({},n,{style:[l.text,o]}),r)}}])}); | ||
//# sourceMappingURL=text.min.map |
228
lib/index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
@@ -16,209 +14,63 @@ | ||
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); } | ||
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 _styleSheet = _index.default; | ||
var Text = | ||
/*#__PURE__*/ | ||
function (_Component) { | ||
_inherits(Text, _Component); | ||
var _default = function _default(props) { | ||
var children = props.children; | ||
function Text() { | ||
var _getPrototypeOf2; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
var _this; | ||
var nativeProps = _extends({}, props, { | ||
style: props.style || {} | ||
}); | ||
_classCallCheck(this, Text); | ||
var textString = ''; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
if (props.children != null) { | ||
if (!Array.isArray(props.children)) { | ||
textString = props.children.toString(); | ||
} else { | ||
textString = props.children.join(''); | ||
} | ||
} | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(Text)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderText", function () { | ||
var props = _this.props; | ||
var nativeProps = _objectSpread({}, props, { | ||
style: props.style || {} | ||
}); | ||
var textString = ''; | ||
if (props.children != null) { | ||
if (!Array.isArray(props.children)) { | ||
textString = props.children.toString(); | ||
} else { | ||
textString = props.children.join(''); | ||
} | ||
} | ||
if (_this.context.isInAParentText) { | ||
return (0, _rax.createElement)("span", nativeProps, textString); | ||
} | ||
if (props.onPress) { | ||
nativeProps.onClick = props.onPress; | ||
} | ||
if (_universalEnv.isWeex) { | ||
if (props.numberOfLines) { | ||
nativeProps.style.lines = props.numberOfLines; | ||
} | ||
nativeProps.value = textString; | ||
return (0, _rax.createElement)("text", nativeProps); | ||
} else { | ||
var styleProps = _objectSpread({ | ||
whiteSpace: 'pre-wrap' | ||
}, nativeProps.style); | ||
var numberOfLines = props.numberOfLines; | ||
if (numberOfLines) { | ||
if (parseInt(numberOfLines) === 1) { | ||
styleProps.whiteSpace = 'nowrap'; | ||
} else { | ||
styleProps.display = '-webkit-box'; | ||
styleProps.webkitBoxOrient = 'vertical'; | ||
styleProps.webkitLineClamp = String(numberOfLines); | ||
} | ||
styleProps.overflow = 'hidden'; | ||
} | ||
return (0, _rax.createElement)("span", _extends({}, nativeProps, { | ||
style: [_styleSheet["text"], styleProps] | ||
}), textString); | ||
} | ||
}); | ||
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "renderRichText", function () { | ||
var props = _this.props; | ||
var children = props.children; | ||
var nativeProps = _objectSpread({}, props, { | ||
style: props.style || {} | ||
}); | ||
if (_universalEnv.isWeex) { | ||
children = transformChildren(children, _assertThisInitialized(_assertThisInitialized(_this))); | ||
} | ||
return (0, _rax.createElement)("p", _extends({}, nativeProps, { | ||
style: _styleSheet["richtext"] | ||
}), children); | ||
}); | ||
return _this; | ||
if (props.onPress) { | ||
nativeProps.onClick = props.onPress; | ||
} | ||
_createClass(Text, [{ | ||
key: "getChildContext", | ||
value: function getChildContext() { | ||
return { | ||
isInAParentText: true | ||
}; | ||
if (_universalEnv.isWeex) { | ||
if (props.numberOfLines) { | ||
nativeProps.style.lines = props.numberOfLines; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var props = this.props; | ||
var children = props.children; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
nativeProps.value = textString; | ||
return (0, _rax.createElement)("text", nativeProps); | ||
} else { | ||
var styleProps = _extends({ | ||
whiteSpace: 'pre-wrap' | ||
}, nativeProps.style); | ||
var nested = false; | ||
var numberOfLines = props.numberOfLines; | ||
for (var i = 0; i < children.length; i++) { | ||
var child = children[i]; | ||
if (child && _typeof(child) === 'object') { | ||
nested = true; | ||
break; | ||
} | ||
if (numberOfLines) { | ||
if (parseInt(numberOfLines) === 1) { | ||
styleProps.whiteSpace = 'nowrap'; | ||
} else { | ||
styleProps.display = '-webkit-box'; | ||
styleProps.webkitBoxOrient = 'vertical'; | ||
styleProps.webkitLineClamp = String(numberOfLines); | ||
} | ||
return nested ? this.renderRichText() : this.renderText(); | ||
styleProps.overflow = 'hidden'; | ||
} | ||
}]); | ||
return Text; | ||
}(_rax.Component); | ||
_defineProperty(Text, "propTypes", {}); | ||
_defineProperty(Text, "contextTypes", { | ||
isInAParentText: _rax.PropTypes.bool | ||
}); | ||
_defineProperty(Text, "childContextTypes", { | ||
isInAParentText: _rax.PropTypes.bool | ||
}); | ||
function transformChild(child, instance) { | ||
var ChildComponent = child.type, | ||
props = child.props; | ||
var children = props.children; | ||
if (typeof ChildComponent === 'function') { | ||
var childInstance = new ChildComponent(); | ||
childInstance.props = props; | ||
if (children) { | ||
childInstance.props.children = transformChildren(children, instance); | ||
} | ||
childInstance.context = instance.getChildContext(); | ||
return childInstance.render(); | ||
} else { | ||
return child; | ||
return (0, _rax.createElement)("span", _extends({}, nativeProps, { | ||
style: [_styleSheet["text"], styleProps] | ||
}), textString); | ||
} | ||
} | ||
}; | ||
function transformChildren(children, instance) { | ||
var elements = []; | ||
if (!Array.isArray(children)) { | ||
children = [children]; | ||
} | ||
for (var i = 0; i < children.length; i++) { | ||
var child = children[i]; | ||
if (typeof child === 'string') { | ||
elements.push(child); | ||
} else if (_typeof(child) === 'object') { | ||
elements.push(transformChild(child, instance)); | ||
} | ||
} | ||
return elements; | ||
} | ||
var _default = Text; | ||
exports.default = _default; |
{ | ||
"name": "rax-text", | ||
"version": "1.0.0-beta.0", | ||
"version": "1.0.0-beta.1", | ||
"description": "Text component for Rax.", | ||
@@ -5,0 +5,0 @@ "license": "BSD-3-Clause", |
@@ -10,3 +10,3 @@ import {createElement} from 'rax'; | ||
} | ||
let nativeProps = { | ||
@@ -13,0 +13,0 @@ ...props, |
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
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
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
17
57010
605