allaw-ui 3.6.0 → 3.6.1
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/components/atoms/inputs/Input.css +39 -0
- package/dist/components/atoms/inputs/Input.d.ts +3 -0
- package/dist/components/atoms/inputs/Input.js +34 -8
- package/dist/components/atoms/inputs/Input.stories.d.ts +20 -0
- package/dist/components/atoms/inputs/Input.stories.js +39 -0
- package/package.json +1 -1
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
border: 2px solid var(--grey-venom, #e6edf5);
|
|
67
67
|
background: var(--Primary-Blanc, #fff);
|
|
68
68
|
padding: 10px;
|
|
69
|
+
position: relative;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
.Input-default .Input-input:hover {
|
|
@@ -81,6 +82,7 @@
|
|
|
81
82
|
border: none;
|
|
82
83
|
outline: none;
|
|
83
84
|
color: var(--noir);
|
|
85
|
+
padding-right: 30px;
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
/* Style variation */
|
|
@@ -116,6 +118,7 @@
|
|
|
116
118
|
border: 2px solid var(--grey-venom, #e6edf5);
|
|
117
119
|
background: var(--Primary-Blanc, #fff);
|
|
118
120
|
padding: 10px;
|
|
121
|
+
position: relative;
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
.Input-variation .Input-input:hover {
|
|
@@ -131,6 +134,7 @@
|
|
|
131
134
|
border: none;
|
|
132
135
|
outline: none;
|
|
133
136
|
color: var(--noir);
|
|
137
|
+
padding-right: 30px;
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
.Input-variation .Input-icon-button {
|
|
@@ -200,6 +204,7 @@
|
|
|
200
204
|
flex: 1;
|
|
201
205
|
flex-direction: column;
|
|
202
206
|
align-items: flex-start;
|
|
207
|
+
position: relative;
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
.Input-password .Input-input input {
|
|
@@ -207,6 +212,7 @@
|
|
|
207
212
|
border: none;
|
|
208
213
|
outline: none;
|
|
209
214
|
color: var(--noir);
|
|
215
|
+
padding-right: 30px;
|
|
210
216
|
}
|
|
211
217
|
|
|
212
218
|
.Input-password .Input-button {
|
|
@@ -230,3 +236,36 @@
|
|
|
230
236
|
padding-left: 4px;
|
|
231
237
|
width: 100%;
|
|
232
238
|
}
|
|
239
|
+
|
|
240
|
+
/* Nouveaux styles pour les fonctionnalités ajoutées */
|
|
241
|
+
|
|
242
|
+
/* Style prefilled */
|
|
243
|
+
.Input-prefilled {
|
|
244
|
+
background-color: rgba(255, 200, 87, 0.15) !important;
|
|
245
|
+
border-color: var(--actions-warning, #ffc857) !important;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Bouton clear */
|
|
249
|
+
.Input-clear-button {
|
|
250
|
+
position: absolute;
|
|
251
|
+
right: 10px;
|
|
252
|
+
top: 50%;
|
|
253
|
+
transform: translateY(-50%);
|
|
254
|
+
cursor: pointer;
|
|
255
|
+
color: var(--actions-error, #e15151);
|
|
256
|
+
font-weight: medium;
|
|
257
|
+
font-size: 1.5rem;
|
|
258
|
+
background: none;
|
|
259
|
+
border: none;
|
|
260
|
+
padding: 0;
|
|
261
|
+
width: 16px;
|
|
262
|
+
height: 16px;
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
z-index: 2;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.Input-clear-button:hover {
|
|
270
|
+
color: #c62828;
|
|
271
|
+
}
|
|
@@ -21,6 +21,9 @@ export interface InputProps {
|
|
|
21
21
|
color?: "bleu-allaw" | "mid-grey" | "dark-grey" | "noir" | "pure-white" | "grey-venom" | "venom-grey-dark";
|
|
22
22
|
variant?: "bold" | "semiBold" | "medium";
|
|
23
23
|
disableZoom?: boolean;
|
|
24
|
+
isPrefilled?: boolean;
|
|
25
|
+
showClearButton?: boolean;
|
|
26
|
+
disableAutofill?: boolean;
|
|
24
27
|
}
|
|
25
28
|
export interface InputRef {
|
|
26
29
|
validate: () => boolean;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
import React, { useState, useEffect, useCallback, forwardRef, useImperativeHandle, useRef, } from "react";
|
|
2
13
|
import "./Input.css";
|
|
3
14
|
import "../../../styles/global.css";
|
|
@@ -6,11 +17,11 @@ import { commonRegex } from "../../../utils/regex";
|
|
|
6
17
|
import TinyInfo from "../typography/TinyInfo";
|
|
7
18
|
import Paragraph from "../typography/Paragraph";
|
|
8
19
|
var Input = forwardRef(function (_a, ref) {
|
|
9
|
-
var title = _a.title, _b = _a.style, style = _b === void 0 ? "default" : _b, rowChange = _a.rowChange, placeholder = _a.placeholder, endIcon = _a.endIcon, _c = _a.isRequired, isRequired = _c === void 0 ? false : _c, validate = _a.validate, onError = _a.onError, onChange = _a.onChange, propValue = _a.value, _d = _a.type, type = _d === void 0 ? "text" : _d, propError = _a.error, _e = _a.color, color = _e === void 0 ? "noir" : _e, _f = _a.variant, variant = _f === void 0 ? "medium" : _f, onKeyDown = _a.onKeyDown, name = _a.name, _g = _a.disableZoom, disableZoom = _g === void 0 ? false : _g;
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
20
|
+
var title = _a.title, _b = _a.style, style = _b === void 0 ? "default" : _b, rowChange = _a.rowChange, placeholder = _a.placeholder, endIcon = _a.endIcon, _c = _a.isRequired, isRequired = _c === void 0 ? false : _c, validate = _a.validate, onError = _a.onError, onChange = _a.onChange, propValue = _a.value, _d = _a.type, type = _d === void 0 ? "text" : _d, propError = _a.error, _e = _a.color, color = _e === void 0 ? "noir" : _e, _f = _a.variant, variant = _f === void 0 ? "medium" : _f, onKeyDown = _a.onKeyDown, name = _a.name, _g = _a.disableZoom, disableZoom = _g === void 0 ? false : _g, _h = _a.isPrefilled, isPrefilled = _h === void 0 ? false : _h, _j = _a.showClearButton, showClearButton = _j === void 0 ? false : _j, _k = _a.disableAutofill, disableAutofill = _k === void 0 ? false : _k;
|
|
21
|
+
var _l = useState(false), isPasswordVisible = _l[0], setIsPasswordVisible = _l[1];
|
|
22
|
+
var _m = useState(propValue || ""), value = _m[0], setValue = _m[1];
|
|
23
|
+
var _o = useState(propError || ""), error = _o[0], setError = _o[1];
|
|
24
|
+
var _p = useState(false), isTouched = _p[0], setIsTouched = _p[1];
|
|
14
25
|
var inputRef = useRef(null);
|
|
15
26
|
useEffect(function () {
|
|
16
27
|
setValue(propValue || "");
|
|
@@ -59,6 +70,15 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
59
70
|
setIsTouched(true);
|
|
60
71
|
validateInput();
|
|
61
72
|
};
|
|
73
|
+
var handleClear = function (e) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
setValue("");
|
|
77
|
+
onChange === null || onChange === void 0 ? void 0 : onChange("");
|
|
78
|
+
if (inputRef.current) {
|
|
79
|
+
inputRef.current.focus();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
62
82
|
var renderEndIcon = function () {
|
|
63
83
|
if (style === "variation" && endIcon) {
|
|
64
84
|
return (React.createElement("button", { className: "Input-icon-button" },
|
|
@@ -81,11 +101,17 @@ var Input = forwardRef(function (_a, ref) {
|
|
|
81
101
|
"*"))),
|
|
82
102
|
React.createElement("div", { className: "Input-wrapper" },
|
|
83
103
|
React.createElement("div", { className: "Input-container" },
|
|
84
|
-
React.createElement("div", { className: "Input-input" },
|
|
85
|
-
React.createElement("input", { ref: inputRef, type: style === "password" && !isPasswordVisible ? "password" : type, placeholder: placeholder, className: "Input-placeholder ".concat(disableZoom ? "Input-no-zoom" : ""), value: value, onChange: function (e) {
|
|
104
|
+
React.createElement("div", { className: "Input-input ".concat(isPrefilled ? "Input-prefilled" : "") },
|
|
105
|
+
React.createElement("input", __assign({ ref: inputRef, type: style === "password" && !isPasswordVisible ? "password" : type, placeholder: placeholder, className: "Input-placeholder ".concat(disableZoom ? "Input-no-zoom" : ""), value: value, onChange: function (e) {
|
|
86
106
|
handleChange(e);
|
|
87
107
|
rowChange && rowChange(e);
|
|
88
|
-
}, name: name, onKeyDown: onKeyDown, onBlur: handleBlur }
|
|
108
|
+
}, name: name, onKeyDown: onKeyDown, onBlur: handleBlur }, (disableAutofill && {
|
|
109
|
+
autoComplete: "off",
|
|
110
|
+
"data-form-type": "other",
|
|
111
|
+
"data-lpignore": "true",
|
|
112
|
+
"data-1p-ignore": true,
|
|
113
|
+
}))),
|
|
114
|
+
showClearButton && value && (React.createElement("button", { type: "button", className: "Input-clear-button", onClick: handleClear, "aria-label": "Effacer le contenu" }, "\u00D7"))),
|
|
89
115
|
renderEndIcon()),
|
|
90
116
|
error && isTouched && (React.createElement("div", { className: "error-message" },
|
|
91
117
|
React.createElement(TinyInfo, { variant: "medium12", color: "actions-error", text: error }))))));
|
|
@@ -42,6 +42,23 @@ declare namespace _default {
|
|
|
42
42
|
}
|
|
43
43
|
export { control_4 as control };
|
|
44
44
|
}
|
|
45
|
+
export namespace isPrefilled {
|
|
46
|
+
let control_5: string;
|
|
47
|
+
export { control_5 as control };
|
|
48
|
+
export let description: string;
|
|
49
|
+
}
|
|
50
|
+
export namespace showClearButton {
|
|
51
|
+
let control_6: string;
|
|
52
|
+
export { control_6 as control };
|
|
53
|
+
let description_1: string;
|
|
54
|
+
export { description_1 as description };
|
|
55
|
+
}
|
|
56
|
+
export namespace disableAutofill {
|
|
57
|
+
let control_7: string;
|
|
58
|
+
export { control_7 as control };
|
|
59
|
+
let description_2: string;
|
|
60
|
+
export { description_2 as description };
|
|
61
|
+
}
|
|
45
62
|
}
|
|
46
63
|
export namespace parameters {
|
|
47
64
|
namespace backgrounds {
|
|
@@ -60,4 +77,7 @@ export const Variation: any;
|
|
|
60
77
|
export const Password: any;
|
|
61
78
|
export const WithValidation: any;
|
|
62
79
|
export const PasswordWithError: any;
|
|
80
|
+
export const WithClearButton: any;
|
|
81
|
+
export const PrefilledInput: any;
|
|
82
|
+
export const WithAutofillDisabled: any;
|
|
63
83
|
import Input from "./Input";
|
|
@@ -47,6 +47,18 @@ export default {
|
|
|
47
47
|
options: ["bold", "semiBold", "medium"],
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
|
+
isPrefilled: {
|
|
51
|
+
control: "boolean",
|
|
52
|
+
description: "Indique si le champ a été pré-rempli automatiquement",
|
|
53
|
+
},
|
|
54
|
+
showClearButton: {
|
|
55
|
+
control: "boolean",
|
|
56
|
+
description: "Affiche un bouton pour effacer rapidement le contenu",
|
|
57
|
+
},
|
|
58
|
+
disableAutofill: {
|
|
59
|
+
control: "boolean",
|
|
60
|
+
description: "Désactive l'auto-remplissage des gestionnaires de mots de passe",
|
|
61
|
+
},
|
|
50
62
|
},
|
|
51
63
|
parameters: {
|
|
52
64
|
backgrounds: {
|
|
@@ -108,3 +120,30 @@ PasswordWithError.args = {
|
|
|
108
120
|
isRequired: true,
|
|
109
121
|
error: "Le mot de passe doit contenir au moins 8 caractères",
|
|
110
122
|
};
|
|
123
|
+
export var WithClearButton = Template.bind({});
|
|
124
|
+
WithClearButton.args = {
|
|
125
|
+
name: "clearButtonInput",
|
|
126
|
+
title: "Texte",
|
|
127
|
+
placeholder: "Entrez du texte",
|
|
128
|
+
value: "Test de texte",
|
|
129
|
+
showClearButton: true,
|
|
130
|
+
style: "default",
|
|
131
|
+
};
|
|
132
|
+
export var PrefilledInput = Template.bind({});
|
|
133
|
+
PrefilledInput.args = {
|
|
134
|
+
name: "prefilledInput",
|
|
135
|
+
title: "Prénom",
|
|
136
|
+
placeholder: "Entrez votre prénom",
|
|
137
|
+
value: "Vincent",
|
|
138
|
+
isPrefilled: true,
|
|
139
|
+
showClearButton: true,
|
|
140
|
+
style: "default",
|
|
141
|
+
};
|
|
142
|
+
export var WithAutofillDisabled = Template.bind({});
|
|
143
|
+
WithAutofillDisabled.args = {
|
|
144
|
+
name: "autofillDisabledInput",
|
|
145
|
+
title: "Email",
|
|
146
|
+
placeholder: "Entrez votre email",
|
|
147
|
+
style: "default",
|
|
148
|
+
disableAutofill: true,
|
|
149
|
+
};
|