@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.
- package/CHANGELOG.md +8 -0
- package/README.md +86 -24
- package/dist/AutosizeInput/AutosizeInput.d.ts +2 -2
- package/dist/AutosizeInput/AutosizeInput.js +80 -95
- package/dist/AutosizeInput/AutosizeInput.types.d.ts +1 -1
- package/dist/AutosizeInput/AutosizeInput.types.js +1 -1
- package/dist/AutosizeInput/utils/calculateInputWidth.d.ts +1 -1
- package/dist/AutosizeInput/utils/calculateInputWidth.js +13 -11
- package/dist/AutosizeInput/utils/index.js +4 -1
- package/dist/Input.d.ts +5 -7
- package/dist/Input.js +117 -174
- package/dist/Input.styles.d.ts +22 -22
- package/dist/Input.styles.js +98 -122
- package/dist/Input.types.d.ts +5 -5
- package/dist/Input.types.js +1 -1
- package/dist/InputGroup.d.ts +2 -2
- package/dist/InputGroup.js +21 -38
- package/dist/InputGroup.styles.d.ts +2 -2
- package/dist/InputGroup.styles.js +8 -8
- package/dist/InputGroup.types.d.ts +2 -2
- package/dist/InputGroup.types.js +1 -1
- package/dist/InputMultivalue/Elements/Value.d.ts +2 -2
- package/dist/InputMultivalue/Elements/Value.js +22 -34
- package/dist/InputMultivalue/Elements/Value.types.d.ts +2 -2
- package/dist/InputMultivalue/Elements/Value.types.js +1 -1
- package/dist/InputMultivalue/InputMultivalue.d.ts +2 -2
- package/dist/InputMultivalue/InputMultivalue.js +52 -74
- package/dist/InputMultivalue/InputMultivalue.styles.d.ts +10 -10
- package/dist/InputMultivalue/InputMultivalue.styles.js +48 -67
- package/dist/InputMultivalue/InputMultivalue.types.d.ts +1 -1
- package/dist/InputMultivalue/InputMultivalue.types.js +1 -1
- package/dist/PasswordInput.d.ts +2 -2
- package/dist/PasswordInput.js +31 -45
- package/dist/PasswordInput.types.d.ts +2 -2
- package/dist/PasswordInput.types.js +1 -1
- package/dist/TextArea.d.ts +4 -6
- package/dist/TextArea.js +53 -75
- package/dist/TextArea.types.d.ts +2 -2
- package/dist/TextArea.types.js +1 -1
- package/dist/Textarea/Textarea.d.ts +4 -4
- package/dist/Textarea/Textarea.js +32 -51
- package/dist/Textarea/Textarea.styles.d.ts +2 -2
- package/dist/Textarea/Textarea.styles.js +10 -9
- package/dist/Textarea/Textarea.types.d.ts +3 -3
- package/dist/Textarea/Textarea.types.js +1 -1
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/components/AutosizeWrapper.d.ts +2 -2
- package/dist/components/AutosizeWrapper.js +16 -18
- package/dist/components/ElementIcons.d.ts +2 -2
- package/dist/components/ElementIcons.js +37 -51
- package/dist/components/ExpandableWrapper.d.ts +3 -3
- package/dist/components/ExpandableWrapper.js +20 -21
- package/dist/components/index.js +8 -3
- package/dist/hooks/index.js +6 -2
- package/dist/hooks/useCounterLimit.d.ts +2 -2
- package/dist/hooks/useCounterLimit.js +19 -14
- package/dist/hooks/useElementFocus.d.ts +2 -2
- package/dist/hooks/useElementFocus.js +6 -3
- package/dist/hooks/useInputAddonHeight.d.ts +2 -2
- package/dist/hooks/useInputAddonHeight.js +10 -10
- package/dist/index.js +24 -12
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/getCharCount.d.ts +2 -2
- package/dist/utils/getCharCount.js +5 -2
- package/dist/utils/index.js +4 -1
- package/package.json +9 -9
|
@@ -1,87 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
37
|
-
if (e.key ===
|
|
38
|
-
handleNewValue([
|
|
30
|
+
const handleKeyDown = (e) => {
|
|
31
|
+
if (e.key === "Enter") {
|
|
32
|
+
handleNewValue([...selectedValues, value]);
|
|
39
33
|
setValue(emptyValue);
|
|
40
34
|
}
|
|
41
35
|
};
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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(
|
|
7
|
-
export declare const ErrorText: import(
|
|
8
|
-
export declare const Label: import(
|
|
9
|
-
export declare const Description: import(
|
|
10
|
-
export declare const ContentAbove: import(
|
|
11
|
-
export declare const IconWrapper: import(
|
|
12
|
-
export declare const ValueText: import(
|
|
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(
|
|
17
|
-
export declare const ValueWrapper: import(
|
|
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(
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
24
|
+
const ErrorText = /* @__PURE__ */ styled.div.withConfig({
|
|
22
25
|
displayName: "InputMultivaluestyles__ErrorText",
|
|
23
26
|
componentId: "sc-1vmqtuf-1"
|
|
24
|
-
})(["color:", ";margin-bottom:4px;"],
|
|
25
|
-
|
|
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;"],
|
|
31
|
-
|
|
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:", ";"],
|
|
37
|
-
|
|
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
|
-
|
|
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:", ";"],
|
|
47
|
-
|
|
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
|
-
|
|
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;", " ", " ", " ", ""],
|
|
57
|
-
|
|
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;}", ""],
|
|
73
|
-
|
|
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:", ";}", ""],
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/PasswordInput.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
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;
|
package/dist/PasswordInput.js
CHANGED
|
@@ -1,52 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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:
|
|
27
|
-
icon:
|
|
18
|
+
type: "text",
|
|
19
|
+
icon: /* @__PURE__ */ jsx(HideM, {}),
|
|
28
20
|
tooltip: allTexts.hideText
|
|
29
21
|
},
|
|
30
22
|
password: {
|
|
31
|
-
type:
|
|
32
|
-
icon:
|
|
23
|
+
type: "password",
|
|
24
|
+
icon: /* @__PURE__ */ jsx(ShowM, {}),
|
|
33
25
|
tooltip: allTexts.showText
|
|
34
26
|
}
|
|
35
27
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/TextArea.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '
|
|
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(
|
|
4
|
+
export declare const RawTextArea: import('styled-components').StyledComponent<React.ForwardRefExoticComponent<import('antd/lib/input').TextAreaProps & {
|
|
7
5
|
error?: boolean;
|
|
8
|
-
} & React.RefAttributes<import(
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var 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
|
-
|
|
45
|
-
|
|
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
|
-
|
|
52
|
-
renderCustomCounter
|
|
53
|
-
counterLimit
|
|
54
|
-
charCount
|
|
49
|
+
const rightSide = useCounterLimit({
|
|
50
|
+
renderCustomCounter,
|
|
51
|
+
counterLimit,
|
|
52
|
+
charCount
|
|
55
53
|
});
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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;
|
package/dist/TextArea.types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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'>;
|
package/dist/TextArea.types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export declare const RawTextArea: React.ForwardRefExoticComponent<import(
|
|
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(
|
|
7
|
+
resize?: import('csstype').ResizeProperty;
|
|
8
8
|
} & React.RefAttributes<TextAreaRef>>;
|
|
9
9
|
export default RawTextArea;
|