@synerise/ds-input 1.6.9 → 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 (66) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/AutosizeInput/AutosizeInput.d.ts +2 -2
  3. package/dist/AutosizeInput/AutosizeInput.js +80 -95
  4. package/dist/AutosizeInput/AutosizeInput.types.d.ts +1 -1
  5. package/dist/AutosizeInput/AutosizeInput.types.js +1 -1
  6. package/dist/AutosizeInput/utils/calculateInputWidth.d.ts +1 -1
  7. package/dist/AutosizeInput/utils/calculateInputWidth.js +13 -11
  8. package/dist/AutosizeInput/utils/index.js +4 -1
  9. package/dist/Input.d.ts +5 -7
  10. package/dist/Input.js +117 -174
  11. package/dist/Input.styles.d.ts +22 -22
  12. package/dist/Input.styles.js +98 -122
  13. package/dist/Input.types.d.ts +5 -5
  14. package/dist/Input.types.js +1 -1
  15. package/dist/InputGroup.d.ts +2 -2
  16. package/dist/InputGroup.js +21 -38
  17. package/dist/InputGroup.styles.d.ts +2 -2
  18. package/dist/InputGroup.styles.js +8 -8
  19. package/dist/InputGroup.types.d.ts +2 -2
  20. package/dist/InputGroup.types.js +1 -1
  21. package/dist/InputMultivalue/Elements/Value.d.ts +2 -2
  22. package/dist/InputMultivalue/Elements/Value.js +22 -34
  23. package/dist/InputMultivalue/Elements/Value.types.d.ts +2 -2
  24. package/dist/InputMultivalue/Elements/Value.types.js +1 -1
  25. package/dist/InputMultivalue/InputMultivalue.d.ts +2 -2
  26. package/dist/InputMultivalue/InputMultivalue.js +52 -74
  27. package/dist/InputMultivalue/InputMultivalue.styles.d.ts +10 -10
  28. package/dist/InputMultivalue/InputMultivalue.styles.js +48 -67
  29. package/dist/InputMultivalue/InputMultivalue.types.d.ts +1 -1
  30. package/dist/InputMultivalue/InputMultivalue.types.js +1 -1
  31. package/dist/PasswordInput.d.ts +2 -2
  32. package/dist/PasswordInput.js +31 -45
  33. package/dist/PasswordInput.types.d.ts +2 -2
  34. package/dist/PasswordInput.types.js +1 -1
  35. package/dist/TextArea.d.ts +4 -6
  36. package/dist/TextArea.js +53 -75
  37. package/dist/TextArea.types.d.ts +2 -2
  38. package/dist/TextArea.types.js +1 -1
  39. package/dist/Textarea/Textarea.d.ts +4 -4
  40. package/dist/Textarea/Textarea.js +32 -51
  41. package/dist/Textarea/Textarea.styles.d.ts +2 -2
  42. package/dist/Textarea/Textarea.styles.js +10 -9
  43. package/dist/Textarea/Textarea.types.d.ts +3 -3
  44. package/dist/Textarea/Textarea.types.js +1 -1
  45. package/dist/assets/style/index-tn0RQdqM.css +0 -0
  46. package/dist/components/AutosizeWrapper.d.ts +2 -2
  47. package/dist/components/AutosizeWrapper.js +16 -18
  48. package/dist/components/ElementIcons.d.ts +2 -2
  49. package/dist/components/ElementIcons.js +37 -51
  50. package/dist/components/ExpandableWrapper.d.ts +3 -3
  51. package/dist/components/ExpandableWrapper.js +20 -21
  52. package/dist/components/index.js +8 -3
  53. package/dist/hooks/index.js +6 -2
  54. package/dist/hooks/useCounterLimit.d.ts +2 -2
  55. package/dist/hooks/useCounterLimit.js +19 -14
  56. package/dist/hooks/useElementFocus.d.ts +2 -2
  57. package/dist/hooks/useElementFocus.js +6 -3
  58. package/dist/hooks/useInputAddonHeight.d.ts +2 -2
  59. package/dist/hooks/useInputAddonHeight.js +10 -10
  60. package/dist/index.js +24 -12
  61. package/dist/modules.d.js +1 -1
  62. package/dist/modules.d.ts +0 -0
  63. package/dist/utils/getCharCount.d.ts +2 -2
  64. package/dist/utils/getCharCount.js +5 -2
  65. package/dist/utils/index.js +4 -1
  66. package/package.json +9 -9
@@ -1,87 +1,65 @@
1
- var _excluded = ["className", "errorText", "label", "description", "values", "onChange", "onBlur", "onFocus", "disabled", "maxLength", "error"];
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
- import React from 'react';
5
- import Value from './Elements/Value';
6
- import * as S from './InputMultivalue.styles';
7
- var emptyValue = '';
8
- var InputMultivalue = function InputMultivalue(props) {
9
- var className = props.className,
10
- errorText = props.errorText,
11
- label = props.label,
12
- description = props.description,
13
- values = props.values,
14
- onChange = props.onChange,
15
- _onBlur = props.onBlur,
16
- onFocus = props.onFocus,
17
- disabled = props.disabled,
18
- maxLength = props.maxLength,
19
- error = props.error,
20
- antdProps = _objectWithoutPropertiesLoose(props, _excluded);
21
- var showError = error || !!errorText;
22
- var _React$useState = React.useState(emptyValue),
23
- value = _React$useState[0],
24
- setValue = _React$useState[1];
25
- var _React$useState2 = React.useState(false),
26
- isFocused = _React$useState2[0],
27
- setFocused = _React$useState2[1];
28
- var inputRef = React.useRef(null);
29
- var _React$useState3 = React.useState(values),
30
- selectedValues = _React$useState3[0],
31
- setSelectedValues = _React$useState3[1];
32
- var handleNewValue = function handleNewValue(selected) {
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import Value from "./Elements/Value.js";
4
+ import { ContentAbove, Label, InputWrapper, BorderLessInput, ContentBelow, ErrorText, Description } from "./InputMultivalue.styles.js";
5
+ const emptyValue = "";
6
+ const InputMultivalue = (props) => {
7
+ const {
8
+ className,
9
+ errorText,
10
+ label,
11
+ description,
12
+ values,
13
+ onChange,
14
+ onBlur,
15
+ onFocus,
16
+ disabled,
17
+ maxLength,
18
+ error,
19
+ ...antdProps
20
+ } = props;
21
+ const showError = error || !!errorText;
22
+ const [value, setValue] = React.useState(emptyValue);
23
+ const [isFocused, setFocused] = React.useState(false);
24
+ const inputRef = React.useRef(null);
25
+ const [selectedValues, setSelectedValues] = React.useState(values);
26
+ const handleNewValue = (selected) => {
33
27
  onChange && onChange(selected);
34
28
  setSelectedValues(selected);
35
29
  };
36
- var handleKeyDown = function handleKeyDown(e) {
37
- if (e.key === 'Enter') {
38
- handleNewValue([].concat(selectedValues, [value]));
30
+ const handleKeyDown = (e) => {
31
+ if (e.key === "Enter") {
32
+ handleNewValue([...selectedValues, value]);
39
33
  setValue(emptyValue);
40
34
  }
41
35
  };
42
- return /*#__PURE__*/React.createElement(React.Fragment, null, label && /*#__PURE__*/React.createElement(S.ContentAbove, null, /*#__PURE__*/React.createElement(S.Label, null, label)), /*#__PURE__*/React.createElement(S.InputWrapper, _extends({
43
- tabIndex: 0
44
- }, antdProps, {
45
- className: className,
46
- error: showError,
47
- onFocus: function onFocus() {
36
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
37
+ label && /* @__PURE__ */ jsx(ContentAbove, { children: /* @__PURE__ */ jsx(Label, { children: label }) }),
38
+ /* @__PURE__ */ jsxs(InputWrapper, { tabIndex: 0, ...antdProps, className, error: showError, onFocus: () => {
48
39
  if (inputRef && inputRef.current && inputRef.current !== null) {
49
40
  inputRef.current.focus();
50
41
  }
51
42
  setFocused(true);
52
- },
53
- focus: isFocused && !disabled,
54
- disabled: disabled
55
- }), selectedValues.map(function (val, index) {
56
- return /*#__PURE__*/React.createElement(Value, {
57
- disabled: disabled,
58
- key: val + "-" + index,
59
- onRemoveClick: function onRemoveClick() {
60
- var filteredItems = [].concat(selectedValues);
43
+ }, focus: isFocused && !disabled, disabled, children: [
44
+ selectedValues.map((val, index) => /* @__PURE__ */ jsx(Value, { disabled, onRemoveClick: () => {
45
+ const filteredItems = [...selectedValues];
61
46
  filteredItems.splice(index, 1);
62
47
  handleNewValue(filteredItems);
63
- },
64
- value: val,
65
- focused: isFocused
66
- });
67
- }), /*#__PURE__*/React.createElement(S.BorderLessInput, {
68
- value: value,
69
- onChange: function onChange(e) {
70
- return setValue(e.target.value);
71
- },
72
- onKeyDown: handleKeyDown,
73
- ref: inputRef,
74
- onBlur: function onBlur() {
75
- _onBlur && _onBlur();
76
- if (inputRef && inputRef.current && inputRef.current !== null) {
77
- inputRef.current.blur();
78
- }
79
- setFocused(false);
80
- },
81
- onFocus: onFocus,
82
- disabled: disabled,
83
- maxLength: maxLength,
84
- "data-testid": "input-multivalue"
85
- })), (showError || description) && /*#__PURE__*/React.createElement(S.ContentBelow, null, showError && /*#__PURE__*/React.createElement(S.ErrorText, null, errorText), description && /*#__PURE__*/React.createElement(S.Description, null, description)));
48
+ }, value: val, focused: isFocused }, `${val}-${index}`)),
49
+ /* @__PURE__ */ jsx(BorderLessInput, { value, onChange: (e) => setValue(e.target.value), onKeyDown: handleKeyDown, ref: inputRef, onBlur: () => {
50
+ onBlur && onBlur();
51
+ if (inputRef && inputRef.current && inputRef.current !== null) {
52
+ inputRef.current.blur();
53
+ }
54
+ setFocused(false);
55
+ }, onFocus, disabled, maxLength, "data-testid": "input-multivalue" })
56
+ ] }),
57
+ (showError || description) && /* @__PURE__ */ jsxs(ContentBelow, { children: [
58
+ showError && /* @__PURE__ */ jsx(ErrorText, { children: errorText }),
59
+ description && /* @__PURE__ */ jsx(Description, { children: description })
60
+ ] })
61
+ ] });
62
+ };
63
+ export {
64
+ InputMultivalue as default
86
65
  };
87
- export default InputMultivalue;
@@ -3,20 +3,20 @@ export type InputWrapperProps = {
3
3
  focus?: boolean;
4
4
  disabled?: boolean;
5
5
  };
6
- export declare const ContentBelow: import("styled-components").StyledComponent<"div", any, {}, never>;
7
- export declare const ErrorText: import("styled-components").StyledComponent<"div", any, {}, never>;
8
- export declare const Label: import("styled-components").StyledComponent<"label", any, {}, never>;
9
- export declare const Description: import("styled-components").StyledComponent<"div", any, {}, never>;
10
- export declare const ContentAbove: import("styled-components").StyledComponent<"div", any, {}, never>;
11
- export declare const IconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
12
- export declare const ValueText: import("styled-components").StyledComponent<"div", any, {
6
+ export declare const ContentBelow: import('styled-components').StyledComponent<"div", any, {}, never>;
7
+ export declare const ErrorText: import('styled-components').StyledComponent<"div", any, {}, never>;
8
+ export declare const Label: import('styled-components').StyledComponent<"label", any, {}, never>;
9
+ export declare const Description: import('styled-components').StyledComponent<"div", any, {}, never>;
10
+ export declare const ContentAbove: import('styled-components').StyledComponent<"div", any, {}, never>;
11
+ export declare const IconWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
12
+ export declare const ValueText: import('styled-components').StyledComponent<"div", any, {
13
13
  shrink?: boolean;
14
14
  disabled?: boolean;
15
15
  }, never>;
16
- export declare const InputWrapper: import("styled-components").StyledComponent<"div", any, InputWrapperProps, never>;
17
- export declare const ValueWrapper: import("styled-components").StyledComponent<"div", any, {
16
+ export declare const InputWrapper: import('styled-components').StyledComponent<"div", any, InputWrapperProps, never>;
17
+ export declare const ValueWrapper: import('styled-components').StyledComponent<"div", any, {
18
18
  disabled?: boolean;
19
19
  }, never>;
20
- export declare const BorderLessInput: import("styled-components").StyledComponent<"input", any, {
20
+ export declare const BorderLessInput: import('styled-components').StyledComponent<"input", any, {
21
21
  disabled?: boolean;
22
22
  }, never>;
@@ -1,90 +1,71 @@
1
- import styled, { css } from 'styled-components';
2
- var errorInputStyle = function errorInputStyle(props) {
3
- return "\n &&, .ant-input {\n border-color: " + props.theme.palette['red-600'] + ";\n box-shadow: inset 0 0 0 2px " + props.theme.palette['red-600'] + ";\n background: " + props.theme.palette['red-050'] + ";\n border-radius: 4px;\n }\n";
4
- };
5
- var focusStyle = function focusStyle(props) {
6
- return "\n && {\n box-shadow: inset 0 0 0 2px " + props.theme.palette['blue-600'] + ";\n border-color: " + props.theme.palette['blue-600'] + ";\n background: " + props.theme.palette['blue-050'] + ";\n }\n";
7
- };
8
- var contentShrinkStyle = function contentShrinkStyle() {
9
- return css(["&&{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}"]);
10
- };
11
- var disabledStyled = function disabledStyled(props) {
12
- return css(["&:hover,&,&& > *{cursor:not-allowed;}opacity:0.8;color:", ";background:", ";"], props.theme.palette["grey-600"], props.theme.palette['grey-050']);
13
- };
14
- var hoverStyle = function hoverStyle(props) {
15
- return css(["&:hover{border-color:", ";box-shadow:inset 0 0 0 1px ", ";}"], props.theme.palette['grey-200'], props.theme.palette['grey-400']);
16
- };
17
- export var ContentBelow = styled.div.withConfig({
1
+ import styled, { css } from "styled-components";
2
+ const errorInputStyle = (props) => `
3
+ &&, .ant-input {
4
+ border-color: ${props.theme.palette["red-600"]};
5
+ box-shadow: inset 0 0 0 2px ${props.theme.palette["red-600"]};
6
+ background: ${props.theme.palette["red-050"]};
7
+ border-radius: 4px;
8
+ }
9
+ `;
10
+ const focusStyle = (props) => `
11
+ && {
12
+ box-shadow: inset 0 0 0 2px ${props.theme.palette["blue-600"]};
13
+ border-color: ${props.theme.palette["blue-600"]};
14
+ background: ${props.theme.palette["blue-050"]};
15
+ }
16
+ `;
17
+ const contentShrinkStyle = () => css(["&&{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}"]);
18
+ const disabledStyled = (props) => css(["&:hover,&,&& > *{cursor:not-allowed;}opacity:0.8;color:", ";background:", ";"], props.theme.palette[`grey-600`], props.theme.palette["grey-050"]);
19
+ const hoverStyle = (props) => css(["&:hover{border-color:", ";box-shadow:inset 0 0 0 1px ", ";}"], props.theme.palette["grey-200"], props.theme.palette["grey-400"]);
20
+ const ContentBelow = /* @__PURE__ */ styled.div.withConfig({
18
21
  displayName: "InputMultivaluestyles__ContentBelow",
19
22
  componentId: "sc-1vmqtuf-0"
20
23
  })(["margin-top:8px;line-height:13px;"]);
21
- export var ErrorText = styled.div.withConfig({
24
+ const ErrorText = /* @__PURE__ */ styled.div.withConfig({
22
25
  displayName: "InputMultivaluestyles__ErrorText",
23
26
  componentId: "sc-1vmqtuf-1"
24
- })(["color:", ";margin-bottom:4px;"], function (props) {
25
- return props.theme.palette['red-600'];
26
- });
27
- export var Label = styled.label.withConfig({
27
+ })(["color:", ";margin-bottom:4px;"], (props) => props.theme.palette["red-600"]);
28
+ const Label = /* @__PURE__ */ styled.label.withConfig({
28
29
  displayName: "InputMultivaluestyles__Label",
29
30
  componentId: "sc-1vmqtuf-2"
30
- })(["color:", ";font-weight:500;display:block;white-space:nowrap;"], function (props) {
31
- return props.theme.palette['grey-800'];
32
- });
33
- export var Description = styled.div.withConfig({
31
+ })(["color:", ";font-weight:500;display:block;white-space:nowrap;"], (props) => props.theme.palette["grey-800"]);
32
+ const Description = /* @__PURE__ */ styled.div.withConfig({
34
33
  displayName: "InputMultivaluestyles__Description",
35
34
  componentId: "sc-1vmqtuf-3"
36
- })(["color:", ";"], function (props) {
37
- return props.theme.palette['grey-600'];
38
- });
39
- export var ContentAbove = styled.div.withConfig({
35
+ })(["color:", ";"], (props) => props.theme.palette["grey-600"]);
36
+ const ContentAbove = /* @__PURE__ */ styled.div.withConfig({
40
37
  displayName: "InputMultivaluestyles__ContentAbove",
41
38
  componentId: "sc-1vmqtuf-4"
42
39
  })(["display:flex;justify-content:space-between;margin-bottom:8px;"]);
43
- export var IconWrapper = styled.div.withConfig({
40
+ const IconWrapper = /* @__PURE__ */ styled.div.withConfig({
44
41
  displayName: "InputMultivaluestyles__IconWrapper",
45
42
  componentId: "sc-1vmqtuf-5"
46
- })(["overflow:hidden;width:24px;margin-left:-16px;display:none;color:", ";"], function (props) {
47
- return props.theme.palette['red-600'];
48
- });
49
- export var ValueText = styled.div.withConfig({
43
+ })(["overflow:hidden;width:24px;margin-left:-16px;display:none;color:", ";"], (props) => props.theme.palette["red-600"]);
44
+ const ValueText = /* @__PURE__ */ styled.div.withConfig({
50
45
  displayName: "InputMultivaluestyles__ValueText",
51
46
  componentId: "sc-1vmqtuf-6"
52
47
  })(["line-height:22px;text-decoration:none;text-overflow:ellipsis;display:block;overflow:hidden;white-space:nowrap;"]);
53
- export var InputWrapper = styled.div.withConfig({
48
+ const InputWrapper = /* @__PURE__ */ styled.div.withConfig({
54
49
  displayName: "InputMultivaluestyles__InputWrapper",
55
50
  componentId: "sc-1vmqtuf-7"
56
- })(["box-shadow:inset 0 0 0 1px ", ";background-color:", ";width:100%;border-radius:3px;display:flex;padding:2px 12px;min-height:32px;flex-wrap:wrap;transition:0.3s all;", " ", " ", " ", ""], function (props) {
57
- return props.theme.palette['grey-300'];
58
- }, function (props) {
59
- return props.theme.palette.white;
60
- }, function (props) {
61
- return !props.disabled && hoverStyle(props);
62
- }, function (props) {
63
- return props.focus && !props.disabled ? focusStyle(props) : '';
64
- }, function (props) {
65
- return props.error ? errorInputStyle(props) : '';
66
- }, function (props) {
67
- return !!props.disabled && disabledStyled(props);
68
- });
69
- export var ValueWrapper = styled.div.withConfig({
51
+ })(["box-shadow:inset 0 0 0 1px ", ";background-color:", ";width:100%;border-radius:3px;display:flex;padding:2px 12px;min-height:32px;flex-wrap:wrap;transition:0.3s all;", " ", " ", " ", ""], (props) => props.theme.palette["grey-300"], (props) => props.theme.palette.white, (props) => !props.disabled && hoverStyle(props), (props) => props.focus && !props.disabled ? focusStyle(props) : "", (props) => props.error ? errorInputStyle(props) : "", (props) => !!props.disabled && disabledStyled(props));
52
+ const ValueWrapper = /* @__PURE__ */ styled.div.withConfig({
70
53
  displayName: "InputMultivaluestyles__ValueWrapper",
71
54
  componentId: "sc-1vmqtuf-8"
72
- })(["display:grid;height:24px;&{background-color:", ";}border-radius:3px;border:none;margin:2px;white-space:nowrap;position:relative;padding:0 8px;right:8px;overflow:hidden;grid-template-columns:calc(100%) 0px;transition:background-color 0.1s ease-in-out,color 0.1s ease-in-out;&:hover{", " background-color:", ";color:", ";cursor:pointer;}", ""], function (props) {
73
- return props.disabled ? props.theme.palette['grey-200'] : props.theme.palette['grey-100'];
74
- }, function (props) {
75
- return !props.disabled && css(["", "{max-width:calc(100% - 16px);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}", "{display:block;}", ""], ValueText, IconWrapper, contentShrinkStyle());
76
- }, function (props) {
77
- return props.theme.palette['grey-200'];
78
- }, function (props) {
79
- return !props.disabled && props.theme.palette['grey-800'];
80
- }, function (props) {
81
- return !!props.disabled && disabledStyled(props);
82
- });
83
- export var BorderLessInput = styled.input.withConfig({
55
+ })(["display:grid;height:24px;&{background-color:", ";}border-radius:3px;border:none;margin:2px;white-space:nowrap;position:relative;padding:0 8px;right:8px;overflow:hidden;grid-template-columns:calc(100%) 0px;transition:background-color 0.1s ease-in-out,color 0.1s ease-in-out;&:hover{", " background-color:", ";color:", ";cursor:pointer;}", ""], (props) => props.disabled ? props.theme.palette["grey-200"] : props.theme.palette["grey-100"], (props) => !props.disabled && css(["", "{max-width:calc(100% - 16px);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}", "{display:block;}", ""], ValueText, IconWrapper, contentShrinkStyle()), (props) => props.theme.palette["grey-200"], (props) => !props.disabled && props.theme.palette["grey-800"], (props) => !!props.disabled && disabledStyled(props));
56
+ const BorderLessInput = /* @__PURE__ */ styled.input.withConfig({
84
57
  displayName: "InputMultivaluestyles__BorderLessInput",
85
58
  componentId: "sc-1vmqtuf-9"
86
- })(["box-shadow:none;border:none;min-width:0;display:flex;flex:1;margin-left:-8px;&&{background-color:rgba(255,255,255,0);}&::placeholder{color:", ";}", ""], function (props) {
87
- return props.theme.palette['grey-500'];
88
- }, function (props) {
89
- return !!props.disabled && disabledStyled(props);
90
- });
59
+ })(["box-shadow:none;border:none;min-width:0;display:flex;flex:1;margin-left:-8px;&&{background-color:rgba(255,255,255,0);}&::placeholder{color:", ";}", ""], (props) => props.theme.palette["grey-500"], (props) => !!props.disabled && disabledStyled(props));
60
+ export {
61
+ BorderLessInput,
62
+ ContentAbove,
63
+ ContentBelow,
64
+ Description,
65
+ ErrorText,
66
+ IconWrapper,
67
+ InputWrapper,
68
+ Label,
69
+ ValueText,
70
+ ValueWrapper
71
+ };
@@ -1,4 +1,4 @@
1
- import { type ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  export type InputMultivalueProps = {
3
3
  error?: boolean;
4
4
  className?: string;
@@ -1 +1 @@
1
- export {};
1
+
@@ -1,3 +1,3 @@
1
- import React from 'react';
2
- import type { PasswordInputProps } from './PasswordInput.types';
1
+ import { default as React } from 'react';
2
+ import { PasswordInputProps } from './PasswordInput.types';
3
3
  export declare const PasswordInput: ({ texts, ...inputProps }: PasswordInputProps) => React.JSX.Element;
@@ -1,52 +1,38 @@
1
- var _excluded = ["texts"];
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
- import React, { useState } from 'react';
5
- import { FormattedMessage } from 'react-intl';
6
- import Icon, { HideM, ShowM } from '@synerise/ds-icon';
7
- import { Input } from './Input';
8
- export var PasswordInput = function PasswordInput(_ref) {
9
- var texts = _ref.texts,
10
- inputProps = _objectWithoutPropertiesLoose(_ref, _excluded);
11
- var _useState = useState(false),
12
- isVisible = _useState[0],
13
- setIsVisible = _useState[1];
14
- var allTexts = _extends({
15
- showText: /*#__PURE__*/React.createElement(FormattedMessage, {
16
- id: "DS.INPUT.SHOW-PASSWORD",
17
- defaultMessage: "Show password"
18
- }),
19
- hideText: /*#__PURE__*/React.createElement(FormattedMessage, {
20
- id: "DS.INPUT.HIDE-PASSWORD",
21
- defaultMessage: "Hide password"
22
- })
23
- }, texts);
24
- var inputConfig = {
1
+ import { jsx, Fragment } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { FormattedMessage } from "react-intl";
4
+ import Icon, { ShowM, HideM } from "@synerise/ds-icon";
5
+ import { Input } from "./Input.js";
6
+ const PasswordInput = ({
7
+ texts,
8
+ ...inputProps
9
+ }) => {
10
+ const [isVisible, setIsVisible] = useState(false);
11
+ const allTexts = {
12
+ showText: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.INPUT.SHOW-PASSWORD", defaultMessage: "Show password" }),
13
+ hideText: /* @__PURE__ */ jsx(FormattedMessage, { id: "DS.INPUT.HIDE-PASSWORD", defaultMessage: "Hide password" }),
14
+ ...texts
15
+ };
16
+ const inputConfig = {
25
17
  text: {
26
- type: 'text',
27
- icon: /*#__PURE__*/React.createElement(HideM, null),
18
+ type: "text",
19
+ icon: /* @__PURE__ */ jsx(HideM, {}),
28
20
  tooltip: allTexts.hideText
29
21
  },
30
22
  password: {
31
- type: 'password',
32
- icon: /*#__PURE__*/React.createElement(ShowM, null),
23
+ type: "password",
24
+ icon: /* @__PURE__ */ jsx(ShowM, {}),
33
25
  tooltip: allTexts.showText
34
26
  }
35
27
  };
36
- var inputState = isVisible ? inputConfig.text : inputConfig.password;
37
- var passwordIcon = /*#__PURE__*/React.createElement(Icon, {
38
- onClick: function onClick(event) {
39
- event.preventDefault();
40
- event.stopPropagation();
41
- setIsVisible(function (value) {
42
- return !value;
43
- });
44
- },
45
- component: inputState.icon
46
- });
47
- return /*#__PURE__*/React.createElement(Input, _extends({}, inputProps, {
48
- type: inputState.type,
49
- icon1: passwordIcon,
50
- icon1Tooltip: /*#__PURE__*/React.createElement(React.Fragment, null, inputState.tooltip)
51
- }));
52
- };
28
+ const inputState = isVisible ? inputConfig.text : inputConfig.password;
29
+ const passwordIcon = /* @__PURE__ */ jsx(Icon, { onClick: (event) => {
30
+ event.preventDefault();
31
+ event.stopPropagation();
32
+ setIsVisible((value) => !value);
33
+ }, component: inputState.icon });
34
+ return /* @__PURE__ */ jsx(Input, { ...inputProps, type: inputState.type, icon1: passwordIcon, icon1Tooltip: /* @__PURE__ */ jsx(Fragment, { children: inputState.tooltip }) });
35
+ };
36
+ export {
37
+ PasswordInput
38
+ };
@@ -1,5 +1,5 @@
1
- import { type ReactNode } from 'react';
2
- import { type InputProps } from './Input.types';
1
+ import { ReactNode } from 'react';
2
+ import { InputProps } from './Input.types';
3
3
  export type PasswordInputTexts = {
4
4
  showText: ReactNode;
5
5
  hideText: ReactNode;
@@ -1 +1 @@
1
- export {};
1
+
@@ -1,10 +1,8 @@
1
- import React from 'react';
2
- import '@synerise/ds-core/dist/js/style';
3
- import { type TextareaProps } from './TextArea.types';
4
- import './style/index.less';
1
+ import { default as React } from 'react';
2
+ import { TextareaProps } from './TextArea.types';
5
3
  export declare const TextArea: ({ className, errorText, label, description, counterLimit, tooltip, tooltipConfig, icon1, icon1Tooltip, icon2, icon2Tooltip, resetMargin, handleInputRef, prefixel, suffixel, error, renderCustomCounter, ...antdTextareaProps }: TextareaProps) => React.JSX.Element;
6
- export declare const RawTextArea: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<import("antd/lib/input").TextAreaProps & {
4
+ export declare const RawTextArea: import('styled-components').StyledComponent<React.ForwardRefExoticComponent<import('antd/lib/input').TextAreaProps & {
7
5
  error?: boolean;
8
- } & React.RefAttributes<import("antd/lib/input/TextArea").TextAreaRef>>, any, {
6
+ } & React.RefAttributes<import('antd/lib/input/TextArea').TextAreaRef>>, any, {
9
7
  error?: boolean;
10
8
  }, never>;
package/dist/TextArea.js CHANGED
@@ -1,85 +1,63 @@
1
- var _excluded = ["className", "errorText", "label", "description", "counterLimit", "tooltip", "tooltipConfig", "icon1", "icon1Tooltip", "icon2", "icon2Tooltip", "resetMargin", "handleInputRef", "prefixel", "suffixel", "error", "renderCustomCounter"];
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
- import React, { useCallback, useEffect, useMemo, useRef } from 'react';
5
- import { v4 as uuid } from 'uuid';
6
- import '@synerise/ds-core/dist/js/style';
7
- import FormField from '@synerise/ds-form-field';
8
- import * as S from './Input.styles';
9
- import DSTextArea from './Textarea/Textarea';
10
- import { ElementIcons } from './components/ElementIcons';
11
- import { useElementFocus } from './hooks';
12
- import { useCounterLimit } from './hooks/useCounterLimit';
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useRef, useEffect, useCallback } from "react";
3
+ import { v4 } from "uuid";
4
+ import FormField from "@synerise/ds-form-field";
5
+ import { AntdTextArea, OuterWrapper, InputWrapper } from "./Input.styles.js";
6
+ import { RawTextArea as RawTextArea$1 } from "./Textarea/Textarea.js";
7
+ import { ElementIcons } from "./components/ElementIcons.js";
8
+ import { useElementFocus } from "./hooks/useElementFocus.js";
9
+ import { useCounterLimit } from "./hooks/useCounterLimit.js";
10
+ import { getCharCount } from "./utils/getCharCount.js";
13
11
  import "./style/index.css";
14
- import { getCharCount } from './utils';
15
- export var TextArea = function TextArea(_ref) {
16
- var className = _ref.className,
17
- errorText = _ref.errorText,
18
- label = _ref.label,
19
- description = _ref.description,
20
- counterLimit = _ref.counterLimit,
21
- tooltip = _ref.tooltip,
22
- tooltipConfig = _ref.tooltipConfig,
23
- icon1 = _ref.icon1,
24
- icon1Tooltip = _ref.icon1Tooltip,
25
- icon2 = _ref.icon2,
26
- icon2Tooltip = _ref.icon2Tooltip,
27
- resetMargin = _ref.resetMargin,
28
- handleInputRef = _ref.handleInputRef,
29
- prefixel = _ref.prefixel,
30
- suffixel = _ref.suffixel,
31
- error = _ref.error,
32
- renderCustomCounter = _ref.renderCustomCounter,
33
- antdTextareaProps = _objectWithoutPropertiesLoose(_ref, _excluded);
34
- var id = useMemo(function () {
35
- return uuid();
36
- }, []);
37
- var charCount = getCharCount(antdTextareaProps.value, counterLimit);
38
- var hasErrorMessage = Boolean(errorText);
39
- var ref = useRef(null);
40
- var handleIconsClick = useElementFocus(ref);
41
- useEffect(function () {
12
+ const TextArea = ({
13
+ className,
14
+ errorText,
15
+ label,
16
+ description,
17
+ counterLimit,
18
+ tooltip,
19
+ tooltipConfig,
20
+ icon1,
21
+ icon1Tooltip,
22
+ icon2,
23
+ icon2Tooltip,
24
+ resetMargin,
25
+ handleInputRef,
26
+ prefixel,
27
+ suffixel,
28
+ error,
29
+ renderCustomCounter,
30
+ ...antdTextareaProps
31
+ }) => {
32
+ const id = useMemo(() => v4(), []);
33
+ const charCount = getCharCount(antdTextareaProps.value, counterLimit);
34
+ const hasErrorMessage = Boolean(errorText);
35
+ const ref = useRef(null);
36
+ const handleIconsClick = useElementFocus(ref);
37
+ useEffect(() => {
42
38
  handleInputRef && handleInputRef(ref);
43
39
  }, [ref, handleInputRef]);
44
- var handleChange = useCallback(function (e) {
45
- var newValue = e.currentTarget.value;
40
+ const handleChange = useCallback((e) => {
41
+ const {
42
+ value: newValue
43
+ } = e.currentTarget;
46
44
  if (counterLimit && newValue.length > counterLimit) {
47
45
  return;
48
46
  }
49
47
  antdTextareaProps.onChange && antdTextareaProps.onChange(e);
50
48
  }, [antdTextareaProps, counterLimit]);
51
- var rightSide = useCounterLimit({
52
- renderCustomCounter: renderCustomCounter,
53
- counterLimit: counterLimit,
54
- charCount: charCount
49
+ const rightSide = useCounterLimit({
50
+ renderCustomCounter,
51
+ counterLimit,
52
+ charCount
55
53
  });
56
- return /*#__PURE__*/React.createElement(S.OuterWrapper, {
57
- className: className,
58
- resetMargin: resetMargin
59
- }, /*#__PURE__*/React.createElement(FormField, {
60
- label: label,
61
- rightSide: rightSide,
62
- id: id,
63
- tooltip: tooltip,
64
- tooltipConfig: tooltipConfig,
65
- description: description,
66
- errorText: errorText
67
- }, /*#__PURE__*/React.createElement(S.InputWrapper, null, /*#__PURE__*/React.createElement(ElementIcons, {
68
- handleIconsClick: handleIconsClick,
69
- disabled: antdTextareaProps.disabled,
70
- icon1Tooltip: icon1Tooltip,
71
- icon1: icon1,
72
- icon2: icon2,
73
- icon2Tooltip: icon2Tooltip,
74
- className: className,
75
- type: "textArea"
76
- }), /*#__PURE__*/React.createElement(DSTextArea, _extends({}, antdTextareaProps, {
77
- className: hasErrorMessage || error ? 'error' : undefined,
78
- error: hasErrorMessage || error,
79
- onChange: handleChange,
80
- value: antdTextareaProps.value,
81
- id: id,
82
- autoComplete: "off"
83
- })))));
54
+ return /* @__PURE__ */ jsx(OuterWrapper, { className, resetMargin, children: /* @__PURE__ */ jsx(FormField, { label, rightSide, id, tooltip, tooltipConfig, description, errorText, children: /* @__PURE__ */ jsxs(InputWrapper, { children: [
55
+ /* @__PURE__ */ jsx(ElementIcons, { handleIconsClick, disabled: antdTextareaProps.disabled, icon1Tooltip, icon1, icon2, icon2Tooltip, className, type: "textArea" }),
56
+ /* @__PURE__ */ jsx(RawTextArea$1, { ...antdTextareaProps, className: hasErrorMessage || error ? "error" : void 0, error: hasErrorMessage || error, onChange: handleChange, value: antdTextareaProps.value, id, autoComplete: "off" })
57
+ ] }) }) });
58
+ };
59
+ const RawTextArea = AntdTextArea;
60
+ export {
61
+ RawTextArea,
62
+ TextArea
84
63
  };
85
- export var RawTextArea = S.AntdTextArea;
@@ -1,3 +1,3 @@
1
- import type { BaseProps } from './Input.types';
2
- import type { RawTextAreaProps } from './Textarea/Textarea.types';
1
+ import { BaseProps } from './Input.types';
2
+ import { RawTextAreaProps } from './Textarea/Textarea.types';
3
3
  export type TextareaProps = RawTextAreaProps & Omit<BaseProps<HTMLTextAreaElement>, 'expandable' | 'expandableTooltip' | 'autoResize' | 'autoResizeProps'>;
@@ -1 +1 @@
1
- export {};
1
+
@@ -1,9 +1,9 @@
1
- import type { TextAreaRef } from 'antd/lib/input/TextArea';
2
- import React from 'react';
3
- export declare const RawTextArea: React.ForwardRefExoticComponent<import("antd/lib/input/TextArea").TextAreaProps & {
1
+ import { TextAreaRef } from 'antd/lib/input/TextArea';
2
+ import { default as React } from 'react';
3
+ export declare const RawTextArea: React.ForwardRefExoticComponent<import('antd/lib/input/TextArea').TextAreaProps & {
4
4
  error?: boolean;
5
5
  errorText?: string | React.ReactNode;
6
6
  wrapperStyle?: React.CSSProperties;
7
- resize?: import("csstype").ResizeProperty;
7
+ resize?: import('csstype').ResizeProperty;
8
8
  } & React.RefAttributes<TextAreaRef>>;
9
9
  export default RawTextArea;