@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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/input-group.tsx
|
|
22
|
+
var input_group_exports = {};
|
|
23
|
+
__export(input_group_exports, {
|
|
24
|
+
InputGroup: () => InputGroup
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(input_group_exports);
|
|
27
|
+
var import_shared_utils = require("@kopexa/shared-utils");
|
|
28
|
+
var import_theme = require("@kopexa/theme");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
function InputGroup({ className, ...props }) {
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
"data-slot": "input-group",
|
|
35
|
+
className: (0, import_shared_utils.cn)((0, import_theme.inputGroup)(), className),
|
|
36
|
+
...props
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
InputGroup
|
|
43
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { InputWrapperVariantProps } from '@kopexa/theme';
|
|
3
|
+
import { ComponentProps } from 'react';
|
|
4
|
+
|
|
5
|
+
type InputWrapperProps = ComponentProps<"div"> & InputWrapperVariantProps;
|
|
6
|
+
declare function InputWrapper({ className, size, ...props }: InputWrapperProps): react_jsx_runtime.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { InputWrapper, type InputWrapperProps };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { InputWrapperVariantProps } from '@kopexa/theme';
|
|
3
|
+
import { ComponentProps } from 'react';
|
|
4
|
+
|
|
5
|
+
type InputWrapperProps = ComponentProps<"div"> & InputWrapperVariantProps;
|
|
6
|
+
declare function InputWrapper({ className, size, ...props }: InputWrapperProps): react_jsx_runtime.JSX.Element;
|
|
7
|
+
|
|
8
|
+
export { InputWrapper, type InputWrapperProps };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/input-wrapper.tsx
|
|
22
|
+
var input_wrapper_exports = {};
|
|
23
|
+
__export(input_wrapper_exports, {
|
|
24
|
+
InputWrapper: () => InputWrapper
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(input_wrapper_exports);
|
|
27
|
+
var import_shared_utils = require("@kopexa/shared-utils");
|
|
28
|
+
var import_theme = require("@kopexa/theme");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
+
function InputWrapper({ className, size, ...props }) {
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
"data-slot": "input-wrapper",
|
|
35
|
+
className: (0, import_shared_utils.cn)((0, import_theme.input)({ size }), (0, import_theme.inputWrapper)({ size }), className),
|
|
36
|
+
...props
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
InputWrapper
|
|
43
|
+
});
|
package/dist/input.d.mts
CHANGED
|
@@ -1,42 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { InputVariantProps
|
|
3
|
-
import { InputSlots } from '@kopexa/theme/src/components/input';
|
|
2
|
+
import { InputVariantProps } from '@kopexa/theme';
|
|
4
3
|
import { ComponentProps } from 'react';
|
|
5
4
|
|
|
6
|
-
type
|
|
7
|
-
type BaseProps = {
|
|
8
|
-
/**
|
|
9
|
-
* Element to be rendered in the left side of the input.
|
|
10
|
-
*/
|
|
11
|
-
startContent?: React.ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Element to be rendered in the right side of the input.
|
|
14
|
-
* if you pass this prop and the `onClear` prop, the passed element
|
|
15
|
-
* will have the clear button props and it will be rendered instead of the
|
|
16
|
-
* default clear button.
|
|
17
|
-
*/
|
|
18
|
-
endContent?: React.ReactNode;
|
|
19
|
-
/**
|
|
20
|
-
* Classname or List of classes to change the classNames of the element.
|
|
21
|
-
* if `className` is passed, it will be added to the base slot.
|
|
22
|
-
*/
|
|
23
|
-
classNames?: SlotsToClasses<InputSlots>;
|
|
24
|
-
/**
|
|
25
|
-
* Callback fired when the value is cleared.
|
|
26
|
-
* if you pass this prop, the clear button will be shown.
|
|
27
|
-
*/
|
|
28
|
-
onClear?: () => void;
|
|
29
|
-
/**
|
|
30
|
-
* React aria onChange event.
|
|
31
|
-
*/
|
|
32
|
-
onValueChange?: (value: InputValue) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Loading state of the input.
|
|
35
|
-
* If true, the input will be disabled and a loading spinner will be shown.
|
|
36
|
-
*/
|
|
37
|
-
loading?: boolean;
|
|
38
|
-
};
|
|
39
|
-
type InputProps = Omit<ComponentProps<"input">, "size"> & InputVariantProps & BaseProps;
|
|
5
|
+
type InputProps = Omit<ComponentProps<"input">, "size"> & InputVariantProps;
|
|
40
6
|
declare const Input: (props: InputProps) => react_jsx_runtime.JSX.Element;
|
|
41
7
|
|
|
42
8
|
export { Input, type InputProps };
|
package/dist/input.d.ts
CHANGED
|
@@ -1,42 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { InputVariantProps
|
|
3
|
-
import { InputSlots } from '@kopexa/theme/src/components/input';
|
|
2
|
+
import { InputVariantProps } from '@kopexa/theme';
|
|
4
3
|
import { ComponentProps } from 'react';
|
|
5
4
|
|
|
6
|
-
type
|
|
7
|
-
type BaseProps = {
|
|
8
|
-
/**
|
|
9
|
-
* Element to be rendered in the left side of the input.
|
|
10
|
-
*/
|
|
11
|
-
startContent?: React.ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Element to be rendered in the right side of the input.
|
|
14
|
-
* if you pass this prop and the `onClear` prop, the passed element
|
|
15
|
-
* will have the clear button props and it will be rendered instead of the
|
|
16
|
-
* default clear button.
|
|
17
|
-
*/
|
|
18
|
-
endContent?: React.ReactNode;
|
|
19
|
-
/**
|
|
20
|
-
* Classname or List of classes to change the classNames of the element.
|
|
21
|
-
* if `className` is passed, it will be added to the base slot.
|
|
22
|
-
*/
|
|
23
|
-
classNames?: SlotsToClasses<InputSlots>;
|
|
24
|
-
/**
|
|
25
|
-
* Callback fired when the value is cleared.
|
|
26
|
-
* if you pass this prop, the clear button will be shown.
|
|
27
|
-
*/
|
|
28
|
-
onClear?: () => void;
|
|
29
|
-
/**
|
|
30
|
-
* React aria onChange event.
|
|
31
|
-
*/
|
|
32
|
-
onValueChange?: (value: InputValue) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Loading state of the input.
|
|
35
|
-
* If true, the input will be disabled and a loading spinner will be shown.
|
|
36
|
-
*/
|
|
37
|
-
loading?: boolean;
|
|
38
|
-
};
|
|
39
|
-
type InputProps = Omit<ComponentProps<"input">, "size"> & InputVariantProps & BaseProps;
|
|
5
|
+
type InputProps = Omit<ComponentProps<"input">, "size"> & InputVariantProps;
|
|
40
6
|
declare const Input: (props: InputProps) => react_jsx_runtime.JSX.Element;
|
|
41
7
|
|
|
42
8
|
export { Input, type InputProps };
|
package/dist/input.js
CHANGED
|
@@ -24,146 +24,23 @@ __export(input_exports, {
|
|
|
24
24
|
Input: () => Input
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(input_exports);
|
|
27
|
-
var import_icons = require("@kopexa/icons");
|
|
28
|
-
var import_react_utils = require("@kopexa/react-utils");
|
|
29
27
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
30
|
-
var import_spinner = require("@kopexa/spinner");
|
|
31
28
|
var import_theme = require("@kopexa/theme");
|
|
32
|
-
var import_use_controllable_state = require("@kopexa/use-controllable-state");
|
|
33
|
-
var import_use_safe_layout_effect = require("@kopexa/use-safe-layout-effect");
|
|
34
|
-
var import_react = require("react");
|
|
35
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
30
|
var Input = (props) => {
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
className,
|
|
40
|
-
size,
|
|
41
|
-
radius,
|
|
42
|
-
type = "text",
|
|
43
|
-
startContent,
|
|
44
|
-
endContent,
|
|
45
|
-
classNames,
|
|
46
|
-
value: valueProp,
|
|
47
|
-
onChange: onChangeProp,
|
|
48
|
-
onValueChange,
|
|
49
|
-
ref: refProp,
|
|
50
|
-
onClear,
|
|
51
|
-
loading,
|
|
52
|
-
isClearable: propsIsClearable,
|
|
53
|
-
...rest
|
|
54
|
-
} = props;
|
|
55
|
-
const handleValueChange = (0, import_react.useCallback)(
|
|
56
|
-
(value) => {
|
|
57
|
-
onValueChange == null ? void 0 : onValueChange(value != null ? value : "");
|
|
58
|
-
},
|
|
59
|
-
[onValueChange]
|
|
60
|
-
);
|
|
61
|
-
const [inputValue, setInputValue] = (0, import_use_controllable_state.useControllableState)({
|
|
62
|
-
value: valueProp,
|
|
63
|
-
onChange: handleValueChange,
|
|
64
|
-
defaultValue: (_a = props.defaultValue) != null ? _a : ""
|
|
65
|
-
});
|
|
66
|
-
const domRef = (0, import_react.useRef)(null);
|
|
67
|
-
const isFileTypeInput = type === "file";
|
|
68
|
-
const isClearable = !!onClear || propsIsClearable || false;
|
|
69
|
-
const isFilledByDefault = ["date", "time", "month", "week", "range"].includes(
|
|
70
|
-
type
|
|
71
|
-
);
|
|
72
|
-
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;
|
|
73
|
-
const isFilled = !(0, import_shared_utils.isEmpty)(valueProp) || isFilledByDefault || hasUploadedFiles || !!inputValue;
|
|
74
|
-
const styles = (0, import_react.useMemo)(
|
|
75
|
-
() => (0, import_theme.input)({
|
|
76
|
-
size,
|
|
77
|
-
radius,
|
|
78
|
-
isClearable
|
|
79
|
-
}),
|
|
80
|
-
[size, radius, isClearable]
|
|
81
|
-
);
|
|
82
|
-
const handleClear = (0, import_react.useCallback)(() => {
|
|
83
|
-
var _a2;
|
|
84
|
-
if (isFileTypeInput) {
|
|
85
|
-
domRef.current.value = "";
|
|
86
|
-
} else {
|
|
87
|
-
setInputValue("");
|
|
88
|
-
}
|
|
89
|
-
onClear == null ? void 0 : onClear();
|
|
90
|
-
(_a2 = domRef.current) == null ? void 0 : _a2.focus();
|
|
91
|
-
}, [setInputValue, isFileTypeInput, onClear]);
|
|
92
|
-
const end = (0, import_react.useMemo)(() => {
|
|
93
|
-
if (isClearable) {
|
|
94
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
95
|
-
"button",
|
|
96
|
-
{
|
|
97
|
-
type: "button",
|
|
98
|
-
tabIndex: -1,
|
|
99
|
-
disabled: props.disabled,
|
|
100
|
-
"aria-label": "clear input",
|
|
101
|
-
"data-slot": "clear-button",
|
|
102
|
-
className: styles.clearButton(),
|
|
103
|
-
onClick: handleClear,
|
|
104
|
-
children: endContent || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseIcon, {})
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
return endContent;
|
|
109
|
-
}, [
|
|
110
|
-
endContent,
|
|
111
|
-
props == null ? void 0 : props.disabled,
|
|
112
|
-
isClearable,
|
|
113
|
-
styles.clearButton,
|
|
114
|
-
handleClear
|
|
115
|
-
]);
|
|
116
|
-
const onChange = (event) => {
|
|
117
|
-
if (!isFileTypeInput) {
|
|
118
|
-
setInputValue(event.target.value);
|
|
119
|
-
}
|
|
120
|
-
onChangeProp == null ? void 0 : onChangeProp(event);
|
|
121
|
-
};
|
|
122
|
-
(0, import_use_safe_layout_effect.useSafeLayoutEffect)(() => {
|
|
123
|
-
if (!domRef.current) return;
|
|
124
|
-
setInputValue(domRef.current.value);
|
|
125
|
-
}, [domRef.current]);
|
|
31
|
+
const { className, size, radius, type = "text", ...rest } = props;
|
|
126
32
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
-
"
|
|
33
|
+
"input",
|
|
128
34
|
{
|
|
129
|
-
|
|
130
|
-
|
|
35
|
+
type,
|
|
36
|
+
"data-slot": "input",
|
|
37
|
+
"aria-readonly": (0, import_shared_utils.ariaAttr)(props.readOnly),
|
|
38
|
+
className: (0, import_theme.input)({
|
|
39
|
+
className,
|
|
40
|
+
size,
|
|
41
|
+
radius
|
|
131
42
|
}),
|
|
132
|
-
|
|
133
|
-
"data-readonly": (0, import_shared_utils.dataAttr)(props.readOnly),
|
|
134
|
-
"data-hidden": (0, import_shared_utils.dataAttr)(props.hidden),
|
|
135
|
-
"data-slot": "input-wrapper",
|
|
136
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
137
|
-
"div",
|
|
138
|
-
{
|
|
139
|
-
className: styles.innerWrapper({
|
|
140
|
-
className: classNames == null ? void 0 : classNames.innerWrapper
|
|
141
|
-
}),
|
|
142
|
-
"data-slot": "inner-wrapper",
|
|
143
|
-
children: [
|
|
144
|
-
startContent,
|
|
145
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
146
|
-
"input",
|
|
147
|
-
{
|
|
148
|
-
type,
|
|
149
|
-
"data-slot": "input",
|
|
150
|
-
"data-has-start-content": (0, import_shared_utils.dataAttr)(!!startContent),
|
|
151
|
-
"data-has-end-content": (0, import_shared_utils.dataAttr)(!!endContent),
|
|
152
|
-
"data-filled": (0, import_shared_utils.dataAttr)(isFilled),
|
|
153
|
-
"aria-readonly": (0, import_shared_utils.ariaAttr)(props.readOnly),
|
|
154
|
-
className: styles.input({
|
|
155
|
-
className: (0, import_shared_utils.cn)(classNames == null ? void 0 : classNames.input, className)
|
|
156
|
-
}),
|
|
157
|
-
value: inputValue,
|
|
158
|
-
onChange: (0, import_shared_utils.chain)(onChangeProp, onChange),
|
|
159
|
-
ref: (0, import_react_utils.mergeRefs)(domRef, refProp),
|
|
160
|
-
...rest
|
|
161
|
-
}
|
|
162
|
-
),
|
|
163
|
-
loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { size: "xs" }) : end
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
)
|
|
43
|
+
...rest
|
|
167
44
|
}
|
|
168
45
|
);
|
|
169
46
|
};
|
package/dist/input.mjs
CHANGED
package/dist/password-input.d.ts
CHANGED
package/dist/password-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,199 +25,93 @@ __export(password_input_exports, {
|
|
|
24
25
|
PasswordInput: () => PasswordInput
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(password_input_exports);
|
|
27
|
-
var
|
|
28
|
-
var
|
|
28
|
+
var import_icons = require("@kopexa/icons");
|
|
29
|
+
var import_theme3 = require("@kopexa/theme");
|
|
29
30
|
var import_tooltip = require("@kopexa/tooltip");
|
|
30
|
-
var
|
|
31
|
+
var import_react = require("react");
|
|
31
32
|
|
|
32
33
|
// src/input.tsx
|
|
33
|
-
var import_icons = require("@kopexa/icons");
|
|
34
|
-
var import_react_utils = require("@kopexa/react-utils");
|
|
35
34
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
36
|
-
var import_spinner = require("@kopexa/spinner");
|
|
37
35
|
var import_theme = require("@kopexa/theme");
|
|
38
|
-
var import_use_controllable_state = require("@kopexa/use-controllable-state");
|
|
39
|
-
var import_use_safe_layout_effect = require("@kopexa/use-safe-layout-effect");
|
|
40
|
-
var import_react = require("react");
|
|
41
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
37
|
var Input = (props) => {
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
className,
|
|
46
|
-
size,
|
|
47
|
-
radius,
|
|
48
|
-
type = "text",
|
|
49
|
-
startContent,
|
|
50
|
-
endContent,
|
|
51
|
-
classNames,
|
|
52
|
-
value: valueProp,
|
|
53
|
-
onChange: onChangeProp,
|
|
54
|
-
onValueChange,
|
|
55
|
-
ref: refProp,
|
|
56
|
-
onClear,
|
|
57
|
-
loading,
|
|
58
|
-
isClearable: propsIsClearable,
|
|
59
|
-
...rest
|
|
60
|
-
} = props;
|
|
61
|
-
const handleValueChange = (0, import_react.useCallback)(
|
|
62
|
-
(value) => {
|
|
63
|
-
onValueChange == null ? void 0 : onValueChange(value != null ? value : "");
|
|
64
|
-
},
|
|
65
|
-
[onValueChange]
|
|
66
|
-
);
|
|
67
|
-
const [inputValue, setInputValue] = (0, import_use_controllable_state.useControllableState)({
|
|
68
|
-
value: valueProp,
|
|
69
|
-
onChange: handleValueChange,
|
|
70
|
-
defaultValue: (_a = props.defaultValue) != null ? _a : ""
|
|
71
|
-
});
|
|
72
|
-
const domRef = (0, import_react.useRef)(null);
|
|
73
|
-
const isFileTypeInput = type === "file";
|
|
74
|
-
const isClearable = !!onClear || propsIsClearable || false;
|
|
75
|
-
const isFilledByDefault = ["date", "time", "month", "week", "range"].includes(
|
|
76
|
-
type
|
|
77
|
-
);
|
|
78
|
-
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;
|
|
79
|
-
const isFilled = !(0, import_shared_utils.isEmpty)(valueProp) || isFilledByDefault || hasUploadedFiles || !!inputValue;
|
|
80
|
-
const styles = (0, import_react.useMemo)(
|
|
81
|
-
() => (0, import_theme.input)({
|
|
82
|
-
size,
|
|
83
|
-
radius,
|
|
84
|
-
isClearable
|
|
85
|
-
}),
|
|
86
|
-
[size, radius, isClearable]
|
|
87
|
-
);
|
|
88
|
-
const handleClear = (0, import_react.useCallback)(() => {
|
|
89
|
-
var _a2;
|
|
90
|
-
if (isFileTypeInput) {
|
|
91
|
-
domRef.current.value = "";
|
|
92
|
-
} else {
|
|
93
|
-
setInputValue("");
|
|
94
|
-
}
|
|
95
|
-
onClear == null ? void 0 : onClear();
|
|
96
|
-
(_a2 = domRef.current) == null ? void 0 : _a2.focus();
|
|
97
|
-
}, [setInputValue, isFileTypeInput, onClear]);
|
|
98
|
-
const end = (0, import_react.useMemo)(() => {
|
|
99
|
-
if (isClearable) {
|
|
100
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
101
|
-
"button",
|
|
102
|
-
{
|
|
103
|
-
type: "button",
|
|
104
|
-
tabIndex: -1,
|
|
105
|
-
disabled: props.disabled,
|
|
106
|
-
"aria-label": "clear input",
|
|
107
|
-
"data-slot": "clear-button",
|
|
108
|
-
className: styles.clearButton(),
|
|
109
|
-
onClick: handleClear,
|
|
110
|
-
children: endContent || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseIcon, {})
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
return endContent;
|
|
115
|
-
}, [
|
|
116
|
-
endContent,
|
|
117
|
-
props == null ? void 0 : props.disabled,
|
|
118
|
-
isClearable,
|
|
119
|
-
styles.clearButton,
|
|
120
|
-
handleClear
|
|
121
|
-
]);
|
|
122
|
-
const onChange = (event) => {
|
|
123
|
-
if (!isFileTypeInput) {
|
|
124
|
-
setInputValue(event.target.value);
|
|
125
|
-
}
|
|
126
|
-
onChangeProp == null ? void 0 : onChangeProp(event);
|
|
127
|
-
};
|
|
128
|
-
(0, import_use_safe_layout_effect.useSafeLayoutEffect)(() => {
|
|
129
|
-
if (!domRef.current) return;
|
|
130
|
-
setInputValue(domRef.current.value);
|
|
131
|
-
}, [domRef.current]);
|
|
38
|
+
const { className, size, radius, type = "text", ...rest } = props;
|
|
132
39
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
133
|
-
"
|
|
40
|
+
"input",
|
|
134
41
|
{
|
|
135
|
-
|
|
136
|
-
|
|
42
|
+
type,
|
|
43
|
+
"data-slot": "input",
|
|
44
|
+
"aria-readonly": (0, import_shared_utils.ariaAttr)(props.readOnly),
|
|
45
|
+
className: (0, import_theme.input)({
|
|
46
|
+
className,
|
|
47
|
+
size,
|
|
48
|
+
radius
|
|
137
49
|
}),
|
|
138
|
-
|
|
139
|
-
"data-readonly": (0, import_shared_utils.dataAttr)(props.readOnly),
|
|
140
|
-
"data-hidden": (0, import_shared_utils.dataAttr)(props.hidden),
|
|
141
|
-
"data-slot": "input-wrapper",
|
|
142
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
143
|
-
"div",
|
|
144
|
-
{
|
|
145
|
-
className: styles.innerWrapper({
|
|
146
|
-
className: classNames == null ? void 0 : classNames.innerWrapper
|
|
147
|
-
}),
|
|
148
|
-
"data-slot": "inner-wrapper",
|
|
149
|
-
children: [
|
|
150
|
-
startContent,
|
|
151
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
-
"input",
|
|
153
|
-
{
|
|
154
|
-
type,
|
|
155
|
-
"data-slot": "input",
|
|
156
|
-
"data-has-start-content": (0, import_shared_utils.dataAttr)(!!startContent),
|
|
157
|
-
"data-has-end-content": (0, import_shared_utils.dataAttr)(!!endContent),
|
|
158
|
-
"data-filled": (0, import_shared_utils.dataAttr)(isFilled),
|
|
159
|
-
"aria-readonly": (0, import_shared_utils.ariaAttr)(props.readOnly),
|
|
160
|
-
className: styles.input({
|
|
161
|
-
className: (0, import_shared_utils.cn)(classNames == null ? void 0 : classNames.input, className)
|
|
162
|
-
}),
|
|
163
|
-
value: inputValue,
|
|
164
|
-
onChange: (0, import_shared_utils.chain)(onChangeProp, onChange),
|
|
165
|
-
ref: (0, import_react_utils.mergeRefs)(domRef, refProp),
|
|
166
|
-
...rest
|
|
167
|
-
}
|
|
168
|
-
),
|
|
169
|
-
loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { size: "xs" }) : end
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
)
|
|
50
|
+
...rest
|
|
173
51
|
}
|
|
174
52
|
);
|
|
175
53
|
};
|
|
176
54
|
|
|
177
|
-
// src/
|
|
55
|
+
// src/input-wrapper.tsx
|
|
56
|
+
var import_shared_utils2 = require("@kopexa/shared-utils");
|
|
57
|
+
var import_theme2 = require("@kopexa/theme");
|
|
178
58
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
59
|
+
function InputWrapper({ className, size, ...props }) {
|
|
60
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
"data-slot": "input-wrapper",
|
|
64
|
+
className: (0, import_shared_utils2.cn)((0, import_theme2.input)({ size }), (0, import_theme2.inputWrapper)({ size }), className),
|
|
65
|
+
...props
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/password-input.tsx
|
|
71
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
179
72
|
var PasswordInput = (props) => {
|
|
180
73
|
const {
|
|
181
74
|
className,
|
|
182
75
|
toggleLabel = "Toggle password visibility",
|
|
183
76
|
...rest
|
|
184
77
|
} = props;
|
|
185
|
-
const [isVisible, setIsVisible] = (0,
|
|
186
|
-
const styles = (0,
|
|
187
|
-
return /* @__PURE__ */ (0,
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
78
|
+
const [isVisible, setIsVisible] = (0, import_react.useState)(false);
|
|
79
|
+
const styles = (0, import_theme3.passwordInput)();
|
|
80
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(InputWrapper, { children: [
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
82
|
+
Input,
|
|
83
|
+
{
|
|
84
|
+
type: isVisible ? "text" : "password",
|
|
85
|
+
"data-slot": "input",
|
|
86
|
+
className,
|
|
87
|
+
...rest
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_tooltip.Tooltip, { content: toggleLabel, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
91
|
+
"button",
|
|
92
|
+
{
|
|
93
|
+
"aria-label": toggleLabel,
|
|
94
|
+
type: "button",
|
|
95
|
+
onClick: () => setIsVisible(!isVisible),
|
|
96
|
+
className: styles.button(),
|
|
97
|
+
children: isVisible ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
98
|
+
import_icons.EyeOffIcon,
|
|
99
|
+
{
|
|
100
|
+
"aria-hidden": true,
|
|
101
|
+
focusable: false,
|
|
102
|
+
className: styles.icon()
|
|
103
|
+
}
|
|
104
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
105
|
+
import_icons.EyeIcon,
|
|
106
|
+
{
|
|
107
|
+
"aria-hidden": true,
|
|
108
|
+
focusable: false,
|
|
109
|
+
className: styles.icon()
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
) })
|
|
114
|
+
] });
|
|
220
115
|
};
|
|
221
116
|
// Annotate the CommonJS export names for ESM import in node:
|
|
222
117
|
0 && (module.exports = {
|