@sytechui/input 2.4.33

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.
@@ -0,0 +1,560 @@
1
+ "use client";
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/textarea.tsx
32
+ var textarea_exports = {};
33
+ __export(textarea_exports, {
34
+ default: () => textarea_default
35
+ });
36
+ module.exports = __toCommonJS(textarea_exports);
37
+ var import_shared_utils2 = require("@sytechui/shared-utils");
38
+ var import_system2 = require("@sytechui/system");
39
+ var import_react2 = require("react");
40
+ var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
41
+ var import_shared_icons = require("@sytechui/shared-icons");
42
+
43
+ // src/use-input.ts
44
+ var import_system = require("@sytechui/system");
45
+ var import_use_safe_layout_effect = require("@sytechui/use-safe-layout-effect");
46
+ var import_focus = require("@react-aria/focus");
47
+ var import_theme = require("@sytechui/theme");
48
+ var import_react_utils = require("@sytechui/react-utils");
49
+ var import_interactions = require("@react-aria/interactions");
50
+ var import_shared_utils = require("@sytechui/shared-utils");
51
+ var import_utils = require("@react-stately/utils");
52
+ var import_react = require("react");
53
+ var import_textfield = require("@react-aria/textfield");
54
+ var import_form = require("@sytechui/form");
55
+ function useInput(originalProps) {
56
+ var _a, _b, _c, _d, _e, _f, _g;
57
+ const globalContext = (0, import_system.useProviderContext)();
58
+ const { validationBehavior: formValidationBehavior } = (0, import_form.useSlottedContext)(import_form.FormContext) || {};
59
+ const [props, variantProps] = (0, import_system.mapPropsVariants)(originalProps, import_theme.input.variantKeys);
60
+ const {
61
+ ref,
62
+ as,
63
+ type,
64
+ label,
65
+ baseRef,
66
+ wrapperRef,
67
+ description,
68
+ className,
69
+ classNames,
70
+ autoFocus,
71
+ startContent,
72
+ endContent,
73
+ onClear,
74
+ onChange,
75
+ validationState,
76
+ validationBehavior = (_a = formValidationBehavior != null ? formValidationBehavior : globalContext == null ? void 0 : globalContext.validationBehavior) != null ? _a : "native",
77
+ innerWrapperRef: innerWrapperRefProp,
78
+ onValueChange = () => {
79
+ },
80
+ ...otherProps
81
+ } = props;
82
+ const handleValueChange = (0, import_react.useCallback)(
83
+ (value) => {
84
+ onValueChange(value != null ? value : "");
85
+ },
86
+ [onValueChange]
87
+ );
88
+ const [isFocusWithin, setFocusWithin] = (0, import_react.useState)(false);
89
+ const Component = as || "div";
90
+ const disableAnimation = (_c = (_b = originalProps.disableAnimation) != null ? _b : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _c : false;
91
+ const domRef = (0, import_react_utils.useDOMRef)(ref);
92
+ const baseDomRef = (0, import_react_utils.useDOMRef)(baseRef);
93
+ const inputWrapperRef = (0, import_react_utils.useDOMRef)(wrapperRef);
94
+ const innerWrapperRef = (0, import_react_utils.useDOMRef)(innerWrapperRefProp);
95
+ const [inputValue, setInputValue] = (0, import_utils.useControlledState)(
96
+ props.value,
97
+ (_d = props.defaultValue) != null ? _d : "",
98
+ handleValueChange
99
+ );
100
+ const isFileTypeInput = type === "file";
101
+ const hasUploadedFiles = ((_g = (_f = (_e = domRef == null ? void 0 : domRef.current) == null ? void 0 : _e.files) == null ? void 0 : _f.length) != null ? _g : 0) > 0;
102
+ const isFilledByDefault = ["date", "time", "month", "week", "range"].includes(type);
103
+ const isFilled = !(0, import_shared_utils.isEmpty)(inputValue) || isFilledByDefault || hasUploadedFiles;
104
+ const isFilledWithin = isFilled || isFocusWithin;
105
+ const isHiddenType = type === "hidden";
106
+ const isMultiline = originalProps.isMultiline;
107
+ const baseStyles = (0, import_theme.cn)(classNames == null ? void 0 : classNames.base, className, isFilled ? "is-filled" : "");
108
+ const handleClear = (0, import_react.useCallback)(() => {
109
+ var _a2;
110
+ if (isFileTypeInput) {
111
+ domRef.current.value = "";
112
+ } else {
113
+ setInputValue("");
114
+ }
115
+ onClear == null ? void 0 : onClear();
116
+ (_a2 = domRef.current) == null ? void 0 : _a2.focus();
117
+ }, [setInputValue, onClear, isFileTypeInput]);
118
+ (0, import_use_safe_layout_effect.useSafeLayoutEffect)(() => {
119
+ if (!domRef.current) return;
120
+ setInputValue(domRef.current.value);
121
+ }, [domRef.current]);
122
+ const {
123
+ labelProps,
124
+ inputProps,
125
+ isInvalid: isAriaInvalid,
126
+ validationErrors,
127
+ validationDetails,
128
+ descriptionProps,
129
+ errorMessageProps
130
+ } = (0, import_textfield.useTextField)(
131
+ {
132
+ ...originalProps,
133
+ validationBehavior,
134
+ autoCapitalize: originalProps.autoCapitalize,
135
+ value: inputValue,
136
+ "aria-label": originalProps.label ? originalProps["aria-label"] : (0, import_shared_utils.safeAriaLabel)(originalProps["aria-label"], originalProps.placeholder),
137
+ inputElementType: isMultiline ? "textarea" : "input",
138
+ onChange: setInputValue
139
+ },
140
+ domRef
141
+ );
142
+ if (isFileTypeInput) {
143
+ delete inputProps.value;
144
+ delete inputProps.onChange;
145
+ }
146
+ const { isFocusVisible, isFocused, focusProps } = (0, import_focus.useFocusRing)({
147
+ autoFocus,
148
+ isTextInput: true
149
+ });
150
+ const { isHovered, hoverProps } = (0, import_interactions.useHover)({ isDisabled: !!(originalProps == null ? void 0 : originalProps.isDisabled) });
151
+ const { isHovered: isLabelHovered, hoverProps: labelHoverProps } = (0, import_interactions.useHover)({
152
+ isDisabled: !!(originalProps == null ? void 0 : originalProps.isDisabled)
153
+ });
154
+ const { focusProps: clearFocusProps, isFocusVisible: isClearButtonFocusVisible } = (0, import_focus.useFocusRing)();
155
+ const { focusWithinProps } = (0, import_interactions.useFocusWithin)({
156
+ onFocusWithinChange: setFocusWithin
157
+ });
158
+ const { pressProps: clearPressProps } = (0, import_interactions.usePress)({
159
+ isDisabled: !!(originalProps == null ? void 0 : originalProps.isDisabled) || !!(originalProps == null ? void 0 : originalProps.isReadOnly),
160
+ onPress: handleClear
161
+ });
162
+ const isInvalid = validationState === "invalid" || isAriaInvalid;
163
+ const labelPlacement = (0, import_system.useLabelPlacement)({
164
+ labelPlacement: originalProps.labelPlacement,
165
+ label
166
+ });
167
+ const errorMessage = typeof props.errorMessage === "function" ? props.errorMessage({ isInvalid, validationErrors, validationDetails }) : props.errorMessage || (validationErrors == null ? void 0 : validationErrors.join(" "));
168
+ const isClearable = !!onClear || originalProps.isClearable;
169
+ const hasElements = !!label || !!description || !!errorMessage;
170
+ const hasPlaceholder = !!props.placeholder;
171
+ const hasLabel = !!label;
172
+ const hasHelper = !!description || !!errorMessage;
173
+ const isOutsideLeft = labelPlacement === "outside-left";
174
+ const isOutsideTop = labelPlacement === "outside-top";
175
+ const shouldLabelBeOutside = (
176
+ // label is outside only when some placeholder is there
177
+ labelPlacement === "outside" || // label is outside regardless of placeholder
178
+ isOutsideLeft || isOutsideTop
179
+ );
180
+ const shouldLabelBeInside = labelPlacement === "inside";
181
+ const isPlaceholderShown = domRef.current ? (!domRef.current.value || domRef.current.value === "" || !inputValue || inputValue === "") && hasPlaceholder : false;
182
+ const hasStartContent = !!startContent;
183
+ const isLabelOutside = shouldLabelBeOutside ? isOutsideLeft || isOutsideTop || hasPlaceholder || labelPlacement === "outside" && hasStartContent : false;
184
+ const isLabelOutsideAsPlaceholder = labelPlacement === "outside" && !hasPlaceholder && !hasStartContent;
185
+ const slots = (0, import_react.useMemo)(
186
+ () => (0, import_theme.input)({
187
+ ...variantProps,
188
+ isInvalid,
189
+ labelPlacement,
190
+ isClearable,
191
+ disableAnimation
192
+ }),
193
+ [
194
+ (0, import_shared_utils.objectToDeps)(variantProps),
195
+ isInvalid,
196
+ labelPlacement,
197
+ isClearable,
198
+ hasStartContent,
199
+ disableAnimation
200
+ ]
201
+ );
202
+ const getBaseProps = (0, import_react.useCallback)(
203
+ (props2 = {}) => {
204
+ return {
205
+ ref: baseDomRef,
206
+ className: slots.base({ class: baseStyles }),
207
+ "data-slot": "base",
208
+ "data-filled": (0, import_shared_utils.dataAttr)(
209
+ isFilled || hasPlaceholder || hasStartContent || isPlaceholderShown || isFileTypeInput
210
+ ),
211
+ "data-filled-within": (0, import_shared_utils.dataAttr)(
212
+ isFilledWithin || hasPlaceholder || hasStartContent || isPlaceholderShown || isFileTypeInput
213
+ ),
214
+ "data-focus-within": (0, import_shared_utils.dataAttr)(isFocusWithin),
215
+ "data-focus-visible": (0, import_shared_utils.dataAttr)(isFocusVisible),
216
+ "data-readonly": (0, import_shared_utils.dataAttr)(originalProps.isReadOnly),
217
+ "data-focus": (0, import_shared_utils.dataAttr)(isFocused),
218
+ "data-hover": (0, import_shared_utils.dataAttr)(isHovered || isLabelHovered),
219
+ "data-required": (0, import_shared_utils.dataAttr)(originalProps.isRequired),
220
+ "data-invalid": (0, import_shared_utils.dataAttr)(isInvalid),
221
+ "data-disabled": (0, import_shared_utils.dataAttr)(originalProps.isDisabled),
222
+ "data-has-elements": (0, import_shared_utils.dataAttr)(hasElements),
223
+ "data-has-helper": (0, import_shared_utils.dataAttr)(hasHelper),
224
+ "data-has-label": (0, import_shared_utils.dataAttr)(hasLabel),
225
+ "data-has-value": (0, import_shared_utils.dataAttr)(!isPlaceholderShown),
226
+ "data-hidden": (0, import_shared_utils.dataAttr)(isHiddenType),
227
+ ...focusWithinProps,
228
+ ...props2
229
+ };
230
+ },
231
+ [
232
+ slots,
233
+ baseStyles,
234
+ isFilled,
235
+ isFocused,
236
+ isHovered,
237
+ isLabelHovered,
238
+ isInvalid,
239
+ hasHelper,
240
+ hasLabel,
241
+ hasElements,
242
+ isPlaceholderShown,
243
+ hasStartContent,
244
+ isFocusWithin,
245
+ isFocusVisible,
246
+ isFilledWithin,
247
+ hasPlaceholder,
248
+ focusWithinProps,
249
+ isHiddenType,
250
+ originalProps.isReadOnly,
251
+ originalProps.isRequired,
252
+ originalProps.isDisabled
253
+ ]
254
+ );
255
+ const getLabelProps = (0, import_react.useCallback)(
256
+ (props2 = {}) => {
257
+ return {
258
+ "data-slot": "label",
259
+ className: slots.label({ class: classNames == null ? void 0 : classNames.label }),
260
+ ...(0, import_shared_utils.mergeProps)(labelProps, labelHoverProps, props2)
261
+ };
262
+ },
263
+ [slots, isLabelHovered, labelProps, classNames == null ? void 0 : classNames.label]
264
+ );
265
+ const handleKeyDown = (0, import_react.useCallback)(
266
+ (e) => {
267
+ if (e.key === "Escape" && inputValue && (isClearable || onClear) && !originalProps.isReadOnly) {
268
+ setInputValue("");
269
+ onClear == null ? void 0 : onClear();
270
+ }
271
+ },
272
+ [inputValue, setInputValue, onClear, isClearable, originalProps.isReadOnly]
273
+ );
274
+ const getInputProps = (0, import_react.useCallback)(
275
+ (props2 = {}) => {
276
+ return {
277
+ "data-slot": "input",
278
+ "data-filled": (0, import_shared_utils.dataAttr)(isFilled),
279
+ "data-filled-within": (0, import_shared_utils.dataAttr)(isFilledWithin),
280
+ "data-has-start-content": (0, import_shared_utils.dataAttr)(hasStartContent),
281
+ "data-has-end-content": (0, import_shared_utils.dataAttr)(!!endContent),
282
+ "data-type": type,
283
+ className: slots.input({
284
+ class: (0, import_theme.cn)(
285
+ classNames == null ? void 0 : classNames.input,
286
+ isFilled ? "is-filled" : "",
287
+ isMultiline ? "pe-0" : "",
288
+ type === "password" ? "[&::-ms-reveal]:hidden" : ""
289
+ )
290
+ }),
291
+ ...(0, import_shared_utils.mergeProps)(
292
+ focusProps,
293
+ inputProps,
294
+ (0, import_react_utils.filterDOMProps)(otherProps, {
295
+ enabled: true,
296
+ labelable: true,
297
+ omitEventNames: new Set(Object.keys(inputProps))
298
+ }),
299
+ props2
300
+ ),
301
+ "aria-readonly": (0, import_shared_utils.dataAttr)(originalProps.isReadOnly),
302
+ onChange: (0, import_shared_utils.chain)(inputProps.onChange, onChange),
303
+ onKeyDown: (0, import_shared_utils.chain)(inputProps.onKeyDown, props2.onKeyDown, handleKeyDown),
304
+ ref: domRef
305
+ };
306
+ },
307
+ [
308
+ slots,
309
+ inputValue,
310
+ focusProps,
311
+ inputProps,
312
+ otherProps,
313
+ isFilled,
314
+ isFilledWithin,
315
+ hasStartContent,
316
+ endContent,
317
+ classNames == null ? void 0 : classNames.input,
318
+ originalProps.isReadOnly,
319
+ originalProps.isRequired,
320
+ onChange,
321
+ handleKeyDown
322
+ ]
323
+ );
324
+ const getInputWrapperProps = (0, import_react.useCallback)(
325
+ (props2 = {}) => {
326
+ return {
327
+ ref: inputWrapperRef,
328
+ "data-slot": "input-wrapper",
329
+ "data-hover": (0, import_shared_utils.dataAttr)(isHovered || isLabelHovered),
330
+ "data-focus-visible": (0, import_shared_utils.dataAttr)(isFocusVisible),
331
+ "data-focus": (0, import_shared_utils.dataAttr)(isFocused),
332
+ className: slots.inputWrapper({
333
+ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.inputWrapper, isFilled ? "is-filled" : "")
334
+ }),
335
+ ...(0, import_shared_utils.mergeProps)(props2, hoverProps),
336
+ onClick: (e) => {
337
+ if (domRef.current && e.currentTarget === e.target) {
338
+ domRef.current.focus();
339
+ }
340
+ },
341
+ style: {
342
+ cursor: "text",
343
+ ...props2.style
344
+ }
345
+ };
346
+ },
347
+ [
348
+ slots,
349
+ isHovered,
350
+ isLabelHovered,
351
+ isFocusVisible,
352
+ isFocused,
353
+ inputValue,
354
+ classNames == null ? void 0 : classNames.inputWrapper
355
+ ]
356
+ );
357
+ const getInnerWrapperProps = (0, import_react.useCallback)(
358
+ (props2 = {}) => {
359
+ return {
360
+ ...props2,
361
+ ref: innerWrapperRef,
362
+ "data-slot": "inner-wrapper",
363
+ onClick: (e) => {
364
+ if (domRef.current && e.currentTarget === e.target) {
365
+ domRef.current.focus();
366
+ }
367
+ },
368
+ className: slots.innerWrapper({
369
+ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.innerWrapper, props2 == null ? void 0 : props2.className)
370
+ })
371
+ };
372
+ },
373
+ [slots, classNames == null ? void 0 : classNames.innerWrapper]
374
+ );
375
+ const getMainWrapperProps = (0, import_react.useCallback)(
376
+ (props2 = {}) => {
377
+ return {
378
+ ...props2,
379
+ "data-slot": "main-wrapper",
380
+ className: slots.mainWrapper({
381
+ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.mainWrapper, props2 == null ? void 0 : props2.className)
382
+ })
383
+ };
384
+ },
385
+ [slots, classNames == null ? void 0 : classNames.mainWrapper]
386
+ );
387
+ const getHelperWrapperProps = (0, import_react.useCallback)(
388
+ (props2 = {}) => {
389
+ return {
390
+ ...props2,
391
+ "data-slot": "helper-wrapper",
392
+ className: slots.helperWrapper({
393
+ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.helperWrapper, props2 == null ? void 0 : props2.className)
394
+ })
395
+ };
396
+ },
397
+ [slots, classNames == null ? void 0 : classNames.helperWrapper]
398
+ );
399
+ const getDescriptionProps = (0, import_react.useCallback)(
400
+ (props2 = {}) => {
401
+ return {
402
+ ...props2,
403
+ ...descriptionProps,
404
+ "data-slot": "description",
405
+ className: slots.description({ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.description, props2 == null ? void 0 : props2.className) })
406
+ };
407
+ },
408
+ [slots, classNames == null ? void 0 : classNames.description]
409
+ );
410
+ const getErrorMessageProps = (0, import_react.useCallback)(
411
+ (props2 = {}) => {
412
+ return {
413
+ ...props2,
414
+ ...errorMessageProps,
415
+ "data-slot": "error-message",
416
+ className: slots.errorMessage({ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.errorMessage, props2 == null ? void 0 : props2.className) })
417
+ };
418
+ },
419
+ [slots, errorMessageProps, classNames == null ? void 0 : classNames.errorMessage]
420
+ );
421
+ const getClearButtonProps = (0, import_react.useCallback)(
422
+ (props2 = {}) => {
423
+ return {
424
+ ...props2,
425
+ type: "button",
426
+ tabIndex: -1,
427
+ disabled: originalProps.isDisabled,
428
+ "aria-label": "clear input",
429
+ "data-slot": "clear-button",
430
+ "data-focus-visible": (0, import_shared_utils.dataAttr)(isClearButtonFocusVisible),
431
+ className: slots.clearButton({
432
+ class: (0, import_theme.cn)(classNames == null ? void 0 : classNames.clearButton, props2 == null ? void 0 : props2.className)
433
+ }),
434
+ ...(0, import_shared_utils.mergeProps)(clearPressProps, clearFocusProps)
435
+ };
436
+ },
437
+ [slots, isClearButtonFocusVisible, clearPressProps, clearFocusProps, classNames == null ? void 0 : classNames.clearButton]
438
+ );
439
+ return {
440
+ Component,
441
+ classNames,
442
+ domRef,
443
+ label,
444
+ description,
445
+ startContent,
446
+ endContent,
447
+ labelPlacement,
448
+ isClearable,
449
+ hasHelper,
450
+ hasStartContent,
451
+ isLabelOutside,
452
+ isOutsideLeft,
453
+ isOutsideTop,
454
+ isLabelOutsideAsPlaceholder,
455
+ shouldLabelBeOutside,
456
+ shouldLabelBeInside,
457
+ hasPlaceholder,
458
+ isInvalid,
459
+ errorMessage,
460
+ getBaseProps,
461
+ getLabelProps,
462
+ getInputProps,
463
+ getMainWrapperProps,
464
+ getInputWrapperProps,
465
+ getInnerWrapperProps,
466
+ getHelperWrapperProps,
467
+ getDescriptionProps,
468
+ getErrorMessageProps,
469
+ getClearButtonProps
470
+ };
471
+ }
472
+
473
+ // src/textarea.tsx
474
+ var import_jsx_runtime = require("react/jsx-runtime");
475
+ var Textarea = (0, import_system2.forwardRef)(
476
+ ({
477
+ style,
478
+ minRows = 3,
479
+ maxRows = 8,
480
+ cacheMeasurements = false,
481
+ disableAutosize = false,
482
+ onHeightChange,
483
+ ...otherProps
484
+ }, ref) => {
485
+ const {
486
+ Component,
487
+ label,
488
+ description,
489
+ startContent,
490
+ endContent,
491
+ hasHelper,
492
+ shouldLabelBeOutside,
493
+ shouldLabelBeInside,
494
+ isInvalid,
495
+ errorMessage,
496
+ getBaseProps,
497
+ getLabelProps,
498
+ getInputProps,
499
+ getInnerWrapperProps,
500
+ getInputWrapperProps,
501
+ getHelperWrapperProps,
502
+ getDescriptionProps,
503
+ getErrorMessageProps,
504
+ isClearable,
505
+ getClearButtonProps
506
+ } = useInput({ ...otherProps, ref, isMultiline: true });
507
+ const [hasMultipleRows, setIsHasMultipleRows] = (0, import_react2.useState)(minRows > 1);
508
+ const [isLimitReached, setIsLimitReached] = (0, import_react2.useState)(false);
509
+ const labelContent = label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { ...getLabelProps(), children: label }) : null;
510
+ const inputProps = getInputProps();
511
+ const handleHeightChange = (height, meta) => {
512
+ if (minRows === 1) {
513
+ setIsHasMultipleRows(height >= meta.rowHeight * 2);
514
+ }
515
+ if (maxRows > minRows) {
516
+ const limitReached = height >= maxRows * meta.rowHeight;
517
+ setIsLimitReached(limitReached);
518
+ }
519
+ onHeightChange == null ? void 0 : onHeightChange(height, meta);
520
+ };
521
+ const content = disableAutosize ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { ...inputProps, style: (0, import_shared_utils2.mergeProps)(inputProps.style, style != null ? style : {}) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
522
+ import_react_textarea_autosize.default,
523
+ {
524
+ ...inputProps,
525
+ cacheMeasurements,
526
+ "data-hide-scroll": (0, import_shared_utils2.dataAttr)(!isLimitReached),
527
+ maxRows,
528
+ minRows,
529
+ style: (0, import_shared_utils2.mergeProps)(inputProps.style, style != null ? style : {}),
530
+ onHeightChange: handleHeightChange
531
+ }
532
+ );
533
+ const clearButtonContent = (0, import_react2.useMemo)(() => {
534
+ return isClearable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ...getClearButtonProps(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_icons.CloseFilledIcon, {}) }) : null;
535
+ }, [isClearable, getClearButtonProps]);
536
+ const innerWrapper = (0, import_react2.useMemo)(() => {
537
+ if (startContent || endContent) {
538
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...getInnerWrapperProps(), children: [
539
+ startContent,
540
+ content,
541
+ endContent
542
+ ] });
543
+ }
544
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...getInnerWrapperProps(), children: content });
545
+ }, [startContent, inputProps, endContent, getInnerWrapperProps]);
546
+ const shouldShowError = isInvalid && errorMessage;
547
+ const hasHelperContent = shouldShowError || description;
548
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Component, { ...getBaseProps(), children: [
549
+ shouldLabelBeOutside ? labelContent : null,
550
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...getInputWrapperProps(), "data-has-multiple-rows": (0, import_shared_utils2.dataAttr)(hasMultipleRows), children: [
551
+ shouldLabelBeInside ? labelContent : null,
552
+ innerWrapper,
553
+ clearButtonContent
554
+ ] }),
555
+ hasHelper && hasHelperContent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...getHelperWrapperProps(), children: shouldShowError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...getErrorMessageProps(), children: errorMessage }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...getDescriptionProps(), children: description }) }) : null
556
+ ] });
557
+ }
558
+ );
559
+ Textarea.displayName = "HeroUI.Textarea";
560
+ var textarea_default = Textarea;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import {
3
+ textarea_default
4
+ } from "./chunk-ZTVVBFTB.mjs";
5
+ import "./chunk-6SGLJYRO.mjs";
6
+ export {
7
+ textarea_default as default
8
+ };
@@ -0,0 +1,105 @@
1
+ import * as react from 'react';
2
+ import { Ref } from 'react';
3
+ import * as _sytechui_system from '@sytechui/system';
4
+ import { HTMLHeroUIProps, PropGetter } from '@sytechui/system';
5
+ import { InputVariantProps, SlotsToClasses, InputSlots } from '@sytechui/theme';
6
+ import { AriaTextFieldProps } from '@react-types/textfield';
7
+
8
+ interface Props<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement> extends Omit<HTMLHeroUIProps<"input">, keyof InputVariantProps> {
9
+ /**
10
+ * Ref to the DOM node.
11
+ */
12
+ ref?: Ref<T>;
13
+ /**
14
+ * Ref to the container DOM node.
15
+ */
16
+ baseRef?: Ref<HTMLDivElement>;
17
+ /**
18
+ * Ref to the input wrapper DOM node.
19
+ * This is the element that wraps the input label and the innerWrapper when the labelPlacement="inside"
20
+ * and the input has start/end content.
21
+ */
22
+ wrapperRef?: Ref<HTMLDivElement>;
23
+ /**
24
+ * Ref to the input inner wrapper DOM node.
25
+ * This is the element that wraps the input and the start/end content when passed.
26
+ */
27
+ innerWrapperRef?: Ref<HTMLDivElement>;
28
+ /**
29
+ * Element to be rendered in the left side of the input.
30
+ */
31
+ startContent?: React.ReactNode;
32
+ /**
33
+ * Element to be rendered in the right side of the input.
34
+ * if you pass this prop and the `onClear` prop, the passed element
35
+ * will have the clear button props and it will be rendered instead of the
36
+ * default clear button.
37
+ */
38
+ endContent?: React.ReactNode;
39
+ /**
40
+ * Classname or List of classes to change the classNames of the element.
41
+ * if `className` is passed, it will be added to the base slot.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * <Input classNames={{
46
+ * base:"base-classes",
47
+ * label: "label-classes",
48
+ * mainWrapper: "main-wrapper-classes",
49
+ * inputWrapper: "input-wrapper-classes",
50
+ * innerWrapper: "inner-wrapper-classes",
51
+ * input: "input-classes",
52
+ * clearButton: "clear-button-classes",
53
+ * helperWrapper: "helper-wrapper-classes",
54
+ * description: "description-classes",
55
+ * errorMessage: "error-message-classes",
56
+ * }} />
57
+ * ```
58
+ */
59
+ classNames?: SlotsToClasses<InputSlots>;
60
+ /**
61
+ * Callback fired when the value is cleared.
62
+ * if you pass this prop, the clear button will be shown.
63
+ */
64
+ onClear?: () => void;
65
+ /**
66
+ * React aria onChange event.
67
+ */
68
+ onValueChange?: (value: string) => void;
69
+ }
70
+ type UseInputProps<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement> = Props<T> & Omit<AriaTextFieldProps, "onChange"> & InputVariantProps;
71
+ declare function useInput<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement>(originalProps: UseInputProps<T>): {
72
+ Component: _sytechui_system.As<any>;
73
+ classNames: SlotsToClasses<"description" | "base" | "label" | "errorMessage" | "input" | "helperWrapper" | "mainWrapper" | "inputWrapper" | "innerWrapper" | "clearButton"> | undefined;
74
+ domRef: react.RefObject<T>;
75
+ label: react.ReactNode;
76
+ description: react.ReactNode;
77
+ startContent: react.ReactNode;
78
+ endContent: react.ReactNode;
79
+ labelPlacement: "inside" | "outside" | "outside-left" | "outside-top";
80
+ isClearable: boolean | undefined;
81
+ hasHelper: boolean;
82
+ hasStartContent: boolean;
83
+ isLabelOutside: boolean;
84
+ isOutsideLeft: boolean;
85
+ isOutsideTop: boolean;
86
+ isLabelOutsideAsPlaceholder: boolean;
87
+ shouldLabelBeOutside: boolean;
88
+ shouldLabelBeInside: boolean;
89
+ hasPlaceholder: boolean;
90
+ isInvalid: boolean;
91
+ errorMessage: react.ReactNode;
92
+ getBaseProps: PropGetter;
93
+ getLabelProps: PropGetter;
94
+ getInputProps: PropGetter;
95
+ getMainWrapperProps: PropGetter;
96
+ getInputWrapperProps: PropGetter;
97
+ getInnerWrapperProps: PropGetter;
98
+ getHelperWrapperProps: PropGetter;
99
+ getDescriptionProps: PropGetter;
100
+ getErrorMessageProps: PropGetter;
101
+ getClearButtonProps: PropGetter;
102
+ };
103
+ type UseInputReturn = ReturnType<typeof useInput>;
104
+
105
+ export { type Props, type UseInputProps, type UseInputReturn, useInput };