@synerise/ds-input 1.0.3 → 1.1.0

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 CHANGED
@@ -3,6 +3,25 @@
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.1.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.0.4...@synerise/ds-input@1.1.0) (2025-04-16)
7
+
8
+
9
+ ### Features
10
+
11
+ * **form-field:** add form-field component ([7f6b191](https://github.com/synerise/synerise-design/commit/7f6b191132a3b0d694c21fb4d649f4deea6acb89))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.0.4](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.0.3...@synerise/ds-input@1.0.4) (2025-04-02)
18
+
19
+ **Note:** Version bump only for package @synerise/ds-input
20
+
21
+
22
+
23
+
24
+
6
25
  ## [1.0.3](https://github.com/synerise/synerise-design/compare/@synerise/ds-input@1.0.2...@synerise/ds-input@1.0.3) (2025-03-31)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-input
@@ -1,4 +1,4 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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
2
  import React, { useEffect, useRef, useLayoutEffect, forwardRef, useImperativeHandle, useCallback, useMemo, useState } from 'react';
3
3
  import { useResizeObserver } from '@synerise/ds-utils';
4
4
  import { calculateInputWidth } from './utils';
@@ -12,7 +12,7 @@ var sizerStyle = {
12
12
  whiteSpace: 'pre'
13
13
  };
14
14
  var FONT_CSS_PROPS = ['fontSize', 'fontFamily', 'fontWeight', 'fontFeatureSettings', 'fontStyle', 'letterSpacing', 'fontStretch', 'textTransform'];
15
- var AutosizeInput = forwardRef(function (_ref, forwardedRef) {
15
+ var AutosizeInput = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
16
16
  var _ref2, _style$display;
17
17
  var _ref$extraWidth = _ref.extraWidth,
18
18
  extraWidth = _ref$extraWidth === void 0 ? 16 : _ref$extraWidth,
package/dist/Input.js CHANGED
@@ -1,15 +1,17 @@
1
1
  var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error", "expandable", "expandableTooltip", "renderCustomCounter"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2
+ 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); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
4
  import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
5
5
  import { v4 as uuid } from 'uuid';
6
6
  import { useResizeObserver } from '@synerise/ds-utils';
7
+ import FormField from '@synerise/ds-form-field';
7
8
  import '@synerise/ds-core/dist/js/style';
8
9
  import "./style/index.css";
9
10
  import * as S from './Input.styles';
10
- import { ContentAboveElement, ContentBelowElement, ElementIcons, AutosizeWrapper, ExpandableWrapper } from './components';
11
+ import { ElementIcons, AutosizeWrapper, ExpandableWrapper } from './components';
11
12
  import { useInputAddonHeight, useElementFocus } from './hooks';
12
13
  import { getCharCount } from './utils';
14
+ import { useCounterLimit } from './hooks/useCounterLimit';
13
15
  var VERTICAL_BORDER_OFFSET = 2;
14
16
  export var Input = function Input(_ref) {
15
17
  var className = _ref.className,
@@ -151,6 +153,11 @@ export var Input = function Input(_ref) {
151
153
  onAutosize();
152
154
  }, [onAutosize, preAutosize]);
153
155
  useResizeObserver(elementRef, handleWrapperResize);
156
+ var rightSide = useCounterLimit({
157
+ renderCustomCounter: renderCustomCounter,
158
+ counterLimit: counterLimit,
159
+ charCount: charCount
160
+ });
154
161
  var autoSizedComponent = /*#__PURE__*/React.createElement(AutosizeWrapper, {
155
162
  preAutosize: preAutosize,
156
163
  onAutosize: onAutosize,
@@ -182,15 +189,15 @@ export var Input = function Input(_ref) {
182
189
  className: className,
183
190
  resetMargin: resetMargin,
184
191
  iconCount: iconCount
185
- }, /*#__PURE__*/React.createElement(ContentAboveElement, {
192
+ }, /*#__PURE__*/React.createElement(FormField, {
186
193
  label: label,
187
- counterLimit: counterLimit,
194
+ rightSide: rightSide,
188
195
  id: id,
189
196
  tooltip: tooltip,
190
197
  tooltipConfig: tooltipConfig,
191
- charCount: charCount,
192
- renderCustomCounter: renderCustomCounter
193
- }), /*#__PURE__*/React.createElement(S.InputWrapper, {
198
+ description: description,
199
+ errorText: errorText
200
+ }, /*#__PURE__*/React.createElement(S.InputWrapper, {
194
201
  iconCount: iconCount
195
202
  }, /*#__PURE__*/React.createElement(ElementIcons, {
196
203
  handleIconsClick: handleIconsClick,
@@ -211,10 +218,7 @@ export var Input = function Input(_ref) {
211
218
  ref: expandableTextAreaRef,
212
219
  value: antdInputProps.value,
213
220
  expanded: expanded
214
- }, autoSizedComponent) : autoSizedComponent), /*#__PURE__*/React.createElement(ContentBelowElement, {
215
- description: description,
216
- errorText: errorText
217
- }));
221
+ }, autoSizedComponent) : autoSizedComponent)));
218
222
  };
219
223
  export var RawInput = function RawInput(props) {
220
224
  var error = props.error;
@@ -1,7 +1,7 @@
1
1
  var _excluded = ["error"],
2
2
  _excluded2 = ["error"];
3
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
3
+ 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); }
4
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
5
5
  import React, { forwardRef } from 'react';
6
6
  import styled, { css } from 'styled-components';
7
7
  import BaseAntInput from 'antd/lib/input';
@@ -79,7 +79,7 @@ export var IconWrapper = styled.div.withConfig({
79
79
  })([".icon:hover{svg{fill:", ";cursor:pointer;}}"], function (props) {
80
80
  return props.theme.palette['blue-600'];
81
81
  });
82
- export var AntdInput = styled(forwardRef(
82
+ export var AntdInput = styled(/*#__PURE__*/forwardRef(
83
83
  // eslint-disable-next-line
84
84
  function (_ref2, ref) {
85
85
  var error = _ref2.error,
@@ -107,7 +107,7 @@ function (_ref2, ref) {
107
107
  theme = _ref3.theme;
108
108
  return readOnly ? "\n &:hover {\n border-color: " + theme.palette['grey-300'] + ";\n }\n &:focus {\n border-color: " + theme.palette['grey-300'] + ";\n box-shadow: none;\n background: #fff;\n }\n " : '';
109
109
  });
110
- export var AntdTextArea = styled(forwardRef(
110
+ export var AntdTextArea = styled(/*#__PURE__*/forwardRef(
111
111
  // eslint-disable-next-line
112
112
  function (_ref4, ref) {
113
113
  var error = _ref4.error,
@@ -1,6 +1,6 @@
1
- import { ReactNode, ReactElement, MutableRefObject } from 'react';
2
- import { InputProps as AntdInputProps, TextAreaProps as AntdTextAreaProps } from 'antd/lib/input';
3
- import { TooltipProps } from '@synerise/ds-tooltip';
1
+ import type { ReactNode, ReactElement, MutableRefObject } from 'react';
2
+ import type { InputProps as AntdInputProps, TextAreaProps as AntdTextAreaProps } from 'antd/lib/input';
3
+ import type { FormFieldCommonProps } from '@synerise/ds-form-field';
4
4
  export type AutoResizeProp = boolean | {
5
5
  minWidth: string;
6
6
  maxWidth?: string;
@@ -10,11 +10,6 @@ export type Props = BaseProps<HTMLInputElement | HTMLTextAreaElement>;
10
10
  export type BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInputElement = HTMLInputElement> = {
11
11
  error?: boolean;
12
12
  className?: string;
13
- tooltip?: ReactNode;
14
- tooltipConfig?: TooltipProps;
15
- errorText?: ReactNode;
16
- label?: ReactNode;
17
- description?: ReactNode;
18
13
  counterLimit?: number;
19
14
  renderCustomCounter?: (count?: number) => ReactNode;
20
15
  icon1?: ReactElement;
@@ -28,7 +23,7 @@ export type BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInputElem
28
23
  autoResize?: AutoResizeProp;
29
24
  expandable?: boolean;
30
25
  expandableTooltip?: ReactNode;
31
- };
26
+ } & FormFieldCommonProps;
32
27
  /**
33
28
  * @deprecated use `InputProps`, `TextareaProps` instead
34
29
  */
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { Props } from './InputGroup.types';
3
- declare const InputGroup: ({ children, label, errors, description, resetMargin, tooltip, ...antdInputGroupProps }: Props) => React.JSX.Element;
3
+ declare const InputGroup: ({ children, label, errors, description, resetMargin, tooltip, tooltipConfig, ...antdInputGroupProps }: Props) => React.JSX.Element;
4
4
  export default InputGroup;
@@ -1,10 +1,10 @@
1
- var _excluded = ["children", "label", "errors", "description", "resetMargin", "tooltip"];
2
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1
+ var _excluded = ["children", "label", "errors", "description", "resetMargin", "tooltip", "tooltipConfig"];
2
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
3
3
  import React, { Children } from 'react';
4
+ import FormField from '@synerise/ds-form-field';
4
5
  import Input from 'antd/lib/input';
5
6
  import * as InputStyles from './Input.styles';
6
7
  import * as S from './InputGroup.styles';
7
- import Label from './Label/Label';
8
8
  var InputGroup = function InputGroup(_ref) {
9
9
  var children = _ref.children,
10
10
  label = _ref.label,
@@ -12,24 +12,28 @@ var InputGroup = function InputGroup(_ref) {
12
12
  description = _ref.description,
13
13
  resetMargin = _ref.resetMargin,
14
14
  tooltip = _ref.tooltip,
15
+ tooltipConfig = _ref.tooltipConfig,
15
16
  antdInputGroupProps = _objectWithoutPropertiesLoose(_ref, _excluded);
16
17
  var childrenArray = Children.toArray(children);
17
18
  return /*#__PURE__*/React.createElement(InputStyles.OuterWrapper, {
18
19
  className: "ds-input-group-outer-wrapper",
19
20
  resetMargin: resetMargin
20
- }, label && /*#__PURE__*/React.createElement(InputStyles.ContentAbove, null, /*#__PURE__*/React.createElement(Label, {
21
+ }, /*#__PURE__*/React.createElement(FormField, {
21
22
  label: label,
22
- tooltip: tooltip
23
- })), /*#__PURE__*/React.createElement(Input.Group, antdInputGroupProps, /*#__PURE__*/React.createElement(S.InputGroupWrapper, {
23
+ tooltip: tooltip,
24
+ tooltipConfig: tooltipConfig,
25
+ description: description,
26
+ errorText: errors && errors.map(function (error) {
27
+ return /*#__PURE__*/React.createElement(InputStyles.ErrorText, {
28
+ key: error
29
+ }, error);
30
+ })
31
+ }, /*#__PURE__*/React.createElement(Input.Group, antdInputGroupProps, /*#__PURE__*/React.createElement(S.InputGroupWrapper, {
24
32
  compact: antdInputGroupProps.compact
25
33
  }, Children.map(childrenArray, function (child, index) {
26
34
  return /*#__PURE__*/React.createElement(S.InputGroupItem, {
27
35
  className: "ds-input-group-item ds-input-group-item-" + index
28
36
  }, child);
29
- }))), (errors && errors.length > 0 || description) && /*#__PURE__*/React.createElement(InputStyles.ContentBelow, null, errors && errors.map(function (error) {
30
- return /*#__PURE__*/React.createElement(InputStyles.ErrorText, {
31
- key: "error"
32
- }, error);
33
- }), description && /*#__PURE__*/React.createElement(InputStyles.Description, null, description)));
37
+ })))));
34
38
  };
35
39
  export default InputGroup;
@@ -1,9 +1,6 @@
1
- import { GroupProps } from 'antd/es/input';
2
- import React from 'react';
3
- export interface Props extends GroupProps {
4
- label?: React.ReactNode;
1
+ import type { GroupProps } from 'antd/es/input';
2
+ import { FormFieldCommonProps } from '@synerise/ds-form-field';
3
+ export type Props = GroupProps & {
5
4
  errors?: string[];
6
- description?: React.ReactNode;
7
5
  resetMargin?: boolean;
8
- tooltip?: React.ReactNode;
9
- }
6
+ } & Omit<FormFieldCommonProps, 'errorText'>;
@@ -1,6 +1,6 @@
1
1
  var _excluded = ["className", "errorText", "label", "description", "values", "onChange", "onBlur", "onFocus", "disabled", "maxLength", "error"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2
+ 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); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
4
  import React from 'react';
5
5
  import * as S from './InputMultivalue.styles';
6
6
  import Value from './Elements/Value';
package/dist/TextArea.js CHANGED
@@ -1,15 +1,17 @@
1
1
  var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "autoResize", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error", "renderCustomCounter"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2
+ 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); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
4
  import React, { useEffect, useRef, useCallback, useMemo } from 'react';
5
5
  import { v4 as uuid } from 'uuid';
6
+ import FormField from '@synerise/ds-form-field';
6
7
  import '@synerise/ds-core/dist/js/style';
7
8
  import "./style/index.css";
8
9
  import * as S from './Input.styles';
9
- import { ContentAboveElement, ContentBelowElement, ElementIcons } from './components';
10
+ import { ElementIcons } from './components';
10
11
  import Textarea from './Textarea/Textarea';
11
12
  import { useElementFocus } from './hooks';
12
13
  import { getCharCount } from './utils';
14
+ import { useCounterLimit } from './hooks/useCounterLimit';
13
15
  export var TextArea = function TextArea(_ref) {
14
16
  var className = _ref.className,
15
17
  errorText = _ref.errorText,
@@ -47,19 +49,24 @@ export var TextArea = function TextArea(_ref) {
47
49
  }
48
50
  antdTextareaProps.onChange && antdTextareaProps.onChange(e);
49
51
  }, [antdTextareaProps, counterLimit]);
52
+ var rightSide = useCounterLimit({
53
+ renderCustomCounter: renderCustomCounter,
54
+ counterLimit: counterLimit,
55
+ charCount: charCount
56
+ });
50
57
  return /*#__PURE__*/React.createElement(S.OuterWrapper, {
51
58
  autoResize: autoResize,
52
59
  className: className,
53
60
  resetMargin: resetMargin
54
- }, /*#__PURE__*/React.createElement(ContentAboveElement, {
61
+ }, /*#__PURE__*/React.createElement(FormField, {
55
62
  label: label,
56
- counterLimit: counterLimit,
63
+ rightSide: rightSide,
57
64
  id: id,
58
65
  tooltip: tooltip,
59
66
  tooltipConfig: tooltipConfig,
60
- charCount: charCount,
61
- renderCustomCounter: renderCustomCounter
62
- }), /*#__PURE__*/React.createElement(S.InputWrapper, null, /*#__PURE__*/React.createElement(ElementIcons, {
67
+ description: description,
68
+ errorText: errorText
69
+ }, /*#__PURE__*/React.createElement(S.InputWrapper, null, /*#__PURE__*/React.createElement(ElementIcons, {
63
70
  handleIconsClick: handleIconsClick,
64
71
  disabled: antdTextareaProps.disabled,
65
72
  icon1Tooltip: icon1Tooltip,
@@ -75,9 +82,6 @@ export var TextArea = function TextArea(_ref) {
75
82
  value: antdTextareaProps.value,
76
83
  id: id,
77
84
  autoComplete: "off"
78
- }))), /*#__PURE__*/React.createElement(ContentBelowElement, {
79
- description: description,
80
- errorText: errorText
81
- }));
85
+ })))));
82
86
  };
83
87
  export var RawTextArea = S.AntdTextArea;
@@ -1,11 +1,11 @@
1
1
  var _excluded = ["disabled", "error", "rows", "wrapperStyle", "onBlur", "onFocus", "resize", "autoSize", "readOnly"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2
+ 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); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
4
  import React, { forwardRef, useState } from 'react';
5
5
  import Scrollbar from '@synerise/ds-scrollbar';
6
6
  import * as S from './Textarea.styles';
7
7
  import * as InputStyles from '../Input.styles';
8
- var Textarea = forwardRef(function (_ref, ref) {
8
+ var Textarea = /*#__PURE__*/forwardRef(function (_ref, ref) {
9
9
  var disabled = _ref.disabled,
10
10
  error = _ref.error,
11
11
  _ref$rows = _ref.rows,
@@ -1,10 +1,10 @@
1
1
  var _excluded = ["autoResize", "extraWidth", "children"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
2
+ 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); }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
4
  import React, { forwardRef } from 'react';
5
5
  import AutosizeInput from '../AutosizeInput/AutosizeInput';
6
6
  var AUTOSIZE_EXTRA_WIDTH = 2;
7
- export var AutosizeWrapper = forwardRef(function (_ref, ref) {
7
+ export var AutosizeWrapper = /*#__PURE__*/forwardRef(function (_ref, ref) {
8
8
  var autoResize = _ref.autoResize,
9
9
  _ref$extraWidth = _ref.extraWidth,
10
10
  extraWidth = _ref$extraWidth === void 0 ? AUTOSIZE_EXTRA_WIDTH : _ref$extraWidth,
@@ -1,4 +1,4 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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
2
  import React, { cloneElement } from 'react';
3
3
  import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
4
4
  import Icon, { ResizeArrowM } from '@synerise/ds-icon';
@@ -35,7 +35,7 @@ export var ElementIcons = function ElementIcons(_ref) {
35
35
  title: icon1Tooltip
36
36
  }, /*#__PURE__*/React.createElement(S.IconWrapper, {
37
37
  className: className
38
- }, icon1 && cloneElement(icon1, _extends({
38
+ }, icon1 && /*#__PURE__*/cloneElement(icon1, _extends({
39
39
  className: 'icon icon1'
40
40
  }, icon2 && {
41
41
  style: {
@@ -45,7 +45,7 @@ export var ElementIcons = function ElementIcons(_ref) {
45
45
  title: icon2Tooltip
46
46
  }, /*#__PURE__*/React.createElement(S.IconWrapper, {
47
47
  className: className
48
- }, icon2 && cloneElement(icon2, {
48
+ }, icon2 && /*#__PURE__*/cloneElement(icon2, {
49
49
  className: 'icon icon2'
50
50
  }))))) : /*#__PURE__*/React.createElement(React.Fragment, null);
51
51
  };
@@ -1,7 +1,7 @@
1
1
  import React, { forwardRef } from 'react';
2
2
  import Textarea from '../Textarea/Textarea';
3
3
  import * as S from '../Input.styles';
4
- export var ExpandableWrapper = forwardRef(function (_ref, expandableTextAreaRef) {
4
+ export var ExpandableWrapper = /*#__PURE__*/forwardRef(function (_ref, expandableTextAreaRef) {
5
5
  var children = _ref.children,
6
6
  value = _ref.value,
7
7
  expanded = _ref.expanded,
@@ -1,5 +1,3 @@
1
- export { ContentAboveElement } from './ContentAboveElement';
2
- export { ContentBelowElement } from './ContentBelowElement';
3
1
  export { ElementIcons } from './ElementIcons';
4
2
  export { ExpandableWrapper } from './ExpandableWrapper';
5
3
  export { AutosizeWrapper } from './AutosizeWrapper';
@@ -1,5 +1,3 @@
1
- export { ContentAboveElement } from './ContentAboveElement';
2
- export { ContentBelowElement } from './ContentBelowElement';
3
1
  export { ElementIcons } from './ElementIcons';
4
2
  export { ExpandableWrapper } from './ExpandableWrapper';
5
3
  export { AutosizeWrapper } from './AutosizeWrapper';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { InputProps } from '../Input.types';
3
+ type UseCounterLimitOptions = Pick<InputProps, 'counterLimit' | 'renderCustomCounter'> & {
4
+ charCount?: number;
5
+ };
6
+ export declare const useCounterLimit: ({ charCount, counterLimit, renderCustomCounter }: UseCounterLimitOptions) => React.JSX.Element | undefined;
7
+ export {};
@@ -0,0 +1,17 @@
1
+ import React, { useMemo } from 'react';
2
+ import * as S from '../Input.styles';
3
+ export var useCounterLimit = function useCounterLimit(_ref) {
4
+ var charCount = _ref.charCount,
5
+ counterLimit = _ref.counterLimit,
6
+ renderCustomCounter = _ref.renderCustomCounter;
7
+ return useMemo(function () {
8
+ if (renderCustomCounter) {
9
+ return /*#__PURE__*/React.createElement(S.Counter, {
10
+ "data-testid": "custom-counter"
11
+ }, renderCustomCounter(charCount));
12
+ }
13
+ return counterLimit ? /*#__PURE__*/React.createElement(S.Counter, {
14
+ "data-testid": "counter"
15
+ }, charCount, "/", counterLimit) : undefined;
16
+ }, [charCount, counterLimit, renderCustomCounter]);
17
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- export { default as Label } from './Label/Label';
1
+ /**
2
+ * @deprecated - import { FormFieldLabel } from '@synerise/ds-form-field';
3
+ */
4
+ export { FormFieldLabel as Label } from '@synerise/ds-form-field';
2
5
  export { Input, RawInput, InputGroup, InputMultivalue } from './Input';
3
6
  export { TextArea, RawTextArea } from './TextArea';
4
7
  export type { TextareaProps } from './TextArea.types';
package/dist/index.js CHANGED
@@ -1,4 +1,7 @@
1
- export { default as Label } from './Label/Label';
1
+ /**
2
+ * @deprecated - import { FormFieldLabel } from '@synerise/ds-form-field';
3
+ */
4
+ export { FormFieldLabel as Label } from '@synerise/ds-form-field';
2
5
  export { Input, RawInput, InputGroup, InputMultivalue } from './Input';
3
6
  export { TextArea, RawTextArea } from './TextArea';
4
7
  import * as _InputStyles from './Input.styles';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-input",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Input UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -34,10 +34,10 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-icon": "^1.2.0",
38
- "@synerise/ds-scrollbar": "^1.0.3",
39
- "@synerise/ds-tooltip": "^1.1.2",
40
- "@synerise/ds-typography": "^1.0.3",
37
+ "@synerise/ds-form-field": "^1.1.0",
38
+ "@synerise/ds-icon": "^1.4.0",
39
+ "@synerise/ds-scrollbar": "^1.0.5",
40
+ "@synerise/ds-tooltip": "^1.1.4",
41
41
  "@synerise/ds-utils": "^1.0.1",
42
42
  "csstype": "2.6.9",
43
43
  "uuid": "^8.3.2"
@@ -48,5 +48,5 @@
48
48
  "react": ">=16.9.0 <= 18.3.1",
49
49
  "styled-components": "^5.3.3"
50
50
  },
51
- "gitHead": "5438445467b16dbc0c2ca97d969ae0e09b74131b"
51
+ "gitHead": "6735f9babfeef53122f54ca86cba5f581e8870d9"
52
52
  }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { LabelProps } from './Label.types';
3
- declare const Label: ({ id, className, label, tooltip, tooltipConfig, style }: LabelProps) => React.JSX.Element;
4
- export default Label;
@@ -1,31 +0,0 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import React from 'react';
3
- import Tooltip from '@synerise/ds-tooltip';
4
- import Icon, { InfoFillS } from '@synerise/ds-icon';
5
- import * as S from './Label.styles';
6
- var Label = function Label(_ref) {
7
- var id = _ref.id,
8
- className = _ref.className,
9
- label = _ref.label,
10
- tooltip = _ref.tooltip,
11
- tooltipConfig = _ref.tooltipConfig,
12
- style = _ref.style;
13
- return /*#__PURE__*/React.createElement(React.Fragment, null, label && /*#__PURE__*/React.createElement(S.Label, {
14
- style: style,
15
- htmlFor: id,
16
- className: className
17
- }, /*#__PURE__*/React.createElement(S.LabelText, {
18
- ellipsis: {
19
- tooltip: label
20
- }
21
- }, label), (tooltip || tooltipConfig) && /*#__PURE__*/React.createElement(Tooltip, _extends({
22
- title: tooltip,
23
- placement: "top",
24
- trigger: "hover",
25
- transitionName: "zoom-big-fast"
26
- }, tooltipConfig), /*#__PURE__*/React.createElement(S.IconWrapper, null, /*#__PURE__*/React.createElement(Icon, {
27
- size: 24,
28
- component: /*#__PURE__*/React.createElement(InfoFillS, null)
29
- })))));
30
- };
31
- export default Label;
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const Label: import("styled-components").StyledComponent<"label", any, {}, never>;
3
- export declare const IconWrapper: import("styled-components").StyledComponent<"span", any, {}, never>;
4
- export declare const LabelText: import("styled-components").StyledComponent<({ size, className, children, ellipsis }: {
5
- size?: import("@synerise/ds-typography").TextSize | undefined;
6
- ellipsis?: import("@synerise/ds-typography/dist/Ellipsis").EllipsisProps | undefined;
7
- children?: import("react").ReactNode;
8
- className?: string | undefined;
9
- }) => import("react").JSX.Element, any, {}, never>;
@@ -1,16 +0,0 @@
1
- import styled from 'styled-components';
2
- import { macro, Text } from '@synerise/ds-typography';
3
- export var Label = styled.label.withConfig({
4
- displayName: "Labelstyles__Label",
5
- componentId: "sc-1eottcg-0"
6
- })(["", ";height:17px;display:flex;align-items:center;cursor:pointer;white-space:nowrap;min-width:0;overflow:hidden;text-overflow:ellipsis;"], macro.heading);
7
- export var IconWrapper = styled.span.withConfig({
8
- displayName: "Labelstyles__IconWrapper",
9
- componentId: "sc-1eottcg-1"
10
- })(["display:inline-block;.ds-icon > svg{margin-top:-1px;fill:", ";}"], function (props) {
11
- return props.theme.palette['grey-400'];
12
- });
13
- export var LabelText = styled(Text).withConfig({
14
- displayName: "Labelstyles__LabelText",
15
- componentId: "sc-1eottcg-2"
16
- })([""]);
@@ -1,10 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import type { TooltipProps } from '@synerise/ds-tooltip';
3
- export type LabelProps = {
4
- id?: string;
5
- label?: ReactNode;
6
- tooltip?: ReactNode;
7
- tooltipConfig?: TooltipProps;
8
- style?: object;
9
- className?: string;
10
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { BaseProps } from '../Input.types';
3
- type ContentAboveProps = Pick<BaseProps, 'tooltip' | 'tooltipConfig' | 'label' | 'renderCustomCounter'> & {
4
- counterLimit?: number;
5
- charCount?: number;
6
- id: string;
7
- };
8
- export declare const ContentAboveElement: ({ label, counterLimit, id, tooltip, tooltipConfig, charCount, renderCustomCounter, }: ContentAboveProps) => React.JSX.Element;
9
- export {};
@@ -1,22 +0,0 @@
1
- import React from 'react';
2
- import Label from '../Label/Label';
3
- import * as S from '../Input.styles';
4
- export var ContentAboveElement = function ContentAboveElement(_ref) {
5
- var label = _ref.label,
6
- counterLimit = _ref.counterLimit,
7
- id = _ref.id,
8
- tooltip = _ref.tooltip,
9
- tooltipConfig = _ref.tooltipConfig,
10
- charCount = _ref.charCount,
11
- renderCustomCounter = _ref.renderCustomCounter;
12
- return label || counterLimit ? /*#__PURE__*/React.createElement(S.ContentAbove, null, /*#__PURE__*/React.createElement(Label, {
13
- label: label,
14
- id: id,
15
- tooltip: tooltip,
16
- tooltipConfig: tooltipConfig
17
- }), renderCustomCounter ? /*#__PURE__*/React.createElement(S.Counter, {
18
- "data-testid": "custom-counter"
19
- }, renderCustomCounter(charCount)) : counterLimit && /*#__PURE__*/React.createElement(S.Counter, {
20
- "data-testid": "counter"
21
- }, charCount, "/", counterLimit)) : /*#__PURE__*/React.createElement(React.Fragment, null);
22
- };
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { BaseProps } from '../Input.types';
3
- type ContentBelowProps = Pick<BaseProps, 'description' | 'errorText'>;
4
- export declare const ContentBelowElement: ({ description, errorText }: ContentBelowProps) => React.JSX.Element | null;
5
- export {};
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import * as S from '../Input.styles';
3
- export var ContentBelowElement = function ContentBelowElement(_ref) {
4
- var description = _ref.description,
5
- errorText = _ref.errorText;
6
- if (!errorText && !description) {
7
- return null;
8
- }
9
- var hasErrorMessage = Boolean(errorText);
10
- return /*#__PURE__*/React.createElement(S.ContentBelow, null, hasErrorMessage && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, null, description));
11
- };