chesai-ui 0.16.4 → 0.16.5
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,55 +1,87 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { X as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { useInput as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { X as H, EyeOff as L, Eye as O } from "lucide-react";
|
|
3
|
+
import R, { forwardRef as S, useMemo as v } from "react";
|
|
4
|
+
import { useInput as V } from "./use-input.mjs";
|
|
5
|
+
const _ = S((P, C) => {
|
|
6
6
|
const {
|
|
7
|
-
Component:
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
Component: I,
|
|
8
|
+
value: a,
|
|
9
|
+
label: i,
|
|
10
|
+
description: n,
|
|
10
11
|
isClearable: p,
|
|
11
|
-
startContent:
|
|
12
|
-
endContent:
|
|
13
|
-
shouldLabelBeOutside:
|
|
14
|
-
errorMessage:
|
|
15
|
-
isInvalid:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
startContent: y,
|
|
13
|
+
endContent: s,
|
|
14
|
+
shouldLabelBeOutside: c,
|
|
15
|
+
errorMessage: o,
|
|
16
|
+
isInvalid: d,
|
|
17
|
+
// Dynamic password toggle context fetched from hook
|
|
18
|
+
originalType: u,
|
|
19
|
+
isPasswordVisible: t,
|
|
20
|
+
setIsPasswordVisible: h,
|
|
21
|
+
getBaseProps: x,
|
|
22
|
+
getLabelProps: N,
|
|
23
|
+
getInputProps: E,
|
|
24
|
+
getInnerWrapperProps: W,
|
|
25
|
+
getInputWrapperProps: B,
|
|
26
|
+
getHelperWrapperProps: m,
|
|
27
|
+
getDescriptionProps: f,
|
|
28
|
+
getErrorMessageProps: g,
|
|
29
|
+
getClearButtonProps: b
|
|
30
|
+
} = V({ ...P, ref: C }), w = i ? /* @__PURE__ */ e("label", { ...N(), children: i }) : null, M = v(() => {
|
|
31
|
+
const r = [];
|
|
32
|
+
return p && a && r.push(
|
|
33
|
+
/* @__PURE__ */ e("button", { ...b(), children: /* @__PURE__ */ e(H, { className: "h-4 w-4" }) }, "clear")
|
|
34
|
+
), u === "password" && r.push(
|
|
35
|
+
/* @__PURE__ */ e(
|
|
36
|
+
"button",
|
|
37
|
+
{
|
|
38
|
+
type: "button",
|
|
39
|
+
onClick: () => h(!t),
|
|
40
|
+
"aria-label": t ? "Hide password" : "Show password",
|
|
41
|
+
className: "p-2 -m-2 z-10 select-none transition-opacity text-on-surface-variant hover:text-on-surface cursor-pointer active:opacity-70 rounded-full",
|
|
42
|
+
children: t ? /* @__PURE__ */ e(L, { className: "h-4 w-4" }) : /* @__PURE__ */ e(O, { className: "h-4 w-4" })
|
|
43
|
+
},
|
|
44
|
+
"password-toggle"
|
|
45
|
+
)
|
|
46
|
+
), s && r.push(
|
|
47
|
+
/* @__PURE__ */ e(R.Fragment, { children: s }, "custom-end")
|
|
48
|
+
), r.length === 0 ? null : /* @__PURE__ */ e("div", { className: "flex items-center gap-2 shrink-0", children: r });
|
|
28
49
|
}, [
|
|
29
|
-
|
|
30
|
-
t,
|
|
31
|
-
r,
|
|
50
|
+
p,
|
|
32
51
|
a,
|
|
33
52
|
u,
|
|
34
|
-
|
|
35
|
-
|
|
53
|
+
t,
|
|
54
|
+
h,
|
|
36
55
|
b,
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
s
|
|
57
|
+
]), j = v(() => {
|
|
58
|
+
const r = d && o;
|
|
59
|
+
return r || n ? /* @__PURE__ */ e("div", { ...m(), children: r ? /* @__PURE__ */ e("div", { ...g(), children: o }) : /* @__PURE__ */ e("div", { ...f(), children: n }) }) : null;
|
|
60
|
+
}, [
|
|
61
|
+
d,
|
|
62
|
+
o,
|
|
63
|
+
n,
|
|
64
|
+
m,
|
|
65
|
+
g,
|
|
66
|
+
f
|
|
67
|
+
]), k = /* @__PURE__ */ l("div", { ...W(), children: [
|
|
68
|
+
y,
|
|
69
|
+
/* @__PURE__ */ e("input", { ...E() }),
|
|
70
|
+
M
|
|
39
71
|
] });
|
|
40
72
|
return (
|
|
41
73
|
// @ts-ignore
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
|
|
46
|
-
|
|
74
|
+
/* @__PURE__ */ l(I, { ...x(), children: [
|
|
75
|
+
c ? w : null,
|
|
76
|
+
/* @__PURE__ */ l("div", { ...B(), children: [
|
|
77
|
+
c ? null : w,
|
|
78
|
+
k
|
|
47
79
|
] }),
|
|
48
|
-
|
|
80
|
+
j
|
|
49
81
|
] })
|
|
50
82
|
);
|
|
51
83
|
});
|
|
52
|
-
|
|
84
|
+
_.displayName = "Input";
|
|
53
85
|
export {
|
|
54
|
-
|
|
86
|
+
_ as Input
|
|
55
87
|
};
|
|
@@ -23,6 +23,7 @@ export interface UseInputProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
23
23
|
export declare function useInput(props: UseInputProps): {
|
|
24
24
|
Component: React.ElementType<any, keyof React.JSX.IntrinsicElements>;
|
|
25
25
|
domRef: React.RefObject<HTMLInputElement | null>;
|
|
26
|
+
value: string | number | readonly string[];
|
|
26
27
|
label: React.ReactNode;
|
|
27
28
|
description: React.ReactNode;
|
|
28
29
|
isClearable: boolean;
|
|
@@ -34,6 +35,9 @@ export declare function useInput(props: UseInputProps): {
|
|
|
34
35
|
shouldLabelBeOutside: boolean;
|
|
35
36
|
errorMessage: React.ReactNode;
|
|
36
37
|
isInvalid: boolean;
|
|
38
|
+
originalType: React.HTMLInputTypeAttribute | undefined;
|
|
39
|
+
isPasswordVisible: boolean;
|
|
40
|
+
setIsPasswordVisible: React.Dispatch<React.SetStateAction<boolean>>;
|
|
37
41
|
getBaseProps: () => {
|
|
38
42
|
'data-slot': string;
|
|
39
43
|
'data-filled': boolean;
|
|
@@ -62,7 +66,6 @@ export declare function useInput(props: UseInputProps): {
|
|
|
62
66
|
formNoValidate?: boolean | undefined | undefined;
|
|
63
67
|
formTarget?: string | undefined | undefined;
|
|
64
68
|
name?: string | undefined | undefined;
|
|
65
|
-
type?: React.HTMLInputTypeAttribute | undefined;
|
|
66
69
|
defaultChecked?: boolean | undefined | undefined;
|
|
67
70
|
suppressContentEditableWarning?: boolean | undefined | undefined;
|
|
68
71
|
suppressHydrationWarning?: boolean | undefined | undefined;
|
|
@@ -358,6 +361,7 @@ export declare function useInput(props: UseInputProps): {
|
|
|
358
361
|
disabled: boolean | undefined;
|
|
359
362
|
readOnly: boolean | undefined;
|
|
360
363
|
value: string | number | readonly string[];
|
|
364
|
+
type: string | (string & {}) | undefined;
|
|
361
365
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
362
366
|
};
|
|
363
367
|
getInputWrapperProps: () => {
|
|
@@ -1,100 +1,109 @@
|
|
|
1
1
|
import { clsx as t } from "clsx";
|
|
2
|
-
import
|
|
3
|
-
import { getInputSlotClassNames as
|
|
4
|
-
function
|
|
2
|
+
import A, { useRef as G, useState as m, useCallback as w } from "react";
|
|
3
|
+
import { getInputSlotClassNames as J, inputSlots as a, inputStyles as K } from "./input-styles.mjs";
|
|
4
|
+
function ne(B) {
|
|
5
5
|
const {
|
|
6
|
-
ref:
|
|
6
|
+
ref: V,
|
|
7
7
|
as: S = "div",
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
type: i,
|
|
9
|
+
// Destructured here to handle dynamic input state switches
|
|
10
|
+
label: f,
|
|
11
|
+
description: L,
|
|
12
|
+
errorMessage: M,
|
|
13
|
+
className: E,
|
|
12
14
|
classNames: e,
|
|
13
|
-
variant:
|
|
14
|
-
color:
|
|
15
|
-
size:
|
|
16
|
-
shape:
|
|
15
|
+
variant: F = "filled",
|
|
16
|
+
color: Q = "primary",
|
|
17
|
+
size: O = "md",
|
|
18
|
+
shape: k = "minimal",
|
|
17
19
|
labelPlacement: s = "inside",
|
|
18
|
-
startContent:
|
|
19
|
-
endContent:
|
|
20
|
-
isClearable:
|
|
21
|
-
isInvalid:
|
|
22
|
-
placeholder:
|
|
23
|
-
onClear:
|
|
24
|
-
onValueChange:
|
|
25
|
-
onChange:
|
|
26
|
-
value:
|
|
27
|
-
defaultValue:
|
|
28
|
-
readOnly:
|
|
29
|
-
disabled:
|
|
30
|
-
...
|
|
31
|
-
} = B, r =
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
20
|
+
startContent: b,
|
|
21
|
+
endContent: x,
|
|
22
|
+
isClearable: H = !1,
|
|
23
|
+
isInvalid: u = !1,
|
|
24
|
+
placeholder: R,
|
|
25
|
+
onClear: P,
|
|
26
|
+
onValueChange: n,
|
|
27
|
+
onChange: C,
|
|
28
|
+
value: h,
|
|
29
|
+
defaultValue: D,
|
|
30
|
+
readOnly: v,
|
|
31
|
+
disabled: I,
|
|
32
|
+
...T
|
|
33
|
+
} = B, r = G(null), [p, W] = m(!1), [_, N] = m(D || ""), [y, z] = m(!1), o = h !== void 0, c = o ? h : _, d = !!c || p;
|
|
34
|
+
A.useImperativeHandle(V, () => r.current);
|
|
35
|
+
const j = w(() => {
|
|
36
|
+
o || N(""), r.current && (r.current.value = "", r.current.focus()), P?.(), n?.("");
|
|
35
37
|
const l = new Event("input", { bubbles: !0 });
|
|
36
38
|
r.current?.dispatchEvent(l);
|
|
37
|
-
}, [
|
|
39
|
+
}, [o, P, n]), q = w(
|
|
38
40
|
(l) => {
|
|
39
|
-
|
|
41
|
+
o || N(l.target.value), C?.(l), n?.(l.target.value);
|
|
40
42
|
},
|
|
41
|
-
[
|
|
42
|
-
),
|
|
43
|
-
variant:
|
|
44
|
-
size:
|
|
45
|
-
shape:
|
|
43
|
+
[o, C, n]
|
|
44
|
+
), g = J({
|
|
45
|
+
variant: F,
|
|
46
|
+
size: O,
|
|
47
|
+
shape: k,
|
|
46
48
|
labelPlacement: s,
|
|
47
|
-
isInvalid:
|
|
48
|
-
isFilled:
|
|
49
|
-
hasStartContent: !!
|
|
50
|
-
hasLabel: !!
|
|
49
|
+
isInvalid: u,
|
|
50
|
+
isFilled: d,
|
|
51
|
+
hasStartContent: !!b,
|
|
52
|
+
hasLabel: !!f
|
|
51
53
|
});
|
|
52
54
|
return {
|
|
53
55
|
Component: S,
|
|
54
56
|
domRef: r,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
value: c,
|
|
58
|
+
label: f,
|
|
59
|
+
description: L,
|
|
60
|
+
isClearable: H,
|
|
61
|
+
startContent: b,
|
|
62
|
+
endContent: x,
|
|
60
63
|
labelPlacement: s,
|
|
61
64
|
isOutsideLeft: s === "outside-left",
|
|
62
65
|
isOutsideTop: s === "outside",
|
|
63
66
|
shouldLabelBeOutside: s === "outside" || s === "outside-left",
|
|
64
|
-
errorMessage:
|
|
65
|
-
isInvalid:
|
|
67
|
+
errorMessage: M,
|
|
68
|
+
isInvalid: u,
|
|
69
|
+
// Exported properties to manage password visibility inside the UI render
|
|
70
|
+
originalType: i,
|
|
71
|
+
isPasswordVisible: y,
|
|
72
|
+
setIsPasswordVisible: z,
|
|
66
73
|
getBaseProps: () => ({
|
|
67
74
|
"data-slot": "base",
|
|
68
|
-
"data-filled":
|
|
69
|
-
"data-filled-within":
|
|
75
|
+
"data-filled": d,
|
|
76
|
+
"data-filled-within": d || p,
|
|
70
77
|
"data-focus": p,
|
|
71
|
-
"data-invalid":
|
|
72
|
-
"data-disabled":
|
|
73
|
-
"data-readonly":
|
|
78
|
+
"data-invalid": u,
|
|
79
|
+
"data-disabled": I,
|
|
80
|
+
"data-readonly": v,
|
|
74
81
|
"data-label-placement": s,
|
|
75
|
-
className: t(a.base,
|
|
82
|
+
className: t(a.base, K({ labelPlacement: s }), E, e?.base)
|
|
76
83
|
}),
|
|
77
84
|
getLabelProps: () => ({
|
|
78
85
|
"data-slot": "label",
|
|
79
|
-
className: t(a.label,
|
|
86
|
+
className: t(a.label, g.label, e?.label)
|
|
80
87
|
}),
|
|
81
88
|
getInputProps: () => ({
|
|
82
89
|
ref: r,
|
|
83
90
|
"data-slot": "input",
|
|
84
|
-
className: t(a.input,
|
|
85
|
-
placeholder:
|
|
86
|
-
disabled:
|
|
87
|
-
readOnly:
|
|
88
|
-
value:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
className: t(a.input, g.input, e?.input),
|
|
92
|
+
placeholder: R,
|
|
93
|
+
disabled: I,
|
|
94
|
+
readOnly: v,
|
|
95
|
+
value: c,
|
|
96
|
+
// Evaluate type dynamically depending on visibility status if type is 'password'
|
|
97
|
+
type: i === "password" ? y ? "text" : "password" : i,
|
|
98
|
+
onChange: q,
|
|
99
|
+
onFocus: () => W(!0),
|
|
100
|
+
onBlur: () => W(!1),
|
|
101
|
+
...T
|
|
93
102
|
}),
|
|
94
103
|
getInputWrapperProps: () => ({
|
|
95
104
|
"data-slot": "input-wrapper",
|
|
96
105
|
"data-focus": p,
|
|
97
|
-
className: t(a.inputWrapper,
|
|
106
|
+
className: t(a.inputWrapper, g.inputWrapper, e?.inputWrapper),
|
|
98
107
|
onClick: () => {
|
|
99
108
|
r.current?.focus();
|
|
100
109
|
}
|
|
@@ -118,11 +127,11 @@ function re(B) {
|
|
|
118
127
|
getClearButtonProps: () => ({
|
|
119
128
|
"data-slot": "clear-button",
|
|
120
129
|
type: "button",
|
|
121
|
-
onClick:
|
|
130
|
+
onClick: j,
|
|
122
131
|
className: t(a.clearButton, e?.clearButton)
|
|
123
132
|
})
|
|
124
133
|
};
|
|
125
134
|
}
|
|
126
135
|
export {
|
|
127
|
-
|
|
136
|
+
ne as useInput
|
|
128
137
|
};
|