@alfalab/core-components-input
Advanced tools
Comparing version 1.1.3 to 1.2.0
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
@@ -13,11 +35,14 @@ if (mod && mod.__esModule) return mod; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = __importStar(require("react")); | ||
const classnames_1 = __importDefault(require("classnames")); | ||
const index_module_css_1 = __importDefault(require("./index.module.css")); | ||
var react_1 = __importStar(require("react")); | ||
var classnames_1 = __importDefault(require("classnames")); | ||
var index_module_css_1 = __importDefault(require("./index.module.css")); | ||
// TODO: Этого не будет, когда появится компонент иконки. | ||
const errorIcon = (react_1.default.createElement("svg", { width: '18', height: '18', viewBox: '0 0 18 18', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, | ||
var errorIcon = (react_1.default.createElement("svg", { width: '18', height: '18', viewBox: '0 0 18 18', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' }, | ||
react_1.default.createElement("path", { d: 'M16.8709 14.432L9.80088 2.61199C9.71724 2.47327 9.59918 2.35852 9.45813 2.27886C9.31709 2.19921 9.15786 2.15735 8.99588 2.15735C8.8339 2.15735 8.67467 2.19921 8.53362 2.27886C8.39258 2.35852 8.27452 2.47327 8.19088 2.61199L1.13088 14.432C1.04895 14.5739 1.00552 14.7347 1.00489 14.8985C1.00426 15.0623 1.04647 15.2235 1.12731 15.366C1.20816 15.5085 1.32484 15.6273 1.46579 15.7108C1.60674 15.7943 1.76707 15.8395 1.93088 15.842H16.0609C16.2259 15.8426 16.3881 15.7993 16.5309 15.7165C16.6736 15.6337 16.7918 15.5145 16.8732 15.3709C16.9546 15.2274 16.9964 15.0648 16.9942 14.8998C16.9921 14.7348 16.9461 14.5733 16.8609 14.432H16.8709ZM9.87088 13.242C9.87088 13.4489 9.7887 13.6473 9.64242 13.7935C9.49614 13.9398 9.29775 14.022 9.09088 14.022H8.86088C8.75845 14.022 8.65702 14.0018 8.56239 13.9626C8.46775 13.9234 8.38177 13.866 8.30934 13.7935C8.23691 13.7211 8.17945 13.6351 8.14025 13.5405C8.10105 13.4458 8.08088 13.3444 8.08088 13.242V13.002C8.08088 12.572 8.43088 12.222 8.86088 12.222H9.13088C9.56188 12.222 9.91088 12.572 9.91088 13.002L9.87088 13.242ZM9.64088 11.242H8.31088L8.09088 5.80199H9.91088L9.64088 11.242Z', fill: '#EF3124' }))); | ||
exports.Input = react_1.default.forwardRef(({ size = 's', type = 'text', block = false, bottomAddons, className, dataTestId, disabled, error, hint, inputClassName, label, leftAddons, onFocus, onBlur, rightAddons, value, ...restProps }, ref) => { | ||
const [focused, setFocused] = react_1.useState(false); | ||
const handleInputFocus = (e) => { | ||
exports.Input = react_1.default.forwardRef(function (_a, ref) { | ||
var _b; | ||
var _c = _a.size, size = _c === void 0 ? 's' : _c, _d = _a.type, type = _d === void 0 ? 'text' : _d, _e = _a.block, block = _e === void 0 ? false : _e, bottomAddons = _a.bottomAddons, className = _a.className, dataTestId = _a.dataTestId, disabled = _a.disabled, error = _a.error, hint = _a.hint, inputClassName = _a.inputClassName, label = _a.label, leftAddons = _a.leftAddons, onFocus = _a.onFocus, onBlur = _a.onBlur, onChange = _a.onChange, rightAddons = _a.rightAddons, value = _a.value, restProps = __rest(_a, ["size", "type", "block", "bottomAddons", "className", "dataTestId", "disabled", "error", "hint", "inputClassName", "label", "leftAddons", "onFocus", "onBlur", "onChange", "rightAddons", "value"]); | ||
var _f = react_1.useState(false), focused = _f[0], setFocused = _f[1]; | ||
var _g = react_1.useState(value !== undefined && value !== ''), filled = _g[0], setFilled = _g[1]; | ||
var handleInputFocus = function (e) { | ||
setFocused(true); | ||
@@ -28,3 +53,3 @@ if (onFocus) { | ||
}; | ||
const handleInputBlur = (e) => { | ||
var handleInputBlur = function (e) { | ||
setFocused(false); | ||
@@ -35,14 +60,24 @@ if (onBlur) { | ||
}; | ||
const rightAddonsRenderer = () => (error || rightAddons) && (react_1.default.createElement("div", { className: classnames_1.default(index_module_css_1.default.addons) }, | ||
error && errorIcon, | ||
rightAddons)); | ||
const leftAddonsRenderer = () => leftAddons && react_1.default.createElement("div", { className: index_module_css_1.default.addons }, leftAddons); | ||
return (react_1.default.createElement("div", { className: classnames_1.default(index_module_css_1.default.component, index_module_css_1.default[size], { | ||
[index_module_css_1.default.focused]: focused, | ||
[index_module_css_1.default.disabled]: disabled, | ||
[index_module_css_1.default.filled]: value, | ||
[index_module_css_1.default.hasLabel]: label, | ||
[index_module_css_1.default.hasError]: error, | ||
[index_module_css_1.default.block]: block, | ||
}, className) }, | ||
var handleInputChange = function (e) { | ||
setFilled(e.target.value !== ''); | ||
if (onChange) { | ||
onChange(e); | ||
} | ||
}; | ||
var rightAddonsRenderer = function () { | ||
return (error || rightAddons) && (react_1.default.createElement("div", { className: classnames_1.default(index_module_css_1.default.addons) }, | ||
error && errorIcon, | ||
rightAddons)); | ||
}; | ||
var leftAddonsRenderer = function () { | ||
return leftAddons && react_1.default.createElement("div", { className: index_module_css_1.default.addons }, leftAddons); | ||
}; | ||
return (react_1.default.createElement("div", { className: classnames_1.default(index_module_css_1.default.component, index_module_css_1.default[size], (_b = {}, | ||
_b[index_module_css_1.default.focused] = focused, | ||
_b[index_module_css_1.default.disabled] = disabled, | ||
_b[index_module_css_1.default.filled] = filled, | ||
_b[index_module_css_1.default.hasLabel] = label, | ||
_b[index_module_css_1.default.hasError] = error, | ||
_b[index_module_css_1.default.block] = block, | ||
_b), className) }, | ||
react_1.default.createElement("div", { className: index_module_css_1.default.inner }, | ||
@@ -52,3 +87,3 @@ leftAddonsRenderer(), | ||
label && react_1.default.createElement("div", { className: index_module_css_1.default.label }, label), | ||
react_1.default.createElement("input", Object.assign({}, restProps, { className: classnames_1.default(index_module_css_1.default.input, inputClassName), disabled: disabled, onBlur: handleInputBlur, onFocus: handleInputFocus, ref: ref, type: type, value: value, "data-test-id": dataTestId }))), | ||
react_1.default.createElement("input", __assign({}, restProps, { className: classnames_1.default(index_module_css_1.default.input, inputClassName), disabled: disabled, onBlur: handleInputBlur, onFocus: handleInputFocus, onChange: handleInputChange, ref: ref, type: type, value: value, "data-test-id": dataTestId }))), | ||
rightAddonsRenderer()), | ||
@@ -55,0 +90,0 @@ (error || hint) && react_1.default.createElement("span", { className: index_module_css_1.default.sub }, error || hint), |
{ | ||
"name": "@alfalab/core-components-input", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "", | ||
@@ -18,3 +18,3 @@ "keywords": [], | ||
}, | ||
"gitHead": "e76512cbc5336ab0420b6ea5afa8c0979cebb749" | ||
"gitHead": "dc692d3f87268477e5b61271fa883588d251a88e" | ||
} |
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
44025
11
1002
3