@true-engineering/true-react-common-ui-kit 4.0.0-alpha21 → 4.0.0-alpha23
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.
- package/dist/components/TextArea/TextArea.d.ts +2 -0
- package/dist/components/TextArea/TextArea.styles.d.ts +5 -3
- package/dist/components/TextArea/index.d.ts +1 -0
- package/dist/components/TextArea/types.d.ts +4 -0
- package/dist/true-react-common-ui-kit.js +49 -37
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +49 -37
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/TextArea/TextArea.stories.tsx +14 -1
- package/src/components/TextArea/TextArea.styles.ts +13 -2
- package/src/components/TextArea/TextArea.tsx +67 -54
- package/src/components/TextArea/index.ts +1 -0
- package/src/components/TextArea/types.ts +6 -0
|
@@ -2,10 +2,12 @@ import { FormEvent, TextareaHTMLAttributes } from 'react';
|
|
|
2
2
|
import { ICommonProps } from '../../types';
|
|
3
3
|
import { IControlWrapperProps } from '../ControlWrapper';
|
|
4
4
|
import { IWithMessagesProps } from '../WithMessages';
|
|
5
|
+
import { ITextAreaCounterPosition } from './types';
|
|
5
6
|
import { ITextAreaStyles } from './TextArea.styles';
|
|
6
7
|
export interface ITextAreaProps extends ICommonProps<ITextAreaStyles>, Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'onChange'>, Pick<IControlWrapperProps, 'label' | 'isInvalid' | 'isRequired' | 'isDisabled' | 'size' | 'groupPlacement'>, Pick<IWithMessagesProps, 'infoMessage' | 'errorMessage'> {
|
|
7
8
|
value?: string;
|
|
8
9
|
placeholder?: string;
|
|
10
|
+
counterPosition?: ITextAreaCounterPosition;
|
|
9
11
|
/** @default false */
|
|
10
12
|
isActive?: boolean;
|
|
11
13
|
/**
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ITweakStyles } from '../../theme';
|
|
2
|
-
import {
|
|
2
|
+
import { IWithPrefix } from '../../types';
|
|
3
|
+
import { IControlWrapperSizes, IControlWrapperStyles } from '../ControlWrapper';
|
|
3
4
|
import { IWithMessagesStyles } from '../WithMessages';
|
|
4
|
-
|
|
5
|
+
import { ITextAreaCounterPositions } from './types';
|
|
6
|
+
export declare const useStyles: import("../../theme").IUseStyles<"root" | "textarea" | "autoSized" | "withLabel" | "wrapper" | "symbolsCount" | "symbolsCountError" | "symbolsCountActive" | "counter-default", unknown>;
|
|
5
7
|
export type ITextAreaStyles = ITweakStyles<typeof useStyles, {
|
|
6
8
|
tweakWithMessages: IWithMessagesStyles;
|
|
7
9
|
tweakControlWrapper: IControlWrapperStyles;
|
|
8
|
-
}>;
|
|
10
|
+
} & IWithPrefix<ITextAreaCounterPositions, 'counter-'> & IControlWrapperSizes>;
|
|
@@ -29668,7 +29668,7 @@ var PhoneInputCountryList = function(param) {
|
|
|
29668
29668
|
]
|
|
29669
29669
|
});
|
|
29670
29670
|
};
|
|
29671
|
-
var DEFAULT_VALUE
|
|
29671
|
+
var DEFAULT_VALUE = {
|
|
29672
29672
|
phoneNumber: "",
|
|
29673
29673
|
dialCode: ""
|
|
29674
29674
|
};
|
|
@@ -29886,7 +29886,7 @@ function _unsupported_iterable_to_array$2(o, minLen) {
|
|
|
29886
29886
|
return _array_like_to_array$2(o, minLen);
|
|
29887
29887
|
}
|
|
29888
29888
|
var PhoneInput = function(_param) {
|
|
29889
|
-
var _param_locale = _param.locale, locale = _param_locale === void 0 ? "ru" : _param_locale, _param_value = _param.value, value = _param_value === void 0 ? DEFAULT_VALUE
|
|
29889
|
+
var _param_locale = _param.locale, locale = _param_locale === void 0 ? "ru" : _param_locale, _param_value = _param.value, value = _param_value === void 0 ? DEFAULT_VALUE : _param_value, onChange = _param.onChange, data = _param.data, testId = _param.testId, isDisabled = _param.isDisabled, isInvalid = _param.isInvalid, isActive = _param.isActive, tweakStyles = _param.tweakStyles, _param_codeSearchPlaceholder = _param.codeSearchPlaceholder, codeSearchPlaceholder = _param_codeSearchPlaceholder === void 0 ? "Поиск" : _param_codeSearchPlaceholder, _param_noMatchesLabel = _param.noMatchesLabel, noMatchesLabel = _param_noMatchesLabel === void 0 ? "Ничего не найдено" : _param_noMatchesLabel, inputProps = _object_without_properties$5(_param, [
|
|
29890
29890
|
"locale",
|
|
29891
29891
|
"value",
|
|
29892
29892
|
"onChange",
|
|
@@ -31329,6 +31329,9 @@ function _object_spread_props$6(target, source) {
|
|
|
31329
31329
|
return target;
|
|
31330
31330
|
}
|
|
31331
31331
|
var useStyles$4 = createThemedStyles("TextArea", {
|
|
31332
|
+
root: {
|
|
31333
|
+
width: "100%"
|
|
31334
|
+
},
|
|
31332
31335
|
textarea: _object_spread_props$6(_object_spread$6({}, helpers.withScrollBar), {
|
|
31333
31336
|
width: "100%",
|
|
31334
31337
|
height: "100%",
|
|
@@ -31388,6 +31391,8 @@ var useStyles$4 = createThemedStyles("TextArea", {
|
|
|
31388
31391
|
symbolsCountError: {
|
|
31389
31392
|
color: "red"
|
|
31390
31393
|
},
|
|
31394
|
+
symbolsCountActive: {},
|
|
31395
|
+
"counter-default": {},
|
|
31391
31396
|
withLabel: {}
|
|
31392
31397
|
});
|
|
31393
31398
|
function _array_like_to_array(arr, len) {
|
|
@@ -31532,12 +31537,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
31532
31537
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
31533
31538
|
return _array_like_to_array(o, minLen);
|
|
31534
31539
|
}
|
|
31535
|
-
var DEFAULT_VALUE = "";
|
|
31536
31540
|
var TextArea = /* @__PURE__ */ forwardRef(function(_param, ref) {
|
|
31537
|
-
var _param_value = _param.value, value = _param_value === void 0 ?
|
|
31541
|
+
var _param_value = _param.value, value = _param_value === void 0 ? "" : _param_value, placeholder = _param.placeholder, name = _param.name, _param_counterPosition = _param.counterPosition, counterPosition = _param_counterPosition === void 0 ? "default" : _param_counterPosition, shouldFocusOnMount = _param.shouldFocusOnMount, _param_hasCounter = _param.hasCounter, hasCounter = _param_hasCounter === void 0 ? true : _param_hasCounter, shouldTrimAfterMaxLength = _param.shouldTrimAfterMaxLength, _param_isAutoSized = _param.isAutoSized, isAutoSized = _param_isAutoSized === void 0 ? true : _param_isAutoSized, shouldAlwaysShowPlaceholder = _param.shouldAlwaysShowPlaceholder, isActive = _param.isActive, maxLength = _param.maxLength, rows = _param.rows, data = _param.data, testId = _param.testId, tweakStyles = _param.tweakStyles, onChange = _param.onChange, onPaste = _param.onPaste, onFocus = _param.onFocus, onBlur = _param.onBlur, infoMessage = _param.infoMessage, errorMessage = _param.errorMessage, label = _param.label, isDisabled = _param.isDisabled, isInvalid = _param.isInvalid, isRequired = _param.isRequired, size2 = _param.size, groupPlacement = _param.groupPlacement, textAreaProps = _object_without_properties$3(_param, [
|
|
31538
31542
|
"value",
|
|
31539
31543
|
"placeholder",
|
|
31540
31544
|
"name",
|
|
31545
|
+
"counterPosition",
|
|
31541
31546
|
"shouldFocusOnMount",
|
|
31542
31547
|
"hasCounter",
|
|
31543
31548
|
"shouldTrimAfterMaxLength",
|
|
@@ -31565,6 +31570,8 @@ var TextArea = /* @__PURE__ */ forwardRef(function(_param, ref) {
|
|
|
31565
31570
|
var classes = useStyles$4({
|
|
31566
31571
|
theme: tweakStyles
|
|
31567
31572
|
});
|
|
31573
|
+
var shouldShowCounter = hasCounter && isNotEmpty(maxLength);
|
|
31574
|
+
var counterString = "".concat(value.length, " / ").concat(maxLength);
|
|
31568
31575
|
var tweakWithMessagesStyles = useTweakStyles({
|
|
31569
31576
|
tweakStyles,
|
|
31570
31577
|
className: "tweakWithMessages",
|
|
@@ -31591,14 +31598,18 @@ var TextArea = /* @__PURE__ */ forwardRef(function(_param, ref) {
|
|
|
31591
31598
|
setFocused(false);
|
|
31592
31599
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
31593
31600
|
};
|
|
31594
|
-
var _obj2;
|
|
31595
|
-
return /* @__PURE__ */
|
|
31596
|
-
|
|
31597
|
-
|
|
31598
|
-
|
|
31599
|
-
|
|
31600
|
-
children:
|
|
31601
|
-
|
|
31601
|
+
var _obj2, _obj1;
|
|
31602
|
+
return /* @__PURE__ */ jsx("div", {
|
|
31603
|
+
className: clsx(classes.root, isNotEmpty(size2) && classes[size2]),
|
|
31604
|
+
style: {
|
|
31605
|
+
"--counter-length": counterString.length
|
|
31606
|
+
},
|
|
31607
|
+
children: /* @__PURE__ */ jsx(WithMessages, {
|
|
31608
|
+
errorMessage,
|
|
31609
|
+
infoMessage,
|
|
31610
|
+
tweakStyles: tweakWithMessagesStyles,
|
|
31611
|
+
testId: getTestId(testId, "wrapper"),
|
|
31612
|
+
children: /* @__PURE__ */ jsx(ControlWrapper, {
|
|
31602
31613
|
label,
|
|
31603
31614
|
tweakStyles: tweakControlWrapperStyles,
|
|
31604
31615
|
isFocused: hasFocus,
|
|
@@ -31609,37 +31620,38 @@ var TextArea = /* @__PURE__ */ forwardRef(function(_param, ref) {
|
|
|
31609
31620
|
groupPlacement,
|
|
31610
31621
|
size: size2,
|
|
31611
31622
|
isFullWidth: true,
|
|
31612
|
-
children: /* @__PURE__ */
|
|
31623
|
+
children: /* @__PURE__ */ jsxs("div", _object_spread_props$5(_object_spread$5({
|
|
31613
31624
|
className: clsx(classes.wrapper, (_obj2 = {}, _define_property$5(_obj2, classes.autoSized, isAutoSized), _define_property$5(_obj2, classes.withLabel, hasLabel), _obj2))
|
|
31614
31625
|
}, isAutoSized && {
|
|
31615
31626
|
"data-value": value
|
|
31616
31627
|
}), {
|
|
31617
|
-
children:
|
|
31618
|
-
|
|
31619
|
-
|
|
31620
|
-
|
|
31621
|
-
|
|
31622
|
-
|
|
31623
|
-
|
|
31624
|
-
|
|
31625
|
-
|
|
31626
|
-
|
|
31627
|
-
|
|
31628
|
-
|
|
31629
|
-
|
|
31630
|
-
|
|
31631
|
-
|
|
31628
|
+
children: [
|
|
31629
|
+
/* @__PURE__ */ jsx("textarea", _object_spread$5({
|
|
31630
|
+
ref,
|
|
31631
|
+
className: classes.textarea,
|
|
31632
|
+
value,
|
|
31633
|
+
disabled: isDisabled,
|
|
31634
|
+
placeholder: hasPlaceholder ? placeholder : void 0,
|
|
31635
|
+
maxLength: shouldTrimAfterMaxLength ? maxLength : void 0,
|
|
31636
|
+
name,
|
|
31637
|
+
rows,
|
|
31638
|
+
onPaste,
|
|
31639
|
+
onFocus: handleFocus,
|
|
31640
|
+
onBlur: handleBlur,
|
|
31641
|
+
onChange: handleChange,
|
|
31642
|
+
autoFocus: shouldFocusOnMount
|
|
31643
|
+
}, addDataAttributes$1(data, testId), textAreaProps)),
|
|
31644
|
+
shouldShowCounter && /* @__PURE__ */ jsx("span", _object_spread_props$5(_object_spread$5({
|
|
31645
|
+
className: clsx(classes.symbolsCount, classes["counter-".concat(counterPosition)], (_obj1 = {}, _define_property$5(_obj1, classes.symbolsCountError, value.length > maxLength), _define_property$5(_obj1, classes.symbolsCountActive, hasFocus || hasValue), _obj1))
|
|
31646
|
+
}, addDataAttributes$1({
|
|
31647
|
+
counterPosition
|
|
31648
|
+
})), {
|
|
31649
|
+
children: counterString
|
|
31650
|
+
}))
|
|
31651
|
+
]
|
|
31632
31652
|
}))
|
|
31633
|
-
}),
|
|
31634
|
-
hasCounter && isNotEmpty(maxLength) && /* @__PURE__ */ jsxs("span", {
|
|
31635
|
-
className: clsx(classes.symbolsCount, _define_property$5({}, classes.symbolsCountError, value.length > maxLength)),
|
|
31636
|
-
children: [
|
|
31637
|
-
value.length,
|
|
31638
|
-
" / ",
|
|
31639
|
-
maxLength
|
|
31640
|
-
]
|
|
31641
31653
|
})
|
|
31642
|
-
|
|
31654
|
+
})
|
|
31643
31655
|
});
|
|
31644
31656
|
});
|
|
31645
31657
|
var useStyles$3 = createThemedStyles("TextButton", {
|