@synerise/ds-input 1.7.11 → 1.7.12

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/AutosizeInput/AutosizeInput.d.ts +6 -7
  3. package/dist/AutosizeInput/AutosizeInput.js +39 -116
  4. package/dist/AutosizeInput/AutosizeInput.types.d.ts +5 -18
  5. package/dist/AutosizeInput/useAutosizeWidth.d.ts +18 -0
  6. package/dist/AutosizeInput/useAutosizeWidth.js +145 -0
  7. package/dist/AutosizeInput/useAutosizeWidth.types.d.ts +29 -0
  8. package/dist/AutosizeInput/useAutosizeWidth.types.js +1 -0
  9. package/dist/AutosizeInput/useStretchToFit.d.ts +26 -0
  10. package/dist/AutosizeInput/useStretchToFit.js +31 -0
  11. package/dist/Input.d.ts +13 -3
  12. package/dist/Input.js +170 -81
  13. package/dist/Input.styles.d.ts +32 -11
  14. package/dist/Input.styles.js +64 -38
  15. package/dist/Input.types.d.ts +23 -7
  16. package/dist/InputGroup.d.ts +1 -1
  17. package/dist/InputGroup.js +11 -4
  18. package/dist/InputGroup.styles.d.ts +1 -0
  19. package/dist/InputGroup.styles.js +9 -2
  20. package/dist/InputGroup.types.d.ts +22 -3
  21. package/dist/InputMultivalue/InputMultivalue.styles.js +1 -1
  22. package/dist/TextArea.d.ts +2 -2
  23. package/dist/TextArea.js +4 -5
  24. package/dist/Textarea/Textarea.d.ts +4 -3
  25. package/dist/Textarea/Textarea.js +33 -4
  26. package/dist/Textarea/Textarea.styles.js +2 -2
  27. package/dist/Textarea/Textarea.types.d.ts +13 -8
  28. package/dist/components/ExpandableWrapper.d.ts +1 -2
  29. package/dist/components/index.d.ts +0 -1
  30. package/dist/components/index.js +0 -2
  31. package/dist/hooks/useElementFocus.d.ts +3 -2
  32. package/dist/hooks/useInputAddonHeight.d.ts +1 -2
  33. package/dist/hooks/useInputAddonHeight.js +1 -1
  34. package/dist/hooks/useTextareaAutosize.d.ts +53 -0
  35. package/dist/hooks/useTextareaAutosize.js +82 -0
  36. package/dist/index.d.ts +6 -2
  37. package/dist/index.js +8 -3
  38. package/dist/utils/getCharCount.d.ts +3 -2
  39. package/package.json +3 -7
  40. package/dist/assets/style/index-tn0RQdqM.css +0 -0
  41. package/dist/components/AutosizeWrapper.d.ts +0 -17
  42. package/dist/components/AutosizeWrapper.js +0 -18
  43. package/dist/style/index.css +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
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.7.12](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.7.11...@synerise/ds-input@1.7.12) (2026-07-09)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-input
9
+
6
10
  ## [1.7.11](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.7.10...@synerise/ds-input@1.7.11) (2026-06-17)
7
11
 
8
12
  **Note:** Version bump only for package @synerise/ds-input
@@ -1,5 +1,9 @@
1
1
  import { default as React, CSSProperties } from 'react';
2
- import { AutosizeInputRefType } from './AutosizeInput.types';
2
+ /**
3
+ * Native auto-width `<input>`: renders its own input plus a hidden sizer, and
4
+ * sizes the input to the text width via `useAutosizeWidth`. The forwarded ref
5
+ * points at the underlying `<input>`.
6
+ */
3
7
  declare const AutosizeInput: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> & {
4
8
  placeholderIsMinWidth?: boolean;
5
9
  wrapperClassName?: string;
@@ -7,10 +11,5 @@ declare const AutosizeInput: React.ForwardRefExoticComponent<Omit<React.InputHTM
7
11
  extraWidth?: number | string;
8
12
  minWidth?: number | string;
9
13
  onAutosize?: (newWidth: number) => void;
10
- preAutosize?: (newWidth: number) => void;
11
- transformRef?: (element: HTMLElement) => HTMLElement;
12
- transformWrapperRef?: (element: HTMLElement) => HTMLElement;
13
- handleInputRef?: (element: HTMLInputElement, originalElement: HTMLElement) => HTMLElement;
14
- children: React.ReactNode;
15
- } & React.RefAttributes<AutosizeInputRefType>>;
14
+ } & React.RefAttributes<HTMLInputElement>>;
16
15
  export default AutosizeInput;
@@ -1,128 +1,51 @@
1
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
- top: 0,
8
- left: 0,
9
- visibility: "hidden",
10
- height: 0,
11
- overflow: "scroll",
12
- whiteSpace: "pre"
2
+ import { forwardRef, useRef } from "react";
3
+ import { useMergeRefs } from "@floating-ui/react";
4
+ import { useAutosizeWidth, SIZER_STYLE } from "./useAutosizeWidth.js";
5
+ const wrapperBaseStyle = {
6
+ position: "relative",
7
+ display: "inline-block"
8
+ };
9
+ const inputBaseStyle = {
10
+ boxSizing: "content-box"
13
11
  };
14
- const FONT_CSS_PROPS = ["fontSize", "fontFamily", "fontWeight", "fontFeatureSettings", "fontStyle", "letterSpacing", "fontStretch", "textTransform"];
15
12
  const AutosizeInput = forwardRef(({
16
- extraWidth = 16,
13
+ minWidth,
14
+ extraWidth,
15
+ placeholderIsMinWidth,
17
16
  wrapperClassName,
18
- wrapperStyle: wrapperStyleProp,
17
+ wrapperStyle,
19
18
  onAutosize,
20
- preAutosize,
21
- placeholderIsMinWidth,
22
- minWidth = 0,
23
- handleInputRef,
24
- children,
25
- transformWrapperRef,
26
- transformRef,
27
- placeholder,
19
+ className,
20
+ style,
28
21
  value,
29
- defaultValue,
30
- style
22
+ placeholder,
23
+ ...inputProps
31
24
  }, forwardedRef) => {
32
- const usedValue = value ?? defaultValue ?? "";
33
25
  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);
40
- }, [transformWrapperRef]);
41
- const transformElement = useMemo(() => {
42
- return transformRef || ((element) => element);
43
- }, [transformRef]);
44
- const contentWidth = useRef();
45
- const placeholderWidth = useRef();
46
- const applyNewWidth = useCallback(() => {
47
- const calculatedWidth = calculateInputWidth({
48
- sizerWidth: contentWidth.current,
49
- hasValue: !!sizerRef.current?.textContent,
50
- placeholderIsMinWidth,
51
- placeholderWidth: placeholderWidth.current ?? placeholderSizerRef.current?.scrollWidth,
52
- minWidth: +minWidth,
53
- placeholder
54
- });
55
- if (inputWrapperRef.current) {
56
- const finalWidth = calculatedWidth + +extraWidth;
57
- if (finalWidth !== parseFloat(inputWrapperRef.current.style.width)) {
58
- preAutosize && preAutosize(calculatedWidth);
59
- inputWrapperRef.current.style.width = `${finalWidth}px`;
60
- onAutosize && onAutosize(calculatedWidth);
61
- }
62
- }
63
- }, [extraWidth, minWidth, onAutosize, placeholder, placeholderIsMinWidth, preAutosize]);
64
- const resizeContentHandler = useCallback((newWidth) => {
65
- contentWidth.current = newWidth.width;
66
- applyNewWidth();
67
- }, [applyNewWidth]);
68
- const resizePlaceholderHandler = useCallback((newWidth) => {
69
- placeholderWidth.current = newWidth.width;
70
- applyNewWidth();
71
- }, [applyNewWidth]);
72
- useResizeObserver(sizerRef, resizeContentHandler);
73
- useResizeObserver(placeholderSizerRef, resizePlaceholderHandler);
74
- const copyInputStyles = () => {
75
- if (inputRef.current) {
76
- const computedStyle = window.getComputedStyle(inputRef.current);
77
- FONT_CSS_PROPS.forEach((cssProperty) => {
78
- if (sizerRef.current) {
79
- sizerRef.current.style[cssProperty] = computedStyle[cssProperty];
80
- }
81
- if (placeholderSizerRef.current) {
82
- placeholderSizerRef.current.style[cssProperty] = computedStyle[cssProperty];
83
- }
84
- });
85
- }
86
- };
87
- useLayoutEffect(() => {
88
- copyInputStyles();
89
- }, []);
90
- useEffect(() => {
91
- if (sizerRef.current) {
92
- const sizerSibling = sizerRef.current.nextElementSibling;
93
- const inputElement = sizerSibling instanceof HTMLElement && transformElement(sizerSibling);
94
- const inputWrapperElement = sizerSibling instanceof HTMLElement && transformWrapper(sizerSibling);
95
- if (inputWrapperElement && inputWrapperElement instanceof HTMLElement) {
96
- inputWrapperRef.current = inputWrapperElement;
97
- }
98
- if (inputElement && !inputRef.current) {
99
- if (inputElement && inputElement instanceof HTMLInputElement) {
100
- inputRef.current = inputElement;
101
- inputRef.current.style.boxSizing = "content-box";
102
- handleInputRef && handleInputRef(inputElement, sizerSibling);
103
- copyInputStyles();
104
- }
105
- }
106
- }
107
- }, [handleInputRef, transformElement, transformWrapper]);
108
- useImperativeHandle(forwardedRef, () => ({
109
- inputRef,
26
+ const measurableValue = typeof value === "string" || typeof value === "number" ? value : void 0;
27
+ const {
110
28
  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 })
29
+ containerRef
30
+ } = useAutosizeWidth({
31
+ value: measurableValue,
32
+ placeholder,
33
+ minWidth,
34
+ extraWidth,
35
+ placeholderIsMinWidth,
36
+ inputRef,
37
+ onAutosize
38
+ });
39
+ const mergedInputRef = useMergeRefs([inputRef, containerRef, forwardedRef]);
40
+ return /* @__PURE__ */ jsxs("div", { className: wrapperClassName, style: {
41
+ ...wrapperBaseStyle,
42
+ ...wrapperStyle
43
+ }, children: [
44
+ /* @__PURE__ */ jsx("input", { ...inputProps, value, placeholder, ref: mergedInputRef, className, style: {
45
+ ...inputBaseStyle,
46
+ ...style
47
+ } }),
48
+ /* @__PURE__ */ jsx("span", { ref: sizerRef, style: SIZER_STYLE, "aria-hidden": true })
126
49
  ] });
127
50
  });
128
51
  export {
@@ -1,4 +1,8 @@
1
- import { CSSProperties, InputHTMLAttributes, MutableRefObject, ReactNode, RefObject } from 'react';
1
+ import { CSSProperties, InputHTMLAttributes } from 'react';
2
+ /**
3
+ * Native auto-width input props. The component renders its own `<input>` and a
4
+ * hidden sizer; the forwarded ref points at the `<input>` element.
5
+ */
2
6
  export type AutosizeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & {
3
7
  placeholderIsMinWidth?: boolean;
4
8
  wrapperClassName?: string;
@@ -6,21 +10,4 @@ export type AutosizeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'si
6
10
  extraWidth?: number | string;
7
11
  minWidth?: number | string;
8
12
  onAutosize?: (newWidth: number) => void;
9
- preAutosize?: (newWidth: number) => void;
10
- transformRef?: (element: HTMLElement) => HTMLElement;
11
- transformWrapperRef?: (element: HTMLElement) => HTMLElement;
12
- handleInputRef?: (element: HTMLInputElement, originalElement: HTMLElement) => HTMLElement;
13
- children: ReactNode;
14
- };
15
- export type AutosizeWrapperProps = AutosizeInputProps & {
16
- autoResize?: boolean;
17
- };
18
- export type AutosizeInputRefType = {
19
- inputRef: MutableRefObject<HTMLInputElement | null>;
20
- sizerRef: RefObject<HTMLDivElement>;
21
- wrapperRef: RefObject<HTMLDivElement>;
22
- inputWrapperRef: RefObject<HTMLElement>;
23
- placeholderSizerRef: RefObject<HTMLDivElement>;
24
- copyInputStyles: () => void;
25
- updateInputWidth: () => void;
26
13
  };
@@ -0,0 +1,18 @@
1
+ import { CSSProperties } from 'react';
2
+ import { UseAutosizeWidthParams, UseAutosizeWidthResult } from './useAutosizeWidth.types';
3
+ /**
4
+ * Styles for the hidden measuring `<span>`. It is taken out of layout flow
5
+ * (`position: absolute`, `height: 0`, `visibility: hidden`) so it never affects
6
+ * the surrounding layout, and `white-space: pre` preserves spacing exactly as
7
+ * typed. Font properties inherit by default; when the consuming input declares
8
+ * its font on the element itself (not an ancestor), pass `inputRef` to copy it.
9
+ */
10
+ export declare const SIZER_STYLE: CSSProperties;
11
+ /**
12
+ * Headless auto-width measurement. The consumer renders a single hidden sizer
13
+ * `<span>` and an inline-block wrapper; this hook measures the text width
14
+ * synchronously in `useLayoutEffect` (before paint) and writes the resulting
15
+ * width to the wrapper imperatively — no ResizeObserver and no per-keystroke
16
+ * state update, so typing does not trigger extra React renders.
17
+ */
18
+ export declare const useAutosizeWidth: <C extends HTMLElement = HTMLDivElement>({ value, placeholder, minWidth, extraWidth, placeholderIsMinWidth, inputRef, onAutosize, }: UseAutosizeWidthParams) => UseAutosizeWidthResult<C>;
@@ -0,0 +1,145 @@
1
+ import { useRef, useCallback, useLayoutEffect, useEffect } from "react";
2
+ import calculateInputWidth from "./utils/calculateInputWidth.js";
3
+ const SIZER_STYLE = {
4
+ position: "absolute",
5
+ top: 0,
6
+ left: 0,
7
+ height: 0,
8
+ visibility: "hidden",
9
+ overflow: "scroll",
10
+ whiteSpace: "pre",
11
+ font: "inherit",
12
+ letterSpacing: "inherit",
13
+ textTransform: "inherit",
14
+ fontFeatureSettings: "inherit",
15
+ fontVariantNumeric: "inherit"
16
+ };
17
+ const FONT_CSS_PROPS = [
18
+ "fontSize",
19
+ "fontFamily",
20
+ "fontWeight",
21
+ "fontFeatureSettings",
22
+ // Mirror tabular/proportional figures onto the sizer — otherwise an input using
23
+ // `font-variant-numeric: tabular-nums` renders tabular but is measured proportional,
24
+ // clipping the value or leaving a gap.
25
+ "fontVariantNumeric",
26
+ "fontStyle",
27
+ "letterSpacing",
28
+ "fontStretch",
29
+ "textTransform"
30
+ ];
31
+ const useAutosizeWidth = ({
32
+ value,
33
+ placeholder,
34
+ minWidth = 0,
35
+ extraWidth = 0,
36
+ placeholderIsMinWidth,
37
+ inputRef,
38
+ onAutosize
39
+ }) => {
40
+ const sizerRef = useRef(null);
41
+ const containerRef = useRef(null);
42
+ const copyFont = useCallback(() => {
43
+ const sizer = sizerRef.current;
44
+ const input = inputRef?.current;
45
+ if (!sizer || !input) {
46
+ return;
47
+ }
48
+ const computedStyle = window.getComputedStyle(input);
49
+ FONT_CSS_PROPS.forEach((cssProperty) => {
50
+ sizer.style[cssProperty] = computedStyle[cssProperty];
51
+ });
52
+ }, [inputRef]);
53
+ const measure = useCallback(() => {
54
+ const sizer = sizerRef.current;
55
+ const container = containerRef.current;
56
+ if (!sizer || !container) {
57
+ return;
58
+ }
59
+ const content = value === void 0 || value === null ? "" : String(value);
60
+ sizer.textContent = content;
61
+ const contentWidth = sizer.scrollWidth;
62
+ let placeholderWidth;
63
+ if (placeholder) {
64
+ sizer.textContent = placeholder;
65
+ placeholderWidth = sizer.scrollWidth;
66
+ sizer.textContent = content;
67
+ }
68
+ const computedWidth = calculateInputWidth({
69
+ sizerWidth: contentWidth,
70
+ hasValue: content.length > 0,
71
+ placeholderIsMinWidth,
72
+ placeholderWidth,
73
+ minWidth: +minWidth,
74
+ placeholder
75
+ });
76
+ const finalWidth = computedWidth + +extraWidth;
77
+ if (parseFloat(container.style.width) !== finalWidth) {
78
+ container.style.width = `${finalWidth}px`;
79
+ onAutosize && onAutosize(computedWidth);
80
+ }
81
+ }, [value, placeholder, placeholderIsMinWidth, minWidth, extraWidth, onAutosize]);
82
+ useLayoutEffect(() => {
83
+ copyFont();
84
+ }, [copyFont]);
85
+ useLayoutEffect(() => {
86
+ measure();
87
+ }, [measure]);
88
+ const measureRef = useRef(measure);
89
+ const copyFontRef = useRef(copyFont);
90
+ useLayoutEffect(() => {
91
+ measureRef.current = measure;
92
+ copyFontRef.current = copyFont;
93
+ });
94
+ useEffect(() => {
95
+ const sizer = sizerRef.current;
96
+ if (!sizer || typeof ResizeObserver === "undefined") {
97
+ return void 0;
98
+ }
99
+ let frame = 0;
100
+ const hasRaf = typeof window.requestAnimationFrame === "function";
101
+ const observer = new ResizeObserver(() => {
102
+ if (hasRaf) {
103
+ window.cancelAnimationFrame(frame);
104
+ frame = window.requestAnimationFrame(() => measureRef.current());
105
+ } else {
106
+ measureRef.current();
107
+ }
108
+ });
109
+ observer.observe(sizer);
110
+ return () => {
111
+ observer.disconnect();
112
+ if (hasRaf) {
113
+ window.cancelAnimationFrame(frame);
114
+ }
115
+ };
116
+ }, []);
117
+ useEffect(() => {
118
+ const fontSet = typeof document !== "undefined" ? document.fonts : void 0;
119
+ if (!fontSet) {
120
+ return void 0;
121
+ }
122
+ const remeasure = () => {
123
+ copyFontRef.current();
124
+ measureRef.current();
125
+ };
126
+ fontSet.ready.then(remeasure).catch(() => void 0);
127
+ fontSet.addEventListener("loadingdone", remeasure);
128
+ return () => {
129
+ fontSet.removeEventListener("loadingdone", remeasure);
130
+ };
131
+ }, []);
132
+ const recalculate = useCallback(() => {
133
+ copyFont();
134
+ measure();
135
+ }, [copyFont, measure]);
136
+ return {
137
+ sizerRef,
138
+ containerRef,
139
+ recalculate
140
+ };
141
+ };
142
+ export {
143
+ SIZER_STYLE,
144
+ useAutosizeWidth
145
+ };
@@ -0,0 +1,29 @@
1
+ import { RefObject } from 'react';
2
+ export type UseAutosizeWidthParams = {
3
+ /** Current input value — drives the measured content width. */
4
+ value?: string | number;
5
+ /** Placeholder text — used as the measured width when there is no value. */
6
+ placeholder?: string;
7
+ /** Lower bound (px) applied to the computed content width. */
8
+ minWidth?: number | string;
9
+ /** Extra px added to the computed width (padding / affordances / icons). */
10
+ extraWidth?: number | string;
11
+ /** When true, the placeholder width is used as a minimum width. */
12
+ placeholderIsMinWidth?: boolean;
13
+ /**
14
+ * Optional ref to the styled input. When provided, its resolved font is
15
+ * copied to the hidden sizer once on mount so measurement matches exactly,
16
+ * even when the font is declared on the input rather than an ancestor.
17
+ */
18
+ inputRef?: RefObject<HTMLElement | null>;
19
+ /** Fired with the computed content width (excl. extraWidth) whenever it changes. */
20
+ onAutosize?: (width: number) => void;
21
+ };
22
+ export type UseAutosizeWidthResult<C extends HTMLElement = HTMLDivElement> = {
23
+ /** Attach to a single hidden, empty `<span>` styled with `SIZER_STYLE`. */
24
+ sizerRef: RefObject<HTMLSpanElement>;
25
+ /** Attach to the inline-block wrapper whose width the hook sets imperatively. */
26
+ containerRef: RefObject<C>;
27
+ /** Force a re-measure (e.g. after a web font loads or layout changes). */
28
+ recalculate: () => void;
29
+ };
@@ -0,0 +1,26 @@
1
+ import { RefObject } from 'react';
2
+ export type UseStretchToFitParams = {
3
+ /** When false the observer is disconnected and no max-width is applied. */
4
+ enabled: boolean;
5
+ /** Element whose `max-width` is clamped to the available width. */
6
+ targetRef: RefObject<HTMLElement | null>;
7
+ /**
8
+ * Maps the measured available width to the max-width to apply. Defaults to
9
+ * identity; consumers tweak it for their own padding/affordances
10
+ * (e.g. `(w) => w - paddingDiff` for Input, `(w) => w + 1` for Autocomplete).
11
+ */
12
+ getMaxWidth?: (availableWidth: number) => number;
13
+ /** Runs before the max-width is applied (e.g. capture scroll position). */
14
+ onBeforeResize?: () => void;
15
+ /** Runs after the max-width is applied (e.g. restore scroll position). */
16
+ onAfterResize?: () => void;
17
+ };
18
+ /**
19
+ * Centralises the (previously triplicated) "stretch the autosize input to fill
20
+ * its container" behaviour. Attach the returned `outerRef` to the bounding
21
+ * element; its width is observed via `useResizeToFit` (no state churn) and the
22
+ * `targetRef` element's `max-width` is updated on resize.
23
+ */
24
+ export declare const useStretchToFit: <T extends HTMLElement = HTMLDivElement>({ enabled, targetRef, getMaxWidth, onBeforeResize, onAfterResize, }: UseStretchToFitParams) => {
25
+ outerRef: RefObject<T>;
26
+ };
@@ -0,0 +1,31 @@
1
+ import { useCallback } from "react";
2
+ import { useResizeToFit } from "@synerise/ds-utils";
3
+ const useStretchToFit = ({
4
+ enabled,
5
+ targetRef,
6
+ getMaxWidth = (availableWidth) => availableWidth,
7
+ onBeforeResize,
8
+ onAfterResize
9
+ }) => {
10
+ const handleResize = useCallback((availableWidth) => {
11
+ const target = targetRef.current;
12
+ if (!enabled || !target) {
13
+ return;
14
+ }
15
+ onBeforeResize && onBeforeResize();
16
+ target.style.maxWidth = `${getMaxWidth(availableWidth)}px`;
17
+ onAfterResize && onAfterResize();
18
+ }, [enabled, targetRef, getMaxWidth, onBeforeResize, onAfterResize]);
19
+ const {
20
+ elementRef: outerRef
21
+ } = useResizeToFit({
22
+ onResize: handleResize,
23
+ autoObserve: enabled
24
+ });
25
+ return {
26
+ outerRef
27
+ };
28
+ };
29
+ export {
30
+ useStretchToFit
31
+ };
package/dist/Input.d.ts CHANGED
@@ -14,10 +14,20 @@ export declare const Input: React.ForwardRefExoticComponent<{
14
14
  prefixel?: React.ReactNode;
15
15
  suffixel?: React.ReactNode;
16
16
  autoResize?: import('./Input.types').AutoResizeProp;
17
- autoResizeProps?: Partial<Pick<import('./AutosizeInput/AutosizeInput.types').AutosizeInputProps, "placeholderIsMinWidth" | "wrapperClassName" | "wrapperStyle" | "extraWidth">>;
17
+ autoResizeProps?: Partial<Pick<import('.').AutosizeInputProps, "placeholderIsMinWidth" | "wrapperClassName" | "wrapperStyle" | "extraWidth">>;
18
18
  expandable?: boolean;
19
19
  expandableTooltip?: React.ReactNode;
20
- } & Omit<import('@synerise/ds-form-field').ContentAboveProps, "id" | "rightSide"> & import('@synerise/ds-form-field').ContentBelowProps & import('antd').InputProps & React.RefAttributes<HTMLDivElement>>;
21
- export declare const RawInput: (props: InputProps) => React.JSX.Element;
20
+ } & Omit<import('@synerise/ds-form-field').ContentAboveProps, "id" | "rightSide"> & import('@synerise/ds-form-field').ContentBelowProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "prefix"> & {
21
+ size?: import('./Input.types').InputSize;
22
+ allowClear?: boolean;
23
+ bordered?: boolean;
24
+ innerPrefix?: React.ReactNode;
25
+ prefix?: React.ReactNode;
26
+ suffix?: React.ReactNode;
27
+ onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;
28
+ addonBefore?: React.ReactNode;
29
+ addonAfter?: React.ReactNode;
30
+ } & React.RefAttributes<HTMLDivElement>>;
31
+ export declare const RawInput: ({ error, size, className, label, description, errorText, tooltip, tooltipConfig, counterLimit, renderCustomCounter, icon1, icon1Tooltip, icon2, icon2Tooltip, resetMargin, handleInputRef, prefixel, suffixel, autoResize, autoResizeProps, expandable, expandableTooltip, allowClear, prefix, suffix, bordered, onPressEnter, addonBefore, addonAfter, ...rest }: InputProps) => React.JSX.Element;
22
32
  export { default as InputGroup } from './InputGroup';
23
33
  export { default as InputMultivalue } from './InputMultivalue/InputMultivalue';