@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.
- package/dist/chunk-EYVXSUHW.mjs +23 -0
- package/dist/chunk-GMM4E7KL.mjs +27 -0
- package/dist/chunk-NMA7BIPU.mjs +20 -0
- package/dist/chunk-TAMOGG4C.mjs +87 -0
- package/dist/chunk-Z5QELHKG.mjs +62 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +151 -190
- package/dist/index.mjs +11 -3
- package/dist/input-group.d.mts +7 -0
- package/dist/input-group.d.ts +7 -0
- package/dist/input-group.js +43 -0
- package/dist/input-group.mjs +7 -0
- package/dist/input-wrapper.d.mts +8 -0
- package/dist/input-wrapper.d.ts +8 -0
- package/dist/input-wrapper.js +43 -0
- package/dist/input-wrapper.mjs +7 -0
- package/dist/input.d.mts +2 -36
- package/dist/input.d.ts +2 -36
- package/dist/input.js +10 -133
- package/dist/input.mjs +1 -1
- package/dist/password-input.d.mts +0 -1
- package/dist/password-input.d.ts +0 -1
- package/dist/password-input.js +67 -172
- package/dist/password-input.mjs +4 -2
- package/dist/search-input.d.mts +32 -3
- package/dist/search-input.d.ts +32 -3
- package/dist/search-input.js +93 -152
- package/dist/search-input.mjs +4 -2
- package/package.json +11 -10
- package/dist/chunk-7MR6363U.mjs +0 -57
- package/dist/chunk-LWM42RB2.mjs +0 -36
- package/dist/chunk-UWFWTFM3.mjs +0 -152
package/dist/password-input.mjs
CHANGED
package/dist/search-input.d.mts
CHANGED
|
@@ -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 = "
|
|
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 };
|
package/dist/search-input.d.ts
CHANGED
|
@@ -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 = "
|
|
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 };
|
package/dist/search-input.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
"
|
|
41
|
+
"input",
|
|
133
42
|
{
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
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/
|
|
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
|
-
|
|
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
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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 = {
|
package/dist/search-input.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kopexa/input",
|
|
3
|
-
"version": "
|
|
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": "
|
|
31
|
+
"@kopexa/theme": "2.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@kopexa/shared-utils": "
|
|
35
|
-
"@kopexa/react-utils": "
|
|
36
|
-
"@kopexa/icons": "
|
|
37
|
-
"@kopexa/tooltip": "
|
|
38
|
-
"@kopexa/use-controllable-state": "
|
|
39
|
-
"@kopexa/use-safe-layout-effect": "
|
|
40
|
-
"@kopexa/spinner": "
|
|
41
|
-
"@kopexa/use-debounced-callback": "
|
|
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",
|
package/dist/chunk-7MR6363U.mjs
DELETED
|
@@ -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
|
-
};
|
package/dist/chunk-LWM42RB2.mjs
DELETED
|
@@ -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
|
-
};
|
package/dist/chunk-UWFWTFM3.mjs
DELETED
|
@@ -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
|
-
};
|