@chayns-components/core 5.0.43 → 5.0.45
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/lib/cjs/components/checkbox/Checkbox.js +7 -1
- package/lib/cjs/components/checkbox/Checkbox.js.map +1 -1
- package/lib/cjs/components/checkbox/Checkbox.styles.js +17 -8
- package/lib/cjs/components/checkbox/Checkbox.styles.js.map +1 -1
- package/lib/cjs/components/list/List.js +60 -46
- package/lib/cjs/components/list/List.js.map +1 -1
- package/lib/cjs/components/text-area/TextArea.js +141 -56
- package/lib/cjs/components/text-area/TextArea.js.map +1 -1
- package/lib/cjs/components/text-area/TextArea.styles.js +10 -9
- package/lib/cjs/components/text-area/TextArea.styles.js.map +1 -1
- package/lib/esm/components/checkbox/Checkbox.js +7 -1
- package/lib/esm/components/checkbox/Checkbox.js.map +1 -1
- package/lib/esm/components/checkbox/Checkbox.styles.js +17 -8
- package/lib/esm/components/checkbox/Checkbox.styles.js.map +1 -1
- package/lib/esm/components/list/List.js +60 -46
- package/lib/esm/components/list/List.js.map +1 -1
- package/lib/esm/components/text-area/TextArea.js +141 -56
- package/lib/esm/components/text-area/TextArea.js.map +1 -1
- package/lib/esm/components/text-area/TextArea.styles.js +10 -9
- package/lib/esm/components/text-area/TextArea.styles.js.map +1 -1
- package/lib/types/components/checkbox/Checkbox.d.ts +20 -1
- package/lib/types/components/checkbox/Checkbox.styles.d.ts +5 -0
- package/lib/types/components/text-area/TextArea.d.ts +8 -0
- package/lib/types/components/text-area/TextArea.styles.d.ts +5 -1
- package/package.json +2 -2
|
@@ -1,69 +1,154 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
1
2
|
import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
2
3
|
import { AreaContext } from '../area-provider/AreaContextProvider';
|
|
3
4
|
import { StyledInputRightElement } from '../input/Input.styles';
|
|
4
5
|
import { StyledTextArea, StyledTextAreaContent, StyledTextAreaContentWrapper, StyledTextAreaInput, StyledTextAreaLabel, StyledTextAreaLabelWrapper } from './TextArea.styles';
|
|
5
6
|
import { useCursorRepaint } from '../../hooks/resize';
|
|
6
|
-
const TextArea = /*#__PURE__*/forwardRef(({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
const TextArea = /*#__PURE__*/forwardRef((t0, ref) => {
|
|
8
|
+
"use memo";
|
|
9
|
+
|
|
10
|
+
const $ = _c(28);
|
|
11
|
+
const {
|
|
12
|
+
isDisabled,
|
|
13
|
+
isInvalid,
|
|
14
|
+
placeholder,
|
|
15
|
+
value,
|
|
16
|
+
onChange,
|
|
17
|
+
onFocus,
|
|
18
|
+
onKeyDown,
|
|
19
|
+
rightElement,
|
|
20
|
+
onBlur,
|
|
21
|
+
maxHeight: t1,
|
|
22
|
+
minHeight: t2,
|
|
23
|
+
colors
|
|
24
|
+
} = t0;
|
|
25
|
+
const maxHeight = t1 === undefined ? "120px" : t1;
|
|
26
|
+
const minHeight = t2 === undefined ? "41px" : t2;
|
|
19
27
|
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
20
28
|
const areaProvider = useContext(AreaContext);
|
|
21
29
|
const textareaRef = useRef(null);
|
|
22
30
|
useCursorRepaint(textareaRef);
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
25
31
|
const shouldShowBorder = rightElement?.props?.style?.backgroundColor === undefined;
|
|
26
|
-
const shouldChangeColor =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
textareaRef.current
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
$
|
|
61
|
-
$
|
|
62
|
-
$
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
$
|
|
66
|
-
}
|
|
32
|
+
const shouldChangeColor = areaProvider.shouldChangeColor ?? false;
|
|
33
|
+
let t3;
|
|
34
|
+
if ($[0] !== maxHeight) {
|
|
35
|
+
t3 = () => {
|
|
36
|
+
if (textareaRef.current) {
|
|
37
|
+
textareaRef.current.style.height = "auto";
|
|
38
|
+
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;
|
|
39
|
+
setIsOverflowing(textareaRef.current.scrollHeight > parseInt(maxHeight.toString(), 10));
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
$[0] = maxHeight;
|
|
43
|
+
$[1] = t3;
|
|
44
|
+
} else {
|
|
45
|
+
t3 = $[1];
|
|
46
|
+
}
|
|
47
|
+
const adjustTextareaHeight = t3;
|
|
48
|
+
let t4;
|
|
49
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
50
|
+
t4 = () => textareaRef.current;
|
|
51
|
+
$[2] = t4;
|
|
52
|
+
} else {
|
|
53
|
+
t4 = $[2];
|
|
54
|
+
}
|
|
55
|
+
useImperativeHandle(ref, t4);
|
|
56
|
+
let t5;
|
|
57
|
+
let t6;
|
|
58
|
+
if ($[3] !== adjustTextareaHeight || $[4] !== value) {
|
|
59
|
+
t5 = () => {
|
|
60
|
+
if (typeof value === "string" && value.length > -1) {
|
|
61
|
+
adjustTextareaHeight();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
t6 = [adjustTextareaHeight, value];
|
|
65
|
+
$[3] = adjustTextareaHeight;
|
|
66
|
+
$[4] = value;
|
|
67
|
+
$[5] = t5;
|
|
68
|
+
$[6] = t6;
|
|
69
|
+
} else {
|
|
70
|
+
t5 = $[5];
|
|
71
|
+
t6 = $[6];
|
|
72
|
+
}
|
|
73
|
+
useEffect(t5, t6);
|
|
74
|
+
const hasValue = value !== undefined && value.length > 0;
|
|
75
|
+
let t7;
|
|
76
|
+
if ($[7] !== hasValue) {
|
|
77
|
+
t7 = hasValue ? {
|
|
78
|
+
bottom: "2px",
|
|
79
|
+
right: "2px"
|
|
80
|
+
} : {
|
|
81
|
+
top: "12px",
|
|
82
|
+
left: "10px"
|
|
83
|
+
};
|
|
84
|
+
$[7] = hasValue;
|
|
85
|
+
$[8] = t7;
|
|
86
|
+
} else {
|
|
87
|
+
t7 = $[8];
|
|
88
|
+
}
|
|
89
|
+
const labelPosition = t7;
|
|
90
|
+
let t8;
|
|
91
|
+
if ($[9] !== colors?.backgroundColor || $[10] !== colors?.borderColor || $[11] !== hasValue || $[12] !== isDisabled || $[13] !== isInvalid || $[14] !== isOverflowing || $[15] !== labelPosition || $[16] !== maxHeight || $[17] !== minHeight || $[18] !== onBlur || $[19] !== onChange || $[20] !== onFocus || $[21] !== onKeyDown || $[22] !== placeholder || $[23] !== rightElement || $[24] !== shouldChangeColor || $[25] !== shouldShowBorder || $[26] !== value) {
|
|
92
|
+
colors?.backgroundColor;
|
|
93
|
+
colors?.borderColor;
|
|
94
|
+
t8 = (() => /*#__PURE__*/React.createElement(StyledTextArea, {
|
|
95
|
+
$isDisabled: isDisabled
|
|
96
|
+
}, /*#__PURE__*/React.createElement(StyledTextAreaContentWrapper, {
|
|
97
|
+
$isInvalid: isInvalid,
|
|
98
|
+
$shouldChangeColor: shouldChangeColor,
|
|
99
|
+
$backgroundColor: colors?.backgroundColor,
|
|
100
|
+
$borderColor: colors?.borderColor
|
|
101
|
+
}, /*#__PURE__*/React.createElement(StyledTextAreaContent, null, /*#__PURE__*/React.createElement(StyledTextAreaInput, {
|
|
102
|
+
className: "chayns-scrollbar",
|
|
103
|
+
disabled: isDisabled,
|
|
104
|
+
$isInvalid: isInvalid,
|
|
105
|
+
ref: textareaRef,
|
|
106
|
+
value: value,
|
|
107
|
+
onBlur: onBlur,
|
|
108
|
+
onChange: onChange,
|
|
109
|
+
onFocus: onFocus,
|
|
110
|
+
onKeyDown: onKeyDown,
|
|
111
|
+
$maxHeight: maxHeight,
|
|
112
|
+
$minHeight: minHeight,
|
|
113
|
+
$isOverflowing: isOverflowing,
|
|
114
|
+
rows: 1
|
|
115
|
+
}), /*#__PURE__*/React.createElement(StyledTextAreaLabelWrapper, {
|
|
116
|
+
animate: {
|
|
117
|
+
fontSize: hasValue ? "9px" : undefined
|
|
118
|
+
},
|
|
119
|
+
initial: false,
|
|
120
|
+
layout: true,
|
|
121
|
+
style: labelPosition,
|
|
122
|
+
transition: {
|
|
123
|
+
type: "tween",
|
|
124
|
+
duration: 0.1
|
|
125
|
+
}
|
|
126
|
+
}, /*#__PURE__*/React.createElement(StyledTextAreaLabel, {
|
|
127
|
+
$isInvalid: isInvalid
|
|
128
|
+
}, placeholder))), rightElement && shouldShowBorder && rightElement), rightElement && !shouldShowBorder && /*#__PURE__*/React.createElement(StyledInputRightElement, null, rightElement)))();
|
|
129
|
+
$[9] = colors?.backgroundColor;
|
|
130
|
+
$[10] = colors?.borderColor;
|
|
131
|
+
$[11] = hasValue;
|
|
132
|
+
$[12] = isDisabled;
|
|
133
|
+
$[13] = isInvalid;
|
|
134
|
+
$[14] = isOverflowing;
|
|
135
|
+
$[15] = labelPosition;
|
|
136
|
+
$[16] = maxHeight;
|
|
137
|
+
$[17] = minHeight;
|
|
138
|
+
$[18] = onBlur;
|
|
139
|
+
$[19] = onChange;
|
|
140
|
+
$[20] = onFocus;
|
|
141
|
+
$[21] = onKeyDown;
|
|
142
|
+
$[22] = placeholder;
|
|
143
|
+
$[23] = rightElement;
|
|
144
|
+
$[24] = shouldChangeColor;
|
|
145
|
+
$[25] = shouldShowBorder;
|
|
146
|
+
$[26] = value;
|
|
147
|
+
$[27] = t8;
|
|
148
|
+
} else {
|
|
149
|
+
t8 = $[27];
|
|
150
|
+
}
|
|
151
|
+
return t8;
|
|
67
152
|
});
|
|
68
153
|
TextArea.displayName = 'TextArea';
|
|
69
154
|
export default TextArea;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.js","names":["React","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useMemo","useRef","useState","AreaContext","StyledInputRightElement","StyledTextArea","StyledTextAreaContent","StyledTextAreaContentWrapper","StyledTextAreaInput","StyledTextAreaLabel","StyledTextAreaLabelWrapper","useCursorRepaint","TextArea","isDisabled","isInvalid","placeholder","value","onChange","onFocus","onKeyDown","rightElement","onBlur","maxHeight","minHeight","ref","isOverflowing","setIsOverflowing","areaProvider","textareaRef","shouldShowBorder","props","style","backgroundColor","undefined","shouldChangeColor","adjustTextareaHeight","current","height","scrollHeight","parseInt","toString","length","createElement","$isDisabled","$isInvalid","$shouldChangeColor","className","disabled","$maxHeight","$minHeight","$isOverflowing","rows","displayName"],"sources":["../../../../src/components/text-area/TextArea.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n CSSProperties,\n FocusEventHandler,\n forwardRef,\n KeyboardEventHandler,\n ReactElement,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport { StyledInputRightElement } from '../input/Input.styles';\nimport {\n StyledTextArea,\n StyledTextAreaContent,\n StyledTextAreaContentWrapper,\n StyledTextAreaInput,\n StyledTextAreaLabel,\n StyledTextAreaLabelWrapper,\n} from './TextArea.styles';\nimport { useCursorRepaint } from '../../hooks/resize';\n\nexport type TextAreaProps = {\n /**\n * Disables the text area so that it cannot be changed.\n */\n isDisabled?: boolean;\n /**\n * If true, the text area is marked as invalid\n */\n isInvalid?: boolean;\n /**\n * The maximum height of the text area.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * The minimum height of the text area.\n */\n minHeight?: CSSProperties['minHeight'];\n /**\n * Function that is executed when the text area loses focus.\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the text of the text area changes.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Placeholder for the text area field.\n */\n placeholder?: string | ReactElement;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactElement;\n /**\n * Value if the text area should be controlled.\n */\n value?: string;\n};\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n (\n {\n isDisabled,\n isInvalid,\n placeholder,\n value,\n onChange,\n onFocus,\n onKeyDown,\n rightElement,\n onBlur,\n maxHeight = '120px',\n minHeight = '41px',\n },\n ref,\n ) => {\n const [isOverflowing, setIsOverflowing] = useState(false);\n\n const areaProvider = useContext(AreaContext);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useCursorRepaint(textareaRef);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const shouldShowBorder = rightElement?.props?.style?.backgroundColor === undefined;\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\n setIsOverflowing(\n textareaRef.current.scrollHeight > parseInt(maxHeight.toString(), 10),\n );\n }\n }, [maxHeight]);\n\n useImperativeHandle(ref, () => textareaRef.current as HTMLTextAreaElement);\n\n /**\n * This hook calculates the height of the TextArea after the displayValue is changed and the content is inside the \"textareaRef\".\n * To maintain the functionality while clearing the input, the length need to be greater than -1.\n */\n useEffect(() => {\n if (typeof value === 'string' && value.length > -1) {\n adjustTextareaHeight();\n }\n }, [adjustTextareaHeight, value]);\n\n return useMemo(\n () => (\n <StyledTextArea $isDisabled={isDisabled}>\n <StyledTextAreaContentWrapper\n $isInvalid={isInvalid}\n $shouldChangeColor={shouldChangeColor}\n >\n <StyledTextAreaContent>\n <StyledTextAreaInput\n className=\"chayns-scrollbar\"\n disabled={isDisabled}\n $isInvalid={isInvalid}\n ref={textareaRef}\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n $maxHeight={maxHeight}\n $minHeight={minHeight}\n $isOverflowing={isOverflowing}\n rows={1}\n />\n {!value && (\n <StyledTextAreaLabelWrapper>\n <StyledTextAreaLabel $isInvalid={isInvalid}>\n {placeholder}\n </StyledTextAreaLabel>\n </StyledTextAreaLabelWrapper>\n )}\n </StyledTextAreaContent>\n {rightElement && shouldShowBorder && rightElement}\n </StyledTextAreaContentWrapper>\n {rightElement && !shouldShowBorder && (\n <StyledInputRightElement>{rightElement}</StyledInputRightElement>\n )}\n </StyledTextArea>\n ),\n [\n isDisabled,\n isInvalid,\n isOverflowing,\n maxHeight,\n minHeight,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n placeholder,\n rightElement,\n shouldChangeColor,\n shouldShowBorder,\n value,\n ],\n );\n },\n);\n\nTextArea.displayName = 'TextArea';\n\nexport default TextArea;\n"],"mappings":"AAAA,OAAOA,KAAK,IAIRC,UAAU,EAGVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,WAAW,QAAQ,sCAAsC;AAClE,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SACIC,cAAc,EACdC,qBAAqB,EACrBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,mBAAmB,EACnBC,0BAA0B,QACvB,mBAAmB;AAC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S,EACTW,aAAa,EACbH,SAAS,EACTC,SAAS,EACTF,MAAM,EACNJ,QAAQ,EACRC,OAAO,EACPC,SAAS,EACTJ,WAAW,EACXK,YAAY,EACZc,iBAAiB,EACjBL,gBAAgB,EAChBb,KAAK,CAEb,CAAC;AACL,CACJ,CAAC;AAEDJ,QAAQ,CAACwC,WAAW,GAAG,UAAU;AAEjC,eAAexC,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TextArea.js","names":["React","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useMemo","useRef","useState","AreaContext","StyledInputRightElement","StyledTextArea","StyledTextAreaContent","StyledTextAreaContentWrapper","StyledTextAreaInput","StyledTextAreaLabel","StyledTextAreaLabelWrapper","useCursorRepaint","TextArea","t0","ref","$","_c","isDisabled","isInvalid","placeholder","value","onChange","onFocus","onKeyDown","rightElement","onBlur","maxHeight","t1","minHeight","t2","colors","undefined","isOverflowing","setIsOverflowing","areaProvider","textareaRef","shouldShowBorder","props","style","backgroundColor","shouldChangeColor","t3","current","height","scrollHeight","parseInt","toString","adjustTextareaHeight","t4","Symbol","for","t5","t6","length","hasValue","t7","bottom","right","top","left","labelPosition","t8","borderColor","createElement","$backgroundColor","$borderColor","className","rows","animate","fontSize","initial","layout","transition","type","duration","displayName"],"sources":["../../../../src/components/text-area/TextArea.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n CSSProperties,\n FocusEventHandler,\n forwardRef,\n KeyboardEventHandler,\n ReactElement,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { AreaContext } from '../area-provider/AreaContextProvider';\nimport { StyledInputRightElement } from '../input/Input.styles';\nimport {\n StyledTextArea,\n StyledTextAreaContent,\n StyledTextAreaContentWrapper,\n StyledTextAreaInput,\n StyledTextAreaLabel,\n StyledTextAreaLabelWrapper,\n} from './TextArea.styles';\nimport { useCursorRepaint } from '../../hooks/resize';\n\ntype TextAreaColors = {\n backgroundColor: CSSProperties['backgroundColor'];\n borderColor: CSSProperties['borderColor'];\n};\n\nexport type TextAreaProps = {\n /**\n * Disables the text area so that it cannot be changed.\n */\n isDisabled?: boolean;\n /**\n * If true, the text area is marked as invalid\n */\n isInvalid?: boolean;\n /**\n * The maximum height of the text area.\n */\n maxHeight?: CSSProperties['maxHeight'];\n /**\n * The minimum height of the text area.\n */\n minHeight?: CSSProperties['minHeight'];\n /**\n * Function that is executed when the text area loses focus.\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the text of the text area changes.\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when the input field is focused\n */\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Function that is executed when a letter is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Placeholder for the text area field.\n */\n placeholder?: string | ReactElement;\n /**\n * An element that should be displayed on the right side of the Input.\n */\n rightElement?: ReactElement;\n /**\n * Value if the text area should be controlled.\n */\n value?: string;\n /**\n * Provide custom colors to the TextArea Component\n */\n colors?: TextAreaColors;\n};\n\nconst TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(\n (\n {\n isDisabled,\n isInvalid,\n placeholder,\n value,\n onChange,\n onFocus,\n onKeyDown,\n rightElement,\n onBlur,\n maxHeight = '120px',\n minHeight = '41px',\n colors,\n },\n ref,\n ) => {\n 'use memo';\n\n const [isOverflowing, setIsOverflowing] = useState(false);\n\n const areaProvider = useContext(AreaContext);\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n\n useCursorRepaint(textareaRef);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const shouldShowBorder = rightElement?.props?.style?.backgroundColor === undefined;\n\n const shouldChangeColor = useMemo(\n () => areaProvider.shouldChangeColor ?? false,\n [areaProvider.shouldChangeColor],\n );\n\n const adjustTextareaHeight = useCallback(() => {\n if (textareaRef.current) {\n textareaRef.current.style.height = 'auto';\n textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`;\n\n setIsOverflowing(\n textareaRef.current.scrollHeight > parseInt(maxHeight.toString(), 10),\n );\n }\n }, [maxHeight]);\n\n useImperativeHandle(ref, () => textareaRef.current as HTMLTextAreaElement);\n\n /**\n * This hook calculates the height of the TextArea after the displayValue is changed and the content is inside the \"textareaRef\".\n * To maintain the functionality while clearing the input, the length need to be greater than -1.\n */\n useEffect(() => {\n if (typeof value === 'string' && value.length > -1) {\n adjustTextareaHeight();\n }\n }, [adjustTextareaHeight, value]);\n\n const hasValue = value !== undefined && value.length > 0;\n\n const labelPosition = useMemo(\n () =>\n hasValue\n ? {\n bottom: '2px',\n right: '2px',\n }\n : {\n top: '12px',\n left: '10px',\n },\n [hasValue],\n );\n\n return useMemo(\n () => (\n <StyledTextArea $isDisabled={isDisabled}>\n <StyledTextAreaContentWrapper\n $isInvalid={isInvalid}\n $shouldChangeColor={shouldChangeColor}\n $backgroundColor={colors?.backgroundColor}\n $borderColor={colors?.borderColor}\n >\n <StyledTextAreaContent>\n <StyledTextAreaInput\n className=\"chayns-scrollbar\"\n disabled={isDisabled}\n $isInvalid={isInvalid}\n ref={textareaRef}\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n $maxHeight={maxHeight}\n $minHeight={minHeight}\n $isOverflowing={isOverflowing}\n rows={1}\n />\n <StyledTextAreaLabelWrapper\n animate={{ fontSize: hasValue ? '9px' : undefined }}\n initial={false}\n layout\n style={labelPosition}\n transition={{ type: 'tween', duration: 0.1 }}\n >\n <StyledTextAreaLabel $isInvalid={isInvalid}>\n {placeholder}\n </StyledTextAreaLabel>\n </StyledTextAreaLabelWrapper>\n </StyledTextAreaContent>\n {rightElement && shouldShowBorder && rightElement}\n </StyledTextAreaContentWrapper>\n {rightElement && !shouldShowBorder && (\n <StyledInputRightElement>{rightElement}</StyledInputRightElement>\n )}\n </StyledTextArea>\n ),\n [\n isDisabled,\n isInvalid,\n shouldChangeColor,\n colors?.backgroundColor,\n colors?.borderColor,\n value,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n maxHeight,\n minHeight,\n isOverflowing,\n hasValue,\n labelPosition,\n placeholder,\n rightElement,\n shouldShowBorder,\n ],\n );\n },\n);\n\nTextArea.displayName = 'TextArea';\n\nexport default TextArea;\n"],"mappings":";AAAA,OAAOA,KAAK,IAIRC,UAAU,EAGVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,WAAW,QAAQ,sCAAsC;AAClE,SAASC,uBAAuB,QAAQ,uBAAuB;AAC/D,SACIC,cAAc,EACdC,qBAAqB,EACrBC,4BAA4B,EAC5BC,mBAAmB,EACnBC,mBAAmB,EACnBC,0BAA0B,QACvB,mBAAmB;AAC1B,SAASC,gBAAgB,QAAQ,oBAAoB;AA0DrD,MAAMC,QAAQ,gBAAGjB,UAAU,CACvB,CAAAkB,EAAA,EAAAC,GAAA;EAAA;;EAAA,MAAAC,CAAA,GAAAC,EAAA;EACI;IAAAC,UAAA;IAAAC,SAAA;IAAAC,WAAA;IAAAC,KAAA;IAAAC,QAAA;IAAAC,OAAA;IAAAC,SAAA;IAAAC,YAAA;IAAAC,MAAA;IAAAC,SAAA,EAAAC,EAAA;IAAAC,SAAA,EAAAC,EAAA;IAAAC;EAAA,IAAAjB,EAaC;EAHG,MAAAa,SAAA,GAAAC,EAAmB,KAAnBI,SAAmB,GAAnB,OAAmB,GAAnBJ,EAAmB;EACnB,MAAAC,SAAA,GAAAC,EAAkB,KAAlBE,SAAkB,GAAlB,MAAkB,GAAlBF,EAAkB;EAOtB,OAAAG,aAAA,EAAAC,gBAAA,IAA0C/B,QAAQ,CAAC,KAAK,CAAC;EAEzD,MAAAgC,YAAA,GAAqBrC,UAAU,CAACM,WAAW,CAAC;EAE5C,MAAAgC,WAAA,GAAoBlC,MAAM,CAAsB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YAAgC,IAAhCY,gBAAgD,IAAhDZ,YACyB,CAAC,EAC9BA,YAAiC,IAAjC,CAAiBY,gBAEjB,iBAFA1C,KAAA,CAAAqE,aAAA,CACI3D,uBAAuB,QAAEoB,YAC9B,CACY,CACnB,EAqBL,CAAC;IAAAT,CAAA,MAAAe,MAAA,EAAAS,eAAA;IAAAxB,CAAA,OAAAe,MAAA,EAAAgC,WAAA;IAAA/C,CAAA,OAAAuC,QAAA;IAAAvC,CAAA,OAAAE,UAAA;IAAAF,CAAA,OAAAG,SAAA;IAAAH,CAAA,OAAAiB,aAAA;IAAAjB,CAAA,OAAA6C,aAAA;IAAA7C,CAAA,OAAAW,SAAA;IAAAX,CAAA,OAAAa,SAAA;IAAAb,CAAA,OAAAU,MAAA;IAAAV,CAAA,OAAAM,QAAA;IAAAN,CAAA,OAAAO,OAAA;IAAAP,CAAA,OAAAQ,SAAA;IAAAR,CAAA,OAAAI,WAAA;IAAAJ,CAAA,OAAAS,YAAA;IAAAT,CAAA,OAAAyB,iBAAA;IAAAzB,CAAA,OAAAqB,gBAAA;IAAArB,CAAA,OAAAK,KAAA;IAAAL,CAAA,OAAA8C,EAAA;EAAA;IAAAA,EAAA,GAAA9C,CAAA;EAAA;EAAA,OAhEM8C,EAgEN;AAAA,CAET,CAAC;AAEDjD,QAAQ,CAAC+D,WAAW,GAAG,UAAU;AAEjC,eAAe/D,QAAQ","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
+
import { motion } from 'motion/react';
|
|
2
3
|
export const StyledTextArea = styled.div`
|
|
3
4
|
display: flex;
|
|
4
5
|
flex: 1 1 auto;
|
|
@@ -11,14 +12,16 @@ export const StyledTextArea = styled.div`
|
|
|
11
12
|
export const StyledTextAreaContentWrapper = styled.div`
|
|
12
13
|
background-color: ${({
|
|
13
14
|
theme,
|
|
14
|
-
$shouldChangeColor
|
|
15
|
-
|
|
15
|
+
$shouldChangeColor,
|
|
16
|
+
$backgroundColor
|
|
17
|
+
}) => $backgroundColor ?? (theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100'])};
|
|
16
18
|
border-radius: 3px;
|
|
17
19
|
border: 1px solid
|
|
18
20
|
${({
|
|
19
21
|
theme,
|
|
20
|
-
$isInvalid
|
|
21
|
-
|
|
22
|
+
$isInvalid,
|
|
23
|
+
$borderColor
|
|
24
|
+
}) => $borderColor ?? ($isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)')};
|
|
22
25
|
width: 100%;
|
|
23
26
|
display: flex;
|
|
24
27
|
`;
|
|
@@ -48,10 +51,8 @@ export const StyledTextAreaInput = styled.textarea`
|
|
|
48
51
|
padding: 8px 10px;
|
|
49
52
|
cursor: text;
|
|
50
53
|
`;
|
|
51
|
-
export const StyledTextAreaLabelWrapper = styled.label`
|
|
52
|
-
|
|
53
|
-
top: 12px;
|
|
54
|
-
align-items: baseline;
|
|
54
|
+
export const StyledTextAreaLabelWrapper = styled(motion.label)`
|
|
55
|
+
align-items: center;
|
|
55
56
|
display: flex;
|
|
56
57
|
flex: 0 0 auto;
|
|
57
58
|
gap: 4px;
|
|
@@ -59,7 +60,7 @@ export const StyledTextAreaLabelWrapper = styled.label`
|
|
|
59
60
|
pointer-events: none;
|
|
60
61
|
position: absolute;
|
|
61
62
|
user-select: none;
|
|
62
|
-
width: calc(100% - 20px);
|
|
63
|
+
max-width: calc(100% - 20px);
|
|
63
64
|
cursor: text;
|
|
64
65
|
`;
|
|
65
66
|
export const StyledTextAreaLabel = styled.label`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.styles.js","names":["styled","StyledTextArea","div","$isDisabled","StyledTextAreaContentWrapper","theme","$shouldChangeColor","colorMode","$isInvalid","wrong","StyledTextAreaContent","StyledTextAreaInput","textarea","text","$isOverflowing","$maxHeight","$minHeight","StyledTextAreaLabelWrapper","label","StyledTextAreaLabel"],"sources":["../../../../src/components/text-area/TextArea.styles.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport styled from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { TextAreaProps } from './TextArea';\n\ntype StyledTextAreaProps = WithTheme<{ $isDisabled?: boolean }>;\n\nexport const StyledTextArea = styled.div<StyledTextAreaProps>`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n position: relative;\n`;\
|
|
1
|
+
{"version":3,"file":"TextArea.styles.js","names":["styled","motion","StyledTextArea","div","$isDisabled","StyledTextAreaContentWrapper","theme","$shouldChangeColor","$backgroundColor","colorMode","$isInvalid","$borderColor","wrong","StyledTextAreaContent","StyledTextAreaInput","textarea","text","$isOverflowing","$maxHeight","$minHeight","StyledTextAreaLabelWrapper","label","StyledTextAreaLabel"],"sources":["../../../../src/components/text-area/TextArea.styles.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\nimport styled from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport type { TextAreaProps } from './TextArea';\nimport { motion } from 'motion/react';\n\ntype StyledTextAreaProps = WithTheme<{ $isDisabled?: boolean }>;\n\nexport const StyledTextArea = styled.div<StyledTextAreaProps>`\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n opacity: ${({ $isDisabled }) => ($isDisabled ? 0.5 : 1)};\n position: relative;\n`;\ntype StyledTextAreaContentWrapperProps = WithTheme<{\n $backgroundColor?: CSSProperties['backgroundColor'];\n $borderColor?: CSSProperties['borderColor'];\n $isInvalid: TextAreaProps['isInvalid'];\n $shouldChangeColor: boolean;\n}>;\n\nexport const StyledTextAreaContentWrapper = styled.div<StyledTextAreaContentWrapperProps>`\n background-color: ${({ theme, $shouldChangeColor, $backgroundColor }) =>\n $backgroundColor ??\n (theme.colorMode === 'classic' || $shouldChangeColor ? theme['000'] : theme['100'])};\n border-radius: 3px;\n border: 1px solid\n ${({ theme, $isInvalid, $borderColor }) =>\n $borderColor ?? ($isInvalid ? theme.wrong : 'rgba(160, 160, 160, 0.3)')};\n width: 100%;\n display: flex;\n`;\n\nexport const StyledTextAreaContent = styled.div`\n position: relative;\n display: flex;\n width: 100%;\n`;\n\ntype StyledTextAreaInputProps = WithTheme<{\n $isInvalid: TextAreaProps['isInvalid'];\n $isOverflowing: boolean;\n $maxHeight: CSSProperties['maxHeight'];\n $minHeight: CSSProperties['minHeight'];\n}>;\n\nexport const StyledTextAreaInput = styled.textarea<StyledTextAreaInputProps>`\n color: ${({ theme, $isInvalid }: StyledTextAreaInputProps) =>\n $isInvalid ? theme.wrong : theme.text};\n background: none;\n border: none;\n resize: none;\n overflow-y: ${({ $isOverflowing }) => ($isOverflowing ? 'scroll' : 'hidden')};\n max-height: ${({ $maxHeight }: StyledTextAreaInputProps) =>\n typeof $maxHeight === 'number' ? `${$maxHeight}px` : $maxHeight};\n min-height: ${({ $minHeight }: StyledTextAreaInputProps) =>\n typeof $minHeight === 'number' ? `${$minHeight}px` : $minHeight};\n width: 100%;\n padding: 8px 10px;\n cursor: text;\n`;\n\nexport const StyledTextAreaLabelWrapper = styled(motion.label)`\n align-items: center;\n display: flex;\n flex: 0 0 auto;\n gap: 4px;\n line-height: 1.3;\n pointer-events: none;\n position: absolute;\n user-select: none;\n max-width: calc(100% - 20px);\n cursor: text;\n`;\n\ntype StyledTextAreaLabelProps = WithTheme<{ $isInvalid?: TextAreaProps['isInvalid'] }>;\n\nexport const StyledTextAreaLabel = styled.label<StyledTextAreaLabelProps>`\n color: ${({ theme, $isInvalid }: StyledTextAreaLabelProps) =>\n $isInvalid ? theme.wrong : `rgba(${theme['text-rgb'] ?? ''}, 0.45)`};\n line-height: 1.3;\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n cursor: text;\n text-overflow: ellipsis;\n`;\n"],"mappings":"AACA,OAAOA,MAAM,MAAM,mBAAmB;AAGtC,SAASC,MAAM,QAAQ,cAAc;AAIrC,OAAO,MAAMC,cAAc,GAAGF,MAAM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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAID,OAAO,MAAMC,mBAAmB,GAAGtB,MAAM,CAACqB,KAA+B;AACzE,aAAa,CAAC;EAAEf,KAAK;EAAEI;AAAqC,CAAC,KACrDA,UAAU,GAAGJ,KAAK,CAACM,KAAK,GAAG,QAAQN,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import { ChangeEventHandler, FC, ReactElement } from 'react';
|
|
1
|
+
import { ChangeEventHandler, CSSProperties, FC, ReactElement } from 'react';
|
|
2
|
+
type CheckboxColors = {
|
|
3
|
+
/**
|
|
4
|
+
* Background color for the checked state.
|
|
5
|
+
*/
|
|
6
|
+
checkedBackgroundColor?: CSSProperties['backgroundColor'];
|
|
7
|
+
/**
|
|
8
|
+
* Background color for the unchecked state.
|
|
9
|
+
*/
|
|
10
|
+
uncheckedBackgroundColor?: CSSProperties['backgroundColor'];
|
|
11
|
+
/**
|
|
12
|
+
* Border color for the checkbox or switch indicator.
|
|
13
|
+
*/
|
|
14
|
+
borderColor?: CSSProperties['borderColor'];
|
|
15
|
+
};
|
|
2
16
|
export type CheckboxProps = {
|
|
3
17
|
/**
|
|
4
18
|
* Text for checkbox or switch
|
|
@@ -28,6 +42,11 @@ export type CheckboxProps = {
|
|
|
28
42
|
* Changes the design to use switch instead of checkbox
|
|
29
43
|
*/
|
|
30
44
|
shouldShowAsSwitch?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Border radius for the checkbox or switch indicator.
|
|
47
|
+
*/
|
|
48
|
+
borderRadius?: CSSProperties['borderRadius'];
|
|
49
|
+
colors?: CheckboxColors;
|
|
31
50
|
/**
|
|
32
51
|
* Whether the Checkbox should be displayed centered to the label or at the top
|
|
33
52
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
1
2
|
import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
|
|
2
3
|
import type { CheckboxProps } from './Checkbox';
|
|
3
4
|
export declare const StyledCheckbox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -10,6 +11,10 @@ type StyledCheckboxBoxProps = WithTheme<{
|
|
|
10
11
|
$shouldShowAsSwitch?: CheckboxProps['shouldShowAsSwitch'];
|
|
11
12
|
$isDisabled?: CheckboxProps['isDisabled'];
|
|
12
13
|
$isChecked?: CheckboxProps['isChecked'];
|
|
14
|
+
$checkedBackgroundColor?: CSSProperties['backgroundColor'];
|
|
15
|
+
$uncheckedBackgroundColor?: CSSProperties['backgroundColor'];
|
|
16
|
+
$borderRadius?: CSSProperties['borderRadius'];
|
|
17
|
+
$borderColor?: CSSProperties['borderColor'];
|
|
13
18
|
}>;
|
|
14
19
|
export declare const StyledCheckboxBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, StyledCheckboxBoxProps>> & string;
|
|
15
20
|
type StyledCheckboxLabelProps = WithTheme<{
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import React, { ChangeEventHandler, CSSProperties, FocusEventHandler, KeyboardEventHandler, ReactElement } from 'react';
|
|
2
|
+
type TextAreaColors = {
|
|
3
|
+
backgroundColor: CSSProperties['backgroundColor'];
|
|
4
|
+
borderColor: CSSProperties['borderColor'];
|
|
5
|
+
};
|
|
2
6
|
export type TextAreaProps = {
|
|
3
7
|
/**
|
|
4
8
|
* Disables the text area so that it cannot be changed.
|
|
@@ -44,6 +48,10 @@ export type TextAreaProps = {
|
|
|
44
48
|
* Value if the text area should be controlled.
|
|
45
49
|
*/
|
|
46
50
|
value?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Provide custom colors to the TextArea Component
|
|
53
|
+
*/
|
|
54
|
+
colors?: TextAreaColors;
|
|
47
55
|
};
|
|
48
56
|
declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
49
57
|
export default TextArea;
|
|
@@ -6,6 +6,8 @@ type StyledTextAreaProps = WithTheme<{
|
|
|
6
6
|
}>;
|
|
7
7
|
export declare const StyledTextArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledTextAreaProps>> & string;
|
|
8
8
|
type StyledTextAreaContentWrapperProps = WithTheme<{
|
|
9
|
+
$backgroundColor?: CSSProperties['backgroundColor'];
|
|
10
|
+
$borderColor?: CSSProperties['borderColor'];
|
|
9
11
|
$isInvalid: TextAreaProps['isInvalid'];
|
|
10
12
|
$shouldChangeColor: boolean;
|
|
11
13
|
}>;
|
|
@@ -18,7 +20,9 @@ type StyledTextAreaInputProps = WithTheme<{
|
|
|
18
20
|
$minHeight: CSSProperties['minHeight'];
|
|
19
21
|
}>;
|
|
20
22
|
export declare const StyledTextAreaInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, StyledTextAreaInputProps>> & string;
|
|
21
|
-
export declare const StyledTextAreaLabelWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<
|
|
23
|
+
export declare const StyledTextAreaLabelWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("motion/react").HTMLMotionProps<"label">, "ref"> & React.RefAttributes<HTMLLabelElement>, "ref"> & {
|
|
24
|
+
ref?: ((instance: HTMLLabelElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLLabelElement> | null | undefined;
|
|
25
|
+
}, never>> & string & Omit<import("motion/react").ForwardRefComponent<HTMLLabelElement, import("motion/react").HTMLMotionProps<"label">>, keyof React.Component<any, {}, any>>;
|
|
22
26
|
type StyledTextAreaLabelProps = WithTheme<{
|
|
23
27
|
$isInvalid?: TextAreaProps['isInvalid'];
|
|
24
28
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.45",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "e9f351199b26ce80ba123c66b9f3de760b9ab58c"
|
|
92
92
|
}
|