@weareconceptstudio/form 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,7 @@ import React, { useRef, cloneElement } from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { hasPrefixSuffix, hasAddon } from './utils';
|
|
4
4
|
const BaseInput = (props) => {
|
|
5
|
-
const { inputElement: inputEl, addonBefore, addonAfter, prefix, suffix, allowClear, disabled, readOnly, components, value,
|
|
5
|
+
const { inputElement: inputEl, addonBefore, addonAfter, prefix, suffix, allowClear, disabled, readOnly, components, value, containerClassName, children } = props;
|
|
6
6
|
const inputElement = children ?? inputEl;
|
|
7
7
|
// ======================== Components ======================== //
|
|
8
8
|
const AffixWrapperComponent = components?.affixWrapper || 'div';
|
|
@@ -52,7 +52,7 @@ const BaseInput = (props) => {
|
|
|
52
52
|
addonAfter && React.createElement(GroupAddonComponent, null, addonAfter))));
|
|
53
53
|
}
|
|
54
54
|
const classString = classNames('base-input-container', {
|
|
55
|
-
[
|
|
55
|
+
[containerClassName]: containerClassName,
|
|
56
56
|
});
|
|
57
57
|
return (React.createElement("div", { className: classString }, cloneElement(element, {
|
|
58
58
|
className: classNames({
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import BaseInput from '../BaseInput';
|
|
3
3
|
import { useInput } from '../../form/hooks/useInput';
|
|
4
|
+
import { useTranslation } from '@weareconceptstudio/core';
|
|
4
5
|
const TextArea = (props) => {
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
});
|
|
6
|
+
const { translate } = useTranslation();
|
|
7
|
+
const { name, placeholder, rows = 5, onChange, onFocus, onBlur, onKeyDown, onKeyUp, disabled, className, autoComplete } = props;
|
|
8
|
+
const input = name ? useInput({ name, onChange, onBlur }) : null;
|
|
9
|
+
const field = input?.field || {
|
|
10
|
+
onChange: onChange,
|
|
11
|
+
onBlur: onBlur,
|
|
12
|
+
};
|
|
8
13
|
return (React.createElement(BaseInput, { ...props },
|
|
9
|
-
React.createElement("textarea", { ...field, rows:
|
|
14
|
+
React.createElement("textarea", { ...field, rows: rows, onFocus: onFocus, onKeyUp: onKeyUp, disabled: disabled, className: className, onKeyDown: onKeyDown, autoComplete: autoComplete, placeholder: translate(placeholder) })));
|
|
10
15
|
};
|
|
11
16
|
if (process.env.NODE_ENV !== 'production') {
|
|
12
17
|
TextArea.displayName = 'TextArea';
|