kelt-ui-kit-react 1.3.0 → 1.3.2
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/form/input/Input.d.ts +25 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +914 -852
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/form/Form.tsx +4 -2
- package/src/form/Form.view.tsx +1 -1
- package/src/form/input/Input.tsx +92 -0
- package/src/form/input/input.css +16 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
package/src/form/Form.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { Icon } from "../icon/Icon";
|
|
|
10
10
|
import { Select } from "../select/Select"; // <--- ton composant
|
|
11
11
|
import "./form.css";
|
|
12
12
|
import { FormInterface, FormValuesInterface } from "./form.interface";
|
|
13
|
+
import { Input } from "./input/Input";
|
|
13
14
|
|
|
14
15
|
export type FormProps<
|
|
15
16
|
T extends { [key: string]: string | number | boolean | Date | string[] }
|
|
@@ -185,12 +186,13 @@ export const DynamicForm = forwardRef(
|
|
|
185
186
|
}
|
|
186
187
|
/>
|
|
187
188
|
) : (
|
|
188
|
-
<
|
|
189
|
+
<Input
|
|
190
|
+
id={v.name}
|
|
189
191
|
ref={(el) => (inputRefs.current[v.name] = el)}
|
|
190
192
|
name={v.name}
|
|
191
193
|
type={v.type}
|
|
192
194
|
placeholder={v.placeholder ?? ""}
|
|
193
|
-
autoComplete={v.autoComplete ?? "
|
|
195
|
+
autoComplete={v.autoComplete ?? "off"}
|
|
194
196
|
tabIndex={0}
|
|
195
197
|
disabled={disabled}
|
|
196
198
|
autoFocus={v.focus ?? false}
|
package/src/form/Form.view.tsx
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { Icon } from "../../icon/Icon";
|
|
3
|
+
import { TypeInputEnum } from "../form.enum";
|
|
4
|
+
import "./input.css";
|
|
5
|
+
|
|
6
|
+
export interface InputProps {
|
|
7
|
+
id: string; // obligatoire pour le label for
|
|
8
|
+
name: string;
|
|
9
|
+
type?: TypeInputEnum;
|
|
10
|
+
onInvalid?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
11
|
+
value?: string | number;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
inputMode?: "text" | "numeric" | "decimal" | "email" | "tel" | "search";
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
autoFocus?: boolean;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
minLength?: number;
|
|
19
|
+
maxLength?: number;
|
|
20
|
+
autoComplete?: "on" | "off";
|
|
21
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
22
|
+
step?: string;
|
|
23
|
+
tabIndex?: number;
|
|
24
|
+
checked?: boolean;
|
|
25
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
26
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Input = ({
|
|
30
|
+
id,
|
|
31
|
+
name,
|
|
32
|
+
type = TypeInputEnum.TEXT,
|
|
33
|
+
value,
|
|
34
|
+
onInvalid,
|
|
35
|
+
placeholder,
|
|
36
|
+
className,
|
|
37
|
+
inputMode,
|
|
38
|
+
minLength,
|
|
39
|
+
maxLength,
|
|
40
|
+
autoFocus = false,
|
|
41
|
+
disabled = false,
|
|
42
|
+
required = false,
|
|
43
|
+
autoComplete = "off",
|
|
44
|
+
ref,
|
|
45
|
+
tabIndex = 0,
|
|
46
|
+
step,
|
|
47
|
+
checked,
|
|
48
|
+
onChange,
|
|
49
|
+
onBlur,
|
|
50
|
+
}: InputProps) => {
|
|
51
|
+
// Si le type est password, on utilise l'input de type password
|
|
52
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
53
|
+
return (
|
|
54
|
+
<div className="input-container">
|
|
55
|
+
<input type="text" style={{ display: "none" }} />
|
|
56
|
+
|
|
57
|
+
<input
|
|
58
|
+
ref={ref}
|
|
59
|
+
id={id}
|
|
60
|
+
name={name}
|
|
61
|
+
inputMode={inputMode ?? (type === "number" ? "numeric" : "text")}
|
|
62
|
+
type={showPassword ? TypeInputEnum.TEXT : type}
|
|
63
|
+
spellCheck="false"
|
|
64
|
+
value={value}
|
|
65
|
+
placeholder={placeholder}
|
|
66
|
+
disabled={disabled}
|
|
67
|
+
required={required}
|
|
68
|
+
autoComplete={autoComplete === "off" ? "fake" : autoComplete}
|
|
69
|
+
step={step}
|
|
70
|
+
tabIndex={tabIndex}
|
|
71
|
+
autoFocus={autoFocus}
|
|
72
|
+
minLength={minLength}
|
|
73
|
+
maxLength={maxLength}
|
|
74
|
+
onChange={onChange}
|
|
75
|
+
checked={checked}
|
|
76
|
+
onBlur={onBlur}
|
|
77
|
+
className={`input-field ${className ?? ""}`}
|
|
78
|
+
onInvalid={onInvalid}
|
|
79
|
+
/>
|
|
80
|
+
<>
|
|
81
|
+
{type === TypeInputEnum.PASSWORD && (
|
|
82
|
+
<div
|
|
83
|
+
onClick={() => setShowPassword(!showPassword)}
|
|
84
|
+
className="input-password-icon"
|
|
85
|
+
>
|
|
86
|
+
<Icon classIcon={showPassword ? "bi-eye-slash" : "bi-eye"} />
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
</>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { Expands } from "./expands/Expands";
|
|
|
14
14
|
export { FilAriane } from "./filAriane/FilAriane";
|
|
15
15
|
export { DynamicForm } from "./form/Form";
|
|
16
16
|
export { TypeInputEnum } from "./form/form.enum";
|
|
17
|
+
export { Input } from "./form/input/Input";
|
|
17
18
|
export { TextArea } from "./form/textArea/TextArea";
|
|
18
19
|
export { Grid } from "./grid/Grid";
|
|
19
20
|
export { Header } from "./header/Header";
|