allaw-ui 3.8.1 → 3.8.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/components/atoms/selects/Select.d.ts +1 -0
- package/dist/components/atoms/selects/Select.js +19 -14
- package/dist/components/atoms/selects/Select.module.css +10 -0
- package/dist/components/atoms/selects/Select.stories.d.ts +13 -4
- package/dist/components/atoms/selects/Select.stories.js +42 -0
- package/package.json +1 -1
|
@@ -14,21 +14,21 @@ import "../../../styles/global.css";
|
|
|
14
14
|
import TinyInfo from "../typography/TinyInfo";
|
|
15
15
|
function Select(_a, ref) {
|
|
16
16
|
var _b;
|
|
17
|
-
var items = _a.items, selectedItem = _a.selectedItem, _c = _a.placeholder, placeholder = _c === void 0 ? "Choisir..." : _c, _d = _a.multiple, multiple = _d === void 0 ? false : _d, _e = _a.isRequired, isRequired = _e === void 0 ? false : _e, _f = _a.showError, showError = _f === void 0 ? false : _f, _g = _a.width, width = _g === void 0 ? 100 : _g, maxItems = _a.maxItems, _h = _a.requireAttention, requireAttention = _h === void 0 ? false : _h, onChange = _a.onChange, onError = _a.onError;
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
17
|
+
var items = _a.items, selectedItem = _a.selectedItem, _c = _a.placeholder, placeholder = _c === void 0 ? "Choisir..." : _c, _d = _a.multiple, multiple = _d === void 0 ? false : _d, _e = _a.isRequired, isRequired = _e === void 0 ? false : _e, _f = _a.showError, showError = _f === void 0 ? false : _f, _g = _a.width, width = _g === void 0 ? 100 : _g, maxItems = _a.maxItems, _h = _a.requireAttention, requireAttention = _h === void 0 ? false : _h, _j = _a.disabledItems, disabledItems = _j === void 0 ? [] : _j, onChange = _a.onChange, onError = _a.onError;
|
|
18
|
+
var _k = useState(false), isOpen = _k[0], setIsOpen = _k[1];
|
|
19
|
+
var _l = useState((multiple ? selectedItem || [] : selectedItem || "")), selected = _l[0], setSelected = _l[1];
|
|
20
|
+
var _m = useState(""), error = _m[0], setError = _m[1];
|
|
21
21
|
var selectRef = useRef(null);
|
|
22
22
|
var listRef = useRef(null);
|
|
23
23
|
var tagContainerRef = useRef(null);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
24
|
+
var _o = useState([]), visibleTags = _o[0], setVisibleTags = _o[1];
|
|
25
|
+
var _p = useState(0), hiddenCount = _p[0], setHiddenCount = _p[1];
|
|
26
|
+
var _q = useState({
|
|
27
27
|
top: 0,
|
|
28
28
|
left: 0,
|
|
29
29
|
width: 0,
|
|
30
|
-
}), listPosition =
|
|
31
|
-
var
|
|
30
|
+
}), listPosition = _q[0], setListPosition = _q[1];
|
|
31
|
+
var _r = useState("bottom"), placement = _r[0], setPlacement = _r[1];
|
|
32
32
|
useEffect(function () {
|
|
33
33
|
setSelected((multiple ? selectedItem || [] : selectedItem || ""));
|
|
34
34
|
}, [selectedItem, multiple]);
|
|
@@ -207,11 +207,16 @@ function Select(_a, ref) {
|
|
|
207
207
|
left: "".concat(listPosition.left, "px"),
|
|
208
208
|
width: "".concat(listPosition.width, "px"),
|
|
209
209
|
margin: placement === "bottom" ? "4px 0 0 0" : "0 0 4px 0",
|
|
210
|
-
} }, items.map(function (item) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
} }, items.map(function (item) {
|
|
211
|
+
var isDisabled = disabledItems.includes(item.value);
|
|
212
|
+
var isSelected = Array.isArray(selected)
|
|
213
|
+
? selected.includes(item.value)
|
|
214
|
+
: item.value === selectedItem;
|
|
215
|
+
var isHighlighted = !multiple && item.value === selectedItem;
|
|
216
|
+
return (React.createElement("div", { key: item.value, "data-value": item.value, className: "".concat(styles.selectItem, " ").concat(isSelected ? styles.selected : "", " ").concat(isHighlighted ? styles.highlighted : "", " ").concat(!multiple ? styles.singleSelect : "", " ").concat(isDisabled ? styles.disabledItem : ""), onClick: function () { return !isDisabled && handleSelect(item); }, "aria-disabled": isDisabled },
|
|
217
|
+
multiple && React.createElement("span", { className: styles.selectItemIcon }),
|
|
218
|
+
React.createElement("span", { className: styles.selectItemText }, item.label)));
|
|
219
|
+
}))); };
|
|
215
220
|
var renderTags = function (selectedValues) {
|
|
216
221
|
if (!selectedValues.length)
|
|
217
222
|
return null;
|
|
@@ -144,6 +144,16 @@
|
|
|
144
144
|
border-radius: 8px;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
.disabledItem {
|
|
148
|
+
color: var(--mid-grey) !important;
|
|
149
|
+
opacity: 0.5;
|
|
150
|
+
cursor: not-allowed;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.disabledItem:hover {
|
|
154
|
+
background: transparent !important;
|
|
155
|
+
}
|
|
156
|
+
|
|
147
157
|
.tagContainer {
|
|
148
158
|
display: flex;
|
|
149
159
|
flex-wrap: nowrap;
|
|
@@ -54,20 +54,27 @@ declare namespace _default {
|
|
|
54
54
|
}
|
|
55
55
|
export { control_6 as control };
|
|
56
56
|
}
|
|
57
|
+
namespace disabledItems {
|
|
58
|
+
export namespace control_7 {
|
|
59
|
+
let type_7: string;
|
|
60
|
+
export { type_7 as type };
|
|
61
|
+
}
|
|
62
|
+
export { control_7 as control };
|
|
63
|
+
}
|
|
57
64
|
namespace onChange {
|
|
58
65
|
namespace table {
|
|
59
66
|
let disable: boolean;
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
namespace width {
|
|
63
|
-
export namespace
|
|
64
|
-
let
|
|
65
|
-
export {
|
|
70
|
+
export namespace control_8 {
|
|
71
|
+
let type_8: string;
|
|
72
|
+
export { type_8 as type };
|
|
66
73
|
let min_1: number;
|
|
67
74
|
export { min_1 as min };
|
|
68
75
|
export let max: number;
|
|
69
76
|
}
|
|
70
|
-
export {
|
|
77
|
+
export { control_8 as control };
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
export namespace parameters {
|
|
@@ -100,4 +107,6 @@ export const Multiple: any;
|
|
|
100
107
|
export const Required: any;
|
|
101
108
|
export const CustomWidth: any;
|
|
102
109
|
export const RequireAttention: any;
|
|
110
|
+
export const WithDisabledItems: any;
|
|
111
|
+
export const MultipleWithDisabledItems: any;
|
|
103
112
|
import Select from "./Select";
|
|
@@ -56,6 +56,11 @@ export default {
|
|
|
56
56
|
min: 1,
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
|
+
disabledItems: {
|
|
60
|
+
control: {
|
|
61
|
+
type: "array",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
59
64
|
onChange: {
|
|
60
65
|
table: {
|
|
61
66
|
disable: true,
|
|
@@ -185,3 +190,40 @@ RequireAttention.args = {
|
|
|
185
190
|
requireAttention: true,
|
|
186
191
|
width: 100,
|
|
187
192
|
};
|
|
193
|
+
export var WithDisabledItems = Template.bind({});
|
|
194
|
+
WithDisabledItems.args = {
|
|
195
|
+
items: [
|
|
196
|
+
{ label: "Lundi 12 août", value: "lundi-12-aout" },
|
|
197
|
+
{ label: "Mardi 13 août", value: "mardi-13-aout" },
|
|
198
|
+
{ label: "Mercredi 14 août", value: "mercredi-14-aout" },
|
|
199
|
+
{ label: "Jeudi 15 août", value: "jeudi-15-aout" },
|
|
200
|
+
{ label: "Vendredi 16 août", value: "vendredi-16-aout" },
|
|
201
|
+
{ label: "Samedi 17 août", value: "samedi-17-aout" },
|
|
202
|
+
],
|
|
203
|
+
selectedItem: "",
|
|
204
|
+
placeholder: "Sélectionner une option...",
|
|
205
|
+
multiple: false,
|
|
206
|
+
isRequired: false,
|
|
207
|
+
requireAttention: false,
|
|
208
|
+
disabledItems: ["mardi-13-aout", "jeudi-15-aout"],
|
|
209
|
+
width: 100,
|
|
210
|
+
};
|
|
211
|
+
export var MultipleWithDisabledItems = Template.bind({});
|
|
212
|
+
MultipleWithDisabledItems.args = {
|
|
213
|
+
items: [
|
|
214
|
+
{ label: "Lundi 12 août", value: "lundi-12-aout" },
|
|
215
|
+
{ label: "Mardi 13 août", value: "mardi-13-aout" },
|
|
216
|
+
{ label: "Mercredi 14 août", value: "mercredi-14-aout" },
|
|
217
|
+
{ label: "Jeudi 15 août", value: "jeudi-15-aout" },
|
|
218
|
+
{ label: "Vendredi 16 août", value: "vendredi-16-aout" },
|
|
219
|
+
{ label: "Samedi 17 août", value: "samedi-17-aout" },
|
|
220
|
+
],
|
|
221
|
+
selectedItem: [],
|
|
222
|
+
placeholder: "Sélectionner des options...",
|
|
223
|
+
multiple: true,
|
|
224
|
+
isRequired: false,
|
|
225
|
+
requireAttention: false,
|
|
226
|
+
disabledItems: ["mardi-13-aout", "vendredi-16-aout"],
|
|
227
|
+
maxItems: 4,
|
|
228
|
+
width: 100,
|
|
229
|
+
};
|