@talend/react-faceted-search
Version:
67 lines (66 loc) • 1.83 kB
JavaScript
import { useMemo } from 'react';
import PropTypes from 'prop-types';
import { ButtonPrimary, Form } from '@talend/design-system';
import { getDataAttrFromProps } from '@talend/utils';
import { getApplyDataFeature } from '../../../helpers/usage.helpers';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const BadgeTextForm = ({
id,
onChange,
onSubmit,
value,
feature,
t,
placeholder,
minLength,
maxLength,
...rest
}) => {
const applyDataFeature = useMemo(() => getApplyDataFeature(feature), [feature]);
const onChangeText = event => {
onChange(event, event.target.value);
};
return /*#__PURE__*/_jsxs(Form, {
id: `${id}-text-area`,
onSubmit: onSubmit,
children: [/*#__PURE__*/_jsx(Form.Text, {
id: `${id}-text`,
onChange: onChangeText,
placeholder: placeholder || t('TYPE_HERE', {
defaultValue: 'Type here'
}),
type: "text",
value: value,
minLength: minLength,
maxLength: maxLength
}), /*#__PURE__*/_jsx(Form.Buttons, {
padding: {
x: 0,
bottom: 0,
top: 'M'
},
children: /*#__PURE__*/_jsx(ButtonPrimary, {
type: "submit",
"data-feature": applyDataFeature,
...getDataAttrFromProps(rest),
children: t('APPLY', {
defaultValue: 'Apply'
})
})
})]
});
};
BadgeTextForm.propTypes = {
id: PropTypes.string.isRequired,
onChange: PropTypes.func,
onSubmit: PropTypes.func.isRequired,
value: PropTypes.string,
feature: PropTypes.string.isRequired,
t: PropTypes.func.isRequired,
placeholder: PropTypes.string,
minLength: PropTypes.number,
maxLength: PropTypes.number
};
// eslint-disable-next-line import/prefer-default-export
export { BadgeTextForm };
//# sourceMappingURL=BadgeTextForm.component.js.map