@monolith-forensics/monolith-ui 1.3.61 → 1.3.62
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/Input/Input.d.ts
CHANGED
|
@@ -5,9 +5,6 @@ export interface InputProps {
|
|
|
5
5
|
size?: Size;
|
|
6
6
|
variant?: Variant;
|
|
7
7
|
width?: string | number | null | undefined;
|
|
8
|
-
password?: boolean;
|
|
9
|
-
clearable?: boolean;
|
|
10
|
-
onClear?: () => void;
|
|
11
8
|
}
|
|
12
9
|
declare const Input: import("react").ForwardRefExoticComponent<Omit<InputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
13
10
|
export default Input;
|
package/dist/Input/Input.js
CHANGED
|
@@ -9,10 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import styled from "styled-components";
|
|
14
|
-
import { forwardRef
|
|
15
|
-
import { Eye, EyeOff, X } from "lucide-react";
|
|
14
|
+
import { forwardRef } from "react";
|
|
16
15
|
const StyledInput = styled.input `
|
|
17
16
|
font-family: ${({ theme }) => theme.typography.fontFamily};
|
|
18
17
|
pointer-events: "all";
|
|
@@ -144,73 +143,8 @@ const StyledInput = styled.input `
|
|
|
144
143
|
opacity: 0.5;
|
|
145
144
|
}
|
|
146
145
|
`;
|
|
147
|
-
const InputContainer = styled.div `
|
|
148
|
-
position: relative;
|
|
149
|
-
display: flex;
|
|
150
|
-
align-items: center;
|
|
151
|
-
width: ${({ width }) => {
|
|
152
|
-
if (typeof width === "undefined")
|
|
153
|
-
return "100%";
|
|
154
|
-
if (width === null)
|
|
155
|
-
return "100%";
|
|
156
|
-
if (typeof width === "string")
|
|
157
|
-
return width;
|
|
158
|
-
if (typeof width === "number")
|
|
159
|
-
return `${width}px`;
|
|
160
|
-
}};
|
|
161
|
-
`;
|
|
162
|
-
const InputButton = styled.button `
|
|
163
|
-
position: absolute;
|
|
164
|
-
right: 8px;
|
|
165
|
-
background: none;
|
|
166
|
-
border: none;
|
|
167
|
-
cursor: pointer;
|
|
168
|
-
display: flex;
|
|
169
|
-
align-items: center;
|
|
170
|
-
justify-content: center;
|
|
171
|
-
color: ${(props) => props.theme.palette.text.secondary};
|
|
172
|
-
padding: 4px;
|
|
173
|
-
border-radius: 4px;
|
|
174
|
-
transition: all 0.2s ease;
|
|
175
|
-
|
|
176
|
-
&:hover {
|
|
177
|
-
color: ${(props) => props.theme.palette.text.primary};
|
|
178
|
-
background-color: ${(props) => props.theme.palette.action.hover};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
&:focus {
|
|
182
|
-
outline: none;
|
|
183
|
-
box-shadow: 0 0 0 2px ${(props) => props.theme.palette.primary.main}40;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
svg {
|
|
187
|
-
width: 16px;
|
|
188
|
-
height: 16px;
|
|
189
|
-
}
|
|
190
|
-
`;
|
|
191
146
|
const Input = forwardRef((_a, ref) => {
|
|
192
|
-
var { className
|
|
193
|
-
|
|
194
|
-
const hasButton = password || (clearable && value);
|
|
195
|
-
const handlePasswordToggle = (e) => {
|
|
196
|
-
e.preventDefault();
|
|
197
|
-
e.stopPropagation();
|
|
198
|
-
setPasswordVisible((prev) => !prev);
|
|
199
|
-
};
|
|
200
|
-
const handleClear = (e) => {
|
|
201
|
-
e.preventDefault();
|
|
202
|
-
e.stopPropagation();
|
|
203
|
-
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
204
|
-
};
|
|
205
|
-
return (_jsxs(InputContainer, { className: className, width: width, children: [_jsx(StyledInput, Object.assign({ ref: ref, value: value, width: width, type: password && !passwordVisible ? "password" : "text", style: {
|
|
206
|
-
paddingRight: hasButton ? "36px" : undefined,
|
|
207
|
-
} }, props)), password ? (_jsx(InputButton, { onClick: handlePasswordToggle, onMouseDown: (e) => {
|
|
208
|
-
e.preventDefault();
|
|
209
|
-
e.stopPropagation();
|
|
210
|
-
}, type: "button", children: passwordVisible ? _jsx(Eye, {}) : _jsx(EyeOff, {}) })) : clearable && value ? (_jsx(InputButton, { onClick: handleClear, onMouseDown: (e) => {
|
|
211
|
-
e.preventDefault();
|
|
212
|
-
e.stopPropagation();
|
|
213
|
-
}, type: "button", children: _jsx(X, {}) })) : null] }));
|
|
147
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
148
|
+
return _jsx(StyledInput, Object.assign({ ref: ref, className: className }, props));
|
|
214
149
|
});
|
|
215
|
-
Input.displayName = "Input";
|
|
216
150
|
export default Input;
|
|
@@ -10,5 +10,9 @@ export type TextInputProps = InputProps & {
|
|
|
10
10
|
description?: string;
|
|
11
11
|
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
|
12
12
|
style?: React.CSSProperties;
|
|
13
|
+
password?: boolean;
|
|
14
|
+
clearable?: boolean;
|
|
15
|
+
onClear?: () => void;
|
|
13
16
|
};
|
|
14
17
|
export declare const TextInput: React.FC<TextInputProps>;
|
|
18
|
+
export default TextInput;
|
|
@@ -13,11 +13,78 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import styled from "styled-components";
|
|
14
14
|
import { FieldLabel } from "..";
|
|
15
15
|
import Input from "../Input/Input";
|
|
16
|
-
import { forwardRef } from "react";
|
|
16
|
+
import { forwardRef, useState } from "react";
|
|
17
|
+
import { Eye, EyeOff, X } from "lucide-react";
|
|
17
18
|
const StyledContainer = styled.div `
|
|
18
19
|
grid-column: span ${({ colSpan }) => colSpan || 1};
|
|
19
20
|
`;
|
|
21
|
+
const InputContainer = styled.div `
|
|
22
|
+
position: relative;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
width: ${({ width }) => {
|
|
26
|
+
if (typeof width === "undefined")
|
|
27
|
+
return "100%";
|
|
28
|
+
if (width === null)
|
|
29
|
+
return "100%";
|
|
30
|
+
if (typeof width === "string")
|
|
31
|
+
return width;
|
|
32
|
+
if (typeof width === "number")
|
|
33
|
+
return `${width}px`;
|
|
34
|
+
}};
|
|
35
|
+
`;
|
|
36
|
+
const InputButton = styled.button `
|
|
37
|
+
position: absolute;
|
|
38
|
+
right: 8px;
|
|
39
|
+
background: none;
|
|
40
|
+
border: none;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
color: ${(props) => props.theme.palette.text.secondary};
|
|
46
|
+
padding: 4px;
|
|
47
|
+
border-radius: 4px;
|
|
48
|
+
transition: all 0.2s ease;
|
|
49
|
+
|
|
50
|
+
&:hover {
|
|
51
|
+
color: ${(props) => props.theme.palette.text.primary};
|
|
52
|
+
background-color: ${(props) => props.theme.palette.action.hover};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&:focus {
|
|
56
|
+
outline: none;
|
|
57
|
+
box-shadow: 0 0 0 2px ${(props) => props.theme.palette.primary.main}40;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
svg {
|
|
61
|
+
width: 16px;
|
|
62
|
+
height: 16px;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
20
65
|
export const TextInput = forwardRef((_a, ref) => {
|
|
21
|
-
var { className, label, error, required, colSpan = 1, description, size = "sm", inputProps } = _a, rest = __rest(_a, ["className", "label", "error", "required", "colSpan", "description", "size", "inputProps"]);
|
|
22
|
-
|
|
66
|
+
var { className, label, error, required, colSpan = 1, description, size = "sm", inputProps, password = false, clearable = false, onClear, type, style, value } = _a, rest = __rest(_a, ["className", "label", "error", "required", "colSpan", "description", "size", "inputProps", "password", "clearable", "onClear", "type", "style", "value"]);
|
|
67
|
+
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
68
|
+
const handlePasswordToggle = (e) => {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
setPasswordVisible((prev) => !prev);
|
|
72
|
+
};
|
|
73
|
+
const handleClear = (e) => {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
77
|
+
};
|
|
78
|
+
// Enhanced features: password or clearable functionality
|
|
79
|
+
const inputType = password && !passwordVisible ? "password" : type || "text";
|
|
80
|
+
const inputStyle = Object.assign(Object.assign({}, style), (password || (clearable && value) ? { paddingRight: "36px" } : {}));
|
|
81
|
+
return (_jsxs(StyledContainer, { className: className, colSpan: colSpan, children: [label && (_jsx(FieldLabel, { error: error, asterisk: required, size: size, description: description, children: label })), _jsxs(InputContainer, { children: [_jsx(Input, Object.assign({ ref: ref, value: value, size: size, type: inputType, style: inputStyle }, inputProps, rest)), password ? (_jsx(InputButton, { onClick: handlePasswordToggle, onMouseDown: (e) => {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
}, type: "button", children: passwordVisible ? _jsx(Eye, {}) : _jsx(EyeOff, {}) })) : clearable && value ? (_jsx(InputButton, { onClick: handleClear, onMouseDown: (e) => {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
}, type: "button", children: _jsx(X, {}) })) : null] })] }));
|
|
23
88
|
});
|
|
89
|
+
TextInput.displayName = "TextInput";
|
|
90
|
+
export default TextInput;
|