kahuna-base-react-components 1.1.0 → 1.1.1

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/dist/types.d.ts CHANGED
@@ -123,6 +123,7 @@ interface KTextAreaProps {
123
123
  fontSize?: string;
124
124
  iconSize?: string;
125
125
  checked?: boolean;
126
+ maxHeight?: number;
126
127
  }
127
128
  declare const KTextArea: React.FC<KTextAreaProps>;
128
129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kahuna-base-react-components",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Kahuna Base React Components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -25,9 +25,13 @@ KTextAreaPrimary.args = {
25
25
  console.log("Enter is clicked and our value is:", event.currentTarget)
26
26
  }
27
27
  },
28
- rows: 4,
29
28
  placeholder: "Placeholder...",
30
- hoverBackground: "white"
29
+ hoverBackground: "white",
30
+ width: 200,
31
+ height: 20,
32
+ leftIcon: TracksIcon,
33
+ activeBackground: "#FFF"
34
+
31
35
  }
32
36
 
33
37
  export const KTextAreaLeftIcon = Template.bind({})
@@ -28,6 +28,7 @@ export interface KTextAreaProps {
28
28
  fontSize?: string
29
29
  iconSize?: string
30
30
  checked?: boolean
31
+ maxHeight?: number
31
32
  }
32
33
 
33
34
  const KTextArea: React.FC<KTextAreaProps> = (props) => {
@@ -58,7 +59,16 @@ const KTextArea: React.FC<KTextAreaProps> = (props) => {
58
59
  const border = props.border || "none"
59
60
  const fontSize = props.fontSize || "14px"
60
61
  const iconSize = props.iconSize || "20px"
61
- const rows = props.rows || 2
62
+ const rows = props.rows || 1
63
+
64
+ const autoResize = props.maxHeight && props.maxHeight !== props.height
65
+ const maxHeight = props.maxHeight || 200
66
+
67
+ const handleInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
68
+ const textarea = e.target
69
+ textarea.style.height = "auto"
70
+ textarea.style.height = `${textarea.scrollHeight}px` // Set the height to scrollHeight
71
+ }
62
72
 
63
73
  return (
64
74
  <div
@@ -89,22 +99,27 @@ const KTextArea: React.FC<KTextAreaProps> = (props) => {
89
99
  width,
90
100
  height,
91
101
  accentColor,
92
- fontSize
102
+ fontSize,
103
+ overflow: autoResize ? "hidden" : "auto",
104
+ minHeight: height,
105
+ resize: autoResize ? "none" : "vertical",
106
+ ...(autoResize && { maxHeight })
93
107
  }}
94
- rows={rows}
95
108
  value={props.value}
109
+ rows={rows}
96
110
  placeholder={props.placeholder || ""}
97
111
  disabled={disabled}
98
112
  onBlur={(event) => {
99
- console.log("onBulur", event.target.value)
100
113
  if (props.onBlur) props.onBlur(event.target.value)
101
114
  }}
102
115
  onChange={(event) => {
103
- console.log("OnChange", event.target.value)
116
+ if (autoResize) {
117
+ handleInput(event)
118
+ }
119
+
104
120
  props.onChange(event.target.value)
105
121
  }}
106
122
  onKeyDown={(event) => {
107
- console.log("OnKeyDown", event)
108
123
  if (props.onKeyDown) props.onKeyDown(event)
109
124
  }}
110
125
  />