@synerise/ds-input 1.6.8 → 1.6.10

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 (67) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +86 -24
  3. package/dist/AutosizeInput/AutosizeInput.d.ts +2 -2
  4. package/dist/AutosizeInput/AutosizeInput.js +80 -95
  5. package/dist/AutosizeInput/AutosizeInput.types.d.ts +1 -1
  6. package/dist/AutosizeInput/AutosizeInput.types.js +1 -1
  7. package/dist/AutosizeInput/utils/calculateInputWidth.d.ts +1 -1
  8. package/dist/AutosizeInput/utils/calculateInputWidth.js +13 -11
  9. package/dist/AutosizeInput/utils/index.js +4 -1
  10. package/dist/Input.d.ts +5 -7
  11. package/dist/Input.js +117 -174
  12. package/dist/Input.styles.d.ts +22 -22
  13. package/dist/Input.styles.js +98 -122
  14. package/dist/Input.types.d.ts +5 -5
  15. package/dist/Input.types.js +1 -1
  16. package/dist/InputGroup.d.ts +2 -2
  17. package/dist/InputGroup.js +21 -38
  18. package/dist/InputGroup.styles.d.ts +2 -2
  19. package/dist/InputGroup.styles.js +8 -8
  20. package/dist/InputGroup.types.d.ts +2 -2
  21. package/dist/InputGroup.types.js +1 -1
  22. package/dist/InputMultivalue/Elements/Value.d.ts +2 -2
  23. package/dist/InputMultivalue/Elements/Value.js +22 -34
  24. package/dist/InputMultivalue/Elements/Value.types.d.ts +2 -2
  25. package/dist/InputMultivalue/Elements/Value.types.js +1 -1
  26. package/dist/InputMultivalue/InputMultivalue.d.ts +2 -2
  27. package/dist/InputMultivalue/InputMultivalue.js +52 -74
  28. package/dist/InputMultivalue/InputMultivalue.styles.d.ts +10 -10
  29. package/dist/InputMultivalue/InputMultivalue.styles.js +48 -67
  30. package/dist/InputMultivalue/InputMultivalue.types.d.ts +1 -1
  31. package/dist/InputMultivalue/InputMultivalue.types.js +1 -1
  32. package/dist/PasswordInput.d.ts +2 -2
  33. package/dist/PasswordInput.js +31 -45
  34. package/dist/PasswordInput.types.d.ts +2 -2
  35. package/dist/PasswordInput.types.js +1 -1
  36. package/dist/TextArea.d.ts +4 -6
  37. package/dist/TextArea.js +53 -75
  38. package/dist/TextArea.types.d.ts +2 -2
  39. package/dist/TextArea.types.js +1 -1
  40. package/dist/Textarea/Textarea.d.ts +4 -4
  41. package/dist/Textarea/Textarea.js +32 -51
  42. package/dist/Textarea/Textarea.styles.d.ts +2 -2
  43. package/dist/Textarea/Textarea.styles.js +10 -9
  44. package/dist/Textarea/Textarea.types.d.ts +3 -3
  45. package/dist/Textarea/Textarea.types.js +1 -1
  46. package/dist/assets/style/index-tn0RQdqM.css +0 -0
  47. package/dist/components/AutosizeWrapper.d.ts +2 -2
  48. package/dist/components/AutosizeWrapper.js +16 -18
  49. package/dist/components/ElementIcons.d.ts +2 -2
  50. package/dist/components/ElementIcons.js +37 -51
  51. package/dist/components/ExpandableWrapper.d.ts +3 -3
  52. package/dist/components/ExpandableWrapper.js +20 -21
  53. package/dist/components/index.js +8 -3
  54. package/dist/hooks/index.js +6 -2
  55. package/dist/hooks/useCounterLimit.d.ts +2 -2
  56. package/dist/hooks/useCounterLimit.js +19 -14
  57. package/dist/hooks/useElementFocus.d.ts +2 -2
  58. package/dist/hooks/useElementFocus.js +6 -3
  59. package/dist/hooks/useInputAddonHeight.d.ts +2 -2
  60. package/dist/hooks/useInputAddonHeight.js +10 -10
  61. package/dist/index.js +24 -12
  62. package/dist/modules.d.js +1 -1
  63. package/dist/modules.d.ts +0 -0
  64. package/dist/utils/getCharCount.d.ts +2 -2
  65. package/dist/utils/getCharCount.js +5 -2
  66. package/dist/utils/index.js +4 -1
  67. 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.10](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.6.9...@synerise/ds-input@1.6.10) (2026-03-24)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-input
9
+
10
+ ## [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)
11
+
12
+ **Note:** Version bump only for package @synerise/ds-input
13
+
6
14
  ## [1.6.8](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.6.7...@synerise/ds-input@1.6.8) (2026-03-09)
7
15
 
8
16
  **Note:** Version bump only for package @synerise/ds-input
package/README.md CHANGED
@@ -19,44 +19,51 @@ Input UI Component
19
19
 
20
20
  | Property | Description | Type | Default |
21
21
  | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------- | ----------- |
22
- | addonAfter | The label text displayed after (on the right side of) the input field. | string\ReactNode | |
23
- | addonBefore | The label text displayed before (on the left side of) the input field. | string\ReactNode | |
22
+ | addonAfter | The label text displayed after (on the right side of) the input field. | string\|ReactNode | |
23
+ | addonBefore | The label text displayed before (on the left side of) the input field. | string\|ReactNode | |
24
24
  | allowClear | Allow to remove input content with clear icon | boolean | |
25
- | counterLimit | Maximum input length, if provided counter will be shown | number | - |
26
- | renderCustomCounter | render function to display custom char counter instead of counterLimit. counterLimit (max alowed chars) does not have to be defined. | `(count: number) => ReactNode` | - |
25
+ | counterLimit | Maximum input length, if provided counter will be shown; input is blocked at the limit | number | - |
26
+ | renderCustomCounter | render function to display custom char counter instead of counterLimit. counterLimit (max allowed chars) does not have to be defined. | `(count?: number) => ReactNode` | - |
27
27
  | defaultValue | The initial input content | string | |
28
28
  | description | input description | string | - |
29
29
  | disabled | Whether the input is disabled. | boolean | `false` |
30
30
  | errorText | Error message, if provided input will be set in error state | string | - |
31
31
  | error | If provided input will be set in error state, without error message | boolean | - |
32
32
  | expandable | If true then user can switch to a multiline field if text overflows the input | boolean | - |
33
- | handleInputRef | The callback function that is triggered when Component is mounted. | function(ref) | - |
33
+ | expandableTooltip | Tooltip shown on the expand icon | ReactNode | - |
34
+ | handleInputRef | Callback receiving a ref to the underlying `<input>` element after mount. | `(ref: MutableRefObject<HTMLInputElement \| null>) => void` | - |
35
+ | icon1 | Left action icon rendered inside the input (right side) | ReactElement | - |
36
+ | icon1Tooltip | Tooltip for icon1 | ReactElement | - |
37
+ | icon2 | Second action icon (stacks with icon1) | ReactElement | - |
38
+ | icon2Tooltip | Tooltip for icon2 | ReactElement | - |
34
39
  | id | The ID for input | string | |
35
40
  | label | Input label | string | - |
36
41
  | onChange | Callback when user input | function(e) | |
37
42
  | onPressEnter | The callback function that is triggered when Enter key is pressed. | function(e) | |
38
- | prefix | The prefix icon for the Input. | string\ReactNode | |
43
+ | prefix | The prefix icon for the Input. | string\|ReactNode | |
44
+ | prefixel | Attached left addon block (height matched to input height) | ReactNode | - |
39
45
  | resetMargin | Whether input should have margin reset | boolean | - |
40
- | resize | 'resize' CSS property passed to the input component | `none` / `both` / `horizontal` / `vertical` / `initial` / `inherit` | - |
41
46
  | size | The size of the input box. Note: in the context of a form, the `large` size is used. Available: `large` `default` `small` | string | `default` |
42
- | suffix | The suffix icon for the Input. | string\ReactNode | |
47
+ | suffix | The suffix icon for the Input. | string\|ReactNode | |
48
+ | suffixel | Attached right addon block (height matched to input height) | ReactNode | - |
43
49
  | tooltip | Tooltip content | ReactNode | - |
44
50
  | tooltipConfig | Config of tooltip | [TooltipProps](https://design.synerise.com/docs/components/tooltip#api) | - |
45
51
  | type | The type of input, see: [MDN](https://developer.mozilla.org/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types)(use `Input.TextArea` instead of `type="textarea"`) | string | `text` |
46
52
  | value | The input content value | string | |
47
53
  | autoResize | 'resize' width of the input based on width of the text in input | AutoResizeProp (see below) | `undefined` |
54
+ | autoResizeProps | Fine-tuning options for autoResize: `placeholderIsMinWidth`, `wrapperClassName`, `wrapperStyle`, `extraWidth` | `Partial<AutosizeInputProps>` | - |
48
55
 
49
56
  #### AutoResizeProp
50
57
 
51
58
  ```
52
- type AutoResizeProp = `boolean` | {
59
+ type AutoResizeProp = boolean | {
53
60
  minWidth: string;
54
61
  maxWidth?: string;
55
62
  stretchToFit?: boolean
56
63
  };
57
64
  ```
58
65
 
59
- Setting `stretchToFit: true` will make the field stretch to fit the containing element. The component observes the width of the wrapper and adjusts the maxWidth accordingly.
66
+ Setting `stretchToFit: true` will make the field stretch to fit the containing element. The component observes the width of the wrapper and adjusts the maxWidth accordingly.
60
67
  **Important** if the Input is within a flex-item then there is necessary CSS that needs to be applied to the flex-item containers in order for the flex-item to grow to fill the allowed space, but at the same time not stretch the flex container (identical issue happens when text-overflow needs to happen inside a flex-item).
61
68
 
62
69
  ```css
@@ -70,17 +77,72 @@ See https://css-tricks.com/flexbox-truncated-text/ for more details.
70
77
 
71
78
  ### InputGroup
72
79
 
73
- | Property | Description | Type | Default |
74
- | -------- | ------------------------------------------------------------------------------------------------------- | ------- | ------- |
75
- | compact | Whether use compact style | boolean | `false` |
76
- | size | The size of Input.Group specifies the size of the included Input fields. Available: large default small | string | default |
77
-
78
- #### TextArea
79
-
80
- | Property | Description | Type | Default |
81
- | ------------ | ---------------------------------------------------------------------- | ------------------------------------------------------------------- | ------- |
82
- | autoSize | Autosizing the height to fit the content | `{ minRows: number; maxRows: number; }` | - |
83
- | errorText | Error message, if provided textarea will be set in error state | string | - |
84
- | error | If provided textarea will be set in error state, without error message | boolean | - |
85
- | resize | 'resize' CSS property passed to the textarea component | `none` / `both` / `horizontal` / `vertical` / `initial` / `inherit` | - |
86
- | wrapperStyle | CSS properties passed to the textarea component wrapper | `React.CSSProperties` | - |
80
+ | Property | Description | Type | Default |
81
+ | ------------- | ------------------------------------------------------------------------------------------------------- | ------------ | --------- |
82
+ | compact | Whether use compact style | boolean | `false` |
83
+ | size | The size of Input.Group specifies the size of the included Input fields. Available: large default small | string | `default` |
84
+ | errors | Array of error messages displayed below the group | string[] | - |
85
+ | resetMargin | Whether input group should have margin reset | boolean | - |
86
+ | label | Group label | ReactNode | - |
87
+ | description | Helper text below the group | string | - |
88
+ | tooltip | Tooltip content on the label | ReactNode | - |
89
+ | tooltipConfig | Config of tooltip | TooltipProps | - |
90
+
91
+ ### TextArea
92
+
93
+ | Property | Description | Type | Default |
94
+ | ------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------- | ------- |
95
+ | autoSize | Autosizing the height to fit the content | `{ minRows: number; maxRows: number; }` | - |
96
+ | counterLimit | Maximum input length, if provided counter will be shown | number | - |
97
+ | renderCustomCounter | Render function to display custom char counter | `(count?: number) => ReactNode` | - |
98
+ | description | Helper text below the textarea | string | - |
99
+ | errorText | Error message, if provided textarea will be set in error state | string\|ReactNode | - |
100
+ | error | If provided textarea will be set in error state, without error message | boolean | - |
101
+ | handleInputRef | Callback receiving a ref to the underlying `<textarea>` element | `(ref: MutableRefObject<HTMLTextAreaElement \| null>) => void` | - |
102
+ | icon1 | Left action icon rendered inside the textarea (right side) | ReactElement | - |
103
+ | icon1Tooltip | Tooltip for icon1 | ReactElement | - |
104
+ | icon2 | Second action icon | ReactElement | - |
105
+ | icon2Tooltip | Tooltip for icon2 | ReactElement | - |
106
+ | label | Field label | ReactNode | - |
107
+ | prefixel | Attached left addon block | ReactNode | - |
108
+ | resize | 'resize' CSS property passed to the textarea component | `none` / `both` / `horizontal` / `vertical` / `initial` / `inherit` | - |
109
+ | resetMargin | Whether textarea should have margin reset | boolean | - |
110
+ | suffixel | Attached right addon block | ReactNode | - |
111
+ | tooltip | Tooltip content on the label | ReactNode | - |
112
+ | tooltipConfig | Config of tooltip | TooltipProps | - |
113
+ | wrapperStyle | CSS properties passed to the textarea component wrapper | `React.CSSProperties` | - |
114
+
115
+ ### PasswordInput
116
+
117
+ Wraps `Input` with a show/hide password toggle. All `InputProps` are accepted except `icon1`, `icon1Tooltip`, `icon2`, `icon2Tooltip`, `suffixel`, `prefixel`, `type`, and `expandableTooltip`.
118
+
119
+ | Property | Description | Type | Default |
120
+ | -------- | -------------------------------- | ----------------------------- | ------- |
121
+ | texts | Override show/hide label strings | `Partial<PasswordInputTexts>` | - |
122
+
123
+ `PasswordInputTexts`:
124
+
125
+ | Property | Description | Type |
126
+ | -------- | ----------------------- | --------- |
127
+ | showText | Label for "show" button | ReactNode |
128
+ | hideText | Label for "hide" button | ReactNode |
129
+
130
+ Default strings come from `react-intl` (`DS.INPUT.SHOW-PASSWORD` / `DS.INPUT.HIDE-PASSWORD`).
131
+
132
+ ### InputMultivalue
133
+
134
+ Tag-style input that accumulates string values. Press **Enter** to add the current text as a new tag. Tags can be individually removed.
135
+
136
+ | Property | Description | Type | Default |
137
+ | ----------- | ------------------------------------------------------------------------ | ---------------------------- | ------- |
138
+ | values | **Required.** Array of current tag values | string[] | - |
139
+ | onChange | Called with the updated values array when a tag is added or removed | `(values: string[]) => void` | - |
140
+ | error | Sets error styling | boolean | - |
141
+ | errorText | Error message | ReactNode\|string | - |
142
+ | label | Field label | ReactNode\|string | - |
143
+ | description | Helper text | ReactNode\|string | - |
144
+ | disabled | Disables interaction | boolean | - |
145
+ | onBlur | Called on blur | `() => void` | - |
146
+ | onFocus | Called on focus | `() => void` | - |
147
+ | maxLength | Max length of the current entry being typed (not the total values count) | number | - |
148
+ | className | Applied to the input wrapper | string | - |
@@ -1,5 +1,5 @@
1
- import React, { type CSSProperties } from 'react';
2
- import type { AutosizeInputRefType } from './AutosizeInput.types';
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
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef } from 'react';
3
- import { useResizeObserver } from '@synerise/ds-utils';
4
- import { calculateInputWidth } from './utils';
5
- var sizerStyle = {
6
- position: 'absolute',
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: 'hidden',
9
+ visibility: "hidden",
10
10
  height: 0,
11
- overflow: 'scroll',
12
- whiteSpace: 'pre'
11
+ overflow: "scroll",
12
+ whiteSpace: "pre"
13
13
  };
14
- var FONT_CSS_PROPS = ['fontSize', 'fontFamily', 'fontWeight', 'fontFeatureSettings', 'fontStyle', 'letterSpacing', 'fontStretch', 'textTransform'];
15
- var AutosizeInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
16
- var _ref2, _style$display;
17
- var _ref$extraWidth = _ref.extraWidth,
18
- extraWidth = _ref$extraWidth === void 0 ? 16 : _ref$extraWidth,
19
- wrapperClassName = _ref.wrapperClassName,
20
- wrapperStyleProp = _ref.wrapperStyle,
21
- onAutosize = _ref.onAutosize,
22
- preAutosize = _ref.preAutosize,
23
- placeholderIsMinWidth = _ref.placeholderIsMinWidth,
24
- _ref$minWidth = _ref.minWidth,
25
- minWidth = _ref$minWidth === void 0 ? 0 : _ref$minWidth,
26
- handleInputRef = _ref.handleInputRef,
27
- children = _ref.children,
28
- transformWrapperRef = _ref.transformWrapperRef,
29
- transformRef = _ref.transformRef,
30
- placeholder = _ref.placeholder,
31
- value = _ref.value,
32
- defaultValue = _ref.defaultValue,
33
- style = _ref.style;
34
- var usedValue = (_ref2 = value != null ? value : defaultValue) != null ? _ref2 : '';
35
- var inputRef = useRef(null);
36
- var inputWrapperRef = useRef(null);
37
- var sizerRef = useRef(null);
38
- var placeholderSizerRef = useRef(null);
39
- var wrapperRef = useRef(null);
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
- var transformElement = useMemo(function () {
46
- return transformRef || function (element) {
47
- return element;
48
- };
41
+ const transformElement = useMemo(() => {
42
+ return transformRef || ((element) => element);
49
43
  }, [transformRef]);
50
- var contentWidth = useRef();
51
- var placeholderWidth = useRef();
52
- var applyNewWidth = useCallback(function () {
53
- var _sizerRef$current, _placeholderWidth$cur, _placeholderSizerRef$;
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: !!((_sizerRef$current = sizerRef.current) != null && _sizerRef$current.textContent),
57
- placeholderIsMinWidth: placeholderIsMinWidth,
58
- placeholderWidth: (_placeholderWidth$cur = placeholderWidth.current) != null ? _placeholderWidth$cur : (_placeholderSizerRef$ = placeholderSizerRef.current) == null ? void 0 : _placeholderSizerRef$.scrollWidth,
49
+ hasValue: !!sizerRef.current?.textContent,
50
+ placeholderIsMinWidth,
51
+ placeholderWidth: placeholderWidth.current ?? placeholderSizerRef.current?.scrollWidth,
59
52
  minWidth: +minWidth,
60
- placeholder: placeholder
53
+ placeholder
61
54
  });
62
55
  if (inputWrapperRef.current) {
63
- var finalWidth = calculatedWidth + +extraWidth;
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 + "px";
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
- var resizeContentHandler = useCallback(function (newWidth) {
64
+ const resizeContentHandler = useCallback((newWidth) => {
72
65
  contentWidth.current = newWidth.width;
73
66
  applyNewWidth();
74
67
  }, [applyNewWidth]);
75
- var resizePlaceholderHandler = useCallback(function (newWidth) {
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
- var copyInputStyles = function copyInputStyles() {
74
+ const copyInputStyles = () => {
82
75
  if (inputRef.current) {
83
- var computedStyle = window.getComputedStyle(inputRef.current);
84
- FONT_CSS_PROPS.forEach(function (cssProperty) {
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(function () {
87
+ useLayoutEffect(() => {
95
88
  copyInputStyles();
96
89
  }, []);
97
- useEffect(function () {
90
+ useEffect(() => {
98
91
  if (sizerRef.current) {
99
- var sizerSibling = sizerRef.current.nextElementSibling;
100
- var inputElement = sizerSibling instanceof HTMLElement && transformElement(sizerSibling);
101
- var inputWrapperElement = sizerSibling instanceof HTMLElement && transformWrapper(sizerSibling);
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 = 'content-box';
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, function () {
116
- return {
117
- inputRef: inputRef,
118
- sizerRef: sizerRef,
119
- wrapperRef: wrapperRef,
120
- inputWrapperRef: inputWrapperRef,
121
- placeholderSizerRef: placeholderSizerRef,
122
- copyInputStyles: copyInputStyles,
123
- updateInputWidth: applyNewWidth
124
- };
125
- });
126
- var wrapperStyle = _extends({}, wrapperStyleProp, {
127
- position: 'relative',
128
- display: (_style$display = style == null ? void 0 : style.display) != null ? _style$display : 'inline-block'
129
- });
130
- return /*#__PURE__*/React.createElement("div", {
131
- ref: wrapperRef,
132
- className: wrapperClassName,
133
- style: wrapperStyle,
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 default AutosizeInput;
128
+ export {
129
+ AutosizeInput as default
130
+ };
@@ -1,4 +1,4 @@
1
- import type { CSSProperties, InputHTMLAttributes, MutableRefObject, ReactNode, RefObject } from 'react';
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
- export {};
1
+
@@ -1,4 +1,4 @@
1
- import type { AutosizeInputProps } from '../AutosizeInput.types';
1
+ import { AutosizeInputProps } from '../AutosizeInput.types';
2
2
  type CalculateWidthProps = {
3
3
  sizerWidth?: number;
4
4
  hasValue?: boolean;
@@ -1,18 +1,18 @@
1
- var calculateInputWidth = function calculateInputWidth(_ref) {
2
- var sizerWidth = _ref.sizerWidth,
3
- hasValue = _ref.hasValue,
4
- placeholderIsMinWidth = _ref.placeholderIsMinWidth,
5
- placeholderWidth = _ref.placeholderWidth,
6
- minWidth = _ref.minWidth,
7
- placeholder = _ref.placeholder;
8
- var width = 0;
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 !== undefined && width < 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 default calculateInputWidth;
25
+ export {
26
+ calculateInputWidth as default
27
+ };
@@ -1 +1,4 @@
1
- export { default as calculateInputWidth } from './calculateInputWidth';
1
+ import { default as default2 } from "./calculateInputWidth.js";
2
+ export {
3
+ default2 as calculateInputWidth
4
+ };
package/dist/Input.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import React from 'react';
2
- import '@synerise/ds-core/dist/js/style';
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("./Input.types").AutoResizeProp;
19
- autoResizeProps?: Partial<Pick<import("./AutosizeInput/AutosizeInput.types").AutosizeInputProps, "placeholderIsMinWidth" | "wrapperClassName" | "wrapperStyle" | "extraWidth">>;
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("@synerise/ds-form-field").ContentAboveProps, "id" | "rightSide"> & import("@synerise/ds-form-field").ContentBelowProps & import("antd/lib/input").InputProps & React.RefAttributes<HTMLDivElement>>;
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';