pcln-design-system
Advanced tools
Comparing version 1.0.0-61 to 1.0.0-62
@@ -11,3 +11,4 @@ 'use strict'; | ||
var _templateObject = _taggedTemplateLiteral(['\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n'], ['\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n']); | ||
var _templateObject = _taggedTemplateLiteral(['\n & ', ' {\n pointer-events: none;\n }\n'], ['\n & ', ' {\n pointer-events: none;\n }\n']), | ||
_templateObject2 = _taggedTemplateLiteral(['\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n'], ['\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n']); | ||
@@ -66,3 +67,5 @@ var _react = require('react'); | ||
var fadeIn = (0, _styledComponents.keyframes)(_templateObject); | ||
var Root = (0, _styledComponents2.default)(_Box2.default)(_templateObject, _Box2.default); | ||
var fadeIn = (0, _styledComponents.keyframes)(_templateObject2); | ||
var labelStyles = { | ||
@@ -84,32 +87,36 @@ animation: fadeIn + ' 0.3s' | ||
var noop = function noop() {}; | ||
var InputField = function (_React$Component) { | ||
_inherits(InputField, _React$Component); | ||
function InputField(props) { | ||
function InputField() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, InputField); | ||
var _this = _possibleConstructorReturn(this, (InputField.__proto__ || Object.getPrototypeOf(InputField)).call(this, props)); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.onInputChange = function (event) { | ||
_this.setState({ | ||
showLabel: event.target.value | ||
}); | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = InputField.__proto__ || Object.getPrototypeOf(InputField)).call.apply(_ref, [this].concat(args))), _this), _this.handleChange = function (onChange) { | ||
return function (e) { | ||
_this.props.onChange(e); | ||
if (typeof onChange !== 'function') return; | ||
onChange(e); | ||
}; | ||
}, _this.hasValue = function () { | ||
var children = _this.props.children; | ||
_this.props.onChange(event); | ||
}; | ||
return _react2.default.Children.toArray(children).reduce(function (a, child) { | ||
return a || child && child.type === _Input2.default && !!child.props.value; | ||
}, false); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
var hasDefaultValue = void 0; | ||
// for backwards-compatibility | ||
_react2.default.Children.forEach(props.children, function (child) { | ||
if (child && child.type === _Input2.default) { | ||
hasDefaultValue = child.props.defaultValue; | ||
} | ||
}); | ||
_this.state = { | ||
showLabel: hasDefaultValue | ||
}; | ||
return _this; | ||
} | ||
_createClass(InputField, [{ | ||
@@ -151,3 +158,3 @@ key: 'render', | ||
BeforeIcon = child; | ||
iconAdjustment = child.props.size - _Icon2.default.defaultProps.size; | ||
iconAdjustment = child.props.size - 24; | ||
} else { | ||
@@ -175,6 +182,6 @@ AfterIcon = child; | ||
var showLabel = LabelChild && this.state.showLabel; | ||
var showLabel = this.props.alwaysShowLabel || LabelChild && this.hasValue(); | ||
return _react2.default.createElement( | ||
_Box2.default, | ||
Root, | ||
null, | ||
@@ -192,3 +199,7 @@ showLabel && _react2.default.cloneElement(LabelChild, { | ||
_Box2.default, | ||
{ mr: -4, ml: 8 - iconAdjustment, mt: showLabel ? -12 : 2 }, | ||
{ | ||
mr: -4, | ||
ml: 8 - iconAdjustment + 'px', | ||
mt: showLabel ? '-12px' : '2px' | ||
}, | ||
BeforeIcon | ||
@@ -202,7 +213,8 @@ ), | ||
style: getInputStyles(showLabel), | ||
onChange: this.onInputChange, | ||
width: 1, | ||
innerRef: function innerRef(elem) { | ||
_this2.inputRef = elem; | ||
} | ||
}, | ||
// for backwards compatibility | ||
onChange: this.handleChange(InputChild.props.onChange) | ||
}, props)), | ||
@@ -222,4 +234,10 @@ AfterIcon && _react2.default.createElement( | ||
InputField.defaultProps = { | ||
// for backwards-compatibility | ||
onChange: noop, | ||
theme: _theme2.default }; | ||
InputField.propTypes = { | ||
onChange: _propTypes2.default.func.isRequired, | ||
alwaysShowLabel: _propTypes2.default.bool, | ||
children: function children(props, propName, componentName) { | ||
@@ -226,0 +244,0 @@ var prop = props[propName]; |
{ | ||
"name": "pcln-design-system", | ||
"version": "1.0.0-61", | ||
"version": "1.0.0-62", | ||
"description": "Priceline Design System", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
644816
153
6253
0