@synerise/ds-input 1.7.11 → 1.7.13
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/CLAUDE.md +309 -0
- package/dist/AutosizeInput/AutosizeInput.d.ts +6 -7
- package/dist/AutosizeInput/AutosizeInput.js +39 -116
- package/dist/AutosizeInput/AutosizeInput.types.d.ts +5 -18
- package/dist/AutosizeInput/useAutosizeWidth.d.ts +18 -0
- package/dist/AutosizeInput/useAutosizeWidth.js +145 -0
- package/dist/AutosizeInput/useAutosizeWidth.types.d.ts +29 -0
- package/dist/AutosizeInput/useAutosizeWidth.types.js +1 -0
- package/dist/AutosizeInput/useStretchToFit.d.ts +26 -0
- package/dist/AutosizeInput/useStretchToFit.js +31 -0
- package/dist/Input.d.ts +13 -3
- package/dist/Input.js +170 -81
- package/dist/Input.styles.d.ts +32 -11
- package/dist/Input.styles.js +64 -38
- package/dist/Input.types.d.ts +23 -7
- package/dist/InputGroup.d.ts +1 -1
- package/dist/InputGroup.js +11 -4
- package/dist/InputGroup.styles.d.ts +1 -0
- package/dist/InputGroup.styles.js +9 -2
- package/dist/InputGroup.types.d.ts +22 -3
- package/dist/InputMultivalue/InputMultivalue.styles.js +1 -1
- package/dist/TextArea.d.ts +2 -2
- package/dist/TextArea.js +4 -5
- package/dist/Textarea/Textarea.d.ts +4 -3
- package/dist/Textarea/Textarea.js +33 -4
- package/dist/Textarea/Textarea.styles.js +2 -2
- package/dist/Textarea/Textarea.types.d.ts +13 -8
- package/dist/components/ExpandableWrapper.d.ts +1 -2
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -2
- package/dist/hooks/useElementFocus.d.ts +3 -2
- package/dist/hooks/useInputAddonHeight.d.ts +1 -2
- package/dist/hooks/useInputAddonHeight.js +1 -1
- package/dist/hooks/useTextareaAutosize.d.ts +53 -0
- package/dist/hooks/useTextareaAutosize.js +82 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +8 -3
- package/dist/utils/getCharCount.d.ts +3 -2
- package/package.json +9 -12
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/components/AutosizeWrapper.d.ts +0 -17
- package/dist/components/AutosizeWrapper.js +0 -18
- package/dist/style/index.css +0 -1
package/dist/Input.styles.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Input } from "antd";
|
|
3
2
|
import { forwardRef } from "react";
|
|
4
3
|
import styled, { css } from "styled-components";
|
|
5
4
|
import { TextareaWrapper } from "./Textarea/Textarea.styles.js";
|
|
6
|
-
const {
|
|
7
|
-
TextArea
|
|
8
|
-
} = Input;
|
|
9
5
|
const errorInputStyle = (props) => `
|
|
10
|
-
|
|
6
|
+
&&& {
|
|
11
7
|
border-color: ${props.theme.palette["red-600"]};
|
|
12
8
|
box-shadow: inset 0 0 0 1px ${props.theme.palette["red-600"]};
|
|
13
9
|
background: ${props.theme.palette["red-050"]};
|
|
@@ -41,13 +37,13 @@ const Wrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
41
37
|
const InputWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
42
38
|
displayName: "Inputstyles__InputWrapper",
|
|
43
39
|
componentId: "sc-dc57an-1"
|
|
44
|
-
})(["position:relative;&&
|
|
40
|
+
})(["position:relative;&& input{padding-right:", ";&::placeholder{line-height:1.29;}}"], (props) => {
|
|
45
41
|
return `${getIconsWidth(props.iconCount || 0) + INPUT_PADDING}px`;
|
|
46
42
|
});
|
|
47
43
|
const OuterWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
48
44
|
displayName: "Inputstyles__OuterWrapper",
|
|
49
45
|
componentId: "sc-dc57an-2"
|
|
50
|
-
})(["margin:", ";&.active{&&{input{box-shadow:inset 0 0 0 1px ", ";border-color:", ";background-color:", ";}}}input{
|
|
46
|
+
})(["margin:", ";&.active{&&{input{box-shadow:inset 0 0 0 1px ", ";border-color:", ";background-color:", ";}}}input{", "}", ""], (props) => props.resetMargin ? "0" : "0 0 16px 0", (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-050"], (props) => autoresizeConfObjToCss(props), (props) => props.autoResize && `
|
|
51
47
|
${InputWrapper} {
|
|
52
48
|
display: inline-block;
|
|
53
49
|
}`);
|
|
@@ -68,35 +64,61 @@ const IconWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
68
64
|
displayName: "Inputstyles__IconWrapper",
|
|
69
65
|
componentId: "sc-dc57an-5"
|
|
70
66
|
})([".icon:hover{svg{fill:", ";cursor:pointer;}}"], (props) => props.theme.palette["blue-600"]);
|
|
71
|
-
const
|
|
67
|
+
const NativeInput = /* @__PURE__ */ styled(forwardRef(({
|
|
72
68
|
error,
|
|
69
|
+
autoResize,
|
|
70
|
+
$size,
|
|
71
|
+
$hasPrefixel,
|
|
72
|
+
$hasSuffixel,
|
|
73
|
+
$hasInnerPrefix,
|
|
73
74
|
...props
|
|
74
|
-
}, ref) => /* @__PURE__ */ jsx(
|
|
75
|
-
displayName: "
|
|
75
|
+
}, ref) => /* @__PURE__ */ jsx("input", { autoComplete: "off", ...props, ref }))).withConfig({
|
|
76
|
+
displayName: "Inputstyles__NativeInput",
|
|
76
77
|
componentId: "sc-dc57an-6"
|
|
77
|
-
})(["", "
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
})(["box-sizing:", ";width:100%;", " margin:0;padding:7px ", "px;", " color:", ";background-color:", ";border:", "px solid ", ";border-radius:3px;font-family:inherit;font-size:13px;outline:0;grid-area:1 / 1;transition:all 0.3s,width 0ms,min-width 0ms,max-width 0ms;", " ", " &::placeholder{color:", ";line-height:1.29;}&:hover:not(:disabled){border-color:", ";}&:focus{box-shadow:inset 0 0 0 1px ", ";border-color:", ";background-color:", ";}&:disabled{cursor:not-allowed;background-color:", ";}", ";", ";", ""], (props) => props.autoResize ? "content-box" : "border-box", (props) => props.autoResize ? `height: ${props.$size === "large" ? "32" : "16"}px;` : `height: ${props.$size === "large" ? "48" : "32"}px;`, INPUT_PADDING, (props) => props.$hasInnerPrefix && "padding-left: 32px;", (props) => props.disabled ? props.theme.palette["grey-400"] : props.theme.palette["grey-700"], (props) => props.theme.palette.white, INPUT_BORDER, (props) => props.theme.palette["grey-300"], (props) => props.$hasPrefixel && "border-top-left-radius: 0; border-bottom-left-radius: 0;", (props) => props.$hasSuffixel && "border-top-right-radius: 0; border-bottom-right-radius: 0;", (props) => props.theme.palette["grey-500"], (props) => props.theme.palette["grey-400"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-050"], (props) => props.theme.palette["grey-050"], (props) => props.error ? errorInputStyle(props) : "", (props) => autoresizeConfObjToCss({
|
|
79
|
+
autoResize: props.autoResize
|
|
80
|
+
}), (props) => props.readOnly && `
|
|
81
|
+
&&& {
|
|
82
|
+
&:hover {
|
|
83
|
+
border-color: ${props.theme.palette["grey-300"]};
|
|
84
|
+
}
|
|
85
|
+
&:focus {
|
|
86
|
+
border-color: ${props.theme.palette["grey-300"]};
|
|
87
|
+
box-shadow: none;
|
|
88
|
+
background: ${props.theme.palette.white};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`);
|
|
92
|
+
const InputGroupRow = /* @__PURE__ */ styled.div.withConfig({
|
|
93
|
+
displayName: "Inputstyles__InputGroupRow",
|
|
94
|
+
componentId: "sc-dc57an-7"
|
|
95
|
+
})(["display:flex;align-items:stretch;width:100%;"]);
|
|
96
|
+
const Addon = /* @__PURE__ */ styled.div.withConfig({
|
|
97
|
+
displayName: "Inputstyles__Addon",
|
|
98
|
+
componentId: "sc-dc57an-8"
|
|
99
|
+
})(["box-sizing:border-box;height:", "px;display:flex;align-items:center;flex-shrink:0;overflow:hidden;padding:0;white-space:nowrap;color:", ";background-color:", ";border:", "px solid ", ";", ""], (props) => props.$size === "large" ? "48" : "32", (props) => props.theme.palette["grey-700"], (props) => props.theme.palette["grey-050"], INPUT_BORDER, (props) => props.theme.palette["grey-300"], (props) => props.$position === "before" ? "border-right: 0; border-radius: 3px 0 0 3px;" : "border-left: 0; border-radius: 0 3px 3px 0;");
|
|
100
|
+
const ClearButton = /* @__PURE__ */ styled.button.withConfig({
|
|
101
|
+
displayName: "Inputstyles__ClearButton",
|
|
102
|
+
componentId: "sc-dc57an-9"
|
|
103
|
+
})(["position:absolute;top:50%;right:", "px;transform:translateY(-50%);z-index:2;display:flex;align-items:center;justify-content:center;padding:0;border:0;background:transparent;cursor:pointer;color:", ";&:hover{color:", ";}"], (props) => props.$offset, (props) => props.theme.palette["grey-500"], (props) => props.theme.palette["grey-700"]);
|
|
104
|
+
const InnerAffix = /* @__PURE__ */ styled.div.withConfig({
|
|
105
|
+
displayName: "Inputstyles__InnerAffix",
|
|
106
|
+
componentId: "sc-dc57an-10"
|
|
107
|
+
})(["position:absolute;top:50%;left:4px;transform:translateY(-50%);z-index:2;display:flex;align-items:center;"]);
|
|
108
|
+
const RawTextArea = /* @__PURE__ */ styled(forwardRef(({
|
|
91
109
|
error,
|
|
92
110
|
...props
|
|
93
|
-
}, ref) => /* @__PURE__ */ jsx(
|
|
94
|
-
displayName: "
|
|
95
|
-
componentId: "sc-dc57an-
|
|
96
|
-
})(["", "
|
|
111
|
+
}, ref) => /* @__PURE__ */ jsx("textarea", { autoComplete: "off", ...props, ref }))).withConfig({
|
|
112
|
+
displayName: "Inputstyles__RawTextArea",
|
|
113
|
+
componentId: "sc-dc57an-11"
|
|
114
|
+
})(["&&{box-sizing:border-box;width:100%;color:", ";font-family:inherit;font-size:13px;padding:8px 12px;", "}"], (props) => props.theme.palette["grey-700"], (props) => props.error ? `
|
|
115
|
+
box-shadow: inset 0 0 0 1px ${props.theme.palette["red-600"]};
|
|
116
|
+
background: ${props.theme.palette["red-050"]};
|
|
117
|
+
border-color: ${props.theme.palette["red-600"]};
|
|
118
|
+
` : "");
|
|
97
119
|
const ExpandableWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
98
120
|
displayName: "Inputstyles__ExpandableWrapper",
|
|
99
|
-
componentId: "sc-dc57an-
|
|
121
|
+
componentId: "sc-dc57an-12"
|
|
100
122
|
})(["position:relative;overflow:visible;", "{position:absolute;top:0;left:0;right:0;z-index:999;resize:none;max-height:124px;min-height:65px;min-width:282px;", "}"], TextareaWrapper, (props) => {
|
|
101
123
|
if (props.expanded) {
|
|
102
124
|
return css(["pointer-events:initial;display:block;"]);
|
|
@@ -105,36 +127,36 @@ const ExpandableWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
105
127
|
});
|
|
106
128
|
const ContentBelow = /* @__PURE__ */ styled.div.withConfig({
|
|
107
129
|
displayName: "Inputstyles__ContentBelow",
|
|
108
|
-
componentId: "sc-dc57an-
|
|
130
|
+
componentId: "sc-dc57an-13"
|
|
109
131
|
})(["margin-top:8px;"]);
|
|
110
132
|
const ErrorText = /* @__PURE__ */ styled.div.withConfig({
|
|
111
133
|
displayName: "Inputstyles__ErrorText",
|
|
112
|
-
componentId: "sc-dc57an-
|
|
134
|
+
componentId: "sc-dc57an-14"
|
|
113
135
|
})(["color:", ";margin-bottom:4px;"], (props) => props.theme.palette["red-600"]);
|
|
114
136
|
const Label = /* @__PURE__ */ styled.label.withConfig({
|
|
115
137
|
displayName: "Inputstyles__Label",
|
|
116
|
-
componentId: "sc-dc57an-
|
|
138
|
+
componentId: "sc-dc57an-15"
|
|
117
139
|
})(["color:", ";font-weight:500;display:block;"], (props) => props.theme.palette["grey-800"]);
|
|
118
140
|
const Counter = /* @__PURE__ */ styled.div.withConfig({
|
|
119
141
|
displayName: "Inputstyles__Counter",
|
|
120
|
-
componentId: "sc-dc57an-
|
|
142
|
+
componentId: "sc-dc57an-16"
|
|
121
143
|
})(["font-weight:500;flex:1 0 auto;text-align:end;color:", ";"], (props) => props.theme.palette["grey-500"]);
|
|
122
144
|
const Description = /* @__PURE__ */ styled.div.withConfig({
|
|
123
145
|
displayName: "Inputstyles__Description",
|
|
124
|
-
componentId: "sc-dc57an-
|
|
146
|
+
componentId: "sc-dc57an-17"
|
|
125
147
|
})(["color:", ";"], (props) => props.theme.palette["grey-600"]);
|
|
126
148
|
const ContentAbove = /* @__PURE__ */ styled.div.withConfig({
|
|
127
149
|
displayName: "Inputstyles__ContentAbove",
|
|
128
|
-
componentId: "sc-dc57an-
|
|
150
|
+
componentId: "sc-dc57an-18"
|
|
129
151
|
})(["display:flex;justify-content:space-between;margin-bottom:8px;min-height:18px;"]);
|
|
130
152
|
const AddonWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
131
153
|
displayName: "Inputstyles__AddonWrapper",
|
|
132
|
-
componentId: "sc-dc57an-
|
|
154
|
+
componentId: "sc-dc57an-19"
|
|
133
155
|
})(["background:", ";display:flex;align-items:center;height:", ";"], (props) => props.theme.palette["grey-050"], (props) => props.height ? `${props.height}px` : "30px");
|
|
134
156
|
export {
|
|
157
|
+
Addon,
|
|
135
158
|
AddonWrapper,
|
|
136
|
-
|
|
137
|
-
AntdTextArea,
|
|
159
|
+
ClearButton,
|
|
138
160
|
ContentAbove,
|
|
139
161
|
ContentBelow,
|
|
140
162
|
Counter,
|
|
@@ -144,9 +166,13 @@ export {
|
|
|
144
166
|
IconWrapper,
|
|
145
167
|
IconsFlexContainer,
|
|
146
168
|
IconsWrapper,
|
|
169
|
+
InnerAffix,
|
|
170
|
+
InputGroupRow,
|
|
147
171
|
InputWrapper,
|
|
148
172
|
Label,
|
|
173
|
+
NativeInput,
|
|
149
174
|
OuterWrapper,
|
|
175
|
+
RawTextArea,
|
|
150
176
|
Wrapper,
|
|
151
177
|
autoresizeConfObjToCss
|
|
152
178
|
};
|
package/dist/Input.types.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TextAreaProps as AntdTextAreaProps } from 'antd/lib/input';
|
|
3
|
-
import { ForwardRefExoticComponent, MutableRefObject, ReactElement, ReactNode, RefAttributes } from 'react';
|
|
1
|
+
import { ForwardRefExoticComponent, InputHTMLAttributes, KeyboardEventHandler, MutableRefObject, ReactElement, ReactNode, RefAttributes } from 'react';
|
|
4
2
|
import { StyledComponent } from 'styled-components';
|
|
5
3
|
import { FormFieldCommonProps } from '@synerise/ds-form-field';
|
|
6
4
|
import { AutosizeInputProps } from './AutosizeInput/AutosizeInput.types';
|
|
@@ -9,10 +7,24 @@ export type AutoResizeProp = boolean | {
|
|
|
9
7
|
maxWidth?: string;
|
|
10
8
|
stretchToFit?: boolean;
|
|
11
9
|
};
|
|
10
|
+
export type InputSize = 'small' | 'middle' | 'large';
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* Native `<input>` props, preserving the subset of the antd `Input` surface that
|
|
13
|
+
* the design system actually forwards. `size`/`prefix` are redefined (the native
|
|
14
|
+
* HTML attrs have different meanings).
|
|
14
15
|
*/
|
|
15
|
-
export type
|
|
16
|
+
export type NativeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> & {
|
|
17
|
+
size?: InputSize;
|
|
18
|
+
allowClear?: boolean;
|
|
19
|
+
bordered?: boolean;
|
|
20
|
+
/** Inline node rendered inside the input on the left, before the value. */
|
|
21
|
+
innerPrefix?: ReactNode;
|
|
22
|
+
prefix?: ReactNode;
|
|
23
|
+
suffix?: ReactNode;
|
|
24
|
+
onPressEnter?: KeyboardEventHandler<HTMLInputElement>;
|
|
25
|
+
addonBefore?: ReactNode;
|
|
26
|
+
addonAfter?: ReactNode;
|
|
27
|
+
};
|
|
16
28
|
export type BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInputElement = HTMLInputElement> = {
|
|
17
29
|
error?: boolean;
|
|
18
30
|
className?: string;
|
|
@@ -31,9 +43,13 @@ export type BaseProps<RefElementType extends HTMLTextAreaElement | HTMLInputElem
|
|
|
31
43
|
expandable?: boolean;
|
|
32
44
|
expandableTooltip?: ReactNode;
|
|
33
45
|
} & FormFieldCommonProps;
|
|
46
|
+
export type InputProps = BaseProps & NativeInputProps;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated use `InputProps`, `TextareaProps` instead
|
|
49
|
+
*/
|
|
50
|
+
export type Props = BaseProps<HTMLInputElement | HTMLTextAreaElement>;
|
|
34
51
|
/**
|
|
35
52
|
* @deprecated use `InputProps`, `TextareaProps` instead
|
|
36
53
|
*/
|
|
37
|
-
export type EnhancedProps =
|
|
38
|
-
export type InputProps = BaseProps & AntdInputProps;
|
|
54
|
+
export type EnhancedProps = InputProps;
|
|
39
55
|
export type StyledInput<CustomProps extends object = object> = StyledComponent<ForwardRefExoticComponent<InputProps & RefAttributes<HTMLDivElement>>, object, CustomProps, never>;
|
package/dist/InputGroup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { Props } from './InputGroup.types';
|
|
3
|
-
declare const InputGroup: ({ children, label, errors, description, resetMargin, tooltip, tooltipConfig, ...
|
|
3
|
+
declare const InputGroup: ({ children, label, errorText, errors, description, resetMargin, tooltip, tooltipConfig, compact, growItem, className, style, size: _size, ...rest }: Props) => React.JSX.Element;
|
|
4
4
|
export default InputGroup;
|
package/dist/InputGroup.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Input } from "antd";
|
|
3
2
|
import { Children } from "react";
|
|
4
3
|
import FormField from "@synerise/ds-form-field";
|
|
5
|
-
import {
|
|
4
|
+
import { ErrorText, OuterWrapper } from "./Input.styles.js";
|
|
6
5
|
import { InputGroupWrapper, InputGroupItem } from "./InputGroup.styles.js";
|
|
7
6
|
const InputGroup = ({
|
|
8
7
|
children,
|
|
9
8
|
label,
|
|
9
|
+
errorText,
|
|
10
10
|
errors,
|
|
11
11
|
description,
|
|
12
12
|
resetMargin,
|
|
13
13
|
tooltip,
|
|
14
14
|
tooltipConfig,
|
|
15
|
-
|
|
15
|
+
compact,
|
|
16
|
+
growItem,
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
// antd `Input.Group` size cascade is no longer applied; size each child input directly.
|
|
20
|
+
size: _size,
|
|
21
|
+
...rest
|
|
16
22
|
}) => {
|
|
17
23
|
const childrenArray = Children.toArray(children);
|
|
18
|
-
|
|
24
|
+
const resolvedErrorText = errorText ?? (errors && errors.map((error) => /* @__PURE__ */ jsx(ErrorText, { children: error }, error)));
|
|
25
|
+
return /* @__PURE__ */ jsx(OuterWrapper, { className: "ds-input-group-outer-wrapper", resetMargin, children: /* @__PURE__ */ jsx(FormField, { label, tooltip, tooltipConfig, description, errorText: resolvedErrorText, children: /* @__PURE__ */ jsx(InputGroupWrapper, { compact, $growItem: growItem, className, style, ...rest, children: Children.map(childrenArray, (child, index) => /* @__PURE__ */ jsx(InputGroupItem, { className: `ds-input-group-item ds-input-group-item-${index}`, children: child })) }) }) });
|
|
19
26
|
};
|
|
20
27
|
export {
|
|
21
28
|
InputGroup as default
|
|
@@ -2,11 +2,18 @@ import styled, { css } from "styled-components";
|
|
|
2
2
|
const InputGroupItem = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "InputGroupstyles__InputGroupItem",
|
|
4
4
|
componentId: "sc-1cn2cc5-0"
|
|
5
|
-
})([""]);
|
|
5
|
+
})(["min-width:0;"]);
|
|
6
|
+
const CONTROLS = ["input", "textarea", "button", ".ds-input-number", ".ant-select-selector", ".ds-button"];
|
|
7
|
+
const controlsUnder = (itemSelector) => CONTROLS.map((control) => `${itemSelector} ${control}`).join(", ");
|
|
8
|
+
const notLastControls = controlsUnder(`${InputGroupItem}:not(:only-child):not(:last-child)`);
|
|
9
|
+
const lastControls = controlsUnder(`${InputGroupItem}:not(:only-child):last-child`);
|
|
6
10
|
const InputGroupWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
7
11
|
displayName: "InputGroupstyles__InputGroupWrapper",
|
|
8
12
|
componentId: "sc-1cn2cc5-1"
|
|
9
|
-
})(["&&&{", "
|
|
13
|
+
})(["&&&{display:flex;min-width:0;", " ", " .ds-select-container{margin-bottom:0;}", "}"], (props) => props.compact ? "" : "align-items: stretch;", InputGroupItem, (props) => {
|
|
14
|
+
const growChild = props.$growItem === "first" ? "first-child" : "last-child";
|
|
15
|
+
return props.compact ? css(["", ":only-child{flex-grow:1;}", ":not(:only-child):not(:last-child){margin-right:-1px;}", ":not(:only-child):", "{flex:auto;}", ":not(:only-child):not(:", ") .ds-input-number{width:90px;}", "{border-top-right-radius:0;border-bottom-right-radius:0;}", "{border-top-left-radius:0;border-bottom-left-radius:0;}"], InputGroupItem, InputGroupItem, InputGroupItem, growChild, InputGroupItem, growChild, notLastControls, lastControls) : css(["", ":", "{flex-grow:1;}", ":not(:last-child){margin-right:12px;}"], InputGroupItem, growChild, InputGroupItem);
|
|
16
|
+
});
|
|
10
17
|
export {
|
|
11
18
|
InputGroupItem,
|
|
12
19
|
InputGroupWrapper
|
|
@@ -1,6 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import { FormFieldCommonProps } from '@synerise/ds-form-field';
|
|
3
|
-
export type
|
|
3
|
+
export type InputGroupSize = 'large' | 'default' | 'small';
|
|
4
|
+
export type Props = {
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
size?: InputGroupSize;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Which group item stretches to fill the row (the others keep their natural
|
|
12
|
+
* width). Defaults to `'last'` — the trailing control grows, so a fixed-width
|
|
13
|
+
* leading control (e.g. a Select) sits left and the input fills the rest. Use
|
|
14
|
+
* `'first'` for the flipped layout: the leading control stretches while a
|
|
15
|
+
* fixed-width trailing control (e.g. a ColorPicker) stays compact on the right.
|
|
16
|
+
*/
|
|
17
|
+
growItem?: 'first' | 'last';
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use `errorText` (from `FormFieldCommonProps`) instead. This
|
|
20
|
+
* antd-proprietary array of error strings is kept only for backward
|
|
21
|
+
* compatibility and is ignored when `errorText` is provided.
|
|
22
|
+
*/
|
|
4
23
|
errors?: string[];
|
|
5
24
|
resetMargin?: boolean;
|
|
6
|
-
} &
|
|
25
|
+
} & FormFieldCommonProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
2
|
const errorInputStyle = (props) => `
|
|
3
|
-
|
|
3
|
+
&& {
|
|
4
4
|
border-color: ${props.theme.palette["red-600"]};
|
|
5
5
|
box-shadow: inset 0 0 0 2px ${props.theme.palette["red-600"]};
|
|
6
6
|
background: ${props.theme.palette["red-050"]};
|
package/dist/TextArea.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TextareaProps } from './TextArea.types';
|
|
3
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;
|
|
4
|
-
export declare const RawTextArea: import('styled-components').StyledComponent<React.ForwardRefExoticComponent<
|
|
4
|
+
export declare const RawTextArea: import('styled-components').StyledComponent<React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
5
5
|
error?: boolean;
|
|
6
|
-
} & React.RefAttributes<
|
|
6
|
+
} & React.RefAttributes<HTMLTextAreaElement>>, any, {
|
|
7
7
|
error?: boolean;
|
|
8
8
|
}, never>;
|
package/dist/TextArea.js
CHANGED
|
@@ -2,13 +2,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useRef, useEffect, useCallback } from "react";
|
|
3
3
|
import { v4 } from "uuid";
|
|
4
4
|
import FormField from "@synerise/ds-form-field";
|
|
5
|
-
import {
|
|
6
|
-
import { RawTextArea as RawTextArea$
|
|
5
|
+
import { RawTextArea as RawTextArea$1, OuterWrapper, InputWrapper } from "./Input.styles.js";
|
|
6
|
+
import { RawTextArea as RawTextArea$2 } from "./Textarea/Textarea.js";
|
|
7
7
|
import { ElementIcons } from "./components/ElementIcons.js";
|
|
8
8
|
import { useElementFocus } from "./hooks/useElementFocus.js";
|
|
9
9
|
import { useCounterLimit } from "./hooks/useCounterLimit.js";
|
|
10
10
|
import { getCharCount } from "./utils/getCharCount.js";
|
|
11
|
-
import "./style/index.css";
|
|
12
11
|
const TextArea = ({
|
|
13
12
|
className,
|
|
14
13
|
errorText,
|
|
@@ -53,10 +52,10 @@ const TextArea = ({
|
|
|
53
52
|
});
|
|
54
53
|
return /* @__PURE__ */ jsx(OuterWrapper, { className, resetMargin, children: /* @__PURE__ */ jsx(FormField, { label, rightSide, id, tooltip, tooltipConfig, description, errorText, children: /* @__PURE__ */ jsxs(InputWrapper, { children: [
|
|
55
54
|
/* @__PURE__ */ jsx(ElementIcons, { handleIconsClick, disabled: antdTextareaProps.disabled, icon1Tooltip, icon1, icon2, icon2Tooltip, className, type: "textArea" }),
|
|
56
|
-
/* @__PURE__ */ jsx(RawTextArea$
|
|
55
|
+
/* @__PURE__ */ jsx(RawTextArea$2, { ...antdTextareaProps, className: hasErrorMessage || error ? "error" : void 0, error: hasErrorMessage || error, onChange: handleChange, value: antdTextareaProps.value, id, autoComplete: "off" })
|
|
57
56
|
] }) }) });
|
|
58
57
|
};
|
|
59
|
-
const RawTextArea =
|
|
58
|
+
const RawTextArea = RawTextArea$1;
|
|
60
59
|
export {
|
|
61
60
|
RawTextArea,
|
|
62
61
|
TextArea
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { TextAreaRef } from 'antd/lib/input/TextArea';
|
|
2
1
|
import { default as React } from 'react';
|
|
3
|
-
|
|
2
|
+
import { AutoSizeType } from './Textarea.types';
|
|
3
|
+
export declare const RawTextArea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
4
|
+
autoSize?: AutoSizeType;
|
|
4
5
|
error?: boolean;
|
|
5
6
|
errorText?: string | React.ReactNode;
|
|
6
7
|
wrapperStyle?: React.CSSProperties;
|
|
7
8
|
resize?: import('csstype').ResizeProperty;
|
|
8
|
-
} & React.RefAttributes<
|
|
9
|
+
} & React.RefAttributes<HTMLTextAreaElement>>;
|
|
9
10
|
export default RawTextArea;
|
|
@@ -1,25 +1,54 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useState } from "react";
|
|
2
|
+
import { forwardRef, useState, useRef } from "react";
|
|
3
|
+
import { useMergeRefs } from "@floating-ui/react";
|
|
3
4
|
import Scrollbar from "@synerise/ds-scrollbar";
|
|
4
|
-
import {
|
|
5
|
+
import { RawTextArea as RawTextArea$1 } from "../Input.styles.js";
|
|
6
|
+
import { useTextareaAutosize } from "../hooks/useTextareaAutosize.js";
|
|
5
7
|
import { TextareaWrapper } from "./Textarea.styles.js";
|
|
8
|
+
const resolveRows = (autoSize) => typeof autoSize === "object" ? autoSize : void 0;
|
|
6
9
|
const RawTextArea = forwardRef(({
|
|
7
10
|
disabled,
|
|
8
11
|
error,
|
|
12
|
+
errorText,
|
|
9
13
|
rows = 4,
|
|
10
14
|
wrapperStyle,
|
|
11
15
|
onBlur,
|
|
12
16
|
onFocus,
|
|
17
|
+
onChange,
|
|
13
18
|
resize,
|
|
14
19
|
autoSize,
|
|
15
20
|
readOnly,
|
|
21
|
+
value,
|
|
16
22
|
...props
|
|
17
23
|
}, ref) => {
|
|
18
24
|
const [focus, setFocus] = useState(false);
|
|
25
|
+
const [viewportHeight, setViewportHeight] = useState(null);
|
|
26
|
+
const innerRef = useRef(null);
|
|
27
|
+
const mergedRef = useMergeRefs([innerRef, ref]);
|
|
28
|
+
const rowsConfig = resolveRows(autoSize);
|
|
29
|
+
const resize_ = useTextareaAutosize({
|
|
30
|
+
ref: innerRef,
|
|
31
|
+
value,
|
|
32
|
+
minRows: rowsConfig?.minRows,
|
|
33
|
+
maxRows: rowsConfig?.maxRows,
|
|
34
|
+
enabled: Boolean(autoSize),
|
|
35
|
+
onViewportHeight: setViewportHeight
|
|
36
|
+
});
|
|
37
|
+
const handleChange = (event) => {
|
|
38
|
+
onChange && onChange(event);
|
|
39
|
+
if (autoSize) {
|
|
40
|
+
resize_();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
19
43
|
return /* @__PURE__ */ jsx(TextareaWrapper, { className: "ds-textarea", isDisabled: Boolean(disabled), isFocused: focus, isReadOnly: readOnly, hasError: Boolean(error), resize, style: {
|
|
20
|
-
|
|
44
|
+
// In autoSize mode the wrapper is the fixed/max-height viewport the
|
|
45
|
+
// ds-Scrollbar scrolls: the hook reports the clamped viewport height
|
|
46
|
+
// (definite px so the inner `.ps` `height: 100%` resolves) while the
|
|
47
|
+
// textarea grows to its full content height behind it. Falls back to
|
|
48
|
+
// `auto` until the first measurement lands.
|
|
49
|
+
height: autoSize ? viewportHeight !== null ? `${viewportHeight}px` : "auto" : `${rows * 17}px`,
|
|
21
50
|
...wrapperStyle
|
|
22
|
-
}, children: /* @__PURE__ */ jsx(Scrollbar, { absolute: true, classes: "textarea-scrollbar", children: /* @__PURE__ */ jsx(
|
|
51
|
+
}, children: /* @__PURE__ */ jsx(Scrollbar, { absolute: true, classes: "textarea-scrollbar", children: /* @__PURE__ */ jsx(RawTextArea$1, { ...props, value, ref: mergedRef, error, disabled, readOnly, onChange: handleChange, onFocus: (e) => {
|
|
23
52
|
onFocus && onFocus(e);
|
|
24
53
|
setFocus(true);
|
|
25
54
|
}, onBlur: (e) => {
|
|
@@ -2,7 +2,7 @@ import styled, { css } from "styled-components";
|
|
|
2
2
|
const TextareaWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "Textareastyles__TextareaWrapper",
|
|
4
4
|
componentId: "sc-23480t-0"
|
|
5
|
-
})(["position:relative;overflow:hidden;resize:", ";border-radius:3px;transition:background-color 0.3s ease-in-out,border 0.3s ease-in-out,box-shadow 0.3s ease-in-out;", " .scrollbar-container{height:100%;top:1px;bottom:0;right:1px;.ps__rail-y,.ps__thumb-x,.ps__rail-x{height:calc(100% - 1px);max-height:9px;}& > .textarea-scrollbar{&,& > div{height:calc(100% - 2px);}}}&&&{textarea{position:relative;min-height:100%;resize:none;background:transparent;border:0;box-shadow:none;outline:0;word-wrap:break-word;overflow-wrap:break-word;font-variant-numeric:normal
|
|
5
|
+
})(["position:relative;overflow:hidden;resize:", ";border-radius:3px;transition:background-color 0.3s ease-in-out,border 0.3s ease-in-out,box-shadow 0.3s ease-in-out;", " .scrollbar-container{height:100%;top:1px;bottom:0;right:1px;.ps__rail-y,.ps__thumb-x,.ps__rail-x{height:calc(100% - 1px);max-height:9px;}& > .textarea-scrollbar{&,& > div{height:calc(100% - 2px);}}}&&&{textarea{position:relative;min-height:100%;resize:none;background:transparent;border:0;box-shadow:none;outline:0;word-wrap:break-word;overflow-wrap:break-word;font-family:inherit;font-size:13px;font-variant-numeric:normal;&::placeholder,&::-webkit-input-placeholder{color:", ";line-height:1.38;}&:-ms-input-placeholder{color:", ";line-height:1.38;}}}"], (props) => props.resize ? props.resize : "vertical", (props) => {
|
|
6
6
|
if (props.isReadOnly) {
|
|
7
7
|
return css(["border:1px solid ", ";background-color:", ";"], props.theme.palette["grey-300"], props.theme.palette["grey-050"]);
|
|
8
8
|
}
|
|
@@ -16,7 +16,7 @@ const TextareaWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
16
16
|
return css(["background-color:", ";box-shadow:inset 0 0 0 1px ", ";border:1px solid ", ";"], props.theme.palette["red-050"], props.theme.palette["red-600"], props.theme.palette["red-600"]);
|
|
17
17
|
}
|
|
18
18
|
return css(["border:1px solid #dbe0e3;background-color:#fff;"]);
|
|
19
|
-
});
|
|
19
|
+
}, (props) => props.theme.palette["grey-500"], (props) => props.theme.palette["grey-500"]);
|
|
20
20
|
export {
|
|
21
21
|
TextareaWrapper
|
|
22
22
|
};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { TextAreaProps as AntdTextAreaProps } from 'antd/lib/input';
|
|
2
1
|
import { ResizeProperty } from 'csstype';
|
|
3
|
-
import {
|
|
2
|
+
import { CSSProperties, ReactNode, TextareaHTMLAttributes } from 'react';
|
|
3
|
+
export type AutoSizeType = boolean | {
|
|
4
|
+
minRows?: number;
|
|
5
|
+
maxRows?: number;
|
|
6
|
+
};
|
|
7
|
+
export type RawTextAreaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
8
|
+
/** Auto-grow height to fit content. `true` grows freely; object bounds it by rows. */
|
|
9
|
+
autoSize?: AutoSizeType;
|
|
10
|
+
error?: boolean;
|
|
11
|
+
errorText?: string | ReactNode;
|
|
12
|
+
wrapperStyle?: CSSProperties;
|
|
13
|
+
resize?: ResizeProperty;
|
|
14
|
+
};
|
|
4
15
|
/**
|
|
5
16
|
* @deprecated Use RawTextAreaProps instead.
|
|
6
17
|
*/
|
|
7
18
|
export type TextAreaProps = RawTextAreaProps;
|
|
8
|
-
export type RawTextAreaProps = AntdTextAreaProps & {
|
|
9
|
-
error?: boolean;
|
|
10
|
-
errorText?: string | React.ReactNode;
|
|
11
|
-
wrapperStyle?: React.CSSProperties;
|
|
12
|
-
resize?: ResizeProperty;
|
|
13
|
-
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TextAreaRef } from 'antd/lib/input/TextArea';
|
|
2
1
|
import { default as React, ChangeEvent, FocusEvent, ReactNode } from 'react';
|
|
3
2
|
import { InputProps } from '../Input.types';
|
|
4
3
|
export declare const ExpandableWrapper: React.ForwardRefExoticComponent<Pick<InputProps, "value"> & {
|
|
@@ -6,4 +5,4 @@ export declare const ExpandableWrapper: React.ForwardRefExoticComponent<Pick<Inp
|
|
|
6
5
|
expanded: boolean;
|
|
7
6
|
onChange: (Event: ChangeEvent<HTMLInputElement> & ChangeEvent<HTMLTextAreaElement>) => void;
|
|
8
7
|
onBlur: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
9
|
-
} & React.RefAttributes<
|
|
8
|
+
} & React.RefAttributes<HTMLTextAreaElement>>;
|
package/dist/components/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { InputRef } from 'antd';
|
|
2
1
|
import { MutableRefObject } from 'react';
|
|
3
|
-
export declare const useElementFocus:
|
|
2
|
+
export declare const useElementFocus: <T extends {
|
|
3
|
+
focus: () => void;
|
|
4
|
+
}>(ref: MutableRefObject<T | null>) => () => void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { InputRef } from 'antd';
|
|
2
1
|
import { MutableRefObject } from 'react';
|
|
3
|
-
export declare const useInputAddonHeight: (inputRef: MutableRefObject<
|
|
2
|
+
export declare const useInputAddonHeight: (inputRef: MutableRefObject<HTMLInputElement | null>) => {
|
|
4
3
|
inputAddonHeight: number;
|
|
5
4
|
};
|
|
@@ -2,7 +2,7 @@ import { useState, useEffect } from "react";
|
|
|
2
2
|
const useInputAddonHeight = (inputRef) => {
|
|
3
3
|
const [inputAddonHeight, setInputAddonHeight] = useState(0);
|
|
4
4
|
useEffect(() => {
|
|
5
|
-
inputRef.current
|
|
5
|
+
inputRef.current?.offsetHeight && setInputAddonHeight(inputRef.current.offsetHeight);
|
|
6
6
|
}, [inputRef]);
|
|
7
7
|
return {
|
|
8
8
|
inputAddonHeight
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
type TextareaMetrics = {
|
|
3
|
+
/** `scrollHeight` of the textarea (content + vertical padding, border excluded). */
|
|
4
|
+
scrollHeight: number;
|
|
5
|
+
verticalPadding: number;
|
|
6
|
+
verticalBorder: number;
|
|
7
|
+
isBorderBox: boolean;
|
|
8
|
+
/** Floor for the textarea's own height (box px). */
|
|
9
|
+
minHeightPx?: number;
|
|
10
|
+
/** Cap for the scroll viewport (box px); the textarea itself is never capped. */
|
|
11
|
+
maxHeightPx?: number;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Pure height calculation extracted from the hook so the sizing logic is
|
|
15
|
+
* unit-testable without a layout engine. Returns two heights:
|
|
16
|
+
*
|
|
17
|
+
* - `contentHeight` — the textarea's own height. It always tracks the full
|
|
18
|
+
* content (floored at `minHeightPx`) and is **never capped**, so the textarea
|
|
19
|
+
* never scrolls itself; the ds-Scrollbar wrapping it owns the scrolling.
|
|
20
|
+
* - `viewportHeight` — the height for the scroll viewport (the wrapper). It
|
|
21
|
+
* tracks the content but is capped at `maxHeightPx`, so once the content
|
|
22
|
+
* exceeds the cap the textarea overflows the viewport and PerfectScrollbar
|
|
23
|
+
* takes over.
|
|
24
|
+
*/
|
|
25
|
+
export declare const computeTextareaHeight: ({ scrollHeight, verticalPadding, verticalBorder, isBorderBox, minHeightPx, maxHeightPx, }: TextareaMetrics) => {
|
|
26
|
+
contentHeight: number;
|
|
27
|
+
viewportHeight: number;
|
|
28
|
+
};
|
|
29
|
+
type UseTextareaAutosizeParams = {
|
|
30
|
+
ref: RefObject<HTMLTextAreaElement | null>;
|
|
31
|
+
/** Re-measure whenever this changes (typically the controlled value). */
|
|
32
|
+
value?: unknown;
|
|
33
|
+
minRows?: number;
|
|
34
|
+
maxRows?: number;
|
|
35
|
+
/** When false the textarea keeps its CSS height (no auto-sizing). */
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Reports the scroll viewport height (clamped by `minRows`/`maxRows`) so the
|
|
39
|
+
* wrapper can be sized as a definite-height viewport for the ds-Scrollbar.
|
|
40
|
+
*/
|
|
41
|
+
onViewportHeight?: (height: number) => void;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Grows a `<textarea>` to fit its content between `minRows` and `maxRows`,
|
|
45
|
+
* replacing antd's `autoSize={{ minRows, maxRows }}`. The textarea is sized to
|
|
46
|
+
* its full content height with `overflow: hidden` (it never scrolls itself);
|
|
47
|
+
* the clamped viewport height is reported via `onViewportHeight` so the wrapping
|
|
48
|
+
* ds-Scrollbar handles the scrolling once the content exceeds `maxRows`.
|
|
49
|
+
* Measures synchronously in `useLayoutEffect` (before paint) and re-measures on
|
|
50
|
+
* window resize.
|
|
51
|
+
*/
|
|
52
|
+
export declare const useTextareaAutosize: ({ ref, value, minRows, maxRows, enabled, onViewportHeight, }: UseTextareaAutosizeParams) => () => void;
|
|
53
|
+
export {};
|