@alxgrn/telefrag-ui 0.0.50 → 0.0.51

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.
@@ -13,6 +13,7 @@ export type InputProps = {
13
13
  limit?: number | null;
14
14
  rows?: number | null;
15
15
  autoFocus?: boolean;
16
+ autoGrow?: boolean;
16
17
  };
17
18
  declare const Input: FC<InputProps>;
18
19
  export default Input;
@@ -1,64 +1,73 @@
1
- import { jsx as a, jsxs as b } from "react/jsx-runtime";
2
- import C from "../label/Label.js";
1
+ import { jsx as o, jsxs as y } from "react/jsx-runtime";
2
+ import { useRef as j, useEffect as m } from "react";
3
+ import E from "../label/Label.js";
3
4
  import '../../../assets/Input.css';/* empty css */
4
- const I = ({
5
- id: s,
6
- type: e = "text",
7
- value: t,
8
- onChange: x,
9
- label: m,
10
- placeholder: n,
5
+ const z = ({
6
+ id: i,
7
+ type: t = "text",
8
+ value: n,
9
+ onChange: p,
10
+ label: b,
11
+ placeholder: c,
11
12
  rows: l = 5,
12
- top: p,
13
- bottom: h,
14
- autoFocus: u = !1,
15
- required: f = !1,
16
- disabled: o = !1,
17
- limit: i
13
+ top: v,
14
+ bottom: C,
15
+ autoFocus: f = !1,
16
+ autoGrow: s = !1,
17
+ required: u = !1,
18
+ disabled: a = !1,
19
+ limit: g
18
20
  }) => {
19
- const g = () => !!(f && !t.trim().length), c = () => {
20
- if (g()) return {
21
+ const r = j(null);
22
+ m(() => {
23
+ !s || !r.current || (r.current.style.minHeight = `calc(${l} * var(--alxgrn-font-size) * var(--alxgrn-line-height))`);
24
+ }, [l, r, s]), m(() => {
25
+ !s || !r.current || (r.current.style.height = "0px", r.current.style.height = r.current.scrollHeight + "px", r.current.style.overflow = "hidden");
26
+ }, [s, n, r]);
27
+ const h = () => !!(u && !n.trim().length), x = () => {
28
+ if (h()) return {
21
29
  caretColor: "var(--alxgrn-input-caret-error)",
22
30
  borderColor: "var(--alxgrn-input-border-error)",
23
31
  backgroundColor: "var(--alxgrn-input-bg-error)"
24
32
  };
25
- }, d = (r) => {
26
- i && (r = r.substring(0, i)), x(r);
33
+ }, d = (e) => {
34
+ g && (e = e.substring(0, g)), p(e);
27
35
  };
28
- return /* @__PURE__ */ a("div", { className: "FormItem", children: /* @__PURE__ */ b(
29
- C,
36
+ return /* @__PURE__ */ o("div", { className: "FormItem", children: /* @__PURE__ */ y(
37
+ E,
30
38
  {
31
- top: p,
32
- bottom: h,
33
- label: m,
34
- required: f,
35
- disabled: o,
36
- error: g(),
39
+ top: v,
40
+ bottom: C,
41
+ label: b,
42
+ required: u,
43
+ disabled: a,
44
+ error: h(),
37
45
  children: [
38
- (e === "text" || e === "password") && /* @__PURE__ */ a(
46
+ (t === "text" || t === "password") && /* @__PURE__ */ o(
39
47
  "input",
40
48
  {
41
- id: s,
42
- type: e,
43
- value: t,
44
- onChange: (r) => d(r.target.value),
45
- placeholder: n ?? void 0,
46
- style: c(),
47
- disabled: !!o,
48
- autoFocus: !!u
49
+ id: i,
50
+ type: t,
51
+ value: n,
52
+ onChange: (e) => d(e.target.value),
53
+ placeholder: c ?? void 0,
54
+ style: x(),
55
+ disabled: !!a,
56
+ autoFocus: !!f
49
57
  }
50
58
  ),
51
- e === "textarea" && /* @__PURE__ */ a(
59
+ t === "textarea" && /* @__PURE__ */ o(
52
60
  "textarea",
53
61
  {
54
- id: s,
62
+ id: i,
63
+ ref: r,
55
64
  rows: l || 5,
56
- value: t,
57
- onChange: (r) => d(r.target.value),
58
- placeholder: n ?? void 0,
59
- style: c(),
60
- disabled: !!o,
61
- autoFocus: !!u
65
+ value: n,
66
+ onChange: (e) => d(e.target.value),
67
+ placeholder: c ?? void 0,
68
+ style: x(),
69
+ disabled: !!a,
70
+ autoFocus: !!f
62
71
  }
63
72
  )
64
73
  ]
@@ -66,5 +75,5 @@ const I = ({
66
75
  ) });
67
76
  };
68
77
  export {
69
- I as default
78
+ z as default
70
79
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alxgrn/telefrag-ui",
3
3
  "description": "UI library for The Daily Telefrag project",
4
- "version": "0.0.50",
4
+ "version": "0.0.51",
5
5
  "private": false,
6
6
  "author": "Alexander Fedorov <alex@molner.ru>",
7
7
  "license": "Apache-2.0",