allaw-ui 4.8.2 → 4.8.3
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/SearchBar.d.ts +3 -1
- package/dist/components/atoms/inputs/SearchBar.js +17 -8
- package/dist/components/atoms/inputs/SearchBar.stories.d.ts +40 -4
- package/dist/components/atoms/inputs/SearchBar.stories.js +57 -1
- package/dist/components/atoms/inputs/{SearchBar.css → searchBar.module.css} +51 -13
- package/package.json +1 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import "./SearchBar.css";
|
|
3
2
|
import "../../../styles/global.css";
|
|
4
3
|
import "../../../styles/icons.css";
|
|
5
4
|
export interface SearchBarProps {
|
|
6
5
|
placeholder?: string;
|
|
7
6
|
endIcon?: string;
|
|
7
|
+
startIcon?: string;
|
|
8
8
|
value?: string;
|
|
9
9
|
onChange?: (value: string) => void;
|
|
10
10
|
showClear?: boolean;
|
|
11
|
+
size?: "normal" | "big";
|
|
12
|
+
style?: "classic" | "form";
|
|
11
13
|
}
|
|
12
14
|
declare const SearchBar: React.FC<SearchBarProps>;
|
|
13
15
|
export default SearchBar;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import "./
|
|
2
|
+
import styles from "./searchBar.module.css";
|
|
3
3
|
import "../../../styles/global.css";
|
|
4
4
|
import "../../../styles/icons.css";
|
|
5
5
|
var SearchBar = function (_a) {
|
|
6
|
-
var _b = _a.placeholder, placeholder = _b === void 0 ? "Faites une recherche" : _b,
|
|
7
|
-
var
|
|
6
|
+
var _b = _a.placeholder, placeholder = _b === void 0 ? "Faites une recherche" : _b, endIcon = _a.endIcon, startIcon = _a.startIcon, _c = _a.value, controlledValue = _c === void 0 ? "" : _c, onChange = _a.onChange, _d = _a.showClear, showClear = _d === void 0 ? false : _d, _e = _a.size, size = _e === void 0 ? "normal" : _e, _f = _a.style, styleProp = _f === void 0 ? "classic" : _f;
|
|
7
|
+
var _g = useState(controlledValue), value = _g[0], setValue = _g[1];
|
|
8
8
|
var handleChange = function (event) {
|
|
9
9
|
var newValue = event.target.value;
|
|
10
10
|
setValue(newValue);
|
|
@@ -18,11 +18,20 @@ var SearchBar = function (_a) {
|
|
|
18
18
|
onChange("");
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
var wrapperClassName = [
|
|
22
|
+
styles.searchBar,
|
|
23
|
+
styleProp === "form" ? styles.styleForm : "",
|
|
24
|
+
size === "big" ? styles.sizeBig : "",
|
|
25
|
+
]
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.join(" ");
|
|
28
|
+
return (React.createElement("div", { className: wrapperClassName },
|
|
29
|
+
startIcon && (React.createElement("span", { className: styles.searchBarStartIcon, "aria-hidden": "true" },
|
|
30
|
+
React.createElement("i", { className: startIcon }))),
|
|
31
|
+
React.createElement("input", { type: "text", placeholder: placeholder, className: styles.searchBarPlaceholder, value: controlledValue || value, onChange: handleChange }),
|
|
32
|
+
showClear && (controlledValue || value) && (React.createElement("button", { type: "button", className: styles.searchBarClearButton, onClick: handleClear, "aria-label": "Effacer la recherche" },
|
|
24
33
|
React.createElement("i", { className: "allaw-icon-x-small" }))),
|
|
25
|
-
React.createElement("button", { className:
|
|
26
|
-
React.createElement("i", { className: endIcon }))));
|
|
34
|
+
endIcon && (React.createElement("button", { className: styles.searchBarIconButton, tabIndex: -1, "aria-label": "Rechercher" },
|
|
35
|
+
React.createElement("i", { className: endIcon })))));
|
|
27
36
|
};
|
|
28
37
|
export default SearchBar;
|
|
@@ -11,6 +11,9 @@ declare namespace _default {
|
|
|
11
11
|
export namespace args {
|
|
12
12
|
let endIcon: string;
|
|
13
13
|
let showClear: boolean;
|
|
14
|
+
let size: string;
|
|
15
|
+
let style: string;
|
|
16
|
+
let startIcon: undefined;
|
|
14
17
|
}
|
|
15
18
|
export namespace argTypes {
|
|
16
19
|
export namespace placeholder {
|
|
@@ -26,17 +29,46 @@ declare namespace _default {
|
|
|
26
29
|
export { control_1 as control };
|
|
27
30
|
}
|
|
28
31
|
export { endIcon_1 as endIcon };
|
|
29
|
-
export namespace
|
|
32
|
+
export namespace startIcon_1 {
|
|
30
33
|
export namespace control_2 {
|
|
31
34
|
let type_2: string;
|
|
32
35
|
export { type_2 as type };
|
|
33
36
|
}
|
|
34
37
|
export { control_2 as control };
|
|
38
|
+
export let description: string;
|
|
35
39
|
}
|
|
36
|
-
export
|
|
37
|
-
|
|
40
|
+
export { startIcon_1 as startIcon };
|
|
41
|
+
export namespace size_1 {
|
|
42
|
+
export namespace control_3 {
|
|
43
|
+
let type_3: string;
|
|
44
|
+
export { type_3 as type };
|
|
45
|
+
}
|
|
38
46
|
export { control_3 as control };
|
|
39
|
-
export let
|
|
47
|
+
export let options: string[];
|
|
48
|
+
}
|
|
49
|
+
export { size_1 as size };
|
|
50
|
+
export namespace style_1 {
|
|
51
|
+
export namespace control_4 {
|
|
52
|
+
let type_4: string;
|
|
53
|
+
export { type_4 as type };
|
|
54
|
+
}
|
|
55
|
+
export { control_4 as control };
|
|
56
|
+
let options_1: string[];
|
|
57
|
+
export { options_1 as options };
|
|
58
|
+
}
|
|
59
|
+
export { style_1 as style };
|
|
60
|
+
export namespace value {
|
|
61
|
+
export namespace control_5 {
|
|
62
|
+
let type_5: string;
|
|
63
|
+
export { type_5 as type };
|
|
64
|
+
}
|
|
65
|
+
export { control_5 as control };
|
|
66
|
+
}
|
|
67
|
+
export namespace showClear_1 {
|
|
68
|
+
let control_6: string;
|
|
69
|
+
export { control_6 as control };
|
|
70
|
+
let description_1: string;
|
|
71
|
+
export { description_1 as description };
|
|
40
72
|
}
|
|
41
73
|
export { showClear_1 as showClear };
|
|
42
74
|
export namespace onChange_1 {
|
|
@@ -59,4 +91,8 @@ declare namespace _default {
|
|
|
59
91
|
export default _default;
|
|
60
92
|
export const Default: any;
|
|
61
93
|
export const WithClear: any;
|
|
94
|
+
export const Big: any;
|
|
95
|
+
export const FormStyle: any;
|
|
96
|
+
export const WithStartIcon: any;
|
|
97
|
+
export const BigFormStartIconNoEnd: any;
|
|
62
98
|
import SearchBar from "./SearchBar";
|
|
@@ -21,7 +21,7 @@ export default {
|
|
|
21
21
|
component: SearchBar,
|
|
22
22
|
tags: ["autodocs"],
|
|
23
23
|
excludeStories: /.*Data$/,
|
|
24
|
-
args: __assign(__assign({}, ActionsData), { endIcon: "allaw-icon-search", showClear: false }),
|
|
24
|
+
args: __assign(__assign({}, ActionsData), { endIcon: "allaw-icon-search", showClear: false, size: "normal", style: "classic", startIcon: undefined }),
|
|
25
25
|
argTypes: {
|
|
26
26
|
placeholder: {
|
|
27
27
|
control: {
|
|
@@ -33,6 +33,24 @@ export default {
|
|
|
33
33
|
type: "text",
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
|
+
startIcon: {
|
|
37
|
+
control: {
|
|
38
|
+
type: "text",
|
|
39
|
+
},
|
|
40
|
+
description: "Icône au début du champ (ex: allaw-icon-map-pin)",
|
|
41
|
+
},
|
|
42
|
+
size: {
|
|
43
|
+
control: {
|
|
44
|
+
type: "radio",
|
|
45
|
+
},
|
|
46
|
+
options: ["normal", "big"],
|
|
47
|
+
},
|
|
48
|
+
style: {
|
|
49
|
+
control: {
|
|
50
|
+
type: "radio",
|
|
51
|
+
},
|
|
52
|
+
options: ["classic", "form"],
|
|
53
|
+
},
|
|
36
54
|
value: {
|
|
37
55
|
control: {
|
|
38
56
|
type: "text",
|
|
@@ -68,6 +86,8 @@ Default.args = {
|
|
|
68
86
|
placeholder: "Faites une recherche",
|
|
69
87
|
endIcon: "allaw-icon-search",
|
|
70
88
|
showClear: false,
|
|
89
|
+
size: "normal",
|
|
90
|
+
style: "classic",
|
|
71
91
|
onChange: function (value) { return console.log("Search value:", value); },
|
|
72
92
|
};
|
|
73
93
|
export var WithClear = Template.bind({});
|
|
@@ -76,5 +96,41 @@ WithClear.args = {
|
|
|
76
96
|
endIcon: "allaw-icon-search",
|
|
77
97
|
showClear: true,
|
|
78
98
|
value: "test",
|
|
99
|
+
size: "normal",
|
|
100
|
+
style: "classic",
|
|
79
101
|
onChange: function (value) { return console.log("Search value:", value); },
|
|
80
102
|
};
|
|
103
|
+
export var Big = Template.bind({});
|
|
104
|
+
Big.args = {
|
|
105
|
+
placeholder: "Faites une recherche",
|
|
106
|
+
endIcon: "allaw-icon-search",
|
|
107
|
+
showClear: false,
|
|
108
|
+
size: "big",
|
|
109
|
+
style: "classic",
|
|
110
|
+
};
|
|
111
|
+
export var FormStyle = Template.bind({});
|
|
112
|
+
FormStyle.args = {
|
|
113
|
+
placeholder: "Faites une recherche",
|
|
114
|
+
endIcon: "allaw-icon-search",
|
|
115
|
+
showClear: false,
|
|
116
|
+
size: "normal",
|
|
117
|
+
style: "form",
|
|
118
|
+
};
|
|
119
|
+
export var WithStartIcon = Template.bind({});
|
|
120
|
+
WithStartIcon.args = {
|
|
121
|
+
placeholder: "Recherchez une adresse",
|
|
122
|
+
startIcon: "allaw-icon-map-pin",
|
|
123
|
+
endIcon: "allaw-icon-search",
|
|
124
|
+
showClear: false,
|
|
125
|
+
size: "normal",
|
|
126
|
+
style: "classic",
|
|
127
|
+
};
|
|
128
|
+
export var BigFormStartIconNoEnd = Template.bind({});
|
|
129
|
+
BigFormStartIconNoEnd.args = {
|
|
130
|
+
placeholder: "Décrivez votre besoin, ex. : Je veux vendre un appartement",
|
|
131
|
+
startIcon: "allaw-icon-search",
|
|
132
|
+
endIcon: undefined,
|
|
133
|
+
showClear: false,
|
|
134
|
+
size: "big",
|
|
135
|
+
style: "form",
|
|
136
|
+
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
.SearchBar {
|
|
1
|
+
.searchBar {
|
|
4
2
|
display: flex;
|
|
5
3
|
width: 100%;
|
|
6
4
|
height: 45px;
|
|
@@ -9,12 +7,21 @@
|
|
|
9
7
|
gap: 8px;
|
|
10
8
|
flex-shrink: 0;
|
|
11
9
|
border-radius: 73px;
|
|
12
|
-
border: 1px solid
|
|
13
|
-
background:
|
|
10
|
+
border: 1px solid #e6edf5;
|
|
11
|
+
background: #fff;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Size variants */
|
|
15
|
+
.sizeBig {
|
|
16
|
+
height: 52px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.sizeBig .searchBarPlaceholder {
|
|
20
|
+
font-size: 18px;
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
.
|
|
17
|
-
color:
|
|
23
|
+
.searchBarPlaceholder {
|
|
24
|
+
color: #728ea7;
|
|
18
25
|
font-family: "Open Sans";
|
|
19
26
|
font-size: 16px;
|
|
20
27
|
font-style: normal;
|
|
@@ -28,7 +35,20 @@
|
|
|
28
35
|
padding-left: 3px;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
.
|
|
38
|
+
.searchBarStartIcon {
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
width: 20px;
|
|
43
|
+
height: 20px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.searchBarStartIcon i {
|
|
47
|
+
color: #25beeb;
|
|
48
|
+
font-size: 18px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.searchBarIconButton {
|
|
32
52
|
display: flex;
|
|
33
53
|
width: 33px;
|
|
34
54
|
height: 33px;
|
|
@@ -39,11 +59,16 @@
|
|
|
39
59
|
gap: 5px;
|
|
40
60
|
border-radius: 20px;
|
|
41
61
|
border: 1px solid rgba(0, 0, 0, 0.05);
|
|
42
|
-
background:
|
|
62
|
+
background: #25beeb;
|
|
43
63
|
cursor: pointer;
|
|
44
64
|
}
|
|
45
65
|
|
|
46
|
-
.
|
|
66
|
+
.sizeBig .searchBarIconButton {
|
|
67
|
+
width: 36px;
|
|
68
|
+
height: 36px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.searchBarIconButton i {
|
|
47
72
|
width: 18px;
|
|
48
73
|
height: 18px;
|
|
49
74
|
flex-shrink: 0;
|
|
@@ -54,7 +79,7 @@
|
|
|
54
79
|
justify-content: center;
|
|
55
80
|
}
|
|
56
81
|
|
|
57
|
-
.
|
|
82
|
+
.searchBarClearButton {
|
|
58
83
|
display: flex;
|
|
59
84
|
align-items: center;
|
|
60
85
|
justify-content: center;
|
|
@@ -69,12 +94,25 @@
|
|
|
69
94
|
transition: background 0.15s;
|
|
70
95
|
}
|
|
71
96
|
|
|
72
|
-
.
|
|
97
|
+
.searchBarClearButton:hover {
|
|
73
98
|
background: #f6fcfe;
|
|
74
99
|
}
|
|
75
100
|
|
|
76
|
-
.
|
|
101
|
+
.searchBarClearButton i {
|
|
77
102
|
color: #728ea7;
|
|
78
103
|
font-size: 18px;
|
|
79
104
|
pointer-events: none;
|
|
80
105
|
}
|
|
106
|
+
|
|
107
|
+
/* Style variants */
|
|
108
|
+
.styleForm {
|
|
109
|
+
border: 2px solid #e6edf5;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.styleForm:hover {
|
|
113
|
+
border-color: #d1dce8;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.styleForm:focus-within {
|
|
117
|
+
border-color: #728ea7;
|
|
118
|
+
}
|