Repository URL to install this package:
|
Version:
3.12.16 ▾
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _excluded = ["isFilterOptions", "value", "selectOnly", "onChange", "containerHeight", "inputRef", "enableAIDescription", "generateDescription", "isDescriptionLoading", "setIsDescriptionLoading", "isDescripeBtnHidden", "placeholder", "i18n"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
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; }
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; }
import Styled from './MetaDataFieldTextareaType.styled';
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export default (function (_ref) {
var isFilterOptions = _ref.isFilterOptions,
_ref$value = _ref.value,
value = _ref$value === void 0 ? '' : _ref$value,
selectOnly = _ref.selectOnly,
onChange = _ref.onChange,
containerHeight = _ref.containerHeight,
inputRef = _ref.inputRef,
enableAIDescription = _ref.enableAIDescription,
generateDescription = _ref.generateDescription,
isDescriptionLoading = _ref.isDescriptionLoading,
setIsDescriptionLoading = _ref.setIsDescriptionLoading,
isDescripeBtnHidden = _ref.isDescripeBtnHidden,
placeholder = _ref.placeholder,
i18n = _ref.i18n,
rest = _objectWithoutProperties(_ref, _excluded);
var showDescribeWithAIBtn = !isDescripeBtnHidden && enableAIDescription;
var handleOnChange = function handleOnChange(value) {
if (isFilterOptions) selectOnly(value);
onChange(value);
};
var handleClearAll = function handleClearAll() {
onChange('');
};
var handleGenerateDescription = function handleGenerateDescription() {
onChange('');
generateDescription().then(function (generatedDescription) {
return onChange(generatedDescription);
});
};
return /*#__PURE__*/_jsxs(Styled.InputGroupWrapper, {
children: [isDescriptionLoading && /*#__PURE__*/_jsx(Styled.Spinner, {
size: 16.5
}), /*#__PURE__*/_jsx(Styled.InputGroup, _objectSpread(_objectSpread({}, rest), {}, {
placeholder: isDescriptionLoading ? '' : placeholder,
value: value,
onChange: function onChange(_ref2) {
var value = _ref2.target.value;
return handleOnChange(value);
},
fullWidth: true,
type: "textarea",
ref: inputRef
})), showDescribeWithAIBtn && /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsx(Styled.Button, {
color: "link-primary",
onClick: handleGenerateDescription,
disabled: isDescriptionLoading,
size: "sm",
children: i18n('DescribeWithAIButtonText')
}), /*#__PURE__*/_jsx(Styled.ClearAllButton, {
color: "link-secondary",
onClick: handleClearAll,
size: "sm",
children: i18n('DescribeClearAllButton')
})]
})]
});
});