@synerise/ds-input 1.6.9 → 1.6.11
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/CHANGELOG.md +8 -0
- package/dist/AutosizeInput/AutosizeInput.d.ts +2 -2
- package/dist/AutosizeInput/AutosizeInput.js +80 -95
- package/dist/AutosizeInput/AutosizeInput.types.d.ts +1 -1
- package/dist/AutosizeInput/AutosizeInput.types.js +1 -1
- package/dist/AutosizeInput/utils/calculateInputWidth.d.ts +1 -1
- package/dist/AutosizeInput/utils/calculateInputWidth.js +13 -11
- package/dist/AutosizeInput/utils/index.js +4 -1
- package/dist/Input.d.ts +5 -7
- package/dist/Input.js +117 -174
- package/dist/Input.styles.d.ts +22 -22
- package/dist/Input.styles.js +98 -122
- package/dist/Input.types.d.ts +5 -5
- package/dist/Input.types.js +1 -1
- package/dist/InputGroup.d.ts +2 -2
- package/dist/InputGroup.js +21 -38
- package/dist/InputGroup.styles.d.ts +2 -2
- package/dist/InputGroup.styles.js +8 -8
- package/dist/InputGroup.types.d.ts +2 -2
- package/dist/InputGroup.types.js +1 -1
- package/dist/InputMultivalue/Elements/Value.d.ts +2 -2
- package/dist/InputMultivalue/Elements/Value.js +22 -34
- package/dist/InputMultivalue/Elements/Value.types.d.ts +2 -2
- package/dist/InputMultivalue/Elements/Value.types.js +1 -1
- package/dist/InputMultivalue/InputMultivalue.d.ts +2 -2
- package/dist/InputMultivalue/InputMultivalue.js +52 -74
- package/dist/InputMultivalue/InputMultivalue.styles.d.ts +10 -10
- package/dist/InputMultivalue/InputMultivalue.styles.js +48 -67
- package/dist/InputMultivalue/InputMultivalue.types.d.ts +1 -1
- package/dist/InputMultivalue/InputMultivalue.types.js +1 -1
- package/dist/PasswordInput.d.ts +2 -2
- package/dist/PasswordInput.js +31 -45
- package/dist/PasswordInput.types.d.ts +2 -2
- package/dist/PasswordInput.types.js +1 -1
- package/dist/TextArea.d.ts +4 -6
- package/dist/TextArea.js +53 -75
- package/dist/TextArea.types.d.ts +2 -2
- package/dist/TextArea.types.js +1 -1
- package/dist/Textarea/Textarea.d.ts +4 -4
- package/dist/Textarea/Textarea.js +32 -51
- package/dist/Textarea/Textarea.styles.d.ts +2 -2
- package/dist/Textarea/Textarea.styles.js +10 -9
- package/dist/Textarea/Textarea.types.d.ts +3 -3
- package/dist/Textarea/Textarea.types.js +1 -1
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/components/AutosizeWrapper.d.ts +2 -2
- package/dist/components/AutosizeWrapper.js +16 -18
- package/dist/components/ElementIcons.d.ts +2 -2
- package/dist/components/ElementIcons.js +37 -51
- package/dist/components/ExpandableWrapper.d.ts +3 -3
- package/dist/components/ExpandableWrapper.js +20 -21
- package/dist/components/index.js +8 -3
- package/dist/hooks/index.js +6 -2
- package/dist/hooks/useCounterLimit.d.ts +2 -2
- package/dist/hooks/useCounterLimit.js +19 -14
- package/dist/hooks/useElementFocus.d.ts +2 -2
- package/dist/hooks/useElementFocus.js +6 -3
- package/dist/hooks/useInputAddonHeight.d.ts +2 -2
- package/dist/hooks/useInputAddonHeight.js +10 -10
- package/dist/index.js +24 -12
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/getCharCount.d.ts +2 -2
- package/dist/utils/getCharCount.js +5 -2
- package/dist/utils/index.js +4 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.6.11](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.6.10...@synerise/ds-input@1.6.11) (2026-04-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-input
|
|
9
|
+
|
|
10
|
+
## [1.6.10](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.6.9...@synerise/ds-input@1.6.10) (2026-03-24)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-input
|
|
13
|
+
|
|
6
14
|
## [1.6.9](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.6.8...@synerise/ds-input@1.6.9) (2026-03-20)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-input
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
|
+
import { AutosizeInputRefType } from './AutosizeInput.types';
|
|
3
3
|
declare const AutosizeInput: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> & {
|
|
4
4
|
placeholderIsMinWidth?: boolean;
|
|
5
5
|
wrapperClassName?: string;
|
|
@@ -1,87 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { useResizeObserver } from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
position:
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useMemo, useCallback, useLayoutEffect, useEffect, useImperativeHandle } from "react";
|
|
3
|
+
import { useResizeObserver } from "@synerise/ds-utils";
|
|
4
|
+
import calculateInputWidth from "./utils/calculateInputWidth.js";
|
|
5
|
+
const sizerStyle = {
|
|
6
|
+
position: "absolute",
|
|
7
7
|
top: 0,
|
|
8
8
|
left: 0,
|
|
9
|
-
visibility:
|
|
9
|
+
visibility: "hidden",
|
|
10
10
|
height: 0,
|
|
11
|
-
overflow:
|
|
12
|
-
whiteSpace:
|
|
11
|
+
overflow: "scroll",
|
|
12
|
+
whiteSpace: "pre"
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var transformWrapper = useMemo(function () {
|
|
41
|
-
return transformWrapperRef || function (element) {
|
|
42
|
-
return element;
|
|
43
|
-
};
|
|
14
|
+
const FONT_CSS_PROPS = ["fontSize", "fontFamily", "fontWeight", "fontFeatureSettings", "fontStyle", "letterSpacing", "fontStretch", "textTransform"];
|
|
15
|
+
const AutosizeInput = forwardRef(({
|
|
16
|
+
extraWidth = 16,
|
|
17
|
+
wrapperClassName,
|
|
18
|
+
wrapperStyle: wrapperStyleProp,
|
|
19
|
+
onAutosize,
|
|
20
|
+
preAutosize,
|
|
21
|
+
placeholderIsMinWidth,
|
|
22
|
+
minWidth = 0,
|
|
23
|
+
handleInputRef,
|
|
24
|
+
children,
|
|
25
|
+
transformWrapperRef,
|
|
26
|
+
transformRef,
|
|
27
|
+
placeholder,
|
|
28
|
+
value,
|
|
29
|
+
defaultValue,
|
|
30
|
+
style
|
|
31
|
+
}, forwardedRef) => {
|
|
32
|
+
const usedValue = value ?? defaultValue ?? "";
|
|
33
|
+
const inputRef = useRef(null);
|
|
34
|
+
const inputWrapperRef = useRef(null);
|
|
35
|
+
const sizerRef = useRef(null);
|
|
36
|
+
const placeholderSizerRef = useRef(null);
|
|
37
|
+
const wrapperRef = useRef(null);
|
|
38
|
+
const transformWrapper = useMemo(() => {
|
|
39
|
+
return transformWrapperRef || ((element) => element);
|
|
44
40
|
}, [transformWrapperRef]);
|
|
45
|
-
|
|
46
|
-
return transformRef ||
|
|
47
|
-
return element;
|
|
48
|
-
};
|
|
41
|
+
const transformElement = useMemo(() => {
|
|
42
|
+
return transformRef || ((element) => element);
|
|
49
43
|
}, [transformRef]);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var calculatedWidth = calculateInputWidth({
|
|
44
|
+
const contentWidth = useRef();
|
|
45
|
+
const placeholderWidth = useRef();
|
|
46
|
+
const applyNewWidth = useCallback(() => {
|
|
47
|
+
const calculatedWidth = calculateInputWidth({
|
|
55
48
|
sizerWidth: contentWidth.current,
|
|
56
|
-
hasValue: !!
|
|
57
|
-
placeholderIsMinWidth
|
|
58
|
-
placeholderWidth:
|
|
49
|
+
hasValue: !!sizerRef.current?.textContent,
|
|
50
|
+
placeholderIsMinWidth,
|
|
51
|
+
placeholderWidth: placeholderWidth.current ?? placeholderSizerRef.current?.scrollWidth,
|
|
59
52
|
minWidth: +minWidth,
|
|
60
|
-
placeholder
|
|
53
|
+
placeholder
|
|
61
54
|
});
|
|
62
55
|
if (inputWrapperRef.current) {
|
|
63
|
-
|
|
56
|
+
const finalWidth = calculatedWidth + +extraWidth;
|
|
64
57
|
if (finalWidth !== parseFloat(inputWrapperRef.current.style.width)) {
|
|
65
58
|
preAutosize && preAutosize(calculatedWidth);
|
|
66
|
-
inputWrapperRef.current.style.width = finalWidth
|
|
59
|
+
inputWrapperRef.current.style.width = `${finalWidth}px`;
|
|
67
60
|
onAutosize && onAutosize(calculatedWidth);
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
63
|
}, [extraWidth, minWidth, onAutosize, placeholder, placeholderIsMinWidth, preAutosize]);
|
|
71
|
-
|
|
64
|
+
const resizeContentHandler = useCallback((newWidth) => {
|
|
72
65
|
contentWidth.current = newWidth.width;
|
|
73
66
|
applyNewWidth();
|
|
74
67
|
}, [applyNewWidth]);
|
|
75
|
-
|
|
68
|
+
const resizePlaceholderHandler = useCallback((newWidth) => {
|
|
76
69
|
placeholderWidth.current = newWidth.width;
|
|
77
70
|
applyNewWidth();
|
|
78
71
|
}, [applyNewWidth]);
|
|
79
72
|
useResizeObserver(sizerRef, resizeContentHandler);
|
|
80
73
|
useResizeObserver(placeholderSizerRef, resizePlaceholderHandler);
|
|
81
|
-
|
|
74
|
+
const copyInputStyles = () => {
|
|
82
75
|
if (inputRef.current) {
|
|
83
|
-
|
|
84
|
-
FONT_CSS_PROPS.forEach(
|
|
76
|
+
const computedStyle = window.getComputedStyle(inputRef.current);
|
|
77
|
+
FONT_CSS_PROPS.forEach((cssProperty) => {
|
|
85
78
|
if (sizerRef.current) {
|
|
86
79
|
sizerRef.current.style[cssProperty] = computedStyle[cssProperty];
|
|
87
80
|
}
|
|
@@ -91,55 +84,47 @@ var AutosizeInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
|
|
91
84
|
});
|
|
92
85
|
}
|
|
93
86
|
};
|
|
94
|
-
useLayoutEffect(
|
|
87
|
+
useLayoutEffect(() => {
|
|
95
88
|
copyInputStyles();
|
|
96
89
|
}, []);
|
|
97
|
-
useEffect(
|
|
90
|
+
useEffect(() => {
|
|
98
91
|
if (sizerRef.current) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
92
|
+
const sizerSibling = sizerRef.current.nextElementSibling;
|
|
93
|
+
const inputElement = sizerSibling instanceof HTMLElement && transformElement(sizerSibling);
|
|
94
|
+
const inputWrapperElement = sizerSibling instanceof HTMLElement && transformWrapper(sizerSibling);
|
|
102
95
|
if (inputWrapperElement && inputWrapperElement instanceof HTMLElement) {
|
|
103
96
|
inputWrapperRef.current = inputWrapperElement;
|
|
104
97
|
}
|
|
105
98
|
if (inputElement && !inputRef.current) {
|
|
106
99
|
if (inputElement && inputElement instanceof HTMLInputElement) {
|
|
107
100
|
inputRef.current = inputElement;
|
|
108
|
-
inputRef.current.style.boxSizing =
|
|
101
|
+
inputRef.current.style.boxSizing = "content-box";
|
|
109
102
|
handleInputRef && handleInputRef(inputElement, sizerSibling);
|
|
110
103
|
copyInputStyles();
|
|
111
104
|
}
|
|
112
105
|
}
|
|
113
106
|
}
|
|
114
107
|
}, [handleInputRef, transformElement, transformWrapper]);
|
|
115
|
-
useImperativeHandle(forwardedRef,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"data-testid": "wrapper"
|
|
135
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
136
|
-
style: sizerStyle,
|
|
137
|
-
ref: sizerRef,
|
|
138
|
-
"data-testid": "sizer"
|
|
139
|
-
}, usedValue), children, placeholder ? /*#__PURE__*/React.createElement("div", {
|
|
140
|
-
ref: placeholderSizerRef,
|
|
141
|
-
style: sizerStyle,
|
|
142
|
-
"data-testid": "placeholder-sizer"
|
|
143
|
-
}, placeholder) : null);
|
|
108
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
109
|
+
inputRef,
|
|
110
|
+
sizerRef,
|
|
111
|
+
wrapperRef,
|
|
112
|
+
inputWrapperRef,
|
|
113
|
+
placeholderSizerRef,
|
|
114
|
+
copyInputStyles,
|
|
115
|
+
updateInputWidth: applyNewWidth
|
|
116
|
+
}));
|
|
117
|
+
const wrapperStyle = {
|
|
118
|
+
...wrapperStyleProp,
|
|
119
|
+
position: "relative",
|
|
120
|
+
display: style?.display ?? "inline-block"
|
|
121
|
+
};
|
|
122
|
+
return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: wrapperClassName, style: wrapperStyle, "data-testid": "wrapper", children: [
|
|
123
|
+
/* @__PURE__ */ jsx("div", { style: sizerStyle, ref: sizerRef, "data-testid": "sizer", children: usedValue }),
|
|
124
|
+
children,
|
|
125
|
+
placeholder ? /* @__PURE__ */ jsx("div", { ref: placeholderSizerRef, style: sizerStyle, "data-testid": "placeholder-sizer", children: placeholder }) : null
|
|
126
|
+
] });
|
|
144
127
|
});
|
|
145
|
-
export
|
|
128
|
+
export {
|
|
129
|
+
AutosizeInput as default
|
|
130
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CSSProperties, InputHTMLAttributes, MutableRefObject, ReactNode, RefObject } from 'react';
|
|
2
2
|
export type AutosizeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & {
|
|
3
3
|
placeholderIsMinWidth?: boolean;
|
|
4
4
|
wrapperClassName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const calculateInputWidth = ({
|
|
2
|
+
sizerWidth,
|
|
3
|
+
hasValue,
|
|
4
|
+
placeholderIsMinWidth,
|
|
5
|
+
placeholderWidth,
|
|
6
|
+
minWidth,
|
|
7
|
+
placeholder
|
|
8
|
+
}) => {
|
|
9
|
+
let width = 0;
|
|
9
10
|
if (sizerWidth && hasValue) {
|
|
10
|
-
/* If the input field has content, update the sizer to match its width */
|
|
11
11
|
width = sizerWidth;
|
|
12
12
|
if (placeholderIsMinWidth && placeholderWidth && sizerWidth < placeholderWidth) {
|
|
13
13
|
width = placeholderWidth;
|
|
14
14
|
}
|
|
15
|
-
if (minWidth !==
|
|
15
|
+
if (minWidth !== void 0 && width < minWidth) {
|
|
16
16
|
width = minWidth;
|
|
17
17
|
}
|
|
18
18
|
} else if (placeholder && placeholderWidth) {
|
|
@@ -22,4 +22,6 @@ var calculateInputWidth = function calculateInputWidth(_ref) {
|
|
|
22
22
|
}
|
|
23
23
|
return width;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
25
|
+
export {
|
|
26
|
+
calculateInputWidth as default
|
|
27
|
+
};
|
package/dist/Input.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '
|
|
3
|
-
import type { InputProps } from './Input.types';
|
|
4
|
-
import './style/index.less';
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { InputProps } from './Input.types';
|
|
5
3
|
export declare const Input: React.ForwardRefExoticComponent<{
|
|
6
4
|
error?: boolean;
|
|
7
5
|
className?: string;
|
|
@@ -15,11 +13,11 @@ export declare const Input: React.ForwardRefExoticComponent<{
|
|
|
15
13
|
handleInputRef?: ((ref: React.MutableRefObject<HTMLInputElement | null>) => void) | undefined;
|
|
16
14
|
prefixel?: React.ReactNode;
|
|
17
15
|
suffixel?: React.ReactNode;
|
|
18
|
-
autoResize?: import(
|
|
19
|
-
autoResizeProps?: Partial<Pick<import(
|
|
16
|
+
autoResize?: import('./Input.types').AutoResizeProp;
|
|
17
|
+
autoResizeProps?: Partial<Pick<import('./AutosizeInput/AutosizeInput.types').AutosizeInputProps, "placeholderIsMinWidth" | "wrapperClassName" | "wrapperStyle" | "extraWidth">>;
|
|
20
18
|
expandable?: boolean;
|
|
21
19
|
expandableTooltip?: React.ReactNode;
|
|
22
|
-
} & Omit<import(
|
|
20
|
+
} & Omit<import('@synerise/ds-form-field').ContentAboveProps, "id" | "rightSide"> & import('@synerise/ds-form-field').ContentBelowProps & import('antd/lib/input').InputProps & React.RefAttributes<HTMLDivElement>>;
|
|
23
21
|
export declare const RawInput: (props: InputProps) => React.JSX.Element;
|
|
24
22
|
export { default as InputGroup } from './InputGroup';
|
|
25
23
|
export { default as InputMultivalue } from './InputMultivalue/InputMultivalue';
|