@hh.ru/magritte-ui-input 9.4.50 → 9.4.52
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/BaseInput.d.ts +2 -2
- package/BaseInput.js +235 -124
- package/BaseInput.js.map +1 -1
- package/DateTimeInput.d.ts +4 -4
- package/DateTimeInput.js +49 -43
- package/DateTimeInput.js.map +1 -1
- package/Input.d.ts +2 -2
- package/Input.js +2 -3
- package/Input.js.map +1 -1
- package/NumberInput.d.ts +2 -2
- package/NumberInput.js +22 -13
- package/NumberInput.js.map +1 -1
- package/PasswordInput.d.ts +2 -2
- package/PasswordInput.js +29 -16
- package/PasswordInput.js.map +1 -1
- package/SearchInput.d.ts +2 -2
- package/SearchInput.js +11 -2
- package/SearchInput.js.map +1 -1
- package/UncontrolledDateTimeInput.d.ts +4 -4
- package/UncontrolledDateTimeInput.js +4 -4
- package/UncontrolledDateTimeInput.js.map +1 -1
- package/UncontrolledInput.d.ts +2 -2
- package/UncontrolledInput.js +3 -3
- package/UncontrolledInput.js.map +1 -1
- package/UncontrolledNumberInput.d.ts +2 -2
- package/UncontrolledNumberInput.js +3 -3
- package/UncontrolledNumberInput.js.map +1 -1
- package/UncontrolledPasswordInput.d.ts +2 -2
- package/UncontrolledPasswordInput.js +3 -3
- package/UncontrolledPasswordInput.js.map +1 -1
- package/UncontrolledSearchInput.d.ts +2 -2
- package/UncontrolledSearchInput.js +3 -3
- package/UncontrolledSearchInput.js.map +1 -1
- package/index.css +266 -266
- package/index.d.ts +13 -13
- package/{index.esm-CYELQMAZ.js → index.esm-t97x9DTo.js} +1 -1
- package/{index.esm-CYELQMAZ.js.map → index.esm-t97x9DTo.js.map} +1 -1
- package/index.js +1 -1
- package/index.mock.d.ts +1 -1
- package/index.mock.js +55 -27
- package/index.mock.js.map +1 -1
- package/maskito-exports.js +1 -1
- package/numberFormatter.d.ts +1 -1
- package/numberFormatter.js +42 -42
- package/numberFormatter.js.map +1 -1
- package/package.json +7 -7
- package/useDateTimeMask.d.ts +1 -1
- package/useDateTimeMask.js +107 -133
- package/useDateTimeMask.js.map +1 -1
- package/useFocus.js +22 -13
- package/useFocus.js.map +1 -1
- package/useInputAriaProps.js +16 -10
- package/useInputAriaProps.js.map +1 -1
- package/useUncontrolledInput.js +9 -6
- package/useUncontrolledInput.js.map +1 -1
package/BaseInput.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { InputHTMLAttributes } from 'react';
|
|
2
|
-
import { BaseInputProps } from '
|
|
3
|
-
declare const BaseInput: import("react").ForwardRefExoticComponent<(BaseInputProps & Omit<InputHTMLAttributes<HTMLInputElement>, "
|
|
2
|
+
import { BaseInputProps } from './types';
|
|
3
|
+
declare const BaseInput: import("react").ForwardRefExoticComponent<(BaseInputProps & Omit<InputHTMLAttributes<HTMLInputElement>, "buttonDataQa" | "buttonIcon" | "buttonIconAriaLabel" | "buttonRef" | "clearable" | "clearableOnFocus" | "description" | "disabled" | "elevatePlaceholder" | "errorMessage" | "fixedPlaceholder" | "formatter" | "hint" | "inputIcon" | "invalid" | "maxLength" | "onBlur" | "onButtonClick" | "onChange" | "onFocus" | "placeholder" | "postfix" | "showHintAlways" | "size" | "value" | "wrapperRef">) & import("react").RefAttributes<HTMLInputElement>>;
|
|
4
4
|
export { BaseInput };
|
package/BaseInput.js
CHANGED
|
@@ -13,144 +13,255 @@ import { useFocus } from './useFocus.js';
|
|
|
13
13
|
import { useInputAriaProps } from './useInputAriaProps.js';
|
|
14
14
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
15
15
|
|
|
16
|
-
var styles = {"input":"magritte-input___LVTID_9-4-
|
|
16
|
+
var styles = {"input":"magritte-input___LVTID_9-4-52","label":"magritte-label___YlOQk_9-4-52","elevated":"magritte-elevated___kPcsM_9-4-52","focused":"magritte-focused___dxrHD_9-4-52","invalid":"magritte-invalid___L5MVa_9-4-52","disabled":"magritte-disabled___0NH6E_9-4-52","position-container":"magritte-position-container___kZnvZ_9-4-52","positionContainer":"magritte-position-container___kZnvZ_9-4-52","field":"magritte-field___9S8Tw_9-4-52","hint":"magritte-hint___EFGK0_9-4-52","additional-value":"magritte-additional-value___9Kyap_9-4-52","additionalValue":"magritte-additional-value___9Kyap_9-4-52","label_elevated":"magritte-label_elevated___PVcpC_9-4-52","labelElevated":"magritte-label_elevated___PVcpC_9-4-52","fixed-placeholder":"magritte-fixed-placeholder___PYJIH_9-4-52","fixedPlaceholder":"magritte-fixed-placeholder___PYJIH_9-4-52","icon":"magritte-icon___HEDsQ_9-4-52","focus-visible":"magritte-focus-visible___QvCO1_9-4-52","focusVisible":"magritte-focus-visible___QvCO1_9-4-52","right-container":"magritte-right-container___N0B0o_9-4-52","rightContainer":"magritte-right-container___N0B0o_9-4-52","with-icon":"magritte-with-icon___TPBe2_9-4-52","withIcon":"magritte-with-icon___TPBe2_9-4-52","large":"magritte-large___9frRh_9-4-52","small":"magritte-small___iQL4F_9-4-52","autofill-helper":"magritte-autofill-helper___WFjOW_9-4-52","autofillHelper":"magritte-autofill-helper___WFjOW_9-4-52","content-container":"magritte-content-container___s-0kX_9-4-52","contentContainer":"magritte-content-container___s-0kX_9-4-52","rigging-container":"magritte-rigging-container___Up9Lb_9-4-52","riggingContainer":"magritte-rigging-container___Up9Lb_9-4-52","input__mask":"magritte-input__mask___CHda2_9-4-52","inputMask":"magritte-input__mask___CHda2_9-4-52","value-ghost":"magritte-value-ghost___IXNZj_9-4-52","valueGhost":"magritte-value-ghost___IXNZj_9-4-52","hint-container":"magritte-hint-container___rGsD8_9-4-52","hintContainer":"magritte-hint-container___rGsD8_9-4-52","counter":"magritte-counter___Bld3Q_9-4-52","value-container":"magritte-value-container___6ReT7_9-4-52","valueContainer":"magritte-value-container___6ReT7_9-4-52"};
|
|
17
17
|
|
|
18
18
|
const matchIconSize = (size, icon) => {
|
|
19
|
-
|
|
20
|
-
(((size === 'medium' || size === 'large') && icon._size === 24) ||
|
|
21
|
-
(size === 'small' && icon._size === 16))
|
|
22
|
-
? icon
|
|
23
|
-
: null;
|
|
19
|
+
return icon && ((size === "medium" || size === "large") && icon._size === 24 || size === "small" && icon._size === 16) ? icon : null;
|
|
24
20
|
};
|
|
25
|
-
// В safari при вставке числа и последующем его стирании задваивалась каретка если использовалась groupSize = 0
|
|
26
|
-
// Это происходило только после вставки из буфера
|
|
27
|
-
// каретка возвращалась на место если стриггерить setCaretPosition повторно
|
|
28
|
-
// Запуск сдвига дважды фиксит эту проблему
|
|
29
21
|
const setCaretPosition = (el, position) => {
|
|
22
|
+
requestAnimationFrame(() => {
|
|
23
|
+
Selection.setCaretPosition(el, position);
|
|
30
24
|
requestAnimationFrame(() => {
|
|
31
|
-
|
|
32
|
-
requestAnimationFrame(() => {
|
|
33
|
-
Selection.setCaretPosition(el, position);
|
|
34
|
-
});
|
|
25
|
+
Selection.setCaretPosition(el, position);
|
|
35
26
|
});
|
|
27
|
+
});
|
|
36
28
|
};
|
|
37
|
-
const BaseInputForwardRefRenderFunc = ({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
29
|
+
const BaseInputForwardRefRenderFunc = ({
|
|
30
|
+
onChange,
|
|
31
|
+
onFocus,
|
|
32
|
+
onBlur,
|
|
33
|
+
value,
|
|
34
|
+
placeholder,
|
|
35
|
+
disabled = false,
|
|
36
|
+
postfix,
|
|
37
|
+
size = "medium",
|
|
38
|
+
elevatePlaceholder = false,
|
|
39
|
+
invalid = false,
|
|
40
|
+
description,
|
|
41
|
+
errorMessage,
|
|
42
|
+
formatter,
|
|
43
|
+
buttonIcon: _buttonIcon,
|
|
44
|
+
buttonIconAriaLabel: _buttonIconAriaLabel,
|
|
45
|
+
clearable = false,
|
|
46
|
+
clearableOnFocus,
|
|
47
|
+
onButtonClick,
|
|
48
|
+
buttonDataQa,
|
|
49
|
+
buttonRef,
|
|
50
|
+
inputIcon,
|
|
51
|
+
wrapperRef,
|
|
52
|
+
fixedPlaceholder,
|
|
53
|
+
maxLength,
|
|
54
|
+
hint,
|
|
55
|
+
showHintAlways = false,
|
|
56
|
+
"aria-describedby": ariaDescribedBy,
|
|
57
|
+
...restProps
|
|
58
|
+
}, ref) => {
|
|
59
|
+
const wrapperCurrentRef = useRef(null);
|
|
60
|
+
const inputRef = useRef(null);
|
|
61
|
+
const [isActionVisible, setActionVisible] = useState(false);
|
|
62
|
+
const inputRefCallback = useMultipleRefs(ref, inputRef);
|
|
63
|
+
const wrapperRefCallback = useMultipleRefs(wrapperRef, wrapperCurrentRef);
|
|
64
|
+
const descriptionId = useId();
|
|
65
|
+
const labelId = useId();
|
|
66
|
+
const hintRef = useRef(null);
|
|
67
|
+
const hintMaxWidthRef = useRef(null);
|
|
68
|
+
const change = useCallback(
|
|
69
|
+
(newValue, event) => {
|
|
70
|
+
if (inputRef.current && formatter) {
|
|
71
|
+
const caretPosition = Selection.getCaretPosition(inputRef.current);
|
|
72
|
+
const formatResult = formatter(value, newValue, caretPosition || 0);
|
|
73
|
+
setCaretPosition(inputRef.current, formatResult.caretPosition);
|
|
74
|
+
onChange(formatResult.outputValue, event);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
onChange(newValue, event);
|
|
78
|
+
},
|
|
79
|
+
[formatter, onChange, value, inputRef]
|
|
80
|
+
);
|
|
81
|
+
const clearClickHandler = useCallback(
|
|
82
|
+
(event) => {
|
|
83
|
+
onChange("");
|
|
84
|
+
inputRef.current && inputRef.current.focus();
|
|
85
|
+
onButtonClick?.(event);
|
|
86
|
+
},
|
|
87
|
+
[onChange, inputRef, onButtonClick]
|
|
88
|
+
);
|
|
89
|
+
const forceDisabled = useDisabled();
|
|
90
|
+
const isComponentDisabled = forceDisabled || !!disabled;
|
|
91
|
+
const { changeHandler, focusHandler, blurHandler, isFocused } = useFocus(change, onFocus, onBlur);
|
|
92
|
+
const placeholderCanBeElevated = size === "large" && !!elevatePlaceholder && !!placeholder;
|
|
93
|
+
const [isFocusVisible, setFocusVisible] = useState(false);
|
|
94
|
+
const currentValue = formatter?.("", value, 0).formattedValue || value;
|
|
95
|
+
const buttonQaLabel = buttonDataQa || `input-${clearable ? "clearable-" : ""}button`;
|
|
96
|
+
const ariaProps = useInputAriaProps({
|
|
97
|
+
invalid,
|
|
98
|
+
hasDescription: !!description || !!errorMessage || !!ariaDescribedBy,
|
|
99
|
+
hasPlaceholder: !!placeholder,
|
|
100
|
+
descriptionId: ariaDescribedBy || `input-description-${descriptionId}`,
|
|
101
|
+
labelId
|
|
102
|
+
});
|
|
103
|
+
const handleWrapperFocus = () => {
|
|
104
|
+
setActionVisible(true);
|
|
105
|
+
};
|
|
106
|
+
const handleWrapperBlur = () => {
|
|
107
|
+
requestAnimationFrame(() => {
|
|
108
|
+
if (!wrapperCurrentRef.current?.contains(document.activeElement)) {
|
|
109
|
+
setActionVisible(false);
|
|
110
|
+
}
|
|
75
111
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
112
|
+
};
|
|
113
|
+
const onClickWrapper = (e) => {
|
|
114
|
+
if (!isEventFromInteractiveComponent(e)) {
|
|
115
|
+
inputRef.current?.focus();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const focusedOrFilled = isFocused || value !== "";
|
|
119
|
+
const placeholderIsElevated = focusedOrFilled && placeholderCanBeElevated;
|
|
120
|
+
const showPostfix = !!postfix && (placeholderIsElevated || value !== "");
|
|
121
|
+
const showFixedPlaceholder = focusedOrFilled && !!fixedPlaceholder;
|
|
122
|
+
const showLabel = placeholderCanBeElevated || value === "" && !showFixedPlaceholder;
|
|
123
|
+
const InputIconComponent = matchIconSize(size, inputIcon);
|
|
124
|
+
const showClearButton = value.length > 0 && (clearable || !!clearableOnFocus && isActionVisible);
|
|
125
|
+
const showHint = !!hint && (showHintAlways || value.length > 0);
|
|
126
|
+
const buttonIcon = matchIconSize(size, _buttonIcon);
|
|
127
|
+
let ButtonIconComponent = buttonIcon;
|
|
128
|
+
let buttonIconAriaLabel = _buttonIconAriaLabel;
|
|
129
|
+
const trlClear = useTranslation("Input", "clear");
|
|
130
|
+
if (showClearButton) {
|
|
131
|
+
ButtonIconComponent = size === "small" ? CrossOutlinedSize16 : CrossOutlinedSize24;
|
|
132
|
+
buttonIconAriaLabel = trlClear;
|
|
133
|
+
}
|
|
134
|
+
const hintWrapperRefCallback = useCallback(
|
|
135
|
+
(element) => {
|
|
136
|
+
if (element && hintRef.current) {
|
|
137
|
+
const text = hintRef.current.innerText;
|
|
138
|
+
if (text.length > 30) {
|
|
139
|
+
let maxWidth;
|
|
140
|
+
if (text !== hintMaxWidthRef.current?.text) {
|
|
141
|
+
const newText = text.slice(0, 30);
|
|
142
|
+
hintRef.current.innerText = newText;
|
|
143
|
+
maxWidth = hintRef.current.offsetWidth;
|
|
144
|
+
hintRef.current.innerText = text;
|
|
145
|
+
hintMaxWidthRef.current = {
|
|
146
|
+
width: maxWidth,
|
|
147
|
+
text
|
|
148
|
+
};
|
|
149
|
+
} else {
|
|
150
|
+
maxWidth = hintMaxWidthRef.current.width;
|
|
151
|
+
}
|
|
152
|
+
element.style.maxWidth = `${maxWidth}px`;
|
|
89
153
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const showHint = !!hint && (showHintAlways || value.length > 0);
|
|
99
|
-
const buttonIcon = matchIconSize(size, _buttonIcon);
|
|
100
|
-
let ButtonIconComponent = buttonIcon;
|
|
101
|
-
let buttonIconAriaLabel = _buttonIconAriaLabel;
|
|
102
|
-
const trlClear = useTranslation('Input', 'clear');
|
|
103
|
-
if (showClearButton) {
|
|
104
|
-
ButtonIconComponent = size === 'small' ? CrossOutlinedSize16 : CrossOutlinedSize24;
|
|
105
|
-
buttonIconAriaLabel = trlClear;
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
157
|
+
[hint]
|
|
158
|
+
);
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (inputRef.current) {
|
|
161
|
+
setFocusVisible(isFocused && inputRef.current.classList.contains("focus-visible"));
|
|
106
162
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
163
|
+
}, [isFocused]);
|
|
164
|
+
return /* @__PURE__ */ jsxs(
|
|
165
|
+
"div",
|
|
166
|
+
{
|
|
167
|
+
ref: wrapperRefCallback,
|
|
168
|
+
className: classnames(styles.input, {
|
|
169
|
+
[styles.focused]: isFocused,
|
|
170
|
+
[styles.focusVisible]: isFocusVisible,
|
|
171
|
+
[styles.disabled]: isComponentDisabled,
|
|
172
|
+
[styles.large]: size === "large",
|
|
173
|
+
[styles.small]: size === "small",
|
|
174
|
+
[styles.elevated]: placeholderCanBeElevated,
|
|
175
|
+
[styles.invalid]: !!invalid,
|
|
176
|
+
[styles.withIcon]: !!inputIcon
|
|
177
|
+
}),
|
|
178
|
+
onFocus: clearableOnFocus ? handleWrapperFocus : void 0,
|
|
179
|
+
onBlur: clearableOnFocus ? handleWrapperBlur : void 0,
|
|
180
|
+
onClick: onClickWrapper,
|
|
181
|
+
"data-interactive": true,
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("div", { className: styles.positionContainer, children: [
|
|
184
|
+
/* @__PURE__ */ jsxs("div", { className: styles.hintContainer, children: [
|
|
185
|
+
/* @__PURE__ */ jsx("div", { className: styles.autofillHelper }),
|
|
186
|
+
/* @__PURE__ */ jsxs("div", { className: styles.contentContainer, children: [
|
|
187
|
+
!!InputIconComponent && /* @__PURE__ */ jsx("div", { className: styles.icon, children: /* @__PURE__ */ jsx(InputIconComponent, {}) }),
|
|
188
|
+
/* @__PURE__ */ jsx("div", { className: styles.riggingContainer, children: showLabel && /* @__PURE__ */ jsx(
|
|
189
|
+
"label",
|
|
190
|
+
{
|
|
191
|
+
className: classnames(styles.label, {
|
|
192
|
+
[styles.labelElevated]: placeholderIsElevated
|
|
193
|
+
}),
|
|
194
|
+
id: ariaProps["aria-labelledby"],
|
|
195
|
+
children: placeholder
|
|
121
196
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
197
|
+
) }),
|
|
198
|
+
/* @__PURE__ */ jsxs("div", { className: styles.valueContainer, children: [
|
|
199
|
+
/* @__PURE__ */ jsx(
|
|
200
|
+
"input",
|
|
201
|
+
{
|
|
202
|
+
...restProps,
|
|
203
|
+
...ariaProps,
|
|
204
|
+
maxLength,
|
|
205
|
+
disabled: isComponentDisabled,
|
|
206
|
+
suppressHydrationWarning: true,
|
|
207
|
+
className: styles.field,
|
|
208
|
+
value: currentValue,
|
|
209
|
+
onInput: changeHandler,
|
|
210
|
+
onFocus: focusHandler,
|
|
211
|
+
onBlur: blurHandler,
|
|
212
|
+
ref: inputRefCallback
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
/* @__PURE__ */ jsx("div", { className: styles.additionalValue, children: /* @__PURE__ */ jsxs(
|
|
216
|
+
Text,
|
|
217
|
+
{
|
|
218
|
+
Element: "span",
|
|
219
|
+
typography: size === "small" ? "label-3-regular" : "label-2-regular",
|
|
220
|
+
children: [
|
|
221
|
+
/* @__PURE__ */ jsx("span", { className: styles.valueGhost, children: currentValue }),
|
|
222
|
+
showFixedPlaceholder && /* @__PURE__ */ jsx("span", { className: styles.fixedPlaceholder, children: fixedPlaceholder.slice(value.length) }),
|
|
223
|
+
showPostfix && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
224
|
+
"\xA0",
|
|
225
|
+
postfix
|
|
226
|
+
] })
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
) })
|
|
230
|
+
] })
|
|
231
|
+
] }),
|
|
232
|
+
showHint && /* @__PURE__ */ jsx("div", { className: styles.hint, ref: hintWrapperRefCallback, "data-qa": "input-hint", children: /* @__PURE__ */ jsx(Text, { Element: "span", typography: size === "small" ? "label-4-regular" : "label-3-regular", children: /* @__PURE__ */ jsx("span", { ref: hintRef, children: hint }) }) })
|
|
233
|
+
] }),
|
|
234
|
+
ButtonIconComponent && /* @__PURE__ */ jsx("div", { className: styles.rightContainer, children: /* @__PURE__ */ jsx(
|
|
235
|
+
ButtonIconComponent,
|
|
236
|
+
{
|
|
237
|
+
padding: 8,
|
|
238
|
+
initialColor: "secondary",
|
|
239
|
+
borderRadius: "halfHeight",
|
|
240
|
+
"data-qa": buttonQaLabel,
|
|
241
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
242
|
+
onClick: showClearButton ? clearClickHandler : onButtonClick,
|
|
243
|
+
disabled: isComponentDisabled,
|
|
244
|
+
ref: buttonRef,
|
|
245
|
+
"aria-label": buttonIconAriaLabel
|
|
126
246
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
[styles.elevated]: placeholderCanBeElevated,
|
|
143
|
-
[styles.invalid]: !!invalid,
|
|
144
|
-
[styles.withIcon]: !!inputIcon,
|
|
145
|
-
}), onFocus: clearableOnFocus ? handleWrapperFocus : undefined, onBlur: clearableOnFocus ? handleWrapperBlur : undefined, onClick: onClickWrapper, "data-interactive": true, children: [jsxs("div", { className: styles.positionContainer, children: [jsxs("div", { className: styles.hintContainer, children: [jsx("div", { className: styles.autofillHelper }), jsxs("div", { className: styles.contentContainer, children: [!!InputIconComponent && (jsx("div", { className: styles.icon, children: jsx(InputIconComponent, {}) })), jsx("div", { className: styles.riggingContainer, children: showLabel && (jsx("label", { className: classnames(styles.label, {
|
|
146
|
-
[styles.labelElevated]: placeholderIsElevated,
|
|
147
|
-
}), id: ariaProps['aria-labelledby'], children: placeholder })) }), jsxs("div", { className: styles.valueContainer, children: [jsx("input", { ...restProps, ...ariaProps, maxLength: maxLength, disabled: isComponentDisabled, suppressHydrationWarning: true, className: styles.field, value: currentValue,
|
|
148
|
-
// maskito требует onInput, (https://maskito.dev/frameworks/react) который работает
|
|
149
|
-
// аналогично onChange
|
|
150
|
-
onInput: changeHandler, onFocus: focusHandler, onBlur: blurHandler, ref: inputRefCallback }), jsx("div", { className: styles.additionalValue, children: jsxs(Text, { Element: "span", typography: size === 'small' ? 'label-3-regular' : 'label-2-regular', children: [jsx("span", { className: styles.valueGhost, children: currentValue }), showFixedPlaceholder && (jsx("span", { className: styles.fixedPlaceholder, children: fixedPlaceholder.slice(value.length) })), showPostfix && (jsxs(Fragment, { children: ['\u00A0', postfix] }))] }) })] })] }), showHint && (jsx("div", { className: styles.hint, ref: hintWrapperRefCallback, "data-qa": "input-hint", children: jsx(Text, { Element: "span", typography: size === 'small' ? 'label-4-regular' : 'label-3-regular', children: jsx("span", { ref: hintRef, children: hint }) }) }))] }), ButtonIconComponent && (jsx("div", { className: styles.rightContainer, children: jsx(ButtonIconComponent, { padding: 8, initialColor: "secondary", borderRadius: "halfHeight", "data-qa": buttonQaLabel, onMouseDown: (event) => event.preventDefault(), onClick: showClearButton ? clearClickHandler : onButtonClick, disabled: isComponentDisabled, ref: buttonRef, "aria-label": buttonIconAriaLabel }) }))] }), jsx(FormHelper, { description: description, errorMessage: errorMessage, descriptionId: ariaProps['aria-describedby'], disabled: isComponentDisabled, invalid: invalid })] }));
|
|
247
|
+
) })
|
|
248
|
+
] }),
|
|
249
|
+
/* @__PURE__ */ jsx(
|
|
250
|
+
FormHelper,
|
|
251
|
+
{
|
|
252
|
+
description,
|
|
253
|
+
errorMessage,
|
|
254
|
+
descriptionId: ariaProps["aria-describedby"],
|
|
255
|
+
disabled: isComponentDisabled,
|
|
256
|
+
invalid
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
);
|
|
151
262
|
};
|
|
152
263
|
const BaseInput = forwardRef(BaseInputForwardRefRenderFunc);
|
|
153
|
-
BaseInput.displayName =
|
|
264
|
+
BaseInput.displayName = "BaseInput";
|
|
154
265
|
|
|
155
266
|
export { BaseInput };
|
|
156
267
|
//# sourceMappingURL=BaseInput.js.map
|
package/BaseInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInput.js","sources":["src/BaseInput.tsx"],"sourcesContent":["import {\n InputHTMLAttributes,\n forwardRef,\n ForwardedRef,\n useCallback,\n useId,\n useRef,\n useState,\n useEffect,\n RefCallback,\n MouseEventHandler,\n ChangeEvent,\n} from 'react';\nimport classnames from 'classnames';\n\nimport { isEventFromInteractiveComponent } from '@hh.ru/magritte-common-mouse';\nimport { Selection } from '@hh.ru/magritte-common-text-selection';\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport { FormHelper } from '@hh.ru/magritte-ui-form-helper';\nimport { CrossOutlinedSize16, CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { IconWrapperComponentSize16, IconWrapperComponentSize24 } from '@hh.ru/magritte-ui-icon/src/types';\nimport { BaseInputProps, InputSize } from '@hh.ru/magritte-ui-input/types';\nimport { useFocus } from '@hh.ru/magritte-ui-input/useFocus';\nimport { useInputAriaProps } from '@hh.ru/magritte-ui-input/useInputAriaProps';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './input.less';\n\nconst matchIconSize = (size: InputSize, icon: IconWrapperComponentSize16 | IconWrapperComponentSize24 | undefined) => {\n return icon &&\n (((size === 'medium' || size === 'large') && (icon as IconWrapperComponentSize24)._size === 24) ||\n (size === 'small' && (icon as IconWrapperComponentSize16)._size === 16))\n ? icon\n : null;\n};\n\n// В safari при вставке числа и последующем его стирании задваивалась каретка если использовалась groupSize = 0\n// Это происходило только после вставки из буфера\n// каретка возвращалась на место если стриггерить setCaretPosition повторно\n// Запуск сдвига дважды фиксит эту проблему\nconst setCaretPosition = (el: HTMLInputElement, position: number) => {\n requestAnimationFrame(() => {\n Selection.setCaretPosition(el, position);\n requestAnimationFrame(() => {\n Selection.setCaretPosition(el, position);\n });\n });\n};\n\nconst BaseInputForwardRefRenderFunc = (\n {\n onChange,\n onFocus,\n onBlur,\n value,\n placeholder,\n disabled = false,\n postfix,\n size = 'medium',\n elevatePlaceholder = false,\n invalid = false,\n description,\n errorMessage,\n formatter,\n buttonIcon: _buttonIcon,\n buttonIconAriaLabel: _buttonIconAriaLabel,\n clearable = false,\n clearableOnFocus,\n onButtonClick,\n buttonDataQa,\n buttonRef,\n inputIcon,\n wrapperRef,\n fixedPlaceholder,\n maxLength,\n hint,\n showHintAlways = false,\n 'aria-describedby': ariaDescribedBy,\n ...restProps\n }: BaseInputProps & Omit<InputHTMLAttributes<HTMLInputElement>, keyof BaseInputProps>,\n ref: ForwardedRef<HTMLInputElement>\n) => {\n const wrapperCurrentRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const [isActionVisible, setActionVisible] = useState(false);\n const inputRefCallback = useMultipleRefs(ref, inputRef);\n const wrapperRefCallback = useMultipleRefs(wrapperRef, wrapperCurrentRef);\n const descriptionId = useId();\n const labelId = useId();\n const hintRef = useRef<HTMLDivElement>(null);\n const hintMaxWidthRef = useRef<{ width: number; text: string } | null>(null);\n const change = useCallback(\n (newValue: string, event: ChangeEvent<HTMLInputElement>) => {\n if (inputRef.current && formatter) {\n const caretPosition = Selection.getCaretPosition(inputRef.current);\n const formatResult = formatter(value, newValue, caretPosition || 0);\n setCaretPosition(inputRef.current, formatResult.caretPosition);\n onChange(formatResult.outputValue, event);\n return;\n }\n onChange(newValue, event);\n },\n [formatter, onChange, value, inputRef]\n );\n\n const clearClickHandler = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n onChange('');\n inputRef.current && inputRef.current.focus();\n onButtonClick?.(event);\n },\n [onChange, inputRef, onButtonClick]\n );\n\n const forceDisabled = useDisabled();\n const isComponentDisabled = forceDisabled || !!disabled;\n\n const { changeHandler, focusHandler, blurHandler, isFocused } = useFocus(change, onFocus, onBlur);\n const placeholderCanBeElevated = size === 'large' && !!elevatePlaceholder && !!placeholder;\n const [isFocusVisible, setFocusVisible] = useState(false);\n const currentValue = formatter?.('', value, 0).formattedValue || value;\n const buttonQaLabel = buttonDataQa || `input-${clearable ? 'clearable-' : ''}button`;\n const ariaProps = useInputAriaProps({\n invalid,\n hasDescription: !!description || !!errorMessage || !!ariaDescribedBy,\n hasPlaceholder: !!placeholder,\n descriptionId: ariaDescribedBy || `input-description-${descriptionId}`,\n labelId,\n });\n\n const handleWrapperFocus = () => {\n setActionVisible(true);\n };\n\n const handleWrapperBlur = () => {\n requestAnimationFrame(() => {\n if (!wrapperCurrentRef.current?.contains(document.activeElement)) {\n setActionVisible(false);\n }\n });\n };\n\n const onClickWrapper: MouseEventHandler = (e) => {\n if (!isEventFromInteractiveComponent(e)) {\n inputRef.current?.focus();\n }\n };\n\n const focusedOrFilled = isFocused || value !== '';\n const placeholderIsElevated = focusedOrFilled && placeholderCanBeElevated;\n const showPostfix = !!postfix && (placeholderIsElevated || value !== '');\n const showFixedPlaceholder = focusedOrFilled && !!fixedPlaceholder;\n const showLabel = placeholderCanBeElevated || (value === '' && !showFixedPlaceholder);\n\n const InputIconComponent = matchIconSize(size, inputIcon);\n const showClearButton = value.length > 0 && (clearable || (!!clearableOnFocus && isActionVisible));\n const showHint = !!hint && (showHintAlways || value.length > 0);\n const buttonIcon = matchIconSize(size, _buttonIcon);\n let ButtonIconComponent = buttonIcon;\n let buttonIconAriaLabel = _buttonIconAriaLabel;\n const trlClear = useTranslation('Input', 'clear');\n if (showClearButton) {\n ButtonIconComponent = size === 'small' ? CrossOutlinedSize16 : CrossOutlinedSize24;\n buttonIconAriaLabel = trlClear;\n }\n\n const hintWrapperRefCallback: RefCallback<HTMLDivElement> = useCallback(\n (element) => {\n if (element && hintRef.current) {\n const text = hintRef.current.innerText;\n if (text.length > 30) {\n let maxWidth;\n if (text !== hintMaxWidthRef.current?.text) {\n const newText = text.slice(0, 30);\n hintRef.current.innerText = newText;\n maxWidth = hintRef.current.offsetWidth;\n hintRef.current.innerText = text;\n hintMaxWidthRef.current = {\n width: maxWidth,\n text,\n };\n } else {\n maxWidth = hintMaxWidthRef.current.width;\n }\n\n element.style.maxWidth = `${maxWidth}px`;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [hint]\n );\n\n useEffect(() => {\n if (inputRef.current) {\n setFocusVisible(isFocused && inputRef.current.classList.contains('focus-visible'));\n }\n }, [isFocused]);\n\n return (\n <div\n ref={wrapperRefCallback}\n className={classnames(styles.input, {\n [styles.focused]: isFocused,\n [styles.focusVisible]: isFocusVisible,\n [styles.disabled]: isComponentDisabled,\n [styles.large]: size === 'large',\n [styles.small]: size === 'small',\n [styles.elevated]: placeholderCanBeElevated,\n [styles.invalid]: !!invalid,\n [styles.withIcon]: !!inputIcon,\n })}\n onFocus={clearableOnFocus ? handleWrapperFocus : undefined}\n onBlur={clearableOnFocus ? handleWrapperBlur : undefined}\n onClick={onClickWrapper}\n data-interactive={true}\n >\n <div className={styles.positionContainer}>\n <div className={styles.hintContainer}>\n <div className={styles.autofillHelper} />\n <div className={styles.contentContainer}>\n {!!InputIconComponent && (\n <div className={styles.icon}>\n <InputIconComponent />\n </div>\n )}\n <div className={styles.riggingContainer}>\n {showLabel && (\n <label\n className={classnames(styles.label, {\n [styles.labelElevated]: placeholderIsElevated,\n })}\n id={ariaProps['aria-labelledby']}\n >\n {placeholder}\n </label>\n )}\n </div>\n <div className={styles.valueContainer}>\n <input\n {...restProps}\n {...ariaProps}\n maxLength={maxLength}\n disabled={isComponentDisabled}\n suppressHydrationWarning\n className={styles.field}\n value={currentValue}\n // maskito требует onInput, (https://maskito.dev/frameworks/react) который работает\n // аналогично onChange\n onInput={changeHandler}\n onFocus={focusHandler}\n onBlur={blurHandler}\n ref={inputRefCallback}\n />\n <div className={styles.additionalValue}>\n <Text\n Element=\"span\"\n typography={size === 'small' ? 'label-3-regular' : 'label-2-regular'}\n >\n <span className={styles.valueGhost}>{currentValue}</span>\n {showFixedPlaceholder && (\n <span className={styles.fixedPlaceholder}>\n {fixedPlaceholder.slice(value.length)}\n </span>\n )}\n {showPostfix && (\n <>\n {'\\u00A0'}\n {postfix}\n </>\n )}\n </Text>\n </div>\n </div>\n </div>\n {showHint && (\n <div className={styles.hint} ref={hintWrapperRefCallback} data-qa=\"input-hint\">\n <Text Element=\"span\" typography={size === 'small' ? 'label-4-regular' : 'label-3-regular'}>\n <span ref={hintRef}>{hint}</span>\n </Text>\n </div>\n )}\n </div>\n {ButtonIconComponent && (\n <div className={styles.rightContainer}>\n <ButtonIconComponent\n padding={8}\n initialColor=\"secondary\"\n borderRadius=\"halfHeight\"\n data-qa={buttonQaLabel}\n onMouseDown={(event) => event.preventDefault()} // чтобы инпут не терял фокус\n onClick={showClearButton ? clearClickHandler : onButtonClick}\n disabled={isComponentDisabled}\n ref={buttonRef}\n aria-label={buttonIconAriaLabel}\n />\n </div>\n )}\n </div>\n <FormHelper\n description={description}\n errorMessage={errorMessage}\n descriptionId={ariaProps['aria-describedby']}\n disabled={isComponentDisabled}\n invalid={invalid}\n />\n </div>\n );\n};\n\nconst BaseInput = forwardRef(BaseInputForwardRefRenderFunc);\n\nBaseInput.displayName = 'BaseInput';\n\nexport { BaseInput };\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAM,aAAa,GAAG,CAAC,IAAe,EAAE,IAAyE,KAAI;AACjH,IAAA,OAAO,IAAI;AACP,SAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,KAAM,IAAmC,CAAC,KAAK,KAAK,EAAE;aACzF,IAAI,KAAK,OAAO,IAAK,IAAmC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;AAC5E,UAAE,IAAI;UACJ,IAAI,CAAC;AACf,CAAC,CAAC;AAEF;AACA;AACA;AACA;AACA,MAAM,gBAAgB,GAAG,CAAC,EAAoB,EAAE,QAAgB,KAAI;IAChE,qBAAqB,CAAC,MAAK;AACvB,QAAA,SAAS,CAAC,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;QACzC,qBAAqB,CAAC,MAAK;AACvB,YAAA,SAAS,CAAC,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC7C,SAAC,CAAC,CAAC;AACP,KAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,6BAA6B,GAAG,CAClC,EACI,QAAQ,EACR,OAAO,EACP,MAAM,EACN,KAAK,EACL,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,IAAI,GAAG,QAAQ,EACf,kBAAkB,GAAG,KAAK,EAC1B,OAAO,GAAG,KAAK,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,UAAU,EAAE,WAAW,EACvB,mBAAmB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,eAAe,GAAG,iBAAiB,GAAG,aAAa,EAC5D,QAAQ,EAAE,mBAAmB,EAC7B,GAAG,EAAE,SAAS,EAAA,YAAA,EACF,mBAAmB,EAAA,CACjC,EACA,CAAA,CACT,CACC,EAAA,CAAA,EACNA,IAAC,UAAU,EAAA,EACP,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,SAAS,CAAC,kBAAkB,CAAC,EAC5C,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,OAAO,EAAA,CAClB,CACA,EAAA,CAAA,EACR;AACN,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,UAAU,CAAC,6BAA6B,EAAE;AAE5D,SAAS,CAAC,WAAW,GAAG,WAAW;;;;"}
|
|
1
|
+
{"version":3,"file":"BaseInput.js","sources":["src/BaseInput.tsx"],"sourcesContent":["import {\n InputHTMLAttributes,\n forwardRef,\n ForwardedRef,\n useCallback,\n useId,\n useRef,\n useState,\n useEffect,\n RefCallback,\n MouseEventHandler,\n ChangeEvent,\n} from 'react';\nimport classnames from 'classnames';\n\nimport { isEventFromInteractiveComponent } from '@hh.ru/magritte-common-mouse';\nimport { Selection } from '@hh.ru/magritte-common-text-selection';\nimport { useDisabled } from '@hh.ru/magritte-common-use-disabled';\nimport { useMultipleRefs } from '@hh.ru/magritte-common-use-multiple-refs';\nimport { useTranslation } from '@hh.ru/magritte-common-use-translation';\nimport { FormHelper } from '@hh.ru/magritte-ui-form-helper';\nimport { CrossOutlinedSize16, CrossOutlinedSize24 } from '@hh.ru/magritte-ui-icon/icon';\nimport { IconWrapperComponentSize16, IconWrapperComponentSize24 } from '@hh.ru/magritte-ui-icon/src/types';\nimport { BaseInputProps, InputSize } from '@hh.ru/magritte-ui-input/types';\nimport { useFocus } from '@hh.ru/magritte-ui-input/useFocus';\nimport { useInputAriaProps } from '@hh.ru/magritte-ui-input/useInputAriaProps';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './input.less';\n\nconst matchIconSize = (size: InputSize, icon: IconWrapperComponentSize16 | IconWrapperComponentSize24 | undefined) => {\n return icon &&\n (((size === 'medium' || size === 'large') && (icon as IconWrapperComponentSize24)._size === 24) ||\n (size === 'small' && (icon as IconWrapperComponentSize16)._size === 16))\n ? icon\n : null;\n};\n\n// В safari при вставке числа и последующем его стирании задваивалась каретка если использовалась groupSize = 0\n// Это происходило только после вставки из буфера\n// каретка возвращалась на место если стриггерить setCaretPosition повторно\n// Запуск сдвига дважды фиксит эту проблему\nconst setCaretPosition = (el: HTMLInputElement, position: number) => {\n requestAnimationFrame(() => {\n Selection.setCaretPosition(el, position);\n requestAnimationFrame(() => {\n Selection.setCaretPosition(el, position);\n });\n });\n};\n\nconst BaseInputForwardRefRenderFunc = (\n {\n onChange,\n onFocus,\n onBlur,\n value,\n placeholder,\n disabled = false,\n postfix,\n size = 'medium',\n elevatePlaceholder = false,\n invalid = false,\n description,\n errorMessage,\n formatter,\n buttonIcon: _buttonIcon,\n buttonIconAriaLabel: _buttonIconAriaLabel,\n clearable = false,\n clearableOnFocus,\n onButtonClick,\n buttonDataQa,\n buttonRef,\n inputIcon,\n wrapperRef,\n fixedPlaceholder,\n maxLength,\n hint,\n showHintAlways = false,\n 'aria-describedby': ariaDescribedBy,\n ...restProps\n }: BaseInputProps & Omit<InputHTMLAttributes<HTMLInputElement>, keyof BaseInputProps>,\n ref: ForwardedRef<HTMLInputElement>\n) => {\n const wrapperCurrentRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const [isActionVisible, setActionVisible] = useState(false);\n const inputRefCallback = useMultipleRefs(ref, inputRef);\n const wrapperRefCallback = useMultipleRefs(wrapperRef, wrapperCurrentRef);\n const descriptionId = useId();\n const labelId = useId();\n const hintRef = useRef<HTMLDivElement>(null);\n const hintMaxWidthRef = useRef<{ width: number; text: string } | null>(null);\n const change = useCallback(\n (newValue: string, event: ChangeEvent<HTMLInputElement>) => {\n if (inputRef.current && formatter) {\n const caretPosition = Selection.getCaretPosition(inputRef.current);\n const formatResult = formatter(value, newValue, caretPosition || 0);\n setCaretPosition(inputRef.current, formatResult.caretPosition);\n onChange(formatResult.outputValue, event);\n return;\n }\n onChange(newValue, event);\n },\n [formatter, onChange, value, inputRef]\n );\n\n const clearClickHandler = useCallback(\n (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n onChange('');\n inputRef.current && inputRef.current.focus();\n onButtonClick?.(event);\n },\n [onChange, inputRef, onButtonClick]\n );\n\n const forceDisabled = useDisabled();\n const isComponentDisabled = forceDisabled || !!disabled;\n\n const { changeHandler, focusHandler, blurHandler, isFocused } = useFocus(change, onFocus, onBlur);\n const placeholderCanBeElevated = size === 'large' && !!elevatePlaceholder && !!placeholder;\n const [isFocusVisible, setFocusVisible] = useState(false);\n const currentValue = formatter?.('', value, 0).formattedValue || value;\n const buttonQaLabel = buttonDataQa || `input-${clearable ? 'clearable-' : ''}button`;\n const ariaProps = useInputAriaProps({\n invalid,\n hasDescription: !!description || !!errorMessage || !!ariaDescribedBy,\n hasPlaceholder: !!placeholder,\n descriptionId: ariaDescribedBy || `input-description-${descriptionId}`,\n labelId,\n });\n\n const handleWrapperFocus = () => {\n setActionVisible(true);\n };\n\n const handleWrapperBlur = () => {\n requestAnimationFrame(() => {\n if (!wrapperCurrentRef.current?.contains(document.activeElement)) {\n setActionVisible(false);\n }\n });\n };\n\n const onClickWrapper: MouseEventHandler = (e) => {\n if (!isEventFromInteractiveComponent(e)) {\n inputRef.current?.focus();\n }\n };\n\n const focusedOrFilled = isFocused || value !== '';\n const placeholderIsElevated = focusedOrFilled && placeholderCanBeElevated;\n const showPostfix = !!postfix && (placeholderIsElevated || value !== '');\n const showFixedPlaceholder = focusedOrFilled && !!fixedPlaceholder;\n const showLabel = placeholderCanBeElevated || (value === '' && !showFixedPlaceholder);\n\n const InputIconComponent = matchIconSize(size, inputIcon);\n const showClearButton = value.length > 0 && (clearable || (!!clearableOnFocus && isActionVisible));\n const showHint = !!hint && (showHintAlways || value.length > 0);\n const buttonIcon = matchIconSize(size, _buttonIcon);\n let ButtonIconComponent = buttonIcon;\n let buttonIconAriaLabel = _buttonIconAriaLabel;\n const trlClear = useTranslation('Input', 'clear');\n if (showClearButton) {\n ButtonIconComponent = size === 'small' ? CrossOutlinedSize16 : CrossOutlinedSize24;\n buttonIconAriaLabel = trlClear;\n }\n\n const hintWrapperRefCallback: RefCallback<HTMLDivElement> = useCallback(\n (element) => {\n if (element && hintRef.current) {\n const text = hintRef.current.innerText;\n if (text.length > 30) {\n let maxWidth;\n if (text !== hintMaxWidthRef.current?.text) {\n const newText = text.slice(0, 30);\n hintRef.current.innerText = newText;\n maxWidth = hintRef.current.offsetWidth;\n hintRef.current.innerText = text;\n hintMaxWidthRef.current = {\n width: maxWidth,\n text,\n };\n } else {\n maxWidth = hintMaxWidthRef.current.width;\n }\n\n element.style.maxWidth = `${maxWidth}px`;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [hint]\n );\n\n useEffect(() => {\n if (inputRef.current) {\n setFocusVisible(isFocused && inputRef.current.classList.contains('focus-visible'));\n }\n }, [isFocused]);\n\n return (\n <div\n ref={wrapperRefCallback}\n className={classnames(styles.input, {\n [styles.focused]: isFocused,\n [styles.focusVisible]: isFocusVisible,\n [styles.disabled]: isComponentDisabled,\n [styles.large]: size === 'large',\n [styles.small]: size === 'small',\n [styles.elevated]: placeholderCanBeElevated,\n [styles.invalid]: !!invalid,\n [styles.withIcon]: !!inputIcon,\n })}\n onFocus={clearableOnFocus ? handleWrapperFocus : undefined}\n onBlur={clearableOnFocus ? handleWrapperBlur : undefined}\n onClick={onClickWrapper}\n data-interactive={true}\n >\n <div className={styles.positionContainer}>\n <div className={styles.hintContainer}>\n <div className={styles.autofillHelper} />\n <div className={styles.contentContainer}>\n {!!InputIconComponent && (\n <div className={styles.icon}>\n <InputIconComponent />\n </div>\n )}\n <div className={styles.riggingContainer}>\n {showLabel && (\n <label\n className={classnames(styles.label, {\n [styles.labelElevated]: placeholderIsElevated,\n })}\n id={ariaProps['aria-labelledby']}\n >\n {placeholder}\n </label>\n )}\n </div>\n <div className={styles.valueContainer}>\n <input\n {...restProps}\n {...ariaProps}\n maxLength={maxLength}\n disabled={isComponentDisabled}\n suppressHydrationWarning\n className={styles.field}\n value={currentValue}\n // maskito требует onInput, (https://maskito.dev/frameworks/react) который работает\n // аналогично onChange\n onInput={changeHandler}\n onFocus={focusHandler}\n onBlur={blurHandler}\n ref={inputRefCallback}\n />\n <div className={styles.additionalValue}>\n <Text\n Element=\"span\"\n typography={size === 'small' ? 'label-3-regular' : 'label-2-regular'}\n >\n <span className={styles.valueGhost}>{currentValue}</span>\n {showFixedPlaceholder && (\n <span className={styles.fixedPlaceholder}>\n {fixedPlaceholder.slice(value.length)}\n </span>\n )}\n {showPostfix && (\n <>\n {'\\u00A0'}\n {postfix}\n </>\n )}\n </Text>\n </div>\n </div>\n </div>\n {showHint && (\n <div className={styles.hint} ref={hintWrapperRefCallback} data-qa=\"input-hint\">\n <Text Element=\"span\" typography={size === 'small' ? 'label-4-regular' : 'label-3-regular'}>\n <span ref={hintRef}>{hint}</span>\n </Text>\n </div>\n )}\n </div>\n {ButtonIconComponent && (\n <div className={styles.rightContainer}>\n <ButtonIconComponent\n padding={8}\n initialColor=\"secondary\"\n borderRadius=\"halfHeight\"\n data-qa={buttonQaLabel}\n onMouseDown={(event) => event.preventDefault()} // чтобы инпут не терял фокус\n onClick={showClearButton ? clearClickHandler : onButtonClick}\n disabled={isComponentDisabled}\n ref={buttonRef}\n aria-label={buttonIconAriaLabel}\n />\n </div>\n )}\n </div>\n <FormHelper\n description={description}\n errorMessage={errorMessage}\n descriptionId={ariaProps['aria-describedby']}\n disabled={isComponentDisabled}\n invalid={invalid}\n />\n </div>\n );\n};\n\nconst BaseInput = forwardRef(BaseInputForwardRefRenderFunc);\n\nBaseInput.displayName = 'BaseInput';\n\nexport { BaseInput };\n"],"names":[],"mappings":";;;;;;;;;;;;;;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A,EAAA,SAAA,EAAW,OAAO,cACnB,EAAA,QAAA,kBAAA,GAAA;AAAA,YAAC,mBAAA;AAAA,YAAA;AAAA,cACG,OAAS,EAAA,CAAA;AAAA,cACT,YAAa,EAAA,WAAA;AAAA,cACb,YAAa,EAAA,YAAA;AAAA,cACb,SAAS,EAAA,aAAA;AAAA,cACT,WAAa,EAAA,CAAC,KAAU,KAAA,KAAA,CAAM,cAAe,EAAA;AAAA,cAC7C,OAAA,EAAS,kBAAkB,iBAAoB,GAAA,aAAA;AAAA,cAC/C,QAAU,EAAA,mBAAA;AAAA,cACV,GAAK,EAAA,SAAA;AAAA,cACL,YAAY,EAAA,mBAAA;AAAA,aAAA;AAAA,WAEpB,EAAA,CAAA;AAAA,SAER,EAAA,CAAA;AAAA,wBACA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACG,WAAA;AAAA,YACA,YAAA;AAAA,YACA,aAAA,EAAe,UAAU,kBAAkB,CAAA;AAAA,YAC3C,QAAU,EAAA,mBAAA;AAAA,YACV,OAAA;AAAA,WAAA;AAAA,SACJ;AAAA,OAAA;AAAA,KAAA;AAAA,GACJ,CAAA;AAER,CAAA,CAAA;AAEM,MAAA,SAAA,GAAY,WAAW,6BAA6B,EAAA;AAE1D,SAAA,CAAU,WAAc,GAAA,WAAA;;;;"}
|
package/DateTimeInput.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { InputHTMLAttributes } from 'react';
|
|
2
|
-
export declare const DateTimeInput: import("react").ForwardRefExoticComponent<import("
|
|
3
|
-
dateMask?: import("
|
|
2
|
+
export declare const DateTimeInput: import("react").ForwardRefExoticComponent<import("./types").InputBaseProps & {
|
|
3
|
+
dateMask?: import("./types").DateInputMask;
|
|
4
4
|
timeMask?: boolean;
|
|
5
|
-
timeRounding?: import("
|
|
5
|
+
timeRounding?: import("./types").TimeInputRounding;
|
|
6
6
|
onButtonClick?: (event: import("react").MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
7
7
|
hideMask?: boolean;
|
|
8
8
|
range?: boolean;
|
|
9
|
-
} & import("
|
|
9
|
+
} & import("./types").ControlledProps & Omit<InputHTMLAttributes<HTMLInputElement>, "dateMask" | "hideMask" | "onButtonClick" | "range" | "timeMask" | "timeRounding" | keyof import("./types").ControlledProps | keyof import("./types").InputBaseProps> & import("react").RefAttributes<HTMLInputElement>>;
|