@oneplatformdev/ui 0.0.1-beta.22 → 0.0.1-beta.23
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/Input/Input.mjs +45 -36
- package/Input/Input.types.d.ts +3 -1
- package/package.json +1 -1
package/Input/Input.mjs
CHANGED
@@ -1,61 +1,70 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import
|
3
|
-
import { Eye as
|
4
|
-
import { inputVariants as
|
5
|
-
import { cn as
|
6
|
-
const
|
7
|
-
(t,
|
1
|
+
import { jsxs as f, jsx as s } from "react/jsx-runtime";
|
2
|
+
import p, { useState as b } from "react";
|
3
|
+
import { Eye as g, EyeOff as h } from "lucide-react";
|
4
|
+
import { inputVariants as v } from "./inputVariants.mjs";
|
5
|
+
import { cn as w } from "@oneplatformdev/utils";
|
6
|
+
const c = p.forwardRef(
|
7
|
+
(t, a) => {
|
8
8
|
const {
|
9
|
-
className:
|
9
|
+
className: e,
|
10
10
|
variant: r,
|
11
11
|
type: o,
|
12
|
-
slotProps: { input:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
slotProps: { input: i } = {},
|
13
|
+
onChange: u,
|
14
|
+
onTransform: m,
|
15
|
+
...y
|
16
|
+
} = t, { startAdornment: l } = i || {};
|
17
|
+
return /* @__PURE__ */ f("div", { className: "relative", children: [
|
18
|
+
!!l && /* @__PURE__ */ s("span", { className: "absolute left-[10px] top-1/2 -translate-y-1/2", children: l }),
|
17
19
|
/* @__PURE__ */ s(
|
18
20
|
"input",
|
19
21
|
{
|
20
22
|
type: o,
|
21
|
-
className:
|
22
|
-
|
23
|
-
!!
|
23
|
+
className: w(
|
24
|
+
v({ variant: r, className: e }),
|
25
|
+
!!l && "pl-8"
|
24
26
|
),
|
25
|
-
ref:
|
26
|
-
...
|
27
|
+
ref: a,
|
28
|
+
...y,
|
29
|
+
onChange: (n) => {
|
30
|
+
if (m) {
|
31
|
+
const N = m(n.target.value, n);
|
32
|
+
n.target.value = JSON.stringify(N);
|
33
|
+
}
|
34
|
+
u && u(n);
|
35
|
+
}
|
27
36
|
}
|
28
37
|
)
|
29
38
|
] });
|
30
39
|
}
|
31
40
|
);
|
32
|
-
|
33
|
-
const
|
34
|
-
(t,
|
35
|
-
const [
|
36
|
-
r(!
|
41
|
+
c.displayName = "Input";
|
42
|
+
const d = p.forwardRef(
|
43
|
+
(t, a) => {
|
44
|
+
const [e, r] = b(!1), o = e ? "text" : "password", i = () => {
|
45
|
+
r(!e);
|
37
46
|
};
|
38
|
-
return /* @__PURE__ */
|
39
|
-
/* @__PURE__ */ s(
|
40
|
-
/* @__PURE__ */ s(
|
47
|
+
return /* @__PURE__ */ f("div", { className: "relative", children: [
|
48
|
+
/* @__PURE__ */ s(c, { ...t, type: o, className: "pr-8", ref: a }),
|
49
|
+
/* @__PURE__ */ s(I, { isVisible: e, onClick: i })
|
41
50
|
] });
|
42
51
|
}
|
43
52
|
);
|
44
|
-
|
45
|
-
const
|
53
|
+
d.displayName = "PasswordInput";
|
54
|
+
const I = ({ isVisible: t, onClick: a }) => /* @__PURE__ */ s(
|
46
55
|
"button",
|
47
56
|
{
|
48
57
|
type: "button",
|
49
|
-
onClick:
|
58
|
+
onClick: a,
|
50
59
|
className: "absolute top-1/2 right-3 transform -translate-y-1/2",
|
51
|
-
children: t ? /* @__PURE__ */ s(
|
60
|
+
children: t ? /* @__PURE__ */ s(g, { size: 16 }) : /* @__PURE__ */ s(h, { size: 16 })
|
52
61
|
}
|
53
|
-
),
|
54
|
-
({ type: t, ...
|
62
|
+
), x = p.forwardRef(
|
63
|
+
({ type: t, ...a }, e) => t === "password" ? /* @__PURE__ */ s(d, { type: t, ...a, ref: e }) : /* @__PURE__ */ s(c, { type: t, ...a, ref: e })
|
55
64
|
);
|
56
|
-
|
65
|
+
x.displayName = "Input";
|
57
66
|
export {
|
58
|
-
|
59
|
-
|
60
|
-
|
67
|
+
c as BaseInput,
|
68
|
+
x as Input,
|
69
|
+
d as PasswordInput
|
61
70
|
};
|
package/Input/Input.types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { inputVariants } from './inputVariants';
|
2
2
|
import { VariantProps } from 'class-variance-authority';
|
3
|
-
import { default as React, ReactNode } from 'react';
|
3
|
+
import { default as React, ChangeEvent, ReactNode } from 'react';
|
4
4
|
|
5
5
|
export interface InputSlotInputProps {
|
6
6
|
startAdornment?: ReactNode;
|
@@ -10,4 +10,6 @@ export interface InputSlotProps {
|
|
10
10
|
}
|
11
11
|
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement>, VariantProps<typeof inputVariants> {
|
12
12
|
slotProps?: InputSlotProps;
|
13
|
+
/** func transform event.target.value before onChange event call*/
|
14
|
+
onTransform?: (value: string, event: ChangeEvent<HTMLInputElement>) => string;
|
13
15
|
}
|