@kopexa/input 3.0.10 → 5.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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/input-wrapper.tsx
|
|
4
|
+
import { cn } from "@kopexa/shared-utils";
|
|
5
|
+
import {
|
|
6
|
+
input,
|
|
7
|
+
inputWrapper
|
|
8
|
+
} from "@kopexa/theme";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
function InputWrapper({ className, size, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
"data-slot": "input-wrapper",
|
|
15
|
+
className: cn(input({ size }), inputWrapper({ size }), className),
|
|
16
|
+
...props
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
InputWrapper
|
|
23
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/input.tsx
|
|
4
|
+
import { ariaAttr } from "@kopexa/shared-utils";
|
|
5
|
+
import { input } from "@kopexa/theme";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var Input = (props) => {
|
|
8
|
+
const { className, size, radius, type = "text", ...rest } = props;
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
"input",
|
|
11
|
+
{
|
|
12
|
+
type,
|
|
13
|
+
"data-slot": "input",
|
|
14
|
+
"aria-readonly": ariaAttr(props.readOnly),
|
|
15
|
+
className: input({
|
|
16
|
+
className,
|
|
17
|
+
size,
|
|
18
|
+
radius
|
|
19
|
+
}),
|
|
20
|
+
...rest
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
Input
|
|
27
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/input-group.tsx
|
|
4
|
+
import { cn } from "@kopexa/shared-utils";
|
|
5
|
+
import { inputGroup } from "@kopexa/theme";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function InputGroup({ className, ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
"data-slot": "input-group",
|
|
12
|
+
className: cn(inputGroup(), className),
|
|
13
|
+
...props
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
InputGroup
|
|
20
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
InputWrapper
|
|
4
|
+
} from "./chunk-EYVXSUHW.mjs";
|
|
5
|
+
import {
|
|
6
|
+
Input
|
|
7
|
+
} from "./chunk-GMM4E7KL.mjs";
|
|
8
|
+
|
|
9
|
+
// src/search-input.tsx
|
|
10
|
+
import { CloseIcon, SearchIcon } from "@kopexa/icons";
|
|
11
|
+
import { Spinner } from "@kopexa/spinner";
|
|
12
|
+
import { useCallbackRef } from "@kopexa/use-callback-ref";
|
|
13
|
+
import { useControllableState } from "@kopexa/use-controllable-state";
|
|
14
|
+
import { useEffect } from "react";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var SearchInput = ({
|
|
17
|
+
value: valueProp,
|
|
18
|
+
defaultValue = "",
|
|
19
|
+
onChange,
|
|
20
|
+
onValueChange,
|
|
21
|
+
debounce = 300,
|
|
22
|
+
clearable = true,
|
|
23
|
+
onClear,
|
|
24
|
+
loading = false,
|
|
25
|
+
disabled,
|
|
26
|
+
...props
|
|
27
|
+
}) => {
|
|
28
|
+
const onChangeRef = useCallbackRef(onChange);
|
|
29
|
+
const onValueChangeRef = useCallbackRef(onValueChange);
|
|
30
|
+
const [value, setValue] = useControllableState({
|
|
31
|
+
value: valueProp,
|
|
32
|
+
defaultValue,
|
|
33
|
+
onChange: onChangeRef
|
|
34
|
+
// immediate callback
|
|
35
|
+
});
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!onValueChangeRef) return;
|
|
38
|
+
const id = window.setTimeout(() => {
|
|
39
|
+
onValueChangeRef(value != null ? value : "");
|
|
40
|
+
}, debounce);
|
|
41
|
+
return () => {
|
|
42
|
+
window.clearTimeout(id);
|
|
43
|
+
};
|
|
44
|
+
}, [value, debounce, onValueChangeRef]);
|
|
45
|
+
const handleClear = () => {
|
|
46
|
+
if (disabled) return;
|
|
47
|
+
onClear == null ? void 0 : onClear();
|
|
48
|
+
setValue("");
|
|
49
|
+
};
|
|
50
|
+
const handleKeyDown = (e) => {
|
|
51
|
+
if (e.key === "Escape" && value) {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
handleClear();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const handleChange = (e) => {
|
|
57
|
+
setValue(e.target.value);
|
|
58
|
+
};
|
|
59
|
+
return /* @__PURE__ */ jsxs(InputWrapper, { children: [
|
|
60
|
+
/* @__PURE__ */ jsx(SearchIcon, { "aria-hidden": "true" }),
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
Input,
|
|
63
|
+
{
|
|
64
|
+
...props,
|
|
65
|
+
role: "searchbox",
|
|
66
|
+
value,
|
|
67
|
+
onChange: handleChange,
|
|
68
|
+
onKeyDown: handleKeyDown,
|
|
69
|
+
disabled
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
loading ? /* @__PURE__ */ jsx("div", { "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ jsx(Spinner, { size: "xs" }) }) : clearable && value ? /* @__PURE__ */ jsx(
|
|
73
|
+
"button",
|
|
74
|
+
{
|
|
75
|
+
type: "button",
|
|
76
|
+
onClick: handleClear,
|
|
77
|
+
"aria-label": "Clear search",
|
|
78
|
+
disabled,
|
|
79
|
+
children: /* @__PURE__ */ jsx(CloseIcon, {})
|
|
80
|
+
}
|
|
81
|
+
) : null
|
|
82
|
+
] });
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
SearchInput
|
|
87
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
InputWrapper
|
|
4
|
+
} from "./chunk-EYVXSUHW.mjs";
|
|
5
|
+
import {
|
|
6
|
+
Input
|
|
7
|
+
} from "./chunk-GMM4E7KL.mjs";
|
|
8
|
+
|
|
9
|
+
// src/password-input.tsx
|
|
10
|
+
import { EyeIcon, EyeOffIcon } from "@kopexa/icons";
|
|
11
|
+
import { passwordInput } from "@kopexa/theme";
|
|
12
|
+
import { Tooltip } from "@kopexa/tooltip";
|
|
13
|
+
import { useState } from "react";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var PasswordInput = (props) => {
|
|
16
|
+
const {
|
|
17
|
+
className,
|
|
18
|
+
toggleLabel = "Toggle password visibility",
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
22
|
+
const styles = passwordInput();
|
|
23
|
+
return /* @__PURE__ */ jsxs(InputWrapper, { children: [
|
|
24
|
+
/* @__PURE__ */ jsx(
|
|
25
|
+
Input,
|
|
26
|
+
{
|
|
27
|
+
type: isVisible ? "text" : "password",
|
|
28
|
+
"data-slot": "input",
|
|
29
|
+
className,
|
|
30
|
+
...rest
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ jsx(Tooltip, { content: toggleLabel, children: /* @__PURE__ */ jsx(
|
|
34
|
+
"button",
|
|
35
|
+
{
|
|
36
|
+
"aria-label": toggleLabel,
|
|
37
|
+
type: "button",
|
|
38
|
+
onClick: () => setIsVisible(!isVisible),
|
|
39
|
+
className: styles.button(),
|
|
40
|
+
children: isVisible ? /* @__PURE__ */ jsx(
|
|
41
|
+
EyeOffIcon,
|
|
42
|
+
{
|
|
43
|
+
"aria-hidden": true,
|
|
44
|
+
focusable: false,
|
|
45
|
+
className: styles.icon()
|
|
46
|
+
}
|
|
47
|
+
) : /* @__PURE__ */ jsx(
|
|
48
|
+
EyeIcon,
|
|
49
|
+
{
|
|
50
|
+
"aria-hidden": true,
|
|
51
|
+
focusable: false,
|
|
52
|
+
className: styles.icon()
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
) })
|
|
57
|
+
] });
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
PasswordInput
|
|
62
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { Input, InputProps } from './input.mjs';
|
|
2
|
+
export { InputGroup, InputGroupProps } from './input-group.mjs';
|
|
3
|
+
export { InputWrapper, InputWrapperProps } from './input-wrapper.mjs';
|
|
2
4
|
export { PasswordInput, PasswordInputProps } from './password-input.mjs';
|
|
3
5
|
export { SearchInput, SearchInputProps } from './search-input.mjs';
|
|
4
6
|
import 'react/jsx-runtime';
|
|
5
7
|
import '@kopexa/theme';
|
|
6
|
-
import '@kopexa/theme/src/components/input';
|
|
7
8
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { Input, InputProps } from './input.js';
|
|
2
|
+
export { InputGroup, InputGroupProps } from './input-group.js';
|
|
3
|
+
export { InputWrapper, InputWrapperProps } from './input-wrapper.js';
|
|
2
4
|
export { PasswordInput, PasswordInputProps } from './password-input.js';
|
|
3
5
|
export { SearchInput, SearchInputProps } from './search-input.js';
|
|
4
6
|
import 'react/jsx-runtime';
|
|
5
7
|
import '@kopexa/theme';
|
|
6
|
-
import '@kopexa/theme/src/components/input';
|
|
7
8
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -22,235 +22,196 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
Input: () => Input,
|
|
25
|
+
InputGroup: () => InputGroup,
|
|
26
|
+
InputWrapper: () => InputWrapper,
|
|
25
27
|
PasswordInput: () => PasswordInput,
|
|
26
28
|
SearchInput: () => SearchInput
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(index_exports);
|
|
29
31
|
|
|
30
32
|
// src/input.tsx
|
|
31
|
-
var import_icons = require("@kopexa/icons");
|
|
32
|
-
var import_react_utils = require("@kopexa/react-utils");
|
|
33
33
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
34
|
-
var import_spinner = require("@kopexa/spinner");
|
|
35
34
|
var import_theme = require("@kopexa/theme");
|
|
36
|
-
var import_use_controllable_state = require("@kopexa/use-controllable-state");
|
|
37
|
-
var import_use_safe_layout_effect = require("@kopexa/use-safe-layout-effect");
|
|
38
|
-
var import_react = require("react");
|
|
39
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
36
|
var Input = (props) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
onClear,
|
|
55
|
-
loading,
|
|
56
|
-
isClearable: propsIsClearable,
|
|
57
|
-
...rest
|
|
58
|
-
} = props;
|
|
59
|
-
const handleValueChange = (0, import_react.useCallback)(
|
|
60
|
-
(value) => {
|
|
61
|
-
onValueChange == null ? void 0 : onValueChange(value != null ? value : "");
|
|
62
|
-
},
|
|
63
|
-
[onValueChange]
|
|
64
|
-
);
|
|
65
|
-
const [inputValue, setInputValue] = (0, import_use_controllable_state.useControllableState)({
|
|
66
|
-
value: valueProp,
|
|
67
|
-
onChange: handleValueChange,
|
|
68
|
-
defaultValue: (_a = props.defaultValue) != null ? _a : ""
|
|
69
|
-
});
|
|
70
|
-
const domRef = (0, import_react.useRef)(null);
|
|
71
|
-
const isFileTypeInput = type === "file";
|
|
72
|
-
const isClearable = !!onClear || propsIsClearable || false;
|
|
73
|
-
const isFilledByDefault = ["date", "time", "month", "week", "range"].includes(
|
|
74
|
-
type
|
|
75
|
-
);
|
|
76
|
-
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;
|
|
77
|
-
const isFilled = !(0, import_shared_utils.isEmpty)(valueProp) || isFilledByDefault || hasUploadedFiles || !!inputValue;
|
|
78
|
-
const styles = (0, import_react.useMemo)(
|
|
79
|
-
() => (0, import_theme.input)({
|
|
80
|
-
size,
|
|
81
|
-
radius,
|
|
82
|
-
isClearable
|
|
83
|
-
}),
|
|
84
|
-
[size, radius, isClearable]
|
|
85
|
-
);
|
|
86
|
-
const handleClear = (0, import_react.useCallback)(() => {
|
|
87
|
-
var _a2;
|
|
88
|
-
if (isFileTypeInput) {
|
|
89
|
-
domRef.current.value = "";
|
|
90
|
-
} else {
|
|
91
|
-
setInputValue("");
|
|
92
|
-
}
|
|
93
|
-
onClear == null ? void 0 : onClear();
|
|
94
|
-
(_a2 = domRef.current) == null ? void 0 : _a2.focus();
|
|
95
|
-
}, [setInputValue, isFileTypeInput, onClear]);
|
|
96
|
-
const end = (0, import_react.useMemo)(() => {
|
|
97
|
-
if (isClearable) {
|
|
98
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
-
"button",
|
|
100
|
-
{
|
|
101
|
-
type: "button",
|
|
102
|
-
tabIndex: -1,
|
|
103
|
-
disabled: props.disabled,
|
|
104
|
-
"aria-label": "clear input",
|
|
105
|
-
"data-slot": "clear-button",
|
|
106
|
-
className: styles.clearButton(),
|
|
107
|
-
onClick: handleClear,
|
|
108
|
-
children: endContent || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseIcon, {})
|
|
109
|
-
}
|
|
110
|
-
);
|
|
37
|
+
const { className, size, radius, type = "text", ...rest } = props;
|
|
38
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
39
|
+
"input",
|
|
40
|
+
{
|
|
41
|
+
type,
|
|
42
|
+
"data-slot": "input",
|
|
43
|
+
"aria-readonly": (0, import_shared_utils.ariaAttr)(props.readOnly),
|
|
44
|
+
className: (0, import_theme.input)({
|
|
45
|
+
className,
|
|
46
|
+
size,
|
|
47
|
+
radius
|
|
48
|
+
}),
|
|
49
|
+
...rest
|
|
111
50
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/input-group.tsx
|
|
55
|
+
var import_shared_utils2 = require("@kopexa/shared-utils");
|
|
56
|
+
var import_theme2 = require("@kopexa/theme");
|
|
57
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
58
|
+
function InputGroup({ className, ...props }) {
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
"data-slot": "input-group",
|
|
63
|
+
className: (0, import_shared_utils2.cn)((0, import_theme2.inputGroup)(), className),
|
|
64
|
+
...props
|
|
123
65
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/input-wrapper.tsx
|
|
70
|
+
var import_shared_utils3 = require("@kopexa/shared-utils");
|
|
71
|
+
var import_theme3 = require("@kopexa/theme");
|
|
72
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
73
|
+
function InputWrapper({ className, size, ...props }) {
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
131
75
|
"div",
|
|
132
76
|
{
|
|
133
|
-
className: styles.inputWrapper({
|
|
134
|
-
className: classNames == null ? void 0 : classNames.inputWrapper
|
|
135
|
-
}),
|
|
136
|
-
"data-disabled": (0, import_shared_utils.dataAttr)(props.disabled),
|
|
137
|
-
"data-readonly": (0, import_shared_utils.dataAttr)(props.readOnly),
|
|
138
|
-
"data-hidden": (0, import_shared_utils.dataAttr)(props.hidden),
|
|
139
77
|
"data-slot": "input-wrapper",
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
{
|
|
143
|
-
className: styles.innerWrapper({
|
|
144
|
-
className: classNames == null ? void 0 : classNames.innerWrapper
|
|
145
|
-
}),
|
|
146
|
-
"data-slot": "inner-wrapper",
|
|
147
|
-
children: [
|
|
148
|
-
startContent,
|
|
149
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
|
-
"input",
|
|
151
|
-
{
|
|
152
|
-
type,
|
|
153
|
-
"data-slot": "input",
|
|
154
|
-
"data-has-start-content": (0, import_shared_utils.dataAttr)(!!startContent),
|
|
155
|
-
"data-has-end-content": (0, import_shared_utils.dataAttr)(!!endContent),
|
|
156
|
-
"data-filled": (0, import_shared_utils.dataAttr)(isFilled),
|
|
157
|
-
"aria-readonly": (0, import_shared_utils.ariaAttr)(props.readOnly),
|
|
158
|
-
className: styles.input({
|
|
159
|
-
className: (0, import_shared_utils.cn)(classNames == null ? void 0 : classNames.input, className)
|
|
160
|
-
}),
|
|
161
|
-
value: inputValue,
|
|
162
|
-
onChange: (0, import_shared_utils.chain)(onChangeProp, onChange),
|
|
163
|
-
ref: (0, import_react_utils.mergeRefs)(domRef, refProp),
|
|
164
|
-
...rest
|
|
165
|
-
}
|
|
166
|
-
),
|
|
167
|
-
loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { size: "xs" }) : end
|
|
168
|
-
]
|
|
169
|
-
}
|
|
170
|
-
)
|
|
78
|
+
className: (0, import_shared_utils3.cn)((0, import_theme3.input)({ size }), (0, import_theme3.inputWrapper)({ size }), className),
|
|
79
|
+
...props
|
|
171
80
|
}
|
|
172
81
|
);
|
|
173
|
-
}
|
|
82
|
+
}
|
|
174
83
|
|
|
175
84
|
// src/password-input.tsx
|
|
176
|
-
var
|
|
177
|
-
var
|
|
85
|
+
var import_icons = require("@kopexa/icons");
|
|
86
|
+
var import_theme4 = require("@kopexa/theme");
|
|
178
87
|
var import_tooltip = require("@kopexa/tooltip");
|
|
179
|
-
var
|
|
180
|
-
var
|
|
88
|
+
var import_react = require("react");
|
|
89
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
181
90
|
var PasswordInput = (props) => {
|
|
182
91
|
const {
|
|
183
92
|
className,
|
|
184
93
|
toggleLabel = "Toggle password visibility",
|
|
185
94
|
...rest
|
|
186
95
|
} = props;
|
|
187
|
-
const [isVisible, setIsVisible] = (0,
|
|
188
|
-
const styles = (0,
|
|
189
|
-
return /* @__PURE__ */ (0,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
96
|
+
const [isVisible, setIsVisible] = (0, import_react.useState)(false);
|
|
97
|
+
const styles = (0, import_theme4.passwordInput)();
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(InputWrapper, { children: [
|
|
99
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
100
|
+
Input,
|
|
101
|
+
{
|
|
102
|
+
type: isVisible ? "text" : "password",
|
|
103
|
+
"data-slot": "input",
|
|
104
|
+
className,
|
|
105
|
+
...rest
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_tooltip.Tooltip, { content: toggleLabel, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
109
|
+
"button",
|
|
110
|
+
{
|
|
111
|
+
"aria-label": toggleLabel,
|
|
112
|
+
type: "button",
|
|
113
|
+
onClick: () => setIsVisible(!isVisible),
|
|
114
|
+
className: styles.button(),
|
|
115
|
+
children: isVisible ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
116
|
+
import_icons.EyeOffIcon,
|
|
117
|
+
{
|
|
118
|
+
"aria-hidden": true,
|
|
119
|
+
focusable: false,
|
|
120
|
+
className: styles.icon()
|
|
121
|
+
}
|
|
122
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
123
|
+
import_icons.EyeIcon,
|
|
124
|
+
{
|
|
125
|
+
"aria-hidden": true,
|
|
126
|
+
focusable: false,
|
|
127
|
+
className: styles.icon()
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
) })
|
|
132
|
+
] });
|
|
222
133
|
};
|
|
223
134
|
|
|
224
135
|
// src/search-input.tsx
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
228
|
-
var
|
|
136
|
+
var import_icons2 = require("@kopexa/icons");
|
|
137
|
+
var import_spinner = require("@kopexa/spinner");
|
|
138
|
+
var import_use_callback_ref = require("@kopexa/use-callback-ref");
|
|
139
|
+
var import_use_controllable_state = require("@kopexa/use-controllable-state");
|
|
140
|
+
var import_react2 = require("react");
|
|
141
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
229
142
|
var SearchInput = ({
|
|
230
|
-
|
|
143
|
+
value: valueProp,
|
|
144
|
+
defaultValue = "",
|
|
145
|
+
onChange,
|
|
231
146
|
onValueChange,
|
|
232
147
|
debounce = 300,
|
|
148
|
+
clearable = true,
|
|
149
|
+
onClear,
|
|
150
|
+
loading = false,
|
|
151
|
+
disabled,
|
|
233
152
|
...props
|
|
234
153
|
}) => {
|
|
235
|
-
const
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
154
|
+
const onChangeRef = (0, import_use_callback_ref.useCallbackRef)(onChange);
|
|
155
|
+
const onValueChangeRef = (0, import_use_callback_ref.useCallbackRef)(onValueChange);
|
|
156
|
+
const [value, setValue] = (0, import_use_controllable_state.useControllableState)({
|
|
157
|
+
value: valueProp,
|
|
158
|
+
defaultValue,
|
|
159
|
+
onChange: onChangeRef
|
|
160
|
+
// immediate callback
|
|
161
|
+
});
|
|
162
|
+
(0, import_react2.useEffect)(() => {
|
|
163
|
+
if (!onValueChangeRef) return;
|
|
164
|
+
const id = window.setTimeout(() => {
|
|
165
|
+
onValueChangeRef(value != null ? value : "");
|
|
166
|
+
}, debounce);
|
|
167
|
+
return () => {
|
|
168
|
+
window.clearTimeout(id);
|
|
169
|
+
};
|
|
170
|
+
}, [value, debounce, onValueChangeRef]);
|
|
171
|
+
const handleClear = () => {
|
|
172
|
+
if (disabled) return;
|
|
173
|
+
onClear == null ? void 0 : onClear();
|
|
174
|
+
setValue("");
|
|
175
|
+
};
|
|
176
|
+
const handleKeyDown = (e) => {
|
|
177
|
+
if (e.key === "Escape" && value) {
|
|
178
|
+
e.stopPropagation();
|
|
179
|
+
handleClear();
|
|
248
180
|
}
|
|
249
|
-
|
|
181
|
+
};
|
|
182
|
+
const handleChange = (e) => {
|
|
183
|
+
setValue(e.target.value);
|
|
184
|
+
};
|
|
185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(InputWrapper, { children: [
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons2.SearchIcon, { "aria-hidden": "true" }),
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
188
|
+
Input,
|
|
189
|
+
{
|
|
190
|
+
...props,
|
|
191
|
+
role: "searchbox",
|
|
192
|
+
value,
|
|
193
|
+
onChange: handleChange,
|
|
194
|
+
onKeyDown: handleKeyDown,
|
|
195
|
+
disabled
|
|
196
|
+
}
|
|
197
|
+
),
|
|
198
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_spinner.Spinner, { size: "xs" }) }) : clearable && value ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
199
|
+
"button",
|
|
200
|
+
{
|
|
201
|
+
type: "button",
|
|
202
|
+
onClick: handleClear,
|
|
203
|
+
"aria-label": "Clear search",
|
|
204
|
+
disabled,
|
|
205
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons2.CloseIcon, {})
|
|
206
|
+
}
|
|
207
|
+
) : null
|
|
208
|
+
] });
|
|
250
209
|
};
|
|
251
210
|
// Annotate the CommonJS export names for ESM import in node:
|
|
252
211
|
0 && (module.exports = {
|
|
253
212
|
Input,
|
|
213
|
+
InputGroup,
|
|
214
|
+
InputWrapper,
|
|
254
215
|
PasswordInput,
|
|
255
216
|
SearchInput
|
|
256
217
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
InputGroup
|
|
4
|
+
} from "./chunk-NMA7BIPU.mjs";
|
|
2
5
|
import {
|
|
3
6
|
PasswordInput
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-Z5QELHKG.mjs";
|
|
5
8
|
import {
|
|
6
9
|
SearchInput
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TAMOGG4C.mjs";
|
|
11
|
+
import {
|
|
12
|
+
InputWrapper
|
|
13
|
+
} from "./chunk-EYVXSUHW.mjs";
|
|
8
14
|
import {
|
|
9
15
|
Input
|
|
10
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-GMM4E7KL.mjs";
|
|
11
17
|
export {
|
|
12
18
|
Input,
|
|
19
|
+
InputGroup,
|
|
20
|
+
InputWrapper,
|
|
13
21
|
PasswordInput,
|
|
14
22
|
SearchInput
|
|
15
23
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
type InputGroupProps = ComponentProps<"div">;
|
|
5
|
+
declare function InputGroup({ className, ...props }: InputGroupProps): react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { InputGroup, type InputGroupProps };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
type InputGroupProps = ComponentProps<"div">;
|
|
5
|
+
declare function InputGroup({ className, ...props }: InputGroupProps): react_jsx_runtime.JSX.Element;
|
|
6
|
+
|
|
7
|
+
export { InputGroup, type InputGroupProps };
|