@dr.pogodin/react-utils 1.43.23 → 1.43.24

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.
@@ -1,8 +1,9 @@
1
1
  import { type ChangeEventHandler, type FocusEventHandler, type KeyboardEventHandler } from 'react';
2
2
  import { type Theme } from '@dr.pogodin/react-themes';
3
- type ThemeKeyT = 'container' | 'hidden' | 'textarea';
3
+ type ThemeKeyT = 'container' | 'hidden' | 'label' | 'textarea';
4
4
  type Props = {
5
5
  disabled?: boolean;
6
+ label?: string;
6
7
  onBlur?: FocusEventHandler<HTMLTextAreaElement>;
7
8
  onChange?: ChangeEventHandler<HTMLTextAreaElement>;
8
9
  onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
@@ -3,4 +3,5 @@ export declare const container: string;
3
3
  export declare const context: string;
4
4
  export declare const hidden: string;
5
5
  export declare const hoc: string;
6
+ export declare const label: string;
6
7
  export declare const textarea: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.43.23",
2
+ "version": "1.43.24",
3
3
  "bin": {
4
4
  "react-utils-build": "bin/build.js",
5
5
  "react-utils-setup": "bin/setup.js"
@@ -16,10 +16,12 @@ import defaultTheme from './style.scss';
16
16
  type ThemeKeyT =
17
17
  | 'container'
18
18
  | 'hidden'
19
+ | 'label'
19
20
  | 'textarea';
20
21
 
21
22
  type Props = {
22
23
  disabled?: boolean;
24
+ label?: string;
23
25
  onBlur?: FocusEventHandler<HTMLTextAreaElement>;
24
26
  onChange?: ChangeEventHandler<HTMLTextAreaElement>;
25
27
  onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
@@ -31,6 +33,7 @@ type Props = {
31
33
 
32
34
  const TextArea: FunctionComponent<Props> = ({
33
35
  disabled,
36
+ label,
34
37
  onBlur,
35
38
  onChange,
36
39
  onKeyDown,
@@ -75,6 +78,7 @@ const TextArea: FunctionComponent<Props> = ({
75
78
 
76
79
  return (
77
80
  <div className={theme.container}>
81
+ {label === undefined ? null : <div className={theme.label}>{label}</div>}
78
82
  <textarea
79
83
  className={`${theme.textarea} ${theme.hidden}`}
80
84
 
@@ -8,6 +8,10 @@
8
8
  position: relative;
9
9
  }
10
10
 
11
+ &.label {
12
+ margin: 0 0.3em;
13
+ }
14
+
11
15
  &.textarea {
12
16
  background: white;
13
17
  border: 1px solid gray;
@@ -39,7 +43,9 @@
39
43
  }
40
44
 
41
45
  &.hidden {
46
+ // NOTE: We hide it this way, as setting "display: none" will interfere
47
+ // with measurements, making the hidden input height zero.
48
+ opacity: 0;
42
49
  position: absolute;
43
- z-index: -1;
44
50
  }
45
51
  }