@hig/input
Advanced tools
Comparing version 1.1.4 to 1.1.5
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { css } from 'emotion'; | ||
import { cx, css } from 'emotion'; | ||
import { ThemeContext } from '@hig/theme-context'; | ||
@@ -108,7 +108,17 @@ import { ControlBehavior } from '@hig/behaviors'; | ||
var cssStyles = customStylesheet ? customStylesheet(styles, props, resolvedRoles, metadata.colorSchemeId) : styles; | ||
var className = css(cssStyles.input); | ||
var customClassName = otherProps.className; | ||
if (customClassName) { | ||
className = cx(className, variant === variants.PLAIN ? customClassName : customClassName.split(" ").reduce(function (acc, cur) { | ||
return cx(acc, cur.trim() + "__input"); | ||
}, "")); | ||
} | ||
var tagNameKey = tagName.toUpperCase(); | ||
var Element = tagNames[tagNameKey]; | ||
return React.createElement(Element, _extends$1({ | ||
className: css(cssStyles.input), | ||
return React.createElement(Element, _extends$1({}, otherProps, { | ||
className: className, | ||
disabled: disabled, | ||
@@ -119,3 +129,3 @@ onBlur: onBlur, | ||
onMouseLeave: onMouseLeave | ||
}, otherProps)); | ||
})); | ||
} | ||
@@ -319,2 +329,4 @@ ); | ||
function _objectWithoutProperties$1(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function InputHaloPresenter(props) { | ||
@@ -326,5 +338,5 @@ var children = props.children, | ||
customStylesheet = props.stylesheet, | ||
variant = props.variant; | ||
variant = props.variant, | ||
otherProps = _objectWithoutProperties$1(props, ["children", "hasFocus", "hasHover", "isDisabled", "stylesheet", "variant"]); | ||
return React.createElement( | ||
@@ -340,7 +352,14 @@ ThemeContext.Consumer, | ||
var className = otherProps.className; | ||
return React.createElement( | ||
"div", | ||
{ className: css(cssStyles.wrapper) }, | ||
{ className: cx(css(cssStyles.wrapper), className) }, | ||
children, | ||
React.createElement("div", { className: css(cssStyles.halo) }) | ||
React.createElement("div", { | ||
className: cx(css(cssStyles.halo), className ? className.split(" ").reduce(function (acc, cur) { | ||
return cx(acc, cur.trim() + "__halo"); | ||
}, "") : "") | ||
}) | ||
); | ||
@@ -412,3 +431,3 @@ } | ||
function _objectWithoutProperties$1(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _objectWithoutProperties$2(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
@@ -438,3 +457,3 @@ function Wrapper(props) { | ||
variant = props.variant, | ||
otherProps = _objectWithoutProperties$1(props, ["onFocus", "onBlur", "onMouseEnter", "onMouseLeave", "disabled", "stylesheet", "tagName", "variant"]); | ||
otherProps = _objectWithoutProperties$2(props, ["onFocus", "onBlur", "onMouseEnter", "onMouseLeave", "disabled", "stylesheet", "tagName", "variant"]); | ||
@@ -458,3 +477,3 @@ return React.createElement( | ||
Wrapper, | ||
{ | ||
_extends$3({ | ||
isDisabled: disabledProp, | ||
@@ -466,3 +485,3 @@ hasFocus: hasFocus, | ||
variant: variant | ||
}, | ||
}, otherProps), | ||
React.createElement(InputPresenter, _extends$3({ | ||
@@ -469,0 +488,0 @@ disabled: disabledProp, |
@@ -114,7 +114,17 @@ 'use strict'; | ||
var cssStyles = customStylesheet ? customStylesheet(styles, props, resolvedRoles, metadata.colorSchemeId) : styles; | ||
var className = emotion.css(cssStyles.input); | ||
var customClassName = otherProps.className; | ||
if (customClassName) { | ||
className = emotion.cx(className, variant === variants.PLAIN ? customClassName : customClassName.split(" ").reduce(function (acc, cur) { | ||
return emotion.cx(acc, cur.trim() + "__input"); | ||
}, "")); | ||
} | ||
var tagNameKey = tagName.toUpperCase(); | ||
var Element = tagNames[tagNameKey]; | ||
return React.createElement(Element, _extends$1({ | ||
className: emotion.css(cssStyles.input), | ||
return React.createElement(Element, _extends$1({}, otherProps, { | ||
className: className, | ||
disabled: disabled, | ||
@@ -125,3 +135,3 @@ onBlur: onBlur, | ||
onMouseLeave: onMouseLeave | ||
}, otherProps)); | ||
})); | ||
} | ||
@@ -325,2 +335,4 @@ ); | ||
function _objectWithoutProperties$1(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function InputHaloPresenter(props) { | ||
@@ -332,5 +344,5 @@ var children = props.children, | ||
customStylesheet = props.stylesheet, | ||
variant = props.variant; | ||
variant = props.variant, | ||
otherProps = _objectWithoutProperties$1(props, ["children", "hasFocus", "hasHover", "isDisabled", "stylesheet", "variant"]); | ||
return React.createElement( | ||
@@ -346,7 +358,14 @@ themeContext.ThemeContext.Consumer, | ||
var className = otherProps.className; | ||
return React.createElement( | ||
"div", | ||
{ className: emotion.css(cssStyles.wrapper) }, | ||
{ className: emotion.cx(emotion.css(cssStyles.wrapper), className) }, | ||
children, | ||
React.createElement("div", { className: emotion.css(cssStyles.halo) }) | ||
React.createElement("div", { | ||
className: emotion.cx(emotion.css(cssStyles.halo), className ? className.split(" ").reduce(function (acc, cur) { | ||
return emotion.cx(acc, cur.trim() + "__halo"); | ||
}, "") : "") | ||
}) | ||
); | ||
@@ -418,3 +437,3 @@ } | ||
function _objectWithoutProperties$1(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _objectWithoutProperties$2(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
@@ -444,3 +463,3 @@ function Wrapper(props) { | ||
variant = props.variant, | ||
otherProps = _objectWithoutProperties$1(props, ["onFocus", "onBlur", "onMouseEnter", "onMouseLeave", "disabled", "stylesheet", "tagName", "variant"]); | ||
otherProps = _objectWithoutProperties$2(props, ["onFocus", "onBlur", "onMouseEnter", "onMouseLeave", "disabled", "stylesheet", "tagName", "variant"]); | ||
@@ -464,3 +483,3 @@ return React.createElement( | ||
Wrapper, | ||
{ | ||
_extends$3({ | ||
isDisabled: disabledProp, | ||
@@ -472,3 +491,3 @@ hasFocus: hasFocus, | ||
variant: variant | ||
}, | ||
}, otherProps), | ||
React.createElement(InputPresenter, _extends$3({ | ||
@@ -475,0 +494,0 @@ disabled: disabledProp, |
@@ -0,1 +1,8 @@ | ||
# [@hig/input-v1.1.5](https://github.com/Autodesk/hig/compare/@hig/input@1.1.4...@hig/input@1.1.5) (2019-07-01) | ||
### Bug Fixes | ||
* allow className to be passed down in Input ([bb8e040](https://github.com/Autodesk/hig/commit/bb8e040)) | ||
# [@hig/input-v1.1.4](https://github.com/Autodesk/hig/compare/@hig/input@1.1.3...@hig/input@1.1.4) (2019-05-17) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@hig/input", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "HIG Input", | ||
@@ -33,3 +33,3 @@ "author": "Autodesk Inc.", | ||
"@hig/theme-context": "^3.0.0", | ||
"@hig/theme-data": "^2.5.0", | ||
"@hig/theme-data": "^2.8.0", | ||
"react": "^15.4.1 || ^16.3.2" | ||
@@ -36,0 +36,0 @@ }, |
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
41269
8
1172