@hig/text-area
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -5,2 +5,97 @@ import React from 'react'; | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
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 _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 _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
} | ||
/* | ||
@@ -37,2 +132,3 @@ | ||
for (var i = 0; i < document.styleSheets.length; i++) { | ||
@@ -58,5 +154,3 @@ if (document.styleSheets[i].ownerNode === tag) { | ||
var StyleSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
var StyleSheet = /*#__PURE__*/function () { | ||
function StyleSheet(options) { | ||
@@ -141,4 +235,2 @@ this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function stylis_min(W) { | ||
@@ -477,3 +569,3 @@ function M(d, c, e, h, a) { | ||
for (d = 0 === m ? '' : d[0] + ' '; b < a; ++b) { | ||
c[b] = Z(d, c[b], e, m).trim(); | ||
c[b] = Z(d, c[b], e).trim(); | ||
} | ||
@@ -488,3 +580,3 @@ | ||
for (var n = 0; n < m; ++n) { | ||
c[v++] = Z(d[n] + ' ', h[b], e, m).trim(); | ||
c[v++] = Z(d[n] + ' ', h[b], e).trim(); | ||
} | ||
@@ -693,3 +785,3 @@ } | ||
default: | ||
if ('function' === typeof d) S[A++] = d;else if ('object' === (typeof d === 'undefined' ? 'undefined' : _typeof(d))) for (var c = 0, e = d.length; c < e; ++c) { | ||
if ('function' === typeof d) S[A++] = d;else if ('object' === typeof d) for (var c = 0, e = d.length; c < e; ++c) { | ||
T(d[c]); | ||
@@ -775,5 +867,5 @@ } else Y = !!d | 0; | ||
// https://github.com/thysultan/stylis.js/tree/master/plugins/rule-sheet | ||
// inlined to avoid umd wrapper and peerDep warnings/installing stylis | ||
// since we use stylis after closure compiler | ||
var delimiter = '/*|*/'; | ||
@@ -791,2 +883,3 @@ var needle = delimiter + '}'; | ||
}; | ||
var ruleSheet = function ruleSheet(context, content, selectors, parents, line, column, length, ns, depth, at) { | ||
@@ -851,2 +944,3 @@ switch (context) { | ||
}; | ||
var removeLabel = function removeLabel(context, content) { | ||
@@ -857,9 +951,9 @@ if (context === 1 && // charcode for l | ||
) { | ||
return ''; | ||
} | ||
return ''; | ||
} | ||
}; | ||
var isBrowser = typeof document !== 'undefined'; | ||
var isBrowser$1 = typeof document !== 'undefined'; | ||
var rootServerStylisCache = {}; | ||
var getServerStylisCache = isBrowser ? undefined : weakMemoize(function () { | ||
var getServerStylisCache = isBrowser$1 ? undefined : weakMemoize(function () { | ||
var getCache = weakMemoize(function () { | ||
@@ -907,3 +1001,3 @@ return {}; | ||
if (isBrowser) { | ||
if (isBrowser$1) { | ||
container = options.container || document.head; | ||
@@ -926,3 +1020,3 @@ var nodes = document.querySelectorAll("style[data-emotion-" + key + "]"); | ||
if (isBrowser) { | ||
if (isBrowser$1) { | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
@@ -1154,4 +1248,2 @@ | ||
var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var hyphenateRegex = /[A-Z]|^ms/g; | ||
@@ -1234,3 +1326,3 @@ var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g; | ||
switch (typeof interpolation === 'undefined' ? 'undefined' : _typeof$1(interpolation)) { | ||
switch (typeof interpolation) { | ||
case 'boolean': | ||
@@ -1316,3 +1408,3 @@ { | ||
if ((typeof value === 'undefined' ? 'undefined' : _typeof$1(value)) !== 'object') { | ||
if (typeof value !== 'object') { | ||
if (registered != null && registered[value] !== undefined) { | ||
@@ -1352,4 +1444,5 @@ string += _key + "{" + registered[value] + "}"; | ||
var cursor; | ||
var serializeStyles = function serializeStyles(args, registered, mergedProps) { | ||
if (args.length === 1 && _typeof$1(args[0]) === 'object' && args[0] !== null && args[0].styles !== undefined) { | ||
if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && args[0].styles !== undefined) { | ||
return args[0]; | ||
@@ -1416,3 +1509,4 @@ } | ||
var isBrowser$1 = typeof document !== 'undefined'; | ||
var isBrowser = typeof document !== 'undefined'; | ||
function getRegisteredStyles(registered, registeredStyles, classNames) { | ||
@@ -1429,2 +1523,3 @@ var rawClassName = ''; | ||
} | ||
var insertStyles = function insertStyles(cache, serialized, isStringTag) { | ||
@@ -1442,3 +1537,3 @@ var className = cache.key + "-" + serialized.name; | ||
// also, note that this check will be dead code eliminated in the browser | ||
isBrowser$1 === false && cache.compat !== undefined) && cache.registered[className] === undefined) { | ||
isBrowser === false && cache.compat !== undefined) && cache.registered[className] === undefined) { | ||
cache.registered[className] = serialized.styles; | ||
@@ -1454,3 +1549,3 @@ } | ||
if (!isBrowser$1 && maybeStyles !== undefined) { | ||
if (!isBrowser && maybeStyles !== undefined) { | ||
stylesForSSR += maybeStyles; | ||
@@ -1462,3 +1557,3 @@ } | ||
if (!isBrowser$1 && stylesForSSR.length !== 0) { | ||
if (!isBrowser && stylesForSSR.length !== 0) { | ||
return stylesForSSR; | ||
@@ -1469,4 +1564,2 @@ } | ||
var _typeof$2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function insertWithoutScoping(cache, serialized) { | ||
@@ -1574,3 +1667,3 @@ if (cache.inserted[serialized.name] === undefined) { | ||
switch (typeof arg === 'undefined' ? 'undefined' : _typeof$2(arg)) { | ||
switch (typeof arg) { | ||
case 'boolean': | ||
@@ -1617,24 +1710,25 @@ break; | ||
var _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; }; | ||
function stylesheetOverride(stylesheet, props, themeData) { | ||
const borderStyles = props.variant === `line` ? themeData[`input.textArea.line.borderColor`] : themeData[`input.box.default.borderColor`]; | ||
function stylesheetOverride(stylesheet, props, themeData) { | ||
var borderStyles = props.variant === "line" ? themeData["input.textArea.line.borderColor"] : themeData["input.box.default.borderColor"]; | ||
var textArea = _extends({}, stylesheet.input, { | ||
display: "block", | ||
resize: "vertical", | ||
padding: themeData["input.paddingVertical"] + "\n " + themeData["input.box.paddingHorizontal"], | ||
height: "calc((" + themeData["input.minHeight"] + " - 2px) * 2)" | ||
const textArea = _objectSpread2(_objectSpread2({}, stylesheet.input), {}, { | ||
display: `block`, | ||
resize: `vertical`, | ||
padding: `${themeData["input.paddingVertical"]} | ||
${themeData["input.box.paddingHorizontal"]}`, | ||
height: `calc((${themeData["input.minHeight"]} - 2px) * 2)` | ||
}); | ||
return _extends({}, stylesheet, { | ||
wrapper: _extends({}, stylesheet.wrapper, { | ||
return _objectSpread2(_objectSpread2({}, stylesheet), {}, { | ||
wrapper: _objectSpread2(_objectSpread2({}, stylesheet.wrapper), {}, { | ||
borderLeftColor: borderStyles, | ||
borderRightColor: borderStyles, | ||
borderTopColor: borderStyles, | ||
position: "static" | ||
position: `static` | ||
}), | ||
input: textArea, | ||
halo: _extends({}, stylesheet.halo, { | ||
width: "100%", | ||
halo: _objectSpread2(_objectSpread2({}, stylesheet.halo), {}, { | ||
width: `100%`, | ||
left: 0, | ||
top: "100%" | ||
top: `100%` | ||
}) | ||
@@ -1644,42 +1738,41 @@ }); | ||
var _extends$1 = 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; }; | ||
const _excluded = ["variant", "stylesheet", "textAreaRef"]; | ||
const variantTypes = ["line", "box"]; | ||
function _objectWithoutProperties(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; } | ||
const TextArea = props => { | ||
const { | ||
variant, | ||
stylesheet, | ||
textAreaRef | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded); | ||
var variantTypes = ["line", "box"]; | ||
const { | ||
className | ||
} = otherProps; | ||
const textareaClassName = className && className.split(" ").reduce((acc, cur) => cx(acc, `${cur.trim()}-textarea`), ""); | ||
var TextArea = function TextArea(props) { | ||
var variant = props.variant, | ||
stylesheet = props.stylesheet, | ||
textAreaRef = props.textAreaRef, | ||
otherProps = _objectWithoutProperties(props, ["variant", "stylesheet", "textAreaRef"]); | ||
var className = otherProps.className; | ||
var textareaClassName = className && className.split(" ").reduce(function (acc, cur) { | ||
return cx(acc, cur.trim() + "-textarea"); | ||
}, ""); | ||
var textareaStylesheet = function textareaStylesheet(styles, themeData) { | ||
var textareaStyles = stylesheetOverride(styles, props, themeData); | ||
return stylesheet ? stylesheet(textareaStyles, props, themeData) : textareaStyles; | ||
const textareaStylesheet = (styles, customProps, themeData) => { | ||
const textareaStyles = stylesheetOverride(styles, customProps, themeData); | ||
return stylesheet ? stylesheet(textareaStyles, customProps, themeData) : textareaStyles; | ||
}; | ||
return React.createElement( | ||
"div", | ||
{ style: { position: "relative" }, className: className }, | ||
React.createElement(Input, _extends$1({}, otherProps, { | ||
className: textareaClassName, | ||
inputRef: textAreaRef, | ||
stylesheet: textareaStylesheet, | ||
tagName: "textarea", | ||
variant: variant | ||
})) | ||
); | ||
return /*#__PURE__*/React.createElement("div", { | ||
style: { | ||
position: "relative" | ||
}, | ||
className: className | ||
}, /*#__PURE__*/React.createElement(Input, _extends({}, otherProps, { | ||
className: textareaClassName, | ||
inputRef: textAreaRef, | ||
stylesheet: textareaStylesheet, | ||
tagName: "textarea", | ||
variant: variant | ||
}))); | ||
}; | ||
TextArea.displayName = "TextArea"; | ||
TextArea.propTypes = { | ||
onBlur: PropTypes.func, | ||
/** | ||
@@ -1689,2 +1782,3 @@ * Called after user changes the value of the field | ||
onChange: PropTypes.func, | ||
/** | ||
@@ -1694,2 +1788,3 @@ * Called when user puts focus onto the field | ||
onFocus: PropTypes.func, | ||
/** | ||
@@ -1699,2 +1794,3 @@ * Called as user changes the value of the field | ||
onInput: PropTypes.func, | ||
/** | ||
@@ -1704,2 +1800,3 @@ * A callback ref that gets passed to the HTML textarea | ||
textAreaRef: PropTypes.func, | ||
/** | ||
@@ -1709,2 +1806,3 @@ * The visual variant of the textarea | ||
variant: PropTypes.oneOf(variantTypes), | ||
/** | ||
@@ -1715,3 +1813,2 @@ * Adds custom/overriding styles | ||
}; | ||
TextArea.defaultProps = { | ||
@@ -1787,2 +1884,2 @@ variant: "line" | ||
export default TextArea; | ||
export { TextArea as default }; |
@@ -5,8 +5,107 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = require('react'); | ||
var PropTypes = require('prop-types'); | ||
var Input = require('@hig/input'); | ||
var React = _interopDefault(require('react')); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
var Input = _interopDefault(require('@hig/input')); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); | ||
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input); | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
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 _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 _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
} | ||
return target; | ||
} | ||
function _objectWithoutProperties(source, excluded) { | ||
if (source == null) return {}; | ||
var target = _objectWithoutPropertiesLoose(source, excluded); | ||
var key, i; | ||
if (Object.getOwnPropertySymbols) { | ||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
key = sourceSymbolKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
} | ||
/* | ||
@@ -43,2 +142,3 @@ | ||
for (var i = 0; i < document.styleSheets.length; i++) { | ||
@@ -64,5 +164,3 @@ if (document.styleSheets[i].ownerNode === tag) { | ||
var StyleSheet = | ||
/*#__PURE__*/ | ||
function () { | ||
var StyleSheet = /*#__PURE__*/function () { | ||
function StyleSheet(options) { | ||
@@ -147,4 +245,2 @@ this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function stylis_min(W) { | ||
@@ -483,3 +579,3 @@ function M(d, c, e, h, a) { | ||
for (d = 0 === m ? '' : d[0] + ' '; b < a; ++b) { | ||
c[b] = Z(d, c[b], e, m).trim(); | ||
c[b] = Z(d, c[b], e).trim(); | ||
} | ||
@@ -494,3 +590,3 @@ | ||
for (var n = 0; n < m; ++n) { | ||
c[v++] = Z(d[n] + ' ', h[b], e, m).trim(); | ||
c[v++] = Z(d[n] + ' ', h[b], e).trim(); | ||
} | ||
@@ -699,3 +795,3 @@ } | ||
default: | ||
if ('function' === typeof d) S[A++] = d;else if ('object' === (typeof d === 'undefined' ? 'undefined' : _typeof(d))) for (var c = 0, e = d.length; c < e; ++c) { | ||
if ('function' === typeof d) S[A++] = d;else if ('object' === typeof d) for (var c = 0, e = d.length; c < e; ++c) { | ||
T(d[c]); | ||
@@ -781,5 +877,5 @@ } else Y = !!d | 0; | ||
// https://github.com/thysultan/stylis.js/tree/master/plugins/rule-sheet | ||
// inlined to avoid umd wrapper and peerDep warnings/installing stylis | ||
// since we use stylis after closure compiler | ||
var delimiter = '/*|*/'; | ||
@@ -797,2 +893,3 @@ var needle = delimiter + '}'; | ||
}; | ||
var ruleSheet = function ruleSheet(context, content, selectors, parents, line, column, length, ns, depth, at) { | ||
@@ -857,2 +954,3 @@ switch (context) { | ||
}; | ||
var removeLabel = function removeLabel(context, content) { | ||
@@ -863,9 +961,9 @@ if (context === 1 && // charcode for l | ||
) { | ||
return ''; | ||
} | ||
return ''; | ||
} | ||
}; | ||
var isBrowser = typeof document !== 'undefined'; | ||
var isBrowser$1 = typeof document !== 'undefined'; | ||
var rootServerStylisCache = {}; | ||
var getServerStylisCache = isBrowser ? undefined : weakMemoize(function () { | ||
var getServerStylisCache = isBrowser$1 ? undefined : weakMemoize(function () { | ||
var getCache = weakMemoize(function () { | ||
@@ -913,3 +1011,3 @@ return {}; | ||
if (isBrowser) { | ||
if (isBrowser$1) { | ||
container = options.container || document.head; | ||
@@ -932,3 +1030,3 @@ var nodes = document.querySelectorAll("style[data-emotion-" + key + "]"); | ||
if (isBrowser) { | ||
if (isBrowser$1) { | ||
stylis.use(options.stylisPlugins)(ruleSheet); | ||
@@ -1160,4 +1258,2 @@ | ||
var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var hyphenateRegex = /[A-Z]|^ms/g; | ||
@@ -1240,3 +1336,3 @@ var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g; | ||
switch (typeof interpolation === 'undefined' ? 'undefined' : _typeof$1(interpolation)) { | ||
switch (typeof interpolation) { | ||
case 'boolean': | ||
@@ -1322,3 +1418,3 @@ { | ||
if ((typeof value === 'undefined' ? 'undefined' : _typeof$1(value)) !== 'object') { | ||
if (typeof value !== 'object') { | ||
if (registered != null && registered[value] !== undefined) { | ||
@@ -1358,4 +1454,5 @@ string += _key + "{" + registered[value] + "}"; | ||
var cursor; | ||
var serializeStyles = function serializeStyles(args, registered, mergedProps) { | ||
if (args.length === 1 && _typeof$1(args[0]) === 'object' && args[0] !== null && args[0].styles !== undefined) { | ||
if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && args[0].styles !== undefined) { | ||
return args[0]; | ||
@@ -1422,3 +1519,4 @@ } | ||
var isBrowser$1 = typeof document !== 'undefined'; | ||
var isBrowser = typeof document !== 'undefined'; | ||
function getRegisteredStyles(registered, registeredStyles, classNames) { | ||
@@ -1435,2 +1533,3 @@ var rawClassName = ''; | ||
} | ||
var insertStyles = function insertStyles(cache, serialized, isStringTag) { | ||
@@ -1448,3 +1547,3 @@ var className = cache.key + "-" + serialized.name; | ||
// also, note that this check will be dead code eliminated in the browser | ||
isBrowser$1 === false && cache.compat !== undefined) && cache.registered[className] === undefined) { | ||
isBrowser === false && cache.compat !== undefined) && cache.registered[className] === undefined) { | ||
cache.registered[className] = serialized.styles; | ||
@@ -1460,3 +1559,3 @@ } | ||
if (!isBrowser$1 && maybeStyles !== undefined) { | ||
if (!isBrowser && maybeStyles !== undefined) { | ||
stylesForSSR += maybeStyles; | ||
@@ -1468,3 +1567,3 @@ } | ||
if (!isBrowser$1 && stylesForSSR.length !== 0) { | ||
if (!isBrowser && stylesForSSR.length !== 0) { | ||
return stylesForSSR; | ||
@@ -1475,4 +1574,2 @@ } | ||
var _typeof$2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function insertWithoutScoping(cache, serialized) { | ||
@@ -1580,3 +1677,3 @@ if (cache.inserted[serialized.name] === undefined) { | ||
switch (typeof arg === 'undefined' ? 'undefined' : _typeof$2(arg)) { | ||
switch (typeof arg) { | ||
case 'boolean': | ||
@@ -1623,24 +1720,25 @@ break; | ||
var _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; }; | ||
function stylesheetOverride(stylesheet, props, themeData) { | ||
const borderStyles = props.variant === `line` ? themeData[`input.textArea.line.borderColor`] : themeData[`input.box.default.borderColor`]; | ||
function stylesheetOverride(stylesheet, props, themeData) { | ||
var borderStyles = props.variant === "line" ? themeData["input.textArea.line.borderColor"] : themeData["input.box.default.borderColor"]; | ||
var textArea = _extends({}, stylesheet.input, { | ||
display: "block", | ||
resize: "vertical", | ||
padding: themeData["input.paddingVertical"] + "\n " + themeData["input.box.paddingHorizontal"], | ||
height: "calc((" + themeData["input.minHeight"] + " - 2px) * 2)" | ||
const textArea = _objectSpread2(_objectSpread2({}, stylesheet.input), {}, { | ||
display: `block`, | ||
resize: `vertical`, | ||
padding: `${themeData["input.paddingVertical"]} | ||
${themeData["input.box.paddingHorizontal"]}`, | ||
height: `calc((${themeData["input.minHeight"]} - 2px) * 2)` | ||
}); | ||
return _extends({}, stylesheet, { | ||
wrapper: _extends({}, stylesheet.wrapper, { | ||
return _objectSpread2(_objectSpread2({}, stylesheet), {}, { | ||
wrapper: _objectSpread2(_objectSpread2({}, stylesheet.wrapper), {}, { | ||
borderLeftColor: borderStyles, | ||
borderRightColor: borderStyles, | ||
borderTopColor: borderStyles, | ||
position: "static" | ||
position: `static` | ||
}), | ||
input: textArea, | ||
halo: _extends({}, stylesheet.halo, { | ||
width: "100%", | ||
halo: _objectSpread2(_objectSpread2({}, stylesheet.halo), {}, { | ||
width: `100%`, | ||
left: 0, | ||
top: "100%" | ||
top: `100%` | ||
}) | ||
@@ -1650,68 +1748,71 @@ }); | ||
var _extends$1 = 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; }; | ||
const _excluded = ["variant", "stylesheet", "textAreaRef"]; | ||
const variantTypes = ["line", "box"]; | ||
function _objectWithoutProperties(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; } | ||
const TextArea = props => { | ||
const { | ||
variant, | ||
stylesheet, | ||
textAreaRef | ||
} = props, | ||
otherProps = _objectWithoutProperties(props, _excluded); | ||
var variantTypes = ["line", "box"]; | ||
const { | ||
className | ||
} = otherProps; | ||
const textareaClassName = className && className.split(" ").reduce((acc, cur) => cx(acc, `${cur.trim()}-textarea`), ""); | ||
var TextArea = function TextArea(props) { | ||
var variant = props.variant, | ||
stylesheet = props.stylesheet, | ||
textAreaRef = props.textAreaRef, | ||
otherProps = _objectWithoutProperties(props, ["variant", "stylesheet", "textAreaRef"]); | ||
var className = otherProps.className; | ||
var textareaClassName = className && className.split(" ").reduce(function (acc, cur) { | ||
return cx(acc, cur.trim() + "-textarea"); | ||
}, ""); | ||
var textareaStylesheet = function textareaStylesheet(styles, themeData) { | ||
var textareaStyles = stylesheetOverride(styles, props, themeData); | ||
return stylesheet ? stylesheet(textareaStyles, props, themeData) : textareaStyles; | ||
const textareaStylesheet = (styles, customProps, themeData) => { | ||
const textareaStyles = stylesheetOverride(styles, customProps, themeData); | ||
return stylesheet ? stylesheet(textareaStyles, customProps, themeData) : textareaStyles; | ||
}; | ||
return React.createElement( | ||
"div", | ||
{ style: { position: "relative" }, className: className }, | ||
React.createElement(Input, _extends$1({}, otherProps, { | ||
className: textareaClassName, | ||
inputRef: textAreaRef, | ||
stylesheet: textareaStylesheet, | ||
tagName: "textarea", | ||
variant: variant | ||
})) | ||
); | ||
return /*#__PURE__*/React__default["default"].createElement("div", { | ||
style: { | ||
position: "relative" | ||
}, | ||
className: className | ||
}, /*#__PURE__*/React__default["default"].createElement(Input__default["default"], _extends({}, otherProps, { | ||
className: textareaClassName, | ||
inputRef: textAreaRef, | ||
stylesheet: textareaStylesheet, | ||
tagName: "textarea", | ||
variant: variant | ||
}))); | ||
}; | ||
TextArea.displayName = "TextArea"; | ||
TextArea.propTypes = { | ||
onBlur: PropTypes__default["default"].func, | ||
TextArea.propTypes = { | ||
onBlur: PropTypes.func, | ||
/** | ||
* Called after user changes the value of the field | ||
*/ | ||
onChange: PropTypes.func, | ||
onChange: PropTypes__default["default"].func, | ||
/** | ||
* Called when user puts focus onto the field | ||
*/ | ||
onFocus: PropTypes.func, | ||
onFocus: PropTypes__default["default"].func, | ||
/** | ||
* Called as user changes the value of the field | ||
*/ | ||
onInput: PropTypes.func, | ||
onInput: PropTypes__default["default"].func, | ||
/** | ||
* A callback ref that gets passed to the HTML textarea | ||
*/ | ||
textAreaRef: PropTypes.func, | ||
textAreaRef: PropTypes__default["default"].func, | ||
/** | ||
* The visual variant of the textarea | ||
*/ | ||
variant: PropTypes.oneOf(variantTypes), | ||
variant: PropTypes__default["default"].oneOf(variantTypes), | ||
/** | ||
* Adds custom/overriding styles | ||
*/ | ||
stylesheet: PropTypes.func | ||
stylesheet: PropTypes__default["default"].func | ||
}; | ||
TextArea.defaultProps = { | ||
@@ -1787,2 +1888,2 @@ variant: "line" | ||
exports.default = TextArea; | ||
exports["default"] = TextArea; |
@@ -0,1 +1,8 @@ | ||
# [@hig/text-area-v2.1.1](https://github.com/Autodesk/hig/compare/@hig/text-area@2.1.0...@hig/text-area@2.1.1) (2022-04-24) | ||
### Bug Fixes | ||
* Sending correct parameters in the textareaStylesheet callback function ([a143d9c](https://github.com/Autodesk/hig/commit/a143d9c)) | ||
# [@hig/text-area-v2.1.0](https://github.com/Autodesk/hig/compare/@hig/text-area@2.0.0...@hig/text-area@2.1.0) (2022-01-24) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "@hig/text-area", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "HIG Text Area", | ||
@@ -25,3 +25,3 @@ "author": "Autodesk Inc.", | ||
"@hig/theme-context": "^4.1.0", | ||
"@hig/theme-data": "^2.23.0", | ||
"@hig/theme-data": "^2.25.0", | ||
"react": "^17.0.0" | ||
@@ -28,0 +28,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
109347
3044