@kopexa/input 3.0.9 → 4.0.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.
@@ -1,8 +1,10 @@
1
1
  "use client";
2
+ "use client";
2
3
  import {
3
4
  PasswordInput
4
- } from "./chunk-7MR6363U.mjs";
5
- import "./chunk-UWFWTFM3.mjs";
5
+ } from "./chunk-Z5QELHKG.mjs";
6
+ import "./chunk-EYVXSUHW.mjs";
7
+ import "./chunk-GMM4E7KL.mjs";
6
8
  export {
7
9
  PasswordInput
8
10
  };
@@ -1,14 +1,43 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { InputProps } from './input.mjs';
3
3
  import '@kopexa/theme';
4
- import '@kopexa/theme/src/components/input';
5
4
  import 'react';
6
5
 
7
- type Omitted = "startContent" | "endContent" | "value" | "onValueChange" | "onChange";
6
+ type Omitted = "value" | "onChange" | "defaultValue";
8
7
  type SearchInputProps = Omit<InputProps, Omitted> & {
8
+ /**
9
+ * Controlled value. If provided, component is controlled.
10
+ */
11
+ value?: string;
12
+ /**
13
+ * Default value for uncontrolled mode.
14
+ */
15
+ defaultValue?: string;
16
+ /**
17
+ * Fires on every keystroke (immediate). Mirrors <input onChange>.
18
+ */
19
+ onChange?: (value: string) => void;
20
+ /**
21
+ * Debounced change callback (useful for queries).
22
+ */
9
23
  onValueChange?: (value: string) => void;
24
+ /**
25
+ * Debounce delay in ms for onValueChange.
26
+ */
10
27
  debounce?: number;
28
+ /**
29
+ * Show a clear button when there's a value.
30
+ */
31
+ clearable?: boolean;
32
+ /**
33
+ * Optional custom clear handler. If omitted, it just clears the value.
34
+ */
35
+ onClear?: () => void;
36
+ /**
37
+ * Show loading indicator on the right.
38
+ */
39
+ loading?: boolean;
11
40
  };
12
- declare const SearchInput: ({ defaultValue, onValueChange, debounce, ...props }: SearchInputProps) => react_jsx_runtime.JSX.Element;
41
+ declare const SearchInput: ({ value: valueProp, defaultValue, onChange, onValueChange, debounce, clearable, onClear, loading, disabled, ...props }: SearchInputProps) => react_jsx_runtime.JSX.Element;
13
42
 
14
43
  export { SearchInput, type SearchInputProps };
@@ -1,14 +1,43 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { InputProps } from './input.js';
3
3
  import '@kopexa/theme';
4
- import '@kopexa/theme/src/components/input';
5
4
  import 'react';
6
5
 
7
- type Omitted = "startContent" | "endContent" | "value" | "onValueChange" | "onChange";
6
+ type Omitted = "value" | "onChange" | "defaultValue";
8
7
  type SearchInputProps = Omit<InputProps, Omitted> & {
8
+ /**
9
+ * Controlled value. If provided, component is controlled.
10
+ */
11
+ value?: string;
12
+ /**
13
+ * Default value for uncontrolled mode.
14
+ */
15
+ defaultValue?: string;
16
+ /**
17
+ * Fires on every keystroke (immediate). Mirrors <input onChange>.
18
+ */
19
+ onChange?: (value: string) => void;
20
+ /**
21
+ * Debounced change callback (useful for queries).
22
+ */
9
23
  onValueChange?: (value: string) => void;
24
+ /**
25
+ * Debounce delay in ms for onValueChange.
26
+ */
10
27
  debounce?: number;
28
+ /**
29
+ * Show a clear button when there's a value.
30
+ */
31
+ clearable?: boolean;
32
+ /**
33
+ * Optional custom clear handler. If omitted, it just clears the value.
34
+ */
35
+ onClear?: () => void;
36
+ /**
37
+ * Show loading indicator on the right.
38
+ */
39
+ loading?: boolean;
11
40
  };
12
- declare const SearchInput: ({ defaultValue, onValueChange, debounce, ...props }: SearchInputProps) => react_jsx_runtime.JSX.Element;
41
+ declare const SearchInput: ({ value: valueProp, defaultValue, onChange, onValueChange, debounce, clearable, onClear, loading, disabled, ...props }: SearchInputProps) => react_jsx_runtime.JSX.Element;
13
42
 
14
43
  export { SearchInput, type SearchInputProps };
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  "use strict";
3
+ "use client";
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -24,178 +25,118 @@ __export(search_input_exports, {
24
25
  SearchInput: () => SearchInput
25
26
  });
26
27
  module.exports = __toCommonJS(search_input_exports);
27
- var import_icons2 = require("@kopexa/icons");
28
- var import_theme2 = require("@kopexa/theme");
29
- var import_use_debounced_callback = require("@kopexa/use-debounced-callback");
30
-
31
- // src/input.tsx
32
28
  var import_icons = require("@kopexa/icons");
33
- var import_react_utils = require("@kopexa/react-utils");
34
- var import_shared_utils = require("@kopexa/shared-utils");
35
29
  var import_spinner = require("@kopexa/spinner");
36
- var import_theme = require("@kopexa/theme");
30
+ var import_use_callback_ref = require("@kopexa/use-callback-ref");
37
31
  var import_use_controllable_state = require("@kopexa/use-controllable-state");
38
- var import_use_safe_layout_effect = require("@kopexa/use-safe-layout-effect");
39
32
  var import_react = require("react");
33
+
34
+ // src/input.tsx
35
+ var import_shared_utils = require("@kopexa/shared-utils");
36
+ var import_theme = require("@kopexa/theme");
40
37
  var import_jsx_runtime = require("react/jsx-runtime");
41
38
  var Input = (props) => {
42
- var _a, _b, _c, _d;
43
- const {
44
- className,
45
- size,
46
- radius,
47
- type = "text",
48
- startContent,
49
- endContent,
50
- classNames,
51
- value: valueProp,
52
- onChange: onChangeProp,
53
- onValueChange,
54
- ref: refProp,
55
- onClear,
56
- loading,
57
- isClearable: propsIsClearable,
58
- ...rest
59
- } = props;
60
- const handleValueChange = (0, import_react.useCallback)(
61
- (value) => {
62
- onValueChange == null ? void 0 : onValueChange(value != null ? value : "");
63
- },
64
- [onValueChange]
65
- );
66
- const [inputValue, setInputValue] = (0, import_use_controllable_state.useControllableState)({
67
- value: valueProp,
68
- onChange: handleValueChange,
69
- defaultValue: (_a = props.defaultValue) != null ? _a : ""
70
- });
71
- const domRef = (0, import_react.useRef)(null);
72
- const isFileTypeInput = type === "file";
73
- const isClearable = !!onClear || propsIsClearable || false;
74
- const isFilledByDefault = ["date", "time", "month", "week", "range"].includes(
75
- type
76
- );
77
- const hasUploadedFiles = ((_d = (_c = (_b = domRef == null ? void 0 : domRef.current) == null ? void 0 : _b.files) == null ? void 0 : _c.length) != null ? _d : 0) > 0;
78
- const isFilled = !(0, import_shared_utils.isEmpty)(valueProp) || isFilledByDefault || hasUploadedFiles || !!inputValue;
79
- const styles = (0, import_react.useMemo)(
80
- () => (0, import_theme.input)({
81
- size,
82
- radius,
83
- isClearable
84
- }),
85
- [size, radius, isClearable]
86
- );
87
- const handleClear = (0, import_react.useCallback)(() => {
88
- var _a2;
89
- if (isFileTypeInput) {
90
- domRef.current.value = "";
91
- } else {
92
- setInputValue("");
93
- }
94
- onClear == null ? void 0 : onClear();
95
- (_a2 = domRef.current) == null ? void 0 : _a2.focus();
96
- }, [setInputValue, isFileTypeInput, onClear]);
97
- const end = (0, import_react.useMemo)(() => {
98
- if (isClearable) {
99
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
100
- "button",
101
- {
102
- type: "button",
103
- tabIndex: -1,
104
- disabled: props.disabled,
105
- "aria-label": "clear input",
106
- "data-slot": "clear-button",
107
- className: styles.clearButton(),
108
- onClick: handleClear,
109
- children: endContent || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseIcon, {})
110
- }
111
- );
112
- }
113
- return endContent;
114
- }, [
115
- endContent,
116
- props == null ? void 0 : props.disabled,
117
- isClearable,
118
- styles.clearButton,
119
- handleClear
120
- ]);
121
- const onChange = (event) => {
122
- if (!isFileTypeInput) {
123
- setInputValue(event.target.value);
124
- }
125
- onChangeProp == null ? void 0 : onChangeProp(event);
126
- };
127
- (0, import_use_safe_layout_effect.useSafeLayoutEffect)(() => {
128
- if (!domRef.current) return;
129
- setInputValue(domRef.current.value);
130
- }, [domRef.current]);
39
+ const { className, size, radius, type = "text", ...rest } = props;
131
40
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
132
- "div",
41
+ "input",
133
42
  {
134
- className: styles.inputWrapper({
135
- className: classNames == null ? void 0 : classNames.inputWrapper
43
+ type,
44
+ "data-slot": "input",
45
+ "aria-readonly": (0, import_shared_utils.ariaAttr)(props.readOnly),
46
+ className: (0, import_theme.input)({
47
+ className,
48
+ size,
49
+ radius
136
50
  }),
137
- "data-disabled": (0, import_shared_utils.dataAttr)(props.disabled),
138
- "data-readonly": (0, import_shared_utils.dataAttr)(props.readOnly),
139
- "data-hidden": (0, import_shared_utils.dataAttr)(props.hidden),
140
- "data-slot": "input-wrapper",
141
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
142
- "div",
143
- {
144
- className: styles.innerWrapper({
145
- className: classNames == null ? void 0 : classNames.innerWrapper
146
- }),
147
- "data-slot": "inner-wrapper",
148
- children: [
149
- startContent,
150
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
- "input",
152
- {
153
- type,
154
- "data-slot": "input",
155
- "data-has-start-content": (0, import_shared_utils.dataAttr)(!!startContent),
156
- "data-has-end-content": (0, import_shared_utils.dataAttr)(!!endContent),
157
- "data-filled": (0, import_shared_utils.dataAttr)(isFilled),
158
- "aria-readonly": (0, import_shared_utils.ariaAttr)(props.readOnly),
159
- className: styles.input({
160
- className: (0, import_shared_utils.cn)(classNames == null ? void 0 : classNames.input, className)
161
- }),
162
- value: inputValue,
163
- onChange: (0, import_shared_utils.chain)(onChangeProp, onChange),
164
- ref: (0, import_react_utils.mergeRefs)(domRef, refProp),
165
- ...rest
166
- }
167
- ),
168
- loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { size: "xs" }) : end
169
- ]
170
- }
171
- )
51
+ ...rest
172
52
  }
173
53
  );
174
54
  };
175
55
 
176
- // src/search-input.tsx
56
+ // src/input-wrapper.tsx
57
+ var import_shared_utils2 = require("@kopexa/shared-utils");
58
+ var import_theme2 = require("@kopexa/theme");
177
59
  var import_jsx_runtime2 = require("react/jsx-runtime");
60
+ function InputWrapper({ className, size, ...props }) {
61
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
62
+ "div",
63
+ {
64
+ "data-slot": "input-wrapper",
65
+ className: (0, import_shared_utils2.cn)((0, import_theme2.input)({ size }), (0, import_theme2.inputWrapper)({ size }), className),
66
+ ...props
67
+ }
68
+ );
69
+ }
70
+
71
+ // src/search-input.tsx
72
+ var import_jsx_runtime3 = require("react/jsx-runtime");
178
73
  var SearchInput = ({
179
- defaultValue,
74
+ value: valueProp,
75
+ defaultValue = "",
76
+ onChange,
180
77
  onValueChange,
181
78
  debounce = 300,
79
+ clearable = true,
80
+ onClear,
81
+ loading = false,
82
+ disabled,
182
83
  ...props
183
84
  }) => {
184
- const styles = (0, import_theme2.passwordInput)();
185
- const debounced = (0, import_use_debounced_callback.useDebounceCallback)(
186
- (value) => onValueChange == null ? void 0 : onValueChange(value),
187
- debounce
188
- );
189
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
190
- Input,
191
- {
192
- ...props,
193
- defaultValue,
194
- onChange: (event) => debounced(event.target.value),
195
- startContent: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons2.SearchIcon, { className: styles.icon() }),
196
- isClearable: true
85
+ const onChangeRef = (0, import_use_callback_ref.useCallbackRef)(onChange);
86
+ const onValueChangeRef = (0, import_use_callback_ref.useCallbackRef)(onValueChange);
87
+ const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
88
+ value: valueProp,
89
+ defaultValue,
90
+ onChange: onChangeRef
91
+ // immediate callback
92
+ });
93
+ (0, import_react.useEffect)(() => {
94
+ if (!onValueChangeRef) return;
95
+ const id = window.setTimeout(() => {
96
+ onValueChangeRef(value != null ? value : "");
97
+ }, debounce);
98
+ return () => {
99
+ window.clearTimeout(id);
100
+ };
101
+ }, [value, debounce, onValueChangeRef]);
102
+ const handleClear = () => {
103
+ if (disabled) return;
104
+ onClear == null ? void 0 : onClear();
105
+ setValue("");
106
+ };
107
+ const handleKeyDown = (e) => {
108
+ if (e.key === "Escape" && value) {
109
+ e.stopPropagation();
110
+ handleClear();
197
111
  }
198
- );
112
+ };
113
+ const handleChange = (e) => {
114
+ setValue(e.target.value);
115
+ };
116
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(InputWrapper, { children: [
117
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons.SearchIcon, { "aria-hidden": "true" }),
118
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
119
+ Input,
120
+ {
121
+ ...props,
122
+ role: "searchbox",
123
+ value,
124
+ onChange: handleChange,
125
+ onKeyDown: handleKeyDown,
126
+ disabled
127
+ }
128
+ ),
129
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_spinner.Spinner, { size: "xs" }) }) : clearable && value ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
130
+ "button",
131
+ {
132
+ type: "button",
133
+ onClick: handleClear,
134
+ "aria-label": "Clear search",
135
+ disabled,
136
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons.CloseIcon, {})
137
+ }
138
+ ) : null
139
+ ] });
199
140
  };
200
141
  // Annotate the CommonJS export names for ESM import in node:
201
142
  0 && (module.exports = {
@@ -1,8 +1,10 @@
1
1
  "use client";
2
+ "use client";
2
3
  import {
3
4
  SearchInput
4
- } from "./chunk-LWM42RB2.mjs";
5
- import "./chunk-UWFWTFM3.mjs";
5
+ } from "./chunk-TAMOGG4C.mjs";
6
+ import "./chunk-EYVXSUHW.mjs";
7
+ import "./chunk-GMM4E7KL.mjs";
6
8
  export {
7
9
  SearchInput
8
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopexa/input",
3
- "version": "3.0.9",
3
+ "version": "4.0.0",
4
4
  "description": "A basic text input component",
5
5
  "keywords": [
6
6
  "input"
@@ -28,17 +28,18 @@
28
28
  "react": ">=19.0.0-rc.0",
29
29
  "react-dom": ">=19.0.0-rc.0",
30
30
  "motion": ">=12.23.6",
31
- "@kopexa/theme": "1.7.6"
31
+ "@kopexa/theme": "2.0.0"
32
32
  },
33
33
  "dependencies": {
34
- "@kopexa/shared-utils": "1.1.7",
35
- "@kopexa/react-utils": "2.0.8",
36
- "@kopexa/icons": "10.0.9",
37
- "@kopexa/tooltip": "6.0.6",
38
- "@kopexa/use-controllable-state": "1.1.3",
39
- "@kopexa/use-safe-layout-effect": "1.0.4",
40
- "@kopexa/spinner": "6.0.6",
41
- "@kopexa/use-debounced-callback": "1.0.4"
34
+ "@kopexa/shared-utils": "2.0.0",
35
+ "@kopexa/react-utils": "3.0.0",
36
+ "@kopexa/icons": "11.0.0",
37
+ "@kopexa/tooltip": "7.0.0",
38
+ "@kopexa/use-controllable-state": "2.0.0",
39
+ "@kopexa/use-safe-layout-effect": "2.0.0",
40
+ "@kopexa/spinner": "7.0.0",
41
+ "@kopexa/use-debounced-callback": "2.0.0",
42
+ "@kopexa/use-callback-ref": "2.0.0"
42
43
  },
43
44
  "clean-package": "../../../clean-package.config.json",
44
45
  "module": "dist/index.mjs",
@@ -1,57 +0,0 @@
1
- "use client";
2
- import {
3
- Input
4
- } from "./chunk-UWFWTFM3.mjs";
5
-
6
- // src/password-input.tsx
7
- import { EyeIcon, EyeOffIcon } from "@kopexa/icons";
8
- import { passwordInput } from "@kopexa/theme";
9
- import { Tooltip } from "@kopexa/tooltip";
10
- import { useState } from "react";
11
- import { jsx } from "react/jsx-runtime";
12
- var PasswordInput = (props) => {
13
- const {
14
- className,
15
- toggleLabel = "Toggle password visibility",
16
- ...rest
17
- } = props;
18
- const [isVisible, setIsVisible] = useState(false);
19
- const styles = passwordInput();
20
- return /* @__PURE__ */ jsx(
21
- Input,
22
- {
23
- type: isVisible ? "text" : "password",
24
- "data-slot": "input",
25
- className,
26
- endContent: /* @__PURE__ */ jsx(Tooltip, { content: toggleLabel, children: /* @__PURE__ */ jsx(
27
- "button",
28
- {
29
- "aria-label": toggleLabel,
30
- type: "button",
31
- onClick: () => setIsVisible(!isVisible),
32
- className: styles.button(),
33
- children: isVisible ? /* @__PURE__ */ jsx(
34
- EyeOffIcon,
35
- {
36
- "aria-hidden": true,
37
- focusable: false,
38
- className: styles.icon()
39
- }
40
- ) : /* @__PURE__ */ jsx(
41
- EyeIcon,
42
- {
43
- "aria-hidden": true,
44
- focusable: false,
45
- className: styles.icon()
46
- }
47
- )
48
- }
49
- ) }),
50
- ...rest
51
- }
52
- );
53
- };
54
-
55
- export {
56
- PasswordInput
57
- };
@@ -1,36 +0,0 @@
1
- "use client";
2
- import {
3
- Input
4
- } from "./chunk-UWFWTFM3.mjs";
5
-
6
- // src/search-input.tsx
7
- import { SearchIcon } from "@kopexa/icons";
8
- import { passwordInput } from "@kopexa/theme";
9
- import { useDebounceCallback } from "@kopexa/use-debounced-callback";
10
- import { jsx } from "react/jsx-runtime";
11
- var SearchInput = ({
12
- defaultValue,
13
- onValueChange,
14
- debounce = 300,
15
- ...props
16
- }) => {
17
- const styles = passwordInput();
18
- const debounced = useDebounceCallback(
19
- (value) => onValueChange == null ? void 0 : onValueChange(value),
20
- debounce
21
- );
22
- return /* @__PURE__ */ jsx(
23
- Input,
24
- {
25
- ...props,
26
- defaultValue,
27
- onChange: (event) => debounced(event.target.value),
28
- startContent: /* @__PURE__ */ jsx(SearchIcon, { className: styles.icon() }),
29
- isClearable: true
30
- }
31
- );
32
- };
33
-
34
- export {
35
- SearchInput
36
- };
@@ -1,152 +0,0 @@
1
- "use client";
2
-
3
- // src/input.tsx
4
- import { CloseIcon } from "@kopexa/icons";
5
- import { mergeRefs } from "@kopexa/react-utils";
6
- import { ariaAttr, chain, cn, dataAttr, isEmpty } from "@kopexa/shared-utils";
7
- import { Spinner } from "@kopexa/spinner";
8
- import {
9
- input
10
- } from "@kopexa/theme";
11
- import { useControllableState } from "@kopexa/use-controllable-state";
12
- import { useSafeLayoutEffect } from "@kopexa/use-safe-layout-effect";
13
- import { useCallback, useMemo, useRef } from "react";
14
- import { jsx, jsxs } from "react/jsx-runtime";
15
- var Input = (props) => {
16
- var _a, _b, _c, _d;
17
- const {
18
- className,
19
- size,
20
- radius,
21
- type = "text",
22
- startContent,
23
- endContent,
24
- classNames,
25
- value: valueProp,
26
- onChange: onChangeProp,
27
- onValueChange,
28
- ref: refProp,
29
- onClear,
30
- loading,
31
- isClearable: propsIsClearable,
32
- ...rest
33
- } = props;
34
- const handleValueChange = useCallback(
35
- (value) => {
36
- onValueChange == null ? void 0 : onValueChange(value != null ? value : "");
37
- },
38
- [onValueChange]
39
- );
40
- const [inputValue, setInputValue] = useControllableState({
41
- value: valueProp,
42
- onChange: handleValueChange,
43
- defaultValue: (_a = props.defaultValue) != null ? _a : ""
44
- });
45
- const domRef = useRef(null);
46
- const isFileTypeInput = type === "file";
47
- const isClearable = !!onClear || propsIsClearable || false;
48
- const isFilledByDefault = ["date", "time", "month", "week", "range"].includes(
49
- type
50
- );
51
- const hasUploadedFiles = ((_d = (_c = (_b = domRef == null ? void 0 : domRef.current) == null ? void 0 : _b.files) == null ? void 0 : _c.length) != null ? _d : 0) > 0;
52
- const isFilled = !isEmpty(valueProp) || isFilledByDefault || hasUploadedFiles || !!inputValue;
53
- const styles = useMemo(
54
- () => input({
55
- size,
56
- radius,
57
- isClearable
58
- }),
59
- [size, radius, isClearable]
60
- );
61
- const handleClear = useCallback(() => {
62
- var _a2;
63
- if (isFileTypeInput) {
64
- domRef.current.value = "";
65
- } else {
66
- setInputValue("");
67
- }
68
- onClear == null ? void 0 : onClear();
69
- (_a2 = domRef.current) == null ? void 0 : _a2.focus();
70
- }, [setInputValue, isFileTypeInput, onClear]);
71
- const end = useMemo(() => {
72
- if (isClearable) {
73
- return /* @__PURE__ */ jsx(
74
- "button",
75
- {
76
- type: "button",
77
- tabIndex: -1,
78
- disabled: props.disabled,
79
- "aria-label": "clear input",
80
- "data-slot": "clear-button",
81
- className: styles.clearButton(),
82
- onClick: handleClear,
83
- children: endContent || /* @__PURE__ */ jsx(CloseIcon, {})
84
- }
85
- );
86
- }
87
- return endContent;
88
- }, [
89
- endContent,
90
- props == null ? void 0 : props.disabled,
91
- isClearable,
92
- styles.clearButton,
93
- handleClear
94
- ]);
95
- const onChange = (event) => {
96
- if (!isFileTypeInput) {
97
- setInputValue(event.target.value);
98
- }
99
- onChangeProp == null ? void 0 : onChangeProp(event);
100
- };
101
- useSafeLayoutEffect(() => {
102
- if (!domRef.current) return;
103
- setInputValue(domRef.current.value);
104
- }, [domRef.current]);
105
- return /* @__PURE__ */ jsx(
106
- "div",
107
- {
108
- className: styles.inputWrapper({
109
- className: classNames == null ? void 0 : classNames.inputWrapper
110
- }),
111
- "data-disabled": dataAttr(props.disabled),
112
- "data-readonly": dataAttr(props.readOnly),
113
- "data-hidden": dataAttr(props.hidden),
114
- "data-slot": "input-wrapper",
115
- children: /* @__PURE__ */ jsxs(
116
- "div",
117
- {
118
- className: styles.innerWrapper({
119
- className: classNames == null ? void 0 : classNames.innerWrapper
120
- }),
121
- "data-slot": "inner-wrapper",
122
- children: [
123
- startContent,
124
- /* @__PURE__ */ jsx(
125
- "input",
126
- {
127
- type,
128
- "data-slot": "input",
129
- "data-has-start-content": dataAttr(!!startContent),
130
- "data-has-end-content": dataAttr(!!endContent),
131
- "data-filled": dataAttr(isFilled),
132
- "aria-readonly": ariaAttr(props.readOnly),
133
- className: styles.input({
134
- className: cn(classNames == null ? void 0 : classNames.input, className)
135
- }),
136
- value: inputValue,
137
- onChange: chain(onChangeProp, onChange),
138
- ref: mergeRefs(domRef, refProp),
139
- ...rest
140
- }
141
- ),
142
- loading ? /* @__PURE__ */ jsx(Spinner, { size: "xs" }) : end
143
- ]
144
- }
145
- )
146
- }
147
- );
148
- };
149
-
150
- export {
151
- Input
152
- };