allaw-ui 1.0.99 → 1.0.103
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.
|
@@ -8,8 +8,8 @@ var IconButton = function (_a) {
|
|
|
8
8
|
"--custom-background-color": color,
|
|
9
9
|
}
|
|
10
10
|
: {};
|
|
11
|
-
return (React.createElement("button", { className: "icon-button ".concat(style
|
|
12
|
-
React.createElement("i", { className: "icon ".concat(iconName) })));
|
|
11
|
+
return (React.createElement("button", { className: "icon-button ".concat(style), onClick: onClick, style: customStyle },
|
|
12
|
+
React.createElement("i", { className: "icon ".concat(iconName), style: { color: color ? color : "inherit" } })));
|
|
13
13
|
};
|
|
14
14
|
IconButton.defaultProps = {
|
|
15
15
|
style: "smallFilled",
|
|
@@ -25,6 +25,7 @@ function Select(_a, ref) {
|
|
|
25
25
|
left: 0,
|
|
26
26
|
width: 0,
|
|
27
27
|
}), listPosition = _l[0], setListPosition = _l[1];
|
|
28
|
+
var _m = useState("bottom"), placement = _m[0], setPlacement = _m[1];
|
|
28
29
|
useEffect(function () {
|
|
29
30
|
setSelected((multiple ? selectedItem || [] : selectedItem || ""));
|
|
30
31
|
}, [selectedItem, multiple]);
|
|
@@ -64,20 +65,32 @@ function Select(_a, ref) {
|
|
|
64
65
|
return !errorMessage;
|
|
65
66
|
};
|
|
66
67
|
var updateListPosition = function () {
|
|
67
|
-
if (selectRef.current) {
|
|
68
|
-
var
|
|
68
|
+
if (selectRef.current && listRef.current) {
|
|
69
|
+
var selectRect = selectRef.current.getBoundingClientRect();
|
|
70
|
+
var listHeight = listRef.current.getBoundingClientRect().height;
|
|
71
|
+
var windowHeight = window.innerHeight;
|
|
72
|
+
var spaceBelow = windowHeight - selectRect.bottom;
|
|
73
|
+
var shouldShowBelow = spaceBelow >= listHeight;
|
|
74
|
+
setPlacement(shouldShowBelow ? "bottom" : "top");
|
|
69
75
|
setListPosition({
|
|
70
|
-
top:
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
top: shouldShowBelow
|
|
77
|
+
? selectRect.bottom
|
|
78
|
+
: selectRect.top - listHeight - 5,
|
|
79
|
+
left: selectRect.left,
|
|
80
|
+
width: selectRect.width,
|
|
73
81
|
});
|
|
74
82
|
}
|
|
75
83
|
};
|
|
76
84
|
var toggleOpen = function () {
|
|
77
85
|
if (!isOpen) {
|
|
78
|
-
|
|
86
|
+
setIsOpen(true);
|
|
87
|
+
requestAnimationFrame(function () {
|
|
88
|
+
updateListPosition();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
setIsOpen(false);
|
|
79
93
|
}
|
|
80
|
-
setIsOpen(!isOpen);
|
|
81
94
|
};
|
|
82
95
|
var handleClickOutside = function (event) {
|
|
83
96
|
if (selectRef.current &&
|
|
@@ -98,10 +111,24 @@ function Select(_a, ref) {
|
|
|
98
111
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
99
112
|
};
|
|
100
113
|
}, [isOpen]);
|
|
101
|
-
|
|
114
|
+
useEffect(function () {
|
|
115
|
+
if (isOpen) {
|
|
116
|
+
var handleScroll_1 = function () {
|
|
117
|
+
updateListPosition();
|
|
118
|
+
};
|
|
119
|
+
window.addEventListener("scroll", handleScroll_1, true);
|
|
120
|
+
return function () {
|
|
121
|
+
window.removeEventListener("scroll", handleScroll_1, true);
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return function () { };
|
|
125
|
+
}, [isOpen]);
|
|
126
|
+
var renderList = function () { return (React.createElement("div", { ref: listRef, className: "select-list ".concat(isOpen ? "visible" : "", " ").concat(placement), style: {
|
|
127
|
+
position: "fixed",
|
|
102
128
|
top: "".concat(listPosition.top, "px"),
|
|
103
129
|
left: "".concat(listPosition.left, "px"),
|
|
104
130
|
width: "".concat(listPosition.width, "px"),
|
|
131
|
+
margin: placement === "bottom" ? "4px 0 0 0" : "0 0 4px 0",
|
|
105
132
|
} }, items.map(function (item) { return (React.createElement("div", { key: item.value, "data-value": item.value, className: "select-item ".concat(Array.isArray(selected) && selected.includes(item.value)
|
|
106
133
|
? "selected"
|
|
107
134
|
: "", " ").concat(!multiple && item.value === selectedItem ? "highlighted" : "", " ").concat(!multiple ? "single-select" : ""), onClick: function () { return handleSelect(item); } },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./DocumentCard.css";
|
|
3
3
|
export interface DocumentCardProps {
|
|
4
|
-
type: "document" | "note" | "invoice" | "waiting" | undefined;
|
|
4
|
+
type: "document" | "note" | "invoice" | "waiting" | "payment" | undefined;
|
|
5
5
|
title: string;
|
|
6
6
|
date: Date | undefined;
|
|
7
7
|
status: "sent" | "received" | "internal";
|
|
@@ -15,6 +15,8 @@ var DocumentCard = function (_a) {
|
|
|
15
15
|
return "allaw-icon-file";
|
|
16
16
|
case "waiting":
|
|
17
17
|
return "allaw-icon-clock";
|
|
18
|
+
case "payment":
|
|
19
|
+
return "allaw-icon-prestation";
|
|
18
20
|
default:
|
|
19
21
|
return "allaw-icon-document";
|
|
20
22
|
}
|
|
@@ -38,6 +40,9 @@ var DocumentCard = function (_a) {
|
|
|
38
40
|
if (type === "invoice") {
|
|
39
41
|
return "FACTURE";
|
|
40
42
|
}
|
|
43
|
+
if (type === "payment") {
|
|
44
|
+
return "PAIEMENT";
|
|
45
|
+
}
|
|
41
46
|
return type.toUpperCase();
|
|
42
47
|
};
|
|
43
48
|
var formatDate = function (date) {
|
|
@@ -67,7 +72,7 @@ var DocumentCard = function (_a) {
|
|
|
67
72
|
}
|
|
68
73
|
return (React.createElement("div", { className: "document-card", onClick: function () { return onCardClick && onCardClick(); }, style: { cursor: onCardClick ? "pointer" : "default" } },
|
|
69
74
|
React.createElement("div", { className: "document-card-left" },
|
|
70
|
-
React.createElement(IconButton, { style: "largeFilled", iconName: getIconName() }),
|
|
75
|
+
React.createElement(IconButton, { style: "largeFilled", iconName: getIconName(), color: type == "payment" ? "#25BEEB" : "inherit" }),
|
|
71
76
|
React.createElement("div", { className: "document-card-info" },
|
|
72
77
|
React.createElement("span", { className: "document-card-type" }, getDisplayType(type)),
|
|
73
78
|
React.createElement(Paragraph, { text: title, variant: "semiBold", size: "default", maxLines: 1, color: "noir" }),
|
|
@@ -75,7 +80,7 @@ var DocumentCard = function (_a) {
|
|
|
75
80
|
React.createElement("div", { className: "document-card-right" },
|
|
76
81
|
React.createElement("div", { className: "document-card-status" },
|
|
77
82
|
React.createElement(OtherStatusTag, { type: "information", label: getStatusName() })),
|
|
78
|
-
React.createElement("div", { className: "document-card-icon-eye" },
|
|
83
|
+
type != "payment" && React.createElement("div", { className: "document-card-icon-eye" },
|
|
79
84
|
React.createElement("i", { className: "allaw-icon-eye" })))));
|
|
80
85
|
};
|
|
81
86
|
export default DocumentCard;
|