@x-plat/design-system 0.5.63 → 0.5.65

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.
@@ -57,51 +57,23 @@ var clsx_default = clsx;
57
57
  var import_jsx_runtime = require("react/jsx-runtime");
58
58
  var TextArea = import_react.default.forwardRef(
59
59
  (props, ref) => {
60
- const { value, className, onChange, disabled, ...textareaProps } = props;
61
- const localRef = import_react.default.useRef(null);
62
- const setRefs = (el) => {
63
- localRef.current = el;
64
- if (!ref) return;
65
- if (typeof ref === "function") {
66
- ref(el);
67
- } else if (ref && typeof ref === "object" && "current" in ref) {
68
- ref.current = el;
69
- }
70
- };
71
- const handleOnChange = (e) => {
72
- const val = e.target.value;
73
- if (onChange) {
74
- const event = {
75
- ...e,
76
- target: { value: val }
77
- };
78
- onChange(event);
79
- }
80
- };
81
- import_react.default.useEffect(() => {
82
- const el = localRef.current;
83
- if (!el) return;
84
- el.style.height = "0px";
85
- const nextHeight = Math.min(el.scrollHeight, 400);
86
- el.style.height = `${nextHeight}px`;
87
- }, [value]);
88
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: clsx_default("lib-xplat-textarea-wrapper", className), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
89
- "div",
60
+ const {
61
+ className,
62
+ size = "md",
63
+ resize = "vertical",
64
+ rows = 3,
65
+ disabled,
66
+ ...textareaProps
67
+ } = props;
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: clsx_default("lib-xplat-textarea-wrap", className), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ "textarea",
90
70
  {
91
- className: clsx_default(
92
- "lib-xplat-textarea",
93
- disabled ? "disabled" : void 0
94
- ),
95
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
96
- "textarea",
97
- {
98
- ...textareaProps,
99
- ref: setRefs,
100
- disabled,
101
- value,
102
- onChange: handleOnChange
103
- }
104
- )
71
+ ...textareaProps,
72
+ ref,
73
+ rows,
74
+ disabled,
75
+ className: clsx_default("lib-xplat-textarea", size, disabled && "disabled"),
76
+ style: { resize }
105
77
  }
106
78
  ) });
107
79
  }
@@ -1,48 +1,46 @@
1
1
  /* src/components/TextArea/textArea.scss */
2
- .lib-xplat-textarea-wrapper {
2
+ .lib-xplat-textarea-wrap {
3
3
  display: flex;
4
4
  flex-direction: column;
5
- gap: var(--spacing-space-2);
5
+ width: 100%;
6
6
  }
7
- .lib-xplat-textarea-wrapper .lib-xplat-textarea {
8
- display: flex;
9
- align-items: center;
7
+ .lib-xplat-textarea-wrap .lib-xplat-textarea {
8
+ width: 100%;
10
9
  border: 1px solid var(--semantic-border-default);
11
10
  border-radius: var(--spacing-radius-md);
12
- min-height: var(--spacing-control-height-md);
13
- overflow: hidden;
14
11
  background-color: var(--semantic-surface-neutral-default);
15
- width: 100%;
12
+ color: var(--semantic-text-subtle);
13
+ font-family: inherit;
14
+ outline: none;
16
15
  transition: border-color 0.15s, box-shadow 0.15s;
17
16
  }
18
- .lib-xplat-textarea-wrapper .lib-xplat-textarea:hover:not(.disabled):not(:focus-within) {
17
+ .lib-xplat-textarea-wrap .lib-xplat-textarea.sm {
18
+ padding: var(--spacing-space-2) var(--spacing-space-3);
19
+ font-size: var(--semantic-typo-caption-1-r-size);
20
+ line-height: var(--semantic-typo-caption-1-r-lh);
21
+ }
22
+ .lib-xplat-textarea-wrap .lib-xplat-textarea.md {
23
+ padding: var(--spacing-space-2) var(--spacing-space-4);
24
+ font-size: var(--semantic-typo-label-2-m-size);
25
+ line-height: var(--semantic-typo-label-2-m-lh);
26
+ }
27
+ .lib-xplat-textarea-wrap .lib-xplat-textarea.lg {
28
+ padding: var(--spacing-space-3) var(--spacing-space-4);
29
+ font-size: var(--semantic-typo-label-1-m-size);
30
+ line-height: var(--semantic-typo-label-1-m-lh);
31
+ }
32
+ .lib-xplat-textarea-wrap .lib-xplat-textarea:hover:not(.disabled):not(:focus) {
19
33
  border-color: var(--semantic-border-strong);
20
34
  }
21
- .lib-xplat-textarea-wrapper .lib-xplat-textarea:focus-within {
35
+ .lib-xplat-textarea-wrap .lib-xplat-textarea:focus {
22
36
  border-color: var(--semantic-interaction-focus-ring);
23
37
  box-shadow: 0 0 0 2px var(--semantic-interaction-overlay-10);
24
38
  }
25
- .lib-xplat-textarea-wrapper .lib-xplat-textarea:has(> textarea:not(:placeholder-shown)):not(:focus-within) {
39
+ .lib-xplat-textarea-wrap .lib-xplat-textarea:not(:placeholder-shown):not(:focus) {
26
40
  border-color: var(--semantic-border-strong);
27
41
  }
28
- .lib-xplat-textarea-wrapper .lib-xplat-textarea.disabled {
42
+ .lib-xplat-textarea-wrap .lib-xplat-textarea.disabled {
29
43
  background-color: var(--semantic-surface-neutral-disabled);
30
44
  cursor: not-allowed;
31
- }
32
- .lib-xplat-textarea-wrapper .lib-xplat-textarea > textarea {
33
- border: none;
34
- outline: none;
35
- flex: 1;
36
- padding-left: var(--spacing-space-4);
37
- padding-right: var(--spacing-space-4);
38
- width: 100%;
39
- color: var(--semantic-text-subtle);
40
45
  resize: none;
41
- height: 1.5em;
42
- font-size: var(--semantic-typo-label-2-m-size);
43
- line-height: var(--semantic-typo-label-2-m-lh);
44
- font-family: inherit;
45
- }
46
- .lib-xplat-textarea-wrapper .lib-xplat-textarea > textarea:disabled {
47
- cursor: not-allowed;
48
46
  }
@@ -1,6 +1,13 @@
1
1
  import React from 'react';
2
2
  import { T as TextareaAttributes } from '../../attributes-DJIWir_0.cjs';
3
3
 
4
- declare const TextArea: React.ForwardRefExoticComponent<TextareaAttributes & React.RefAttributes<HTMLTextAreaElement>>;
4
+ type TextAreaSize = "sm" | "md" | "lg";
5
+ type TextAreaResize = "none" | "vertical" | "horizontal" | "both";
6
+ interface TextAreaProps extends Omit<TextareaAttributes, "size"> {
7
+ size?: TextAreaSize;
8
+ resize?: TextAreaResize;
9
+ rows?: number;
10
+ }
11
+ declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
5
12
 
6
13
  export { TextArea };
@@ -1,6 +1,13 @@
1
1
  import React from 'react';
2
2
  import { T as TextareaAttributes } from '../../attributes-DJIWir_0.js';
3
3
 
4
- declare const TextArea: React.ForwardRefExoticComponent<TextareaAttributes & React.RefAttributes<HTMLTextAreaElement>>;
4
+ type TextAreaSize = "sm" | "md" | "lg";
5
+ type TextAreaResize = "none" | "vertical" | "horizontal" | "both";
6
+ interface TextAreaProps extends Omit<TextareaAttributes, "size"> {
7
+ size?: TextAreaSize;
8
+ resize?: TextAreaResize;
9
+ rows?: number;
10
+ }
11
+ declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
5
12
 
6
13
  export { TextArea };
@@ -21,51 +21,23 @@ var clsx_default = clsx;
21
21
  import { jsx } from "react/jsx-runtime";
22
22
  var TextArea = React.forwardRef(
23
23
  (props, ref) => {
24
- const { value, className, onChange, disabled, ...textareaProps } = props;
25
- const localRef = React.useRef(null);
26
- const setRefs = (el) => {
27
- localRef.current = el;
28
- if (!ref) return;
29
- if (typeof ref === "function") {
30
- ref(el);
31
- } else if (ref && typeof ref === "object" && "current" in ref) {
32
- ref.current = el;
33
- }
34
- };
35
- const handleOnChange = (e) => {
36
- const val = e.target.value;
37
- if (onChange) {
38
- const event = {
39
- ...e,
40
- target: { value: val }
41
- };
42
- onChange(event);
43
- }
44
- };
45
- React.useEffect(() => {
46
- const el = localRef.current;
47
- if (!el) return;
48
- el.style.height = "0px";
49
- const nextHeight = Math.min(el.scrollHeight, 400);
50
- el.style.height = `${nextHeight}px`;
51
- }, [value]);
52
- return /* @__PURE__ */ jsx("div", { className: clsx_default("lib-xplat-textarea-wrapper", className), children: /* @__PURE__ */ jsx(
53
- "div",
24
+ const {
25
+ className,
26
+ size = "md",
27
+ resize = "vertical",
28
+ rows = 3,
29
+ disabled,
30
+ ...textareaProps
31
+ } = props;
32
+ return /* @__PURE__ */ jsx("div", { className: clsx_default("lib-xplat-textarea-wrap", className), children: /* @__PURE__ */ jsx(
33
+ "textarea",
54
34
  {
55
- className: clsx_default(
56
- "lib-xplat-textarea",
57
- disabled ? "disabled" : void 0
58
- ),
59
- children: /* @__PURE__ */ jsx(
60
- "textarea",
61
- {
62
- ...textareaProps,
63
- ref: setRefs,
64
- disabled,
65
- value,
66
- onChange: handleOnChange
67
- }
68
- )
35
+ ...textareaProps,
36
+ ref,
37
+ rows,
38
+ disabled,
39
+ className: clsx_default("lib-xplat-textarea", size, disabled && "disabled"),
40
+ style: { resize }
69
41
  }
70
42
  ) });
71
43
  }