@uipath/apollo-wind 2.27.1 → 2.29.0
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/components/ui/index.cjs +16 -16
- package/dist/components/ui/spinner.cjs +12 -5
- package/dist/components/ui/spinner.d.ts +2 -1
- package/dist/components/ui/spinner.js +12 -5
- package/dist/components/ui/textarea.cjs +128 -4
- package/dist/components/ui/textarea.d.ts +12 -2
- package/dist/components/ui/textarea.js +129 -5
- package/dist/styles.css +10 -0
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ var __webpack_modules__ = {
|
|
|
15
15
|
"./avatar" (module) {
|
|
16
16
|
module.exports = require("./avatar.cjs");
|
|
17
17
|
},
|
|
18
|
-
"
|
|
18
|
+
"./badge" (module) {
|
|
19
19
|
module.exports = require("./badge.cjs");
|
|
20
20
|
},
|
|
21
21
|
"./breadcrumb" (module) {
|
|
@@ -27,16 +27,16 @@ var __webpack_modules__ = {
|
|
|
27
27
|
"@/components/ui/button" (module) {
|
|
28
28
|
module.exports = require("./button.cjs");
|
|
29
29
|
},
|
|
30
|
-
"
|
|
30
|
+
"./calendar" (module) {
|
|
31
31
|
module.exports = require("./calendar.cjs");
|
|
32
32
|
},
|
|
33
33
|
"./card" (module) {
|
|
34
34
|
module.exports = require("./card.cjs");
|
|
35
35
|
},
|
|
36
|
-
"
|
|
36
|
+
"./checkbox" (module) {
|
|
37
37
|
module.exports = require("./checkbox.cjs");
|
|
38
38
|
},
|
|
39
|
-
"
|
|
39
|
+
"./collapsible" (module) {
|
|
40
40
|
module.exports = require("./collapsible.cjs");
|
|
41
41
|
},
|
|
42
42
|
"./combobox" (module) {
|
|
@@ -60,7 +60,7 @@ var __webpack_modules__ = {
|
|
|
60
60
|
"./dialog" (module) {
|
|
61
61
|
module.exports = require("./dialog.cjs");
|
|
62
62
|
},
|
|
63
|
-
"
|
|
63
|
+
"./dropdown-menu" (module) {
|
|
64
64
|
module.exports = require("./dropdown-menu.cjs");
|
|
65
65
|
},
|
|
66
66
|
"./editable-cell" (module) {
|
|
@@ -78,10 +78,10 @@ var __webpack_modules__ = {
|
|
|
78
78
|
"@/components/ui/input-group" (module) {
|
|
79
79
|
module.exports = require("./input-group.cjs");
|
|
80
80
|
},
|
|
81
|
-
"
|
|
81
|
+
"./input" (module) {
|
|
82
82
|
module.exports = require("./input.cjs");
|
|
83
83
|
},
|
|
84
|
-
"
|
|
84
|
+
"./label" (module) {
|
|
85
85
|
module.exports = require("./label.cjs");
|
|
86
86
|
},
|
|
87
87
|
"./layout" (module) {
|
|
@@ -156,7 +156,7 @@ var __webpack_modules__ = {
|
|
|
156
156
|
"./toggle-group" (module) {
|
|
157
157
|
module.exports = require("./toggle-group.cjs");
|
|
158
158
|
},
|
|
159
|
-
"
|
|
159
|
+
"@/components/ui/toggle" (module) {
|
|
160
160
|
module.exports = require("./toggle.cjs");
|
|
161
161
|
},
|
|
162
162
|
"./tooltip" (module) {
|
|
@@ -247,7 +247,7 @@ var __webpack_exports__ = {};
|
|
|
247
247
|
"default"
|
|
248
248
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_avatar__rspack_import_4[__rspack_import_key];
|
|
249
249
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
250
|
-
var _badge__rspack_import_5 = __webpack_require__("
|
|
250
|
+
var _badge__rspack_import_5 = __webpack_require__("./badge");
|
|
251
251
|
var __rspack_reexport = {};
|
|
252
252
|
for(const __rspack_import_key in _badge__rspack_import_5)if ([
|
|
253
253
|
"TreeView",
|
|
@@ -275,7 +275,7 @@ var __webpack_exports__ = {};
|
|
|
275
275
|
"default"
|
|
276
276
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_button_group__rspack_import_8[__rspack_import_key];
|
|
277
277
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
278
|
-
var _calendar__rspack_import_9 = __webpack_require__("
|
|
278
|
+
var _calendar__rspack_import_9 = __webpack_require__("./calendar");
|
|
279
279
|
var __rspack_reexport = {};
|
|
280
280
|
for(const __rspack_import_key in _calendar__rspack_import_9)if ([
|
|
281
281
|
"TreeView",
|
|
@@ -289,14 +289,14 @@ var __webpack_exports__ = {};
|
|
|
289
289
|
"default"
|
|
290
290
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_card__rspack_import_10[__rspack_import_key];
|
|
291
291
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
292
|
-
var _checkbox__rspack_import_11 = __webpack_require__("
|
|
292
|
+
var _checkbox__rspack_import_11 = __webpack_require__("./checkbox");
|
|
293
293
|
var __rspack_reexport = {};
|
|
294
294
|
for(const __rspack_import_key in _checkbox__rspack_import_11)if ([
|
|
295
295
|
"TreeView",
|
|
296
296
|
"default"
|
|
297
297
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_checkbox__rspack_import_11[__rspack_import_key];
|
|
298
298
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
299
|
-
var _collapsible__rspack_import_12 = __webpack_require__("
|
|
299
|
+
var _collapsible__rspack_import_12 = __webpack_require__("./collapsible");
|
|
300
300
|
var __rspack_reexport = {};
|
|
301
301
|
for(const __rspack_import_key in _collapsible__rspack_import_12)if ([
|
|
302
302
|
"TreeView",
|
|
@@ -352,7 +352,7 @@ var __webpack_exports__ = {};
|
|
|
352
352
|
"default"
|
|
353
353
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_dialog__rspack_import_19[__rspack_import_key];
|
|
354
354
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
355
|
-
var _dropdown_menu__rspack_import_20 = __webpack_require__("
|
|
355
|
+
var _dropdown_menu__rspack_import_20 = __webpack_require__("./dropdown-menu");
|
|
356
356
|
var __rspack_reexport = {};
|
|
357
357
|
for(const __rspack_import_key in _dropdown_menu__rspack_import_20)if ([
|
|
358
358
|
"TreeView",
|
|
@@ -387,7 +387,7 @@ var __webpack_exports__ = {};
|
|
|
387
387
|
"default"
|
|
388
388
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_hover_card__rspack_import_24[__rspack_import_key];
|
|
389
389
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
390
|
-
var _input__rspack_import_25 = __webpack_require__("
|
|
390
|
+
var _input__rspack_import_25 = __webpack_require__("./input");
|
|
391
391
|
var __rspack_reexport = {};
|
|
392
392
|
for(const __rspack_import_key in _input__rspack_import_25)if ([
|
|
393
393
|
"TreeView",
|
|
@@ -401,7 +401,7 @@ var __webpack_exports__ = {};
|
|
|
401
401
|
"default"
|
|
402
402
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_input_group__rspack_import_26[__rspack_import_key];
|
|
403
403
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
404
|
-
var _label__rspack_import_27 = __webpack_require__("
|
|
404
|
+
var _label__rspack_import_27 = __webpack_require__("./label");
|
|
405
405
|
var __rspack_reexport = {};
|
|
406
406
|
for(const __rspack_import_key in _label__rspack_import_27)if ([
|
|
407
407
|
"TreeView",
|
|
@@ -569,7 +569,7 @@ var __webpack_exports__ = {};
|
|
|
569
569
|
"default"
|
|
570
570
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_textarea__rspack_import_50[__rspack_import_key];
|
|
571
571
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
572
|
-
var _toggle__rspack_import_51 = __webpack_require__("
|
|
572
|
+
var _toggle__rspack_import_51 = __webpack_require__("@/components/ui/toggle");
|
|
573
573
|
var __rspack_reexport = {};
|
|
574
574
|
for(const __rspack_import_key in _toggle__rspack_import_51)if ([
|
|
575
575
|
"TreeView",
|
|
@@ -28,24 +28,30 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
Spinner: ()=>Spinner
|
|
29
29
|
});
|
|
30
30
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
-
const external_react_namespaceObject = require("react");
|
|
32
31
|
const external_class_variance_authority_namespaceObject = require("class-variance-authority");
|
|
33
32
|
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
33
|
+
const external_react_namespaceObject = require("react");
|
|
34
34
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
35
|
-
const spinnerVariants = (0, external_class_variance_authority_namespaceObject.cva)('animate-spin
|
|
35
|
+
const spinnerVariants = (0, external_class_variance_authority_namespaceObject.cva)('animate-spin', {
|
|
36
36
|
variants: {
|
|
37
37
|
size: {
|
|
38
38
|
sm: 'h-4 w-4',
|
|
39
39
|
default: 'h-6 w-6',
|
|
40
40
|
lg: 'h-8 w-8',
|
|
41
41
|
xl: 'h-12 w-12'
|
|
42
|
+
},
|
|
43
|
+
variant: {
|
|
44
|
+
default: 'text-muted-foreground',
|
|
45
|
+
primary: 'text-primary',
|
|
46
|
+
foreground: 'text-foreground'
|
|
42
47
|
}
|
|
43
48
|
},
|
|
44
49
|
defaultVariants: {
|
|
45
|
-
size: 'default'
|
|
50
|
+
size: 'default',
|
|
51
|
+
variant: 'default'
|
|
46
52
|
}
|
|
47
53
|
});
|
|
48
|
-
const Spinner = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, size, label = 'Loading', showLabel = false, ...props }, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
54
|
+
const Spinner = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, size, variant, label = 'Loading', showLabel = false, ...props }, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
49
55
|
ref: ref,
|
|
50
56
|
role: "status",
|
|
51
57
|
"aria-label": label,
|
|
@@ -54,7 +60,8 @@ const Spinner = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ class
|
|
|
54
60
|
children: [
|
|
55
61
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Loader2, {
|
|
56
62
|
className: (0, index_cjs_namespaceObject.cn)(spinnerVariants({
|
|
57
|
-
size
|
|
63
|
+
size,
|
|
64
|
+
variant
|
|
58
65
|
}))
|
|
59
66
|
}),
|
|
60
67
|
showLabel ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
declare const spinnerVariants: (props?: ({
|
|
4
4
|
size?: "default" | "lg" | "sm" | "xl" | null | undefined;
|
|
5
|
+
variant?: "default" | "primary" | "foreground" | null | undefined;
|
|
5
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
7
|
export interface SpinnerProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof spinnerVariants> {
|
|
7
8
|
label?: string;
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
2
|
import { cva } from "class-variance-authority";
|
|
4
3
|
import { Loader2 } from "lucide-react";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
5
|
import { cn } from "../../lib/index.js";
|
|
6
|
-
const spinnerVariants = cva('animate-spin
|
|
6
|
+
const spinnerVariants = cva('animate-spin', {
|
|
7
7
|
variants: {
|
|
8
8
|
size: {
|
|
9
9
|
sm: 'h-4 w-4',
|
|
10
10
|
default: 'h-6 w-6',
|
|
11
11
|
lg: 'h-8 w-8',
|
|
12
12
|
xl: 'h-12 w-12'
|
|
13
|
+
},
|
|
14
|
+
variant: {
|
|
15
|
+
default: 'text-muted-foreground',
|
|
16
|
+
primary: 'text-primary',
|
|
17
|
+
foreground: 'text-foreground'
|
|
13
18
|
}
|
|
14
19
|
},
|
|
15
20
|
defaultVariants: {
|
|
16
|
-
size: 'default'
|
|
21
|
+
size: 'default',
|
|
22
|
+
variant: 'default'
|
|
17
23
|
}
|
|
18
24
|
});
|
|
19
|
-
const Spinner = /*#__PURE__*/ forwardRef(({ className, size, label = 'Loading', showLabel = false, ...props }, ref)=>/*#__PURE__*/ jsxs("div", {
|
|
25
|
+
const Spinner = /*#__PURE__*/ forwardRef(({ className, size, variant, label = 'Loading', showLabel = false, ...props }, ref)=>/*#__PURE__*/ jsxs("div", {
|
|
20
26
|
ref: ref,
|
|
21
27
|
role: "status",
|
|
22
28
|
"aria-label": label,
|
|
@@ -25,7 +31,8 @@ const Spinner = /*#__PURE__*/ forwardRef(({ className, size, label = 'Loading',
|
|
|
25
31
|
children: [
|
|
26
32
|
/*#__PURE__*/ jsx(Loader2, {
|
|
27
33
|
className: cn(spinnerVariants({
|
|
28
|
-
size
|
|
34
|
+
size,
|
|
35
|
+
variant
|
|
29
36
|
}))
|
|
30
37
|
}),
|
|
31
38
|
showLabel ? /*#__PURE__*/ jsx("span", {
|
|
@@ -29,11 +29,135 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
30
|
const external_react_namespaceObject = require("react");
|
|
31
31
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
function normalizeRows(value) {
|
|
33
|
+
if (void 0 === value || !Number.isFinite(value)) return;
|
|
34
|
+
return Math.max(1, Math.floor(value));
|
|
35
|
+
}
|
|
36
|
+
function measureRowMetrics(el) {
|
|
37
|
+
const styles = window.getComputedStyle(el);
|
|
38
|
+
const lineHeight = parseFloat(styles.lineHeight) || 1.2 * parseFloat(styles.fontSize) || 20;
|
|
39
|
+
const padding = parseFloat(styles.paddingTop) + parseFloat(styles.paddingBottom) || 0;
|
|
40
|
+
const border = parseFloat(styles.borderTopWidth) + parseFloat(styles.borderBottomWidth) || 0;
|
|
41
|
+
return {
|
|
42
|
+
lineHeight,
|
|
43
|
+
padding,
|
|
44
|
+
border,
|
|
45
|
+
borderBox: 'border-box' === styles.boxSizing
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function cssLength(value) {
|
|
49
|
+
if (null == value) return '';
|
|
50
|
+
return 'number' == typeof value ? `${value}px` : String(value);
|
|
51
|
+
}
|
|
52
|
+
const Textarea = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, minRows, maxRows, onChange, style, ...props }, ref)=>{
|
|
53
|
+
const { effMinRows, effMaxRows } = external_react_namespaceObject.useMemo(()=>{
|
|
54
|
+
const nMin = normalizeRows(minRows);
|
|
55
|
+
const nMax = normalizeRows(maxRows);
|
|
56
|
+
return {
|
|
57
|
+
effMinRows: void 0 !== nMin && void 0 !== nMax ? Math.min(nMin, nMax) : nMin,
|
|
58
|
+
effMaxRows: nMax
|
|
59
|
+
};
|
|
60
|
+
}, [
|
|
61
|
+
minRows,
|
|
62
|
+
maxRows
|
|
63
|
+
]);
|
|
64
|
+
const managed = void 0 !== effMinRows || void 0 !== effMaxRows;
|
|
65
|
+
const innerRef = external_react_namespaceObject.useRef(null);
|
|
66
|
+
const manuallyResized = external_react_namespaceObject.useRef(false);
|
|
67
|
+
const styleRef = external_react_namespaceObject.useRef(style);
|
|
68
|
+
styleRef.current = style;
|
|
69
|
+
const setRef = external_react_namespaceObject.useCallback((node)=>{
|
|
70
|
+
innerRef.current = node;
|
|
71
|
+
if ('function' == typeof ref) ref(node);
|
|
72
|
+
else if (ref) ref.current = node;
|
|
73
|
+
}, [
|
|
74
|
+
ref
|
|
75
|
+
]);
|
|
76
|
+
const restoreOwnedStyles = external_react_namespaceObject.useCallback((el)=>{
|
|
77
|
+
const consumer = styleRef.current;
|
|
78
|
+
el.style.height = cssLength(consumer?.height);
|
|
79
|
+
el.style.minHeight = cssLength(consumer?.minHeight);
|
|
80
|
+
el.style.overflowY = cssLength(consumer?.overflowY);
|
|
81
|
+
}, []);
|
|
82
|
+
const resize = external_react_namespaceObject.useCallback(()=>{
|
|
83
|
+
const el = innerRef.current;
|
|
84
|
+
if (!el || !managed) return;
|
|
85
|
+
const { lineHeight, padding, border, borderBox } = measureRowMetrics(el);
|
|
86
|
+
const extra = borderBox ? padding + border : 0;
|
|
87
|
+
const minHeight = void 0 !== effMinRows ? effMinRows * lineHeight + extra : 0;
|
|
88
|
+
el.style.minHeight = void 0 !== effMinRows ? `${minHeight}px` : cssLength(styleRef.current?.minHeight);
|
|
89
|
+
if (void 0 === effMaxRows || manuallyResized.current) return;
|
|
90
|
+
const maxHeight = effMaxRows * lineHeight + extra;
|
|
91
|
+
el.style.height = 'auto';
|
|
92
|
+
const contentNeeded = borderBox ? el.scrollHeight + border : Math.max(0, el.scrollHeight - padding);
|
|
93
|
+
const target = Math.min(Math.max(contentNeeded, minHeight), maxHeight);
|
|
94
|
+
el.style.height = `${target}px`;
|
|
95
|
+
el.style.overflowY = contentNeeded > maxHeight ? 'auto' : 'hidden';
|
|
96
|
+
}, [
|
|
97
|
+
managed,
|
|
98
|
+
effMinRows,
|
|
99
|
+
effMaxRows
|
|
100
|
+
]);
|
|
101
|
+
external_react_namespaceObject.useLayoutEffect(()=>{
|
|
102
|
+
resize();
|
|
103
|
+
}, [
|
|
104
|
+
resize,
|
|
105
|
+
props.value,
|
|
106
|
+
props.defaultValue
|
|
107
|
+
]);
|
|
108
|
+
external_react_namespaceObject.useLayoutEffect(()=>{
|
|
109
|
+
manuallyResized.current = false;
|
|
110
|
+
const el = innerRef.current;
|
|
111
|
+
if (!el) return;
|
|
112
|
+
if (!managed) return void restoreOwnedStyles(el);
|
|
113
|
+
if (void 0 === effMaxRows) {
|
|
114
|
+
el.style.height = cssLength(styleRef.current?.height);
|
|
115
|
+
el.style.overflowY = cssLength(styleRef.current?.overflowY);
|
|
116
|
+
}
|
|
117
|
+
resize();
|
|
118
|
+
}, [
|
|
119
|
+
managed,
|
|
120
|
+
effMaxRows,
|
|
121
|
+
resize,
|
|
122
|
+
restoreOwnedStyles
|
|
123
|
+
]);
|
|
124
|
+
external_react_namespaceObject.useLayoutEffect(()=>{
|
|
125
|
+
const el = innerRef.current;
|
|
126
|
+
if (!el || !managed || "u" < typeof ResizeObserver) return;
|
|
127
|
+
let lastWidth = el.clientWidth;
|
|
128
|
+
const observer = new ResizeObserver(()=>{
|
|
129
|
+
const width = el.clientWidth;
|
|
130
|
+
if (width !== lastWidth) {
|
|
131
|
+
lastWidth = width;
|
|
132
|
+
resize();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (void 0 === effMaxRows || manuallyResized.current) return;
|
|
136
|
+
const { lineHeight, padding, border, borderBox } = measureRowMetrics(el);
|
|
137
|
+
const maxHeight = effMaxRows * lineHeight + (borderBox ? padding + border : 0);
|
|
138
|
+
if (el.offsetHeight > maxHeight + 1) {
|
|
139
|
+
manuallyResized.current = true;
|
|
140
|
+
el.style.overflowY = cssLength(styleRef.current?.overflowY) || 'auto';
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
observer.observe(el);
|
|
144
|
+
return ()=>observer.disconnect();
|
|
145
|
+
}, [
|
|
146
|
+
managed,
|
|
147
|
+
effMaxRows,
|
|
148
|
+
resize
|
|
149
|
+
]);
|
|
150
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("textarea", {
|
|
151
|
+
className: (0, index_cjs_namespaceObject.cn)('flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-base transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', 'future:rounded-xl future:border-0 future:bg-surface-overlay future:text-sm future:placeholder:text-foreground-muted future:placeholder:font-normal future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', !managed && 'min-h-[80px]', managed && 'resize-y', className),
|
|
152
|
+
ref: setRef,
|
|
153
|
+
style: style,
|
|
154
|
+
onChange: (event)=>{
|
|
155
|
+
onChange?.(event);
|
|
156
|
+
resize();
|
|
157
|
+
},
|
|
35
158
|
...props
|
|
36
|
-
})
|
|
159
|
+
});
|
|
160
|
+
});
|
|
37
161
|
Textarea.displayName = 'Textarea';
|
|
38
162
|
exports.Textarea = __webpack_exports__.Textarea;
|
|
39
163
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export type TextareaProps = React.ComponentProps<'textarea'
|
|
3
|
-
|
|
2
|
+
export type TextareaProps = React.ComponentProps<'textarea'> & {
|
|
3
|
+
/**
|
|
4
|
+
* Minimum number of visible rows.
|
|
5
|
+
*/
|
|
6
|
+
minRows?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Enables auto-grow and sets the ceiling, in rows. The field grows with its content
|
|
9
|
+
* up to `maxRows`, then scrolls.
|
|
10
|
+
*/
|
|
11
|
+
maxRows?: number;
|
|
12
|
+
};
|
|
13
|
+
declare const Textarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
4
14
|
export { Textarea };
|
|
@@ -1,10 +1,134 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
2
|
+
import { forwardRef, useCallback, useLayoutEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { cn } from "../../lib/index.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
function normalizeRows(value) {
|
|
5
|
+
if (void 0 === value || !Number.isFinite(value)) return;
|
|
6
|
+
return Math.max(1, Math.floor(value));
|
|
7
|
+
}
|
|
8
|
+
function measureRowMetrics(el) {
|
|
9
|
+
const styles = window.getComputedStyle(el);
|
|
10
|
+
const lineHeight = parseFloat(styles.lineHeight) || 1.2 * parseFloat(styles.fontSize) || 20;
|
|
11
|
+
const padding = parseFloat(styles.paddingTop) + parseFloat(styles.paddingBottom) || 0;
|
|
12
|
+
const border = parseFloat(styles.borderTopWidth) + parseFloat(styles.borderBottomWidth) || 0;
|
|
13
|
+
return {
|
|
14
|
+
lineHeight,
|
|
15
|
+
padding,
|
|
16
|
+
border,
|
|
17
|
+
borderBox: 'border-box' === styles.boxSizing
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function cssLength(value) {
|
|
21
|
+
if (null == value) return '';
|
|
22
|
+
return 'number' == typeof value ? `${value}px` : String(value);
|
|
23
|
+
}
|
|
24
|
+
const Textarea = /*#__PURE__*/ forwardRef(({ className, minRows, maxRows, onChange, style, ...props }, ref)=>{
|
|
25
|
+
const { effMinRows, effMaxRows } = useMemo(()=>{
|
|
26
|
+
const nMin = normalizeRows(minRows);
|
|
27
|
+
const nMax = normalizeRows(maxRows);
|
|
28
|
+
return {
|
|
29
|
+
effMinRows: void 0 !== nMin && void 0 !== nMax ? Math.min(nMin, nMax) : nMin,
|
|
30
|
+
effMaxRows: nMax
|
|
31
|
+
};
|
|
32
|
+
}, [
|
|
33
|
+
minRows,
|
|
34
|
+
maxRows
|
|
35
|
+
]);
|
|
36
|
+
const managed = void 0 !== effMinRows || void 0 !== effMaxRows;
|
|
37
|
+
const innerRef = useRef(null);
|
|
38
|
+
const manuallyResized = useRef(false);
|
|
39
|
+
const styleRef = useRef(style);
|
|
40
|
+
styleRef.current = style;
|
|
41
|
+
const setRef = useCallback((node)=>{
|
|
42
|
+
innerRef.current = node;
|
|
43
|
+
if ('function' == typeof ref) ref(node);
|
|
44
|
+
else if (ref) ref.current = node;
|
|
45
|
+
}, [
|
|
46
|
+
ref
|
|
47
|
+
]);
|
|
48
|
+
const restoreOwnedStyles = useCallback((el)=>{
|
|
49
|
+
const consumer = styleRef.current;
|
|
50
|
+
el.style.height = cssLength(consumer?.height);
|
|
51
|
+
el.style.minHeight = cssLength(consumer?.minHeight);
|
|
52
|
+
el.style.overflowY = cssLength(consumer?.overflowY);
|
|
53
|
+
}, []);
|
|
54
|
+
const resize = useCallback(()=>{
|
|
55
|
+
const el = innerRef.current;
|
|
56
|
+
if (!el || !managed) return;
|
|
57
|
+
const { lineHeight, padding, border, borderBox } = measureRowMetrics(el);
|
|
58
|
+
const extra = borderBox ? padding + border : 0;
|
|
59
|
+
const minHeight = void 0 !== effMinRows ? effMinRows * lineHeight + extra : 0;
|
|
60
|
+
el.style.minHeight = void 0 !== effMinRows ? `${minHeight}px` : cssLength(styleRef.current?.minHeight);
|
|
61
|
+
if (void 0 === effMaxRows || manuallyResized.current) return;
|
|
62
|
+
const maxHeight = effMaxRows * lineHeight + extra;
|
|
63
|
+
el.style.height = 'auto';
|
|
64
|
+
const contentNeeded = borderBox ? el.scrollHeight + border : Math.max(0, el.scrollHeight - padding);
|
|
65
|
+
const target = Math.min(Math.max(contentNeeded, minHeight), maxHeight);
|
|
66
|
+
el.style.height = `${target}px`;
|
|
67
|
+
el.style.overflowY = contentNeeded > maxHeight ? 'auto' : 'hidden';
|
|
68
|
+
}, [
|
|
69
|
+
managed,
|
|
70
|
+
effMinRows,
|
|
71
|
+
effMaxRows
|
|
72
|
+
]);
|
|
73
|
+
useLayoutEffect(()=>{
|
|
74
|
+
resize();
|
|
75
|
+
}, [
|
|
76
|
+
resize,
|
|
77
|
+
props.value,
|
|
78
|
+
props.defaultValue
|
|
79
|
+
]);
|
|
80
|
+
useLayoutEffect(()=>{
|
|
81
|
+
manuallyResized.current = false;
|
|
82
|
+
const el = innerRef.current;
|
|
83
|
+
if (!el) return;
|
|
84
|
+
if (!managed) return void restoreOwnedStyles(el);
|
|
85
|
+
if (void 0 === effMaxRows) {
|
|
86
|
+
el.style.height = cssLength(styleRef.current?.height);
|
|
87
|
+
el.style.overflowY = cssLength(styleRef.current?.overflowY);
|
|
88
|
+
}
|
|
89
|
+
resize();
|
|
90
|
+
}, [
|
|
91
|
+
managed,
|
|
92
|
+
effMaxRows,
|
|
93
|
+
resize,
|
|
94
|
+
restoreOwnedStyles
|
|
95
|
+
]);
|
|
96
|
+
useLayoutEffect(()=>{
|
|
97
|
+
const el = innerRef.current;
|
|
98
|
+
if (!el || !managed || "u" < typeof ResizeObserver) return;
|
|
99
|
+
let lastWidth = el.clientWidth;
|
|
100
|
+
const observer = new ResizeObserver(()=>{
|
|
101
|
+
const width = el.clientWidth;
|
|
102
|
+
if (width !== lastWidth) {
|
|
103
|
+
lastWidth = width;
|
|
104
|
+
resize();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (void 0 === effMaxRows || manuallyResized.current) return;
|
|
108
|
+
const { lineHeight, padding, border, borderBox } = measureRowMetrics(el);
|
|
109
|
+
const maxHeight = effMaxRows * lineHeight + (borderBox ? padding + border : 0);
|
|
110
|
+
if (el.offsetHeight > maxHeight + 1) {
|
|
111
|
+
manuallyResized.current = true;
|
|
112
|
+
el.style.overflowY = cssLength(styleRef.current?.overflowY) || 'auto';
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
observer.observe(el);
|
|
116
|
+
return ()=>observer.disconnect();
|
|
117
|
+
}, [
|
|
118
|
+
managed,
|
|
119
|
+
effMaxRows,
|
|
120
|
+
resize
|
|
121
|
+
]);
|
|
122
|
+
return /*#__PURE__*/ jsx("textarea", {
|
|
123
|
+
className: cn('flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-base transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', 'future:rounded-xl future:border-0 future:bg-surface-overlay future:text-sm future:placeholder:text-foreground-muted future:placeholder:font-normal future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', !managed && 'min-h-[80px]', managed && 'resize-y', className),
|
|
124
|
+
ref: setRef,
|
|
125
|
+
style: style,
|
|
126
|
+
onChange: (event)=>{
|
|
127
|
+
onChange?.(event);
|
|
128
|
+
resize();
|
|
129
|
+
},
|
|
7
130
|
...props
|
|
8
|
-
})
|
|
131
|
+
});
|
|
132
|
+
});
|
|
9
133
|
Textarea.displayName = 'Textarea';
|
|
10
134
|
export { Textarea };
|
package/dist/styles.css
CHANGED
|
@@ -1051,6 +1051,9 @@
|
|
|
1051
1051
|
.h-72 {
|
|
1052
1052
|
height: calc(var(--spacing) * 72);
|
|
1053
1053
|
}
|
|
1054
|
+
.h-75 {
|
|
1055
|
+
height: calc(var(--spacing) * 75);
|
|
1056
|
+
}
|
|
1054
1057
|
.h-96 {
|
|
1055
1058
|
height: calc(var(--spacing) * 96);
|
|
1056
1059
|
}
|
|
@@ -1662,6 +1665,9 @@
|
|
|
1662
1665
|
.resize-none {
|
|
1663
1666
|
resize: none;
|
|
1664
1667
|
}
|
|
1668
|
+
.resize-y {
|
|
1669
|
+
resize: vertical;
|
|
1670
|
+
}
|
|
1665
1671
|
.list-inside {
|
|
1666
1672
|
list-style-position: inside;
|
|
1667
1673
|
}
|
|
@@ -4201,6 +4207,10 @@
|
|
|
4201
4207
|
--tw-blur: blur(8px);
|
|
4202
4208
|
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
4203
4209
|
}
|
|
4210
|
+
.invert {
|
|
4211
|
+
--tw-invert: invert(100%);
|
|
4212
|
+
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
4213
|
+
}
|
|
4204
4214
|
.filter {
|
|
4205
4215
|
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
4206
4216
|
}
|