@portnet/ui 2.0.5 → 2.0.7
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.
|
@@ -39,27 +39,22 @@ const StyledMuiFormControl = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((
|
|
|
39
39
|
}))))(() => {
|
|
40
40
|
return {
|
|
41
41
|
"&.MuiFormControl-root": {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
height: "1.4375em",
|
|
45
|
-
display: "flex",
|
|
46
|
-
alignItems: "center",
|
|
47
|
-
lineHeight: "1"
|
|
48
|
-
},
|
|
42
|
+
marginBottom: "16px",
|
|
43
|
+
transition: "all 0.2s ease",
|
|
49
44
|
"&.required .MuiInputBase-root": {
|
|
50
|
-
backgroundColor: _apperance.palette.background.required
|
|
45
|
+
backgroundColor: "".concat(_apperance.palette.background.required)
|
|
51
46
|
},
|
|
52
47
|
"& .MuiFormLabel-root": {
|
|
53
48
|
zIndex: 0,
|
|
54
49
|
lineSpacing: "-0.03em",
|
|
55
50
|
position: "initial",
|
|
56
51
|
transform: "none",
|
|
57
|
-
fontSize: "0.
|
|
52
|
+
fontSize: "0.85rem",
|
|
58
53
|
fontWeight: "600",
|
|
59
|
-
marginBottom: "
|
|
54
|
+
marginBottom: "6px",
|
|
60
55
|
color: _apperance.palette.gray.darker,
|
|
61
|
-
"
|
|
62
|
-
|
|
56
|
+
transition: "color 0.2s ease",
|
|
57
|
+
"&.Mui-focused": {
|
|
63
58
|
color: _apperance.palette.primary
|
|
64
59
|
},
|
|
65
60
|
"&.Mui-disabled": {
|
|
@@ -71,30 +66,59 @@ const StyledMuiFormControl = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((
|
|
|
71
66
|
},
|
|
72
67
|
"& .MuiInputBase-root": {
|
|
73
68
|
backgroundColor: _apperance.palette.white,
|
|
74
|
-
border: "
|
|
75
|
-
borderRadius: "
|
|
76
|
-
"
|
|
77
|
-
|
|
69
|
+
border: "1px solid ".concat(_apperance.palette.gray.dark),
|
|
70
|
+
borderRadius: "8px",
|
|
71
|
+
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.05)",
|
|
72
|
+
transition: "all 0.3s ease",
|
|
73
|
+
"&:hover:not(.Mui-disabled):not(.Mui-error)": {
|
|
74
|
+
borderColor: "".concat(_apperance.palette.primary, "80"),
|
|
75
|
+
boxShadow: "0 3px 6px rgba(0, 0, 0, 0.08)"
|
|
76
|
+
},
|
|
77
|
+
"&.Mui-focused": {
|
|
78
|
+
border: "2px solid ".concat(_apperance.palette.primary),
|
|
79
|
+
boxShadow: "0 0 0 3px ".concat(_apperance.palette.primary, "20")
|
|
78
80
|
},
|
|
79
|
-
"&.Mui-error
|
|
81
|
+
"&.Mui-error": {
|
|
80
82
|
border: "2px solid ".concat(_apperance.palette.error),
|
|
81
|
-
backgroundColor: _apperance.palette.background.error
|
|
83
|
+
backgroundColor: _apperance.palette.background.error,
|
|
84
|
+
boxShadow: "0 0 0 3px ".concat(_apperance.palette.error, "20")
|
|
82
85
|
},
|
|
83
|
-
"&.Mui-disabled
|
|
86
|
+
"&.Mui-disabled": {
|
|
87
|
+
opacity: 0.7,
|
|
88
|
+
border: "1px solid ".concat(_apperance.palette.gray.main),
|
|
84
89
|
backgroundColor: "".concat(_apperance.palette.secondary)
|
|
85
90
|
},
|
|
86
|
-
"& .
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
"& .MuiSelect-select": {
|
|
92
|
+
lineHeight: "1.5",
|
|
93
|
+
padding: "12px 14px",
|
|
94
|
+
fontSize: "0.9rem",
|
|
95
|
+
fontWeight: 400,
|
|
96
|
+
color: "rgba(0, 0, 0, 0.85)",
|
|
97
|
+
minHeight: "auto",
|
|
98
|
+
display: "flex",
|
|
99
|
+
alignItems: "center"
|
|
89
100
|
},
|
|
90
101
|
"& .MuiSvgIcon-root": {
|
|
91
|
-
|
|
102
|
+
fontSize: "1.2rem",
|
|
103
|
+
color: _apperance.palette.gray.dark,
|
|
104
|
+
marginRight: "8px",
|
|
105
|
+
transition: "transform 0.2s ease"
|
|
106
|
+
},
|
|
107
|
+
"&.Mui-focused .MuiSvgIcon-root": {
|
|
108
|
+
transform: "rotate(180deg)",
|
|
109
|
+
color: _apperance.palette.primary
|
|
92
110
|
}
|
|
93
111
|
},
|
|
94
112
|
"& .MuiFormHelperText-root": {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
marginTop: "6px",
|
|
114
|
+
marginLeft: "4px",
|
|
115
|
+
fontWeight: "500",
|
|
116
|
+
fontSize: "0.75rem",
|
|
117
|
+
color: _apperance.palette.gray.darker,
|
|
118
|
+
transition: "color 0.2s ease",
|
|
119
|
+
"&.Mui-error": {
|
|
120
|
+
color: _apperance.palette.error
|
|
121
|
+
}
|
|
98
122
|
},
|
|
99
123
|
"& fieldset": {
|
|
100
124
|
display: "none"
|
|
@@ -169,17 +193,46 @@ const PuiStandardSelect = _ref => {
|
|
|
169
193
|
},
|
|
170
194
|
MenuProps: {
|
|
171
195
|
sx: {
|
|
196
|
+
"& .MuiPaper-root": {
|
|
197
|
+
marginTop: "4px",
|
|
198
|
+
borderRadius: "8px",
|
|
199
|
+
boxShadow: "0 6px 16px rgba(0, 0, 0, 0.1)",
|
|
200
|
+
border: "1px solid ".concat(_apperance.palette.gray.light),
|
|
201
|
+
overflow: "hidden"
|
|
202
|
+
},
|
|
172
203
|
"& .MuiMenu-list": {
|
|
173
|
-
padding: 0,
|
|
174
|
-
"& .MuiMenuItem-root:not(:last-child)": {
|
|
175
|
-
borderBottom: "1px solid ".concat(_apperance.palette.gray.light)
|
|
176
|
-
},
|
|
204
|
+
padding: "4px 0",
|
|
177
205
|
"& .MuiMenuItem-root": {
|
|
178
|
-
fontSize:
|
|
179
|
-
|
|
180
|
-
|
|
206
|
+
fontSize: "0.9rem",
|
|
207
|
+
padding: "8px 16px",
|
|
208
|
+
borderRadius: "0",
|
|
209
|
+
transition: "all 0.2s ease",
|
|
210
|
+
height: "auto",
|
|
211
|
+
minHeight: "40px",
|
|
212
|
+
"&:hover": {
|
|
213
|
+
backgroundColor: "rgba(24, 144, 255, 0.05)"
|
|
214
|
+
},
|
|
215
|
+
"&.Mui-selected": {
|
|
216
|
+
backgroundColor: "rgba(24, 144, 255, 0.1)",
|
|
217
|
+
color: _apperance.palette.primary,
|
|
218
|
+
fontWeight: 500,
|
|
219
|
+
"&:hover": {
|
|
220
|
+
backgroundColor: "rgba(24, 144, 255, 0.15)"
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"&:not(:last-child)": {
|
|
224
|
+
borderBottom: "1px solid ".concat(_apperance.palette.gray.light)
|
|
225
|
+
}
|
|
181
226
|
}
|
|
182
227
|
}
|
|
228
|
+
},
|
|
229
|
+
anchorOrigin: {
|
|
230
|
+
vertical: "bottom",
|
|
231
|
+
horizontal: "left"
|
|
232
|
+
},
|
|
233
|
+
transformOrigin: {
|
|
234
|
+
vertical: "top",
|
|
235
|
+
horizontal: "left"
|
|
183
236
|
}
|
|
184
237
|
}
|
|
185
238
|
}, rest), {}, {
|
|
@@ -6,7 +6,7 @@ require("core-js/modules/esnext.iterator.for-each.js");
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.default = void 0;
|
|
9
|
+
exports.default = exports.PuiTableHeader = void 0;
|
|
10
10
|
require("core-js/modules/es.array.includes.js");
|
|
11
11
|
require("core-js/modules/es.regexp.to-string.js");
|
|
12
12
|
require("core-js/modules/es.string.includes.js");
|
|
@@ -20,18 +20,19 @@ var _PuiTooltip = _interopRequireDefault(require("../others/PuiTooltip"));
|
|
|
20
20
|
var _antd = require("antd");
|
|
21
21
|
var _icons = require("@ant-design/icons");
|
|
22
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
-
const _excluded = ["
|
|
23
|
+
const _excluded = ["field", "headerName", "width", "renderCell", "sortable", "align"],
|
|
24
|
+
_excluded2 = ["id", "className", "sx", "elevate", "rows", "rowCount", "columns", "paginationMode", "page", "pageSize", "checkboxSelection", "loading", "stripped", "actions", "oneActionOnly", "onSelect", "onPageChange", "onPageSizeChange", "stickyColumns", "pinnedColumns", "getRowId", "onSelectionModelChange", "selectionModel", "onRowClick", "highlightHoveredRow", "stickyHeader", "hideFooter", "hideFooterPagination", "components", "componentsProps", "getRowClassName", "onActionClick"];
|
|
24
25
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
25
26
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
27
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
29
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
27
30
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
31
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
32
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
30
33
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
31
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
|
-
|
|
33
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
34
|
-
const tableCustomStyles = "\n /* Styles g\xE9n\xE9raux am\xE9lior\xE9s */\n .pui-table {\n border-radius: 10px;\n overflow: hidden;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);\n }\n \n .pui-table .ant-table {\n border-radius: 8px;\n }\n \n .pui-table .ant-table-thead > tr > th {\n background-color: #f7f9fc;\n color: #1f2937;\n font-weight: 600;\n padding: 12px 16px;\n border-bottom: 2px solid #e5e7eb;\n transition: background-color 0.2s;\n }\n \n .pui-table .ant-table-thead > tr > th:hover {\n background-color: #eef2ff;\n }\n \n .pui-table .ant-table-tbody > tr > td {\n padding: 12px 16px;\n transition: all 0.2s ease;\n }\n \n /* Couleurs altern\xE9es plus contrast\xE9es */\n .pui-table .ant-table-tbody > tr.ant-table-row-light > td {\n background-color: #ffffff;\n }\n \n .pui-table .ant-table-tbody > tr.ant-table-row-dark > td {\n background-color: #f4f6f8;\n }\n \n /* Effet de survol doux */\n .pui-table .ant-table-tbody > tr:hover > td {\n background-color: rgba(24, 144, 255, 0.1) !important;\n transition: background-color 0.3s ease;\n }\n \n /* Indicateur visuel sans d\xE9placement */\n .pui-table .ant-table-tbody > tr {\n position: relative;\n }\n \n .pui-table .ant-table-tbody > tr:hover {\n box-shadow: inset 0 0 0 1px rgba(24, 144, 255, 0.3);\n }\n \n .pui-table .ant-table-tbody > tr > td:first-child {\n position: relative;\n }\n \n .pui-table .ant-table-tbody > tr:hover > td:first-child::before {\n content: '';\n position: absolute;\n left: 0;\n top: 0;\n height: 100%;\n width: 3px;\n background-color: #1890ff;\n animation: pulse 1.5s infinite;\n }\n \n /* Styles des lignes s\xE9lectionn\xE9es */\n .pui-table .ant-table-tbody > tr.ant-table-row-selected > td {\n background-color: rgba(24, 144, 255, 0.05);\n border-left: none !important;\n }\n \n .pui-table .ant-table-tbody > tr.ant-table-row-selected > td:first-child {\n position: relative;\n }\n \n /* Indicateur anim\xE9 discret pour lignes s\xE9lectionn\xE9es */\n .pui-table .ant-table-tbody > tr.ant-table-row-selected > td:first-child::after {\n content: '';\n position: absolute;\n left: 0;\n top: 0;\n height: 100%;\n width: 3px;\n background-color: rgba(24, 144, 255, 0.7);\n animation: pulse 2s infinite;\n }\n \n .pui-table .ant-table-tbody > tr.ant-table-row-selected:hover > td {\n background-color: rgba(24, 144, 255, 0.15) !important;\n }\n \n /* Styles des lignes en \xE9dition */\n .pui-table .ant-table-tbody > tr.ant-table-row-editing {\n background-color: rgba(24, 144, 255, 0.1) !important;\n }\n \n .pui-table .ant-table-tbody > tr.ant-table-row-editing > td {\n border-bottom: 1px solid #1890ff !important;\n border-top: 1px solid #1890ff !important;\n }\n \n .pui-table .ant-table-tbody > tr:first-child.ant-table-row-editing > td {\n border-top: 2px solid #1890ff !important;\n }\n \n .pui-table .ant-table-tbody > tr:last-child.ant-table-row-editing > td {\n border-bottom: 2px solid #1890ff !important;\n }\n \n /* Animation pour l'indicateur de ligne */\n @keyframes pulse {\n 0% { opacity: 0.5; }\n 50% { opacity: 1; }\n 100% { opacity: 0.5; }\n }\n \n /* Pagination ergonomique */\n .pui-table-pagination {\n padding: 14px 24px;\n gap: 16px;\n }\n \n .pui-table-pagination .ant-pagination-item,\n .pui-table-pagination .ant-pagination-prev button,\n .pui-table-pagination .ant-pagination-next button {\n height: 36px;\n min-width: 36px;\n }\n \n .pui-table-pagination .ant-pagination-item {\n border-radius: 6px;\n transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);\n border: 1px solid #e2e8f0;\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .pui-table-pagination .ant-pagination-item a {\n padding: 0 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n width: 100%;\n }\n \n .pui-table-pagination .ant-pagination-prev,\n .pui-table-pagination .ant-pagination-next {\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .pui-table-pagination .ant-pagination-item:hover,\n .pui-table-pagination .ant-pagination-prev:hover button,\n .pui-table-pagination .ant-pagination-next:hover button {\n transform: translateY(-2px);\n box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);\n border-color: #bfdbfe;\n color: #1890ff;\n z-index: 2;\n }\n \n .pui-table-pagination .ant-pagination-item-active {\n background: linear-gradient(135deg, #1890ff, #0050b3);\n border-color: transparent !important;\n font-weight: 600;\n position: relative;\n z-index: 1;\n }\n \n .pui-table-pagination .ant-pagination-item-active::after {\n content: '';\n position: absolute;\n inset: -1px;\n background: linear-gradient(135deg, #40a9ff, #1890ff);\n border-radius: 7px;\n z-index: -1;\n opacity: 0;\n transition: opacity 0.3s;\n }\n \n .pui-table-pagination .ant-pagination-item-active:hover::after {\n opacity: 1;\n }\n \n .pui-table-pagination .ant-pagination-item-active a {\n color: white !important;\n font-weight: 600;\n text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);\n }\n \n .pui-table-pagination .ant-pagination-options {\n margin-left: 16px;\n display: flex;\n align-items: center;\n gap: 12px;\n }\n \n .pui-table-pagination .ant-select-selector {\n border-radius: 6px !important;\n height: 32px !important;\n padding: 0 8px !important;\n border-color: #e2e8f0 !important;\n transition: all 0.2s !important;\n }\n \n .pui-table-pagination .ant-select:hover .ant-select-selector {\n border-color: #bfdbfe !important;\n }\n \n .pui-table-pagination .ant-select-focused .ant-select-selector {\n border-color: #1890ff !important;\n box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2) !important;\n }\n \n .pui-table-pagination .ant-select-selection-item {\n line-height: 30px !important;\n font-weight: 500;\n }\n \n .pui-table-pagination .ant-pagination-options-quick-jumper {\n margin-left: 16px;\n display: flex;\n align-items: center;\n gap: 8px;\n font-weight: 500;\n color: #4b5563;\n }\n \n .pui-table-pagination .ant-pagination-options-quick-jumper input {\n border-radius: 6px;\n transition: all 0.2s;\n height: 32px;\n border-color: #e2e8f0;\n width: 50px;\n padding: 4px 8px;\n text-align: center;\n }\n \n .pui-table-pagination .ant-pagination-options-quick-jumper input:hover {\n border-color: #bfdbfe;\n }\n \n .pui-table-pagination .ant-pagination-options-quick-jumper input:focus {\n border-color: #1890ff;\n box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);\n }\n \n .pui-table-total-items {\n color: #4b5563;\n font-size: 14px;\n font-weight: 500;\n background-color: rgba(255, 255, 255, 0.7);\n padding: 6px 12px;\n border-radius: 6px;\n border: 1px solid #e2e8f0;\n display: flex;\n align-items: center;\n gap: 4px;\n }\n \n .pui-table-total-items strong {\n color: #1f2937;\n background-color: #f1f5f9;\n padding: 1px 6px;\n border-radius: 4px;\n font-weight: 600;\n min-width: 40px;\n text-align: center;\n }\n \n @media (max-width: 640px) {\n .pui-table-pagination {\n flex-direction: column;\n align-items: flex-start;\n }\n \n .pui-table-pagination .ant-pagination {\n width: 100%;\n justify-content: center;\n }\n \n .pui-table-total-items {\n align-self: center;\n }\n }\n";
|
|
34
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Styles personnalisés pour le tableau
|
|
35
|
+
const tableCustomStyles = "\n /* Styles g\xE9n\xE9raux du tableau - inspir\xE9 du design de r\xE9f\xE9rence */\n .pui-table {\n border-radius: 8px;\n overflow: hidden;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);\n background-color: #ffffff;\n }\n \n .pui-table .ant-table {\n border-radius: 8px;\n }\n \n /* En-t\xEAtes de colonnes */\n .pui-table .ant-table-thead > tr > th {\n background-color: #f9fafb;\n color: #374151;\n font-weight: 600;\n font-size: 0.875rem;\n padding: 12px 16px;\n border-bottom: 1px solid #e5e7eb;\n transition: background-color 0.2s;\n }\n \n .pui-table .ant-table-thead > tr > th:hover {\n background-color: #f3f4f6;\n }\n \n /* Cellules du tableau */\n .pui-table .ant-table-tbody > tr > td {\n padding: 12px 16px;\n border-bottom: 1px solid #f3f4f6;\n color: #111827;\n font-size: 0.875rem;\n transition: background-color 0.2s ease;\n }\n \n /* Lignes altern\xE9es */\n .pui-table .ant-table-tbody > tr:nth-child(even) > td {\n background-color: #f9fafb;\n }\n \n .pui-table .ant-table-tbody > tr:nth-child(odd) > td {\n background-color: #ffffff;\n }\n \n /* Effet de survol */\n .pui-table .ant-table-tbody > tr:hover > td {\n background-color: #f3f4f6 !important;\n }\n \n /* Styles des lignes s\xE9lectionn\xE9es */\n .pui-table .ant-table-tbody > tr.ant-table-row-selected > td {\n background-color: rgba(59, 130, 246, 0.05);\n }\n \n .pui-table .ant-table-tbody > tr.ant-table-row-selected:hover > td {\n background-color: rgba(59, 130, 246, 0.1) !important;\n }\n \n /* Styles des statuts */\n .pui-table .status-badge {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 2px 8px;\n border-radius: 9999px;\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1.5;\n }\n \n .pui-table .status-badge.cancelled {\n background-color: #fee2e2;\n color: #b91c1c;\n }\n \n .pui-table .status-badge.delivered {\n background-color: #dcfce7;\n color: #15803d;\n }\n \n .pui-table .status-badge.ready {\n background-color: #e0f2fe;\n color: #0369a1;\n }\n \n .pui-table .status-badge.on-the-way {\n background-color: #fef3c7;\n color: #92400e;\n }\n \n /* Pagination */\n .pui-table-pagination {\n padding: 12px 16px;\n border-top: 1px solid #f3f4f6;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n \n .pui-table-pagination .ant-pagination {\n margin: 0;\n }\n \n .pui-table-pagination .ant-pagination-item,\n .pui-table-pagination .ant-pagination-prev button,\n .pui-table-pagination .ant-pagination-next button {\n border-radius: 6px;\n border: 1px solid #e5e7eb;\n height: 32px;\n min-width: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .pui-table-pagination .ant-pagination-item:hover,\n .pui-table-pagination .ant-pagination-prev:hover button,\n .pui-table-pagination .ant-pagination-next:hover button {\n border-color: #d1d5db;\n color: #4b5563;\n }\n \n .pui-table-pagination .ant-pagination-item-active {\n background-color: #3b82f6;\n border-color: #3b82f6;\n }\n \n .pui-table-pagination .ant-pagination-item-active a {\n color: white;\n }\n \n .pui-table-pagination .ant-pagination-item-active:hover {\n background-color: #2563eb;\n border-color: #2563eb;\n }\n \n /* Styles pour la colonne d'actions */\n .pui-table .actions-column {\n white-space: nowrap !important;\n overflow: visible !important;\n }\n \n .pui-table .action-button {\n padding: 4px 8px !important;\n margin: 0 2px !important;\n min-width: auto !important;\n height: 28px !important;\n line-height: 20px !important;\n transition: all 0.2s !important;\n }\n \n .pui-table .action-button:hover {\n background-color: rgba(24, 144, 255, 0.1) !important;\n color: #1890ff !important;\n }\n \n /* Bouton Cr\xE9er */\n .pui-create-button {\n background-color: #3b82f6;\n color: white;\n border: none;\n border-radius: 6px;\n padding: 8px 16px;\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 8px;\n transition: all 0.2s;\n }\n \n .pui-create-button:hover {\n background-color: #2563eb;\n }\n \n /* Titre de la page */\n .pui-table-title {\n font-size: 1.5rem;\n font-weight: 600;\n color: #111827;\n margin-bottom: 16px;\n }\n";
|
|
35
36
|
|
|
36
37
|
// Injection des styles dans le document
|
|
37
38
|
const injectStyles = () => {
|
|
@@ -54,29 +55,58 @@ const removeStyles = () => {
|
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
// Composant pour les
|
|
58
|
+
// Composant pour les boutons d'action
|
|
58
59
|
const TableActions = _ref => {
|
|
59
60
|
let {
|
|
60
61
|
row,
|
|
61
62
|
actions
|
|
62
63
|
} = _ref;
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
64
|
+
// Empêcher la propagation des événements au niveau du conteneur
|
|
65
|
+
const handleContainerClick = e => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
e.stopPropagation();
|
|
68
68
|
};
|
|
69
69
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Space, {
|
|
70
70
|
size: "small",
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
onClick: handleContainerClick // Arrêter la propagation au niveau du conteneur
|
|
72
|
+
,
|
|
73
|
+
onMouseDown: handleContainerClick // Capturer également les événements mousedown
|
|
74
|
+
,
|
|
75
|
+
style: {
|
|
76
|
+
display: 'inline-flex'
|
|
77
|
+
},
|
|
78
|
+
children: actions.map((action, index) => {
|
|
79
|
+
// Si l'action a une condition et que la condition n'est pas remplie, ne pas afficher le bouton
|
|
80
|
+
if (action.condition && !action.condition(row)) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
84
|
+
title: action.tooltip || action.label,
|
|
85
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
86
|
+
type: "text",
|
|
87
|
+
icon: action.icon,
|
|
88
|
+
onClick: e => {
|
|
89
|
+
// Empêcher la propagation et le comportement par défaut
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
e.stopPropagation();
|
|
92
|
+
// Appeler la fonction onClick de l'action
|
|
93
|
+
if (typeof action.onClick === 'function') {
|
|
94
|
+
action.onClick(row);
|
|
95
|
+
} else if (typeof action.action === 'function') {
|
|
96
|
+
// Pour la rétrocompatibilité
|
|
97
|
+
action.action(row);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
onMouseDown: e => {
|
|
101
|
+
// Empêcher également la propagation des événements mousedown
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
},
|
|
105
|
+
className: "action-button",
|
|
106
|
+
"aria-label": action.label
|
|
107
|
+
})
|
|
108
|
+
}, index);
|
|
109
|
+
})
|
|
80
110
|
});
|
|
81
111
|
};
|
|
82
112
|
|
|
@@ -91,65 +121,249 @@ const customRenderEmpty = () => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
|
91
121
|
})
|
|
92
122
|
});
|
|
93
123
|
|
|
94
|
-
//
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
// Fonction pour rendre les badges de statut
|
|
125
|
+
const renderStatusBadge = status => {
|
|
126
|
+
if (!status) return null;
|
|
127
|
+
const statusText = status.toString().toLowerCase();
|
|
128
|
+
let className = 'status-badge';
|
|
129
|
+
if (statusText.includes('cancel')) {
|
|
130
|
+
className += ' cancelled';
|
|
131
|
+
} else if (statusText.includes('deliver')) {
|
|
132
|
+
className += ' delivered';
|
|
133
|
+
} else if (statusText.includes('ready')) {
|
|
134
|
+
className += ' ready';
|
|
135
|
+
} else if (statusText.includes('way') || statusText.includes('progress')) {
|
|
136
|
+
className += ' on-the-way';
|
|
137
|
+
}
|
|
138
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
139
|
+
className: className,
|
|
140
|
+
children: status
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// Fonction pour transformer les colonnes et ajouter le rendu des badges de statut
|
|
145
|
+
const transformColumns = columns => {
|
|
146
|
+
return columns.map(column => {
|
|
147
|
+
var _newColumn$title;
|
|
148
|
+
const newColumn = _objectSpread({}, column);
|
|
149
|
+
|
|
150
|
+
// Si c'est une colonne de statut, ajouter le rendu personnalisé
|
|
151
|
+
if (newColumn.dataIndex === 'status' || newColumn.key === 'status' || ((_newColumn$title = newColumn.title) === null || _newColumn$title === void 0 ? void 0 : _newColumn$title.toString().toLowerCase()) === 'status') {
|
|
152
|
+
newColumn.render = text => renderStatusBadge(text);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Ajouter d'autres transformations si nécessaire
|
|
156
|
+
|
|
157
|
+
return newColumn;
|
|
158
|
+
});
|
|
159
|
+
};
|
|
106
160
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
161
|
+
// Convertir les colonnes du format DataGrid au format Ant Design
|
|
162
|
+
const convertColumns = (columns, onActionClick, actions) => {
|
|
163
|
+
if (!columns) return [];
|
|
164
|
+
const antColumns = columns.map(column => {
|
|
165
|
+
const {
|
|
166
|
+
field,
|
|
167
|
+
headerName,
|
|
168
|
+
width,
|
|
169
|
+
renderCell,
|
|
170
|
+
sortable,
|
|
171
|
+
align
|
|
172
|
+
} = column,
|
|
173
|
+
rest = _objectWithoutProperties(column, _excluded);
|
|
174
|
+
return _objectSpread({
|
|
175
|
+
title: headerName,
|
|
176
|
+
dataIndex: field,
|
|
177
|
+
key: field,
|
|
178
|
+
width,
|
|
179
|
+
sorter: sortable,
|
|
180
|
+
align: align || 'left',
|
|
181
|
+
render: renderCell ? (text, record) => renderCell({
|
|
110
182
|
row: record,
|
|
111
183
|
value: text
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
antColumn.render = (text, record) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
115
|
-
title: column.titleGetter ? column.titleGetter(record) : String(column.valueGetter({
|
|
116
|
-
row: record
|
|
117
|
-
})),
|
|
118
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
119
|
-
children: column.valueGetter({
|
|
120
|
-
row: record
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
});
|
|
124
|
-
} else if (column.field) {
|
|
125
|
-
antColumn.render = (text, record) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
126
|
-
title: column.titleGetter ? column.titleGetter(record) : String(record[column.field] || ''),
|
|
127
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
128
|
-
children: record[column.field]
|
|
129
|
-
})
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
return antColumn;
|
|
184
|
+
}) : undefined
|
|
185
|
+
}, rest);
|
|
133
186
|
});
|
|
134
187
|
|
|
135
|
-
// Ajouter
|
|
188
|
+
// Ajouter une colonne d'actions si des actions sont fournies
|
|
136
189
|
if (actions && actions.length > 0) {
|
|
137
|
-
|
|
190
|
+
antColumns.push({
|
|
138
191
|
title: 'Actions',
|
|
139
|
-
key: '
|
|
192
|
+
key: 'actions',
|
|
140
193
|
width: 100,
|
|
141
194
|
align: 'center',
|
|
142
195
|
render: (_, record) => /*#__PURE__*/(0, _jsxRuntime.jsx)(TableActions, {
|
|
143
196
|
row: record,
|
|
144
197
|
actions: actions
|
|
145
|
-
})
|
|
198
|
+
}),
|
|
199
|
+
// Empêcher le tri sur la colonne d'actions
|
|
200
|
+
sorter: false,
|
|
201
|
+
// Empêcher le filtrage sur la colonne d'actions
|
|
202
|
+
filterable: false
|
|
146
203
|
});
|
|
147
204
|
}
|
|
148
|
-
|
|
205
|
+
|
|
206
|
+
// Appliquer les transformations pour les badges de statut et autres styles
|
|
207
|
+
return transformColumns(antColumns);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// Composant de pagination ergonomique personnalisé
|
|
211
|
+
const PuiTablePagination = _ref2 => {
|
|
212
|
+
let {
|
|
213
|
+
current,
|
|
214
|
+
pageSize,
|
|
215
|
+
total,
|
|
216
|
+
onChange
|
|
217
|
+
} = _ref2;
|
|
218
|
+
// Calculer le nombre total de pages
|
|
219
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
220
|
+
|
|
221
|
+
// Calculer la plage d'éléments affichés
|
|
222
|
+
const startItem = (current - 1) * pageSize + 1;
|
|
223
|
+
const endItem = Math.min(current * pageSize, total);
|
|
224
|
+
|
|
225
|
+
// Fonction pour aller à la page précédente
|
|
226
|
+
const goToPrevPage = () => {
|
|
227
|
+
if (current > 1) {
|
|
228
|
+
onChange(current - 1, pageSize);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// Fonction pour aller à la page suivante
|
|
233
|
+
const goToNextPage = () => {
|
|
234
|
+
if (current < totalPages) {
|
|
235
|
+
onChange(current + 1, pageSize);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// Fonction pour générer les numéros de page à afficher
|
|
240
|
+
const getPageNumbers = () => {
|
|
241
|
+
const pages = [];
|
|
242
|
+
const maxVisiblePages = 5; // Nombre maximum de pages visibles
|
|
243
|
+
|
|
244
|
+
// Toujours afficher la première page
|
|
245
|
+
pages.push(1);
|
|
246
|
+
|
|
247
|
+
// Calculer la plage de pages à afficher
|
|
248
|
+
let startPage = Math.max(2, current - Math.floor(maxVisiblePages / 2));
|
|
249
|
+
let endPage = Math.min(totalPages - 1, startPage + maxVisiblePages - 3);
|
|
250
|
+
|
|
251
|
+
// Ajuster la plage si nécessaire
|
|
252
|
+
if (endPage < startPage) {
|
|
253
|
+
endPage = startPage;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Ajouter des ellipses si nécessaire
|
|
257
|
+
if (startPage > 2) {
|
|
258
|
+
pages.push('ellipsis1');
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Ajouter les pages intermédiaires
|
|
262
|
+
for (let i = startPage; i <= endPage; i++) {
|
|
263
|
+
pages.push(i);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Ajouter des ellipses si nécessaire
|
|
267
|
+
if (endPage < totalPages - 1) {
|
|
268
|
+
pages.push('ellipsis2');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Toujours afficher la dernière page si elle existe
|
|
272
|
+
if (totalPages > 1) {
|
|
273
|
+
pages.push(totalPages);
|
|
274
|
+
}
|
|
275
|
+
return pages;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// Style pour les boutons de pagination
|
|
279
|
+
const buttonStyle = {
|
|
280
|
+
display: 'flex',
|
|
281
|
+
alignItems: 'center',
|
|
282
|
+
justifyContent: 'center',
|
|
283
|
+
width: '32px',
|
|
284
|
+
height: '32px',
|
|
285
|
+
margin: '0 4px',
|
|
286
|
+
borderRadius: '4px',
|
|
287
|
+
border: '1px solid #d9d9d9',
|
|
288
|
+
backgroundColor: '#fff',
|
|
289
|
+
cursor: 'pointer',
|
|
290
|
+
transition: 'all 0.2s',
|
|
291
|
+
color: '#666',
|
|
292
|
+
fontWeight: 'normal',
|
|
293
|
+
fontSize: '14px',
|
|
294
|
+
lineHeight: '32px',
|
|
295
|
+
userSelect: 'none'
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// Style pour le bouton de page active
|
|
299
|
+
const activeButtonStyle = _objectSpread(_objectSpread({}, buttonStyle), {}, {
|
|
300
|
+
backgroundColor: '#1890ff',
|
|
301
|
+
borderColor: '#1890ff',
|
|
302
|
+
color: '#fff',
|
|
303
|
+
fontWeight: 'bold'
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Style pour les boutons désactivés
|
|
307
|
+
const disabledButtonStyle = _objectSpread(_objectSpread({}, buttonStyle), {}, {
|
|
308
|
+
cursor: 'not-allowed',
|
|
309
|
+
color: '#d9d9d9',
|
|
310
|
+
backgroundColor: '#f5f5f5'
|
|
311
|
+
});
|
|
312
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
313
|
+
style: {
|
|
314
|
+
display: 'flex',
|
|
315
|
+
alignItems: 'center',
|
|
316
|
+
justifyContent: 'space-between'
|
|
317
|
+
},
|
|
318
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
319
|
+
style: {
|
|
320
|
+
fontSize: '14px',
|
|
321
|
+
color: '#666'
|
|
322
|
+
},
|
|
323
|
+
children: ["Affichage de ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
324
|
+
children: startItem
|
|
325
|
+
}), " \xE0 ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
326
|
+
children: endItem
|
|
327
|
+
}), " sur ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
328
|
+
children: total
|
|
329
|
+
}), " \xE9l\xE9ments"]
|
|
330
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
331
|
+
style: {
|
|
332
|
+
display: 'flex',
|
|
333
|
+
alignItems: 'center'
|
|
334
|
+
},
|
|
335
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
336
|
+
style: current === 1 ? disabledButtonStyle : buttonStyle,
|
|
337
|
+
onClick: current === 1 ? undefined : goToPrevPage,
|
|
338
|
+
title: "Page pr\xE9c\xE9dente",
|
|
339
|
+
children: "<"
|
|
340
|
+
}), getPageNumbers().map((page, index) => {
|
|
341
|
+
if (page === 'ellipsis1' || page === 'ellipsis2') {
|
|
342
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
343
|
+
style: _objectSpread(_objectSpread({}, buttonStyle), {}, {
|
|
344
|
+
border: 'none',
|
|
345
|
+
cursor: 'default'
|
|
346
|
+
}),
|
|
347
|
+
children: "..."
|
|
348
|
+
}, page);
|
|
349
|
+
}
|
|
350
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
351
|
+
style: page === current ? activeButtonStyle : buttonStyle,
|
|
352
|
+
onClick: () => page !== current && onChange(page, pageSize),
|
|
353
|
+
children: page
|
|
354
|
+
}, page);
|
|
355
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
356
|
+
style: current === totalPages ? disabledButtonStyle : buttonStyle,
|
|
357
|
+
onClick: current === totalPages ? undefined : goToNextPage,
|
|
358
|
+
title: "Page suivante",
|
|
359
|
+
children: ">"
|
|
360
|
+
})]
|
|
361
|
+
})]
|
|
362
|
+
});
|
|
149
363
|
};
|
|
150
364
|
|
|
151
365
|
// Composant principal PuiTable avec Ant Design
|
|
152
|
-
const PuiTable = /*#__PURE__*/React.forwardRef((
|
|
366
|
+
const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
153
367
|
let {
|
|
154
368
|
id,
|
|
155
369
|
className,
|
|
@@ -170,11 +384,23 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
170
384
|
onPageChange,
|
|
171
385
|
onPageSizeChange,
|
|
172
386
|
stickyColumns = [],
|
|
173
|
-
pinnedColumns
|
|
174
|
-
|
|
175
|
-
|
|
387
|
+
pinnedColumns,
|
|
388
|
+
getRowId,
|
|
389
|
+
onSelectionModelChange,
|
|
390
|
+
selectionModel,
|
|
391
|
+
onRowClick,
|
|
392
|
+
highlightHoveredRow,
|
|
393
|
+
stickyHeader,
|
|
394
|
+
hideFooter,
|
|
395
|
+
hideFooterPagination,
|
|
396
|
+
components,
|
|
397
|
+
componentsProps,
|
|
398
|
+
getRowClassName,
|
|
399
|
+
onActionClick
|
|
400
|
+
} = _ref3,
|
|
401
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
176
402
|
// Convertir les colonnes au format Ant Design
|
|
177
|
-
const antColumns = React.useMemo(() => convertColumns(columns, actions), [columns, actions]);
|
|
403
|
+
const antColumns = React.useMemo(() => convertColumns(columns, onActionClick, actions), [columns, onActionClick, actions]);
|
|
178
404
|
|
|
179
405
|
// Gérer la sélection
|
|
180
406
|
const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
|
|
@@ -227,8 +453,60 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
227
453
|
injectStyles();
|
|
228
454
|
return () => removeStyles();
|
|
229
455
|
}, []);
|
|
456
|
+
|
|
457
|
+
// Mettre à jour les lignes sélectionnées lorsque selectionModel change
|
|
458
|
+
React.useEffect(() => {
|
|
459
|
+
if (selectionModel) {
|
|
460
|
+
setSelectedRowKeys(selectionModel);
|
|
461
|
+
}
|
|
462
|
+
}, [selectionModel]);
|
|
463
|
+
|
|
464
|
+
// Gérer le changement de sélection
|
|
465
|
+
const handleSelectionChange = newSelectedRowKeys => {
|
|
466
|
+
setSelectedRowKeys(newSelectedRowKeys);
|
|
467
|
+
if (onSelectionModelChange) {
|
|
468
|
+
onSelectionModelChange(newSelectedRowKeys);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// Gérer le clic sur une ligne
|
|
473
|
+
const handleRowClick = record => {
|
|
474
|
+
if (onRowClick) {
|
|
475
|
+
onRowClick(record);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// Obtenir les propriétés de ligne (pour les événements et les classes)
|
|
480
|
+
const getRowProps = record => {
|
|
481
|
+
const rowId = getRowId ? getRowId(record) : record.id;
|
|
482
|
+
const isSelected = selectedRowKeys.includes(rowId);
|
|
483
|
+
return {
|
|
484
|
+
onClick: e => {
|
|
485
|
+
// Ne déclencher le clic sur la ligne que si l'événement n'a pas été arrêté par un enfant
|
|
486
|
+
if (!e.isPropagationStopped() && onRowClick) {
|
|
487
|
+
onRowClick(record);
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
className: "".concat(getRowClassName ? getRowClassName(record) : '', " ").concat(isSelected ? 'ant-table-row-selected' : ''),
|
|
491
|
+
style: {
|
|
492
|
+
cursor: onRowClick ? 'pointer' : 'default'
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
// Calculer le nombre total de pages
|
|
498
|
+
const totalPages = Math.ceil(rowCount / pageSize);
|
|
230
499
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.ConfigProvider, {
|
|
231
|
-
|
|
500
|
+
theme: {
|
|
501
|
+
components: {
|
|
502
|
+
Table: {
|
|
503
|
+
headerBg: '#f9fafb',
|
|
504
|
+
headerColor: '#374151',
|
|
505
|
+
borderColor: '#f3f4f6',
|
|
506
|
+
rowHoverBg: '#f3f4f6'
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
},
|
|
232
510
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Spin, {
|
|
233
511
|
spinning: loading,
|
|
234
512
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Table, _objectSpread({
|
|
@@ -251,29 +529,22 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
251
529
|
let className = index % 2 === 0 ? 'ant-table-row-light' : 'ant-table-row-dark';
|
|
252
530
|
if (record.isEditing) className += ' ant-table-row-editing';
|
|
253
531
|
return className;
|
|
254
|
-
}
|
|
255
|
-
|
|
532
|
+
},
|
|
533
|
+
onRow: getRowProps
|
|
534
|
+
}, rest)), !hideFooter && !hideFooterPagination && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
256
535
|
className: "pui-table-pagination",
|
|
257
|
-
children:
|
|
258
|
-
className: "pui-table-total-items",
|
|
259
|
-
children: ["Total : ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
|
|
260
|
-
children: rowCount || rows.length
|
|
261
|
-
}), " \xE9l\xE9ments"]
|
|
262
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Pagination, {
|
|
536
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiTablePagination, {
|
|
263
537
|
current: page + 1,
|
|
264
538
|
pageSize: pageSize,
|
|
265
|
-
total: rowCount
|
|
266
|
-
onChange:
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
onShowSizeChange: (current, size) => {
|
|
272
|
-
if (onPageSizeChange) {
|
|
273
|
-
onPageSizeChange(size);
|
|
539
|
+
total: rowCount,
|
|
540
|
+
onChange: (newPage, newPageSize) => {
|
|
541
|
+
if (newPageSize !== pageSize) {
|
|
542
|
+
onPageSizeChange && onPageSizeChange(newPageSize);
|
|
543
|
+
} else {
|
|
544
|
+
onPageChange && onPageChange(newPage - 1);
|
|
274
545
|
}
|
|
275
546
|
}
|
|
276
|
-
})
|
|
547
|
+
})
|
|
277
548
|
})]
|
|
278
549
|
})
|
|
279
550
|
});
|
|
@@ -302,7 +573,19 @@ PuiTable.propTypes = {
|
|
|
302
573
|
onPageChange: _propTypes.default.func,
|
|
303
574
|
onPageSizeChange: _propTypes.default.func,
|
|
304
575
|
stickyColumns: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
305
|
-
pinnedColumns: _propTypes.default.object
|
|
576
|
+
pinnedColumns: _propTypes.default.object,
|
|
577
|
+
getRowId: _propTypes.default.func,
|
|
578
|
+
onSelectionModelChange: _propTypes.default.func,
|
|
579
|
+
selectionModel: _propTypes.default.array,
|
|
580
|
+
onRowClick: _propTypes.default.func,
|
|
581
|
+
highlightHoveredRow: _propTypes.default.bool,
|
|
582
|
+
stickyHeader: _propTypes.default.bool,
|
|
583
|
+
hideFooter: _propTypes.default.bool,
|
|
584
|
+
hideFooterPagination: _propTypes.default.bool,
|
|
585
|
+
components: _propTypes.default.object,
|
|
586
|
+
componentsProps: _propTypes.default.object,
|
|
587
|
+
getRowClassName: _propTypes.default.func,
|
|
588
|
+
onActionClick: _propTypes.default.func
|
|
306
589
|
};
|
|
307
590
|
PuiTable.defaultProps = {
|
|
308
591
|
oneActionOnly: false,
|
|
@@ -313,6 +596,51 @@ PuiTable.defaultProps = {
|
|
|
313
596
|
stripped: false,
|
|
314
597
|
actions: [],
|
|
315
598
|
stickyColumns: [],
|
|
316
|
-
rows: []
|
|
599
|
+
rows: [],
|
|
600
|
+
getRowId: null,
|
|
601
|
+
onSelectionModelChange: null,
|
|
602
|
+
selectionModel: null,
|
|
603
|
+
onRowClick: null,
|
|
604
|
+
highlightHoveredRow: false,
|
|
605
|
+
stickyHeader: false,
|
|
606
|
+
hideFooter: false,
|
|
607
|
+
hideFooterPagination: false,
|
|
608
|
+
components: null,
|
|
609
|
+
componentsProps: null,
|
|
610
|
+
getRowClassName: null,
|
|
611
|
+
onActionClick: null
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
// Composant pour l'en-tête de la table avec titre et bouton de création
|
|
615
|
+
const PuiTableHeader = _ref4 => {
|
|
616
|
+
let {
|
|
617
|
+
title,
|
|
618
|
+
onCreateClick,
|
|
619
|
+
createButtonText = "Create"
|
|
620
|
+
} = _ref4;
|
|
621
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
622
|
+
style: {
|
|
623
|
+
display: 'flex',
|
|
624
|
+
justifyContent: 'space-between',
|
|
625
|
+
alignItems: 'center',
|
|
626
|
+
marginBottom: '16px'
|
|
627
|
+
},
|
|
628
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
|
|
629
|
+
className: "pui-table-title",
|
|
630
|
+
children: title
|
|
631
|
+
}), onCreateClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
632
|
+
type: "primary",
|
|
633
|
+
onClick: onCreateClick,
|
|
634
|
+
className: "pui-create-button",
|
|
635
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
636
|
+
style: {
|
|
637
|
+
marginRight: '4px'
|
|
638
|
+
},
|
|
639
|
+
children: "+"
|
|
640
|
+
}),
|
|
641
|
+
children: createButtonText
|
|
642
|
+
})]
|
|
643
|
+
});
|
|
317
644
|
};
|
|
645
|
+
exports.PuiTableHeader = PuiTableHeader;
|
|
318
646
|
var _default = exports.default = PuiTable;
|
|
@@ -4,18 +4,18 @@ require("core-js/modules/es.weak-map.js");
|
|
|
4
4
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
5
5
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
6
6
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
7
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
8
7
|
Object.defineProperty(exports, "__esModule", {
|
|
9
8
|
value: true
|
|
10
9
|
});
|
|
11
10
|
exports.default = void 0;
|
|
11
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
var React = _interopRequireWildcard(require("react"));
|
|
14
|
-
var _PuiDialog = _interopRequireDefault(require("../../others/PuiDialog"));
|
|
15
|
-
var _PuiSection = _interopRequireDefault(require("../../others/PuiSection"));
|
|
16
14
|
var _PuiTable = _interopRequireDefault(require("../../table/PuiTable"));
|
|
15
|
+
var _antd = require("antd");
|
|
16
|
+
var _icons = require("@ant-design/icons");
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
const _excluded = ["id", "className", "sx", "open", "title", "maxWidth", "fullWidth", "scroll", "loading", "rowCount", "rows", "page", "pageSize", "columns", "actions", "tableProps", "onPageChange", "onClose", "children"];
|
|
18
|
+
const _excluded = ["id", "className", "sx", "open", "title", "maxWidth", "fullWidth", "scroll", "loading", "rowCount", "rows", "page", "pageSize", "columns", "actions", "tableProps", "onPageChange", "onClose", "onSearch", "onReset", "children"]; // Ant Design imports
|
|
19
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
20
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -26,6 +26,63 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
26
26
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
27
27
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
28
28
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
29
|
+
const {
|
|
30
|
+
Title,
|
|
31
|
+
Text
|
|
32
|
+
} = _antd.Typography;
|
|
33
|
+
const {
|
|
34
|
+
Panel
|
|
35
|
+
} = _antd.Collapse;
|
|
36
|
+
|
|
37
|
+
// Styles pour le composant
|
|
38
|
+
const styles = {
|
|
39
|
+
modal: {
|
|
40
|
+
top: 20
|
|
41
|
+
},
|
|
42
|
+
modalBody: {
|
|
43
|
+
padding: '0',
|
|
44
|
+
maxHeight: 'calc(100vh - 120px)',
|
|
45
|
+
overflow: 'auto'
|
|
46
|
+
},
|
|
47
|
+
header: {
|
|
48
|
+
padding: '16px 24px',
|
|
49
|
+
borderBottom: '1px solid #f0f0f0',
|
|
50
|
+
display: 'flex',
|
|
51
|
+
justifyContent: 'space-between',
|
|
52
|
+
alignItems: 'center'
|
|
53
|
+
},
|
|
54
|
+
title: {
|
|
55
|
+
margin: 0,
|
|
56
|
+
fontSize: '18px',
|
|
57
|
+
fontWeight: 600,
|
|
58
|
+
color: '#111827'
|
|
59
|
+
},
|
|
60
|
+
searchSection: {
|
|
61
|
+
margin: '0 0 16px 0'
|
|
62
|
+
},
|
|
63
|
+
searchHeader: {
|
|
64
|
+
display: 'flex',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
gap: '8px',
|
|
67
|
+
cursor: 'pointer',
|
|
68
|
+
userSelect: 'none'
|
|
69
|
+
},
|
|
70
|
+
searchContent: {
|
|
71
|
+
padding: '16px',
|
|
72
|
+
backgroundColor: '#f9fafb',
|
|
73
|
+
borderRadius: '0 0 8px 8px'
|
|
74
|
+
},
|
|
75
|
+
footer: {
|
|
76
|
+
padding: '12px 24px',
|
|
77
|
+
borderTop: '1px solid #f0f0f0',
|
|
78
|
+
display: 'flex',
|
|
79
|
+
justifyContent: 'flex-end',
|
|
80
|
+
gap: '8px'
|
|
81
|
+
},
|
|
82
|
+
tableContainer: {
|
|
83
|
+
padding: '0 24px 16px 24px'
|
|
84
|
+
}
|
|
85
|
+
};
|
|
29
86
|
const PuiSearchDialog = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
30
87
|
let {
|
|
31
88
|
id,
|
|
@@ -46,37 +103,126 @@ const PuiSearchDialog = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
46
103
|
tableProps,
|
|
47
104
|
onPageChange,
|
|
48
105
|
onClose,
|
|
106
|
+
onSearch,
|
|
107
|
+
onReset,
|
|
49
108
|
children
|
|
50
109
|
} = _ref,
|
|
51
110
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
52
|
-
|
|
111
|
+
const [searchExpanded, setSearchExpanded] = React.useState(true);
|
|
112
|
+
|
|
113
|
+
// Fonction pour gérer le clic sur l'en-tête de la section de recherche
|
|
114
|
+
const toggleSearchSection = e => {
|
|
115
|
+
if (e) {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
}
|
|
119
|
+
setSearchExpanded(prev => !prev);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Fonction pour créer un gestionnaire d'événements sécurisé
|
|
123
|
+
const createSafeHandler = action => e => {
|
|
124
|
+
if (e) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
}
|
|
128
|
+
if (typeof action === 'function') {
|
|
129
|
+
action();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// Calcul de la largeur modale en fonction de maxWidth
|
|
134
|
+
const getModalWidth = () => {
|
|
135
|
+
const widths = {
|
|
136
|
+
xs: 480,
|
|
137
|
+
sm: 600,
|
|
138
|
+
md: 960,
|
|
139
|
+
lg: 1280,
|
|
140
|
+
xl: 1920
|
|
141
|
+
};
|
|
142
|
+
return maxWidth && widths[maxWidth] ? widths[maxWidth] : '80%';
|
|
143
|
+
};
|
|
144
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Modal, _objectSpread(_objectSpread({
|
|
53
145
|
id: id,
|
|
54
146
|
className: className,
|
|
55
|
-
|
|
56
|
-
ref: ref,
|
|
147
|
+
style: _objectSpread(_objectSpread({}, styles.modal), sx),
|
|
57
148
|
open: open,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
149
|
+
width: getModalWidth(),
|
|
150
|
+
centered: true,
|
|
151
|
+
footer: null,
|
|
152
|
+
closable: false,
|
|
153
|
+
bodyStyle: styles.modalBody,
|
|
154
|
+
maskClosable: false
|
|
63
155
|
}, rest), {}, {
|
|
64
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
156
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
157
|
+
style: styles.header,
|
|
158
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Title, {
|
|
159
|
+
level: 4,
|
|
160
|
+
style: styles.title,
|
|
161
|
+
children: title
|
|
162
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
163
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CloseOutlined, {}),
|
|
164
|
+
onClick: onClose,
|
|
165
|
+
type: "text",
|
|
166
|
+
"aria-label": "Fermer"
|
|
167
|
+
})]
|
|
168
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Spin, {
|
|
169
|
+
spinning: loading || false,
|
|
170
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Card, {
|
|
171
|
+
style: styles.searchSection,
|
|
172
|
+
bordered: false,
|
|
173
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Collapse, {
|
|
174
|
+
defaultActiveKey: searchExpanded ? ['search'] : [],
|
|
175
|
+
ghost: true,
|
|
176
|
+
onChange: () => setSearchExpanded(prev => !prev),
|
|
177
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Panel, {
|
|
178
|
+
header: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
179
|
+
style: styles.searchHeader,
|
|
180
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SettingOutlined, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Text, {
|
|
181
|
+
strong: true,
|
|
182
|
+
children: "Param\xE8tres de recherche"
|
|
183
|
+
}), searchExpanded ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.UpOutlined, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.DownOutlined, {})]
|
|
184
|
+
}),
|
|
185
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
186
|
+
style: styles.searchContent,
|
|
187
|
+
children: [children, /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Divider, {
|
|
188
|
+
style: {
|
|
189
|
+
margin: '16px 0'
|
|
190
|
+
}
|
|
191
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
192
|
+
children: [onReset && /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
193
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CloseOutlined, {}),
|
|
194
|
+
onClick: createSafeHandler(onReset),
|
|
195
|
+
children: "Effacer"
|
|
196
|
+
}), onSearch && /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
197
|
+
type: "primary",
|
|
198
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SearchOutlined, {}),
|
|
199
|
+
onClick: createSafeHandler(onSearch),
|
|
200
|
+
children: "Rechercher"
|
|
201
|
+
})]
|
|
202
|
+
})]
|
|
203
|
+
})
|
|
204
|
+
}, "search")
|
|
205
|
+
})
|
|
206
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
207
|
+
style: styles.tableContainer,
|
|
208
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTable.default, _objectSpread(_objectSpread({}, tableProps), {}, {
|
|
209
|
+
loading: loading,
|
|
210
|
+
rowCount: rowCount,
|
|
211
|
+
rows: rows,
|
|
212
|
+
page: page,
|
|
213
|
+
pageSize: pageSize,
|
|
214
|
+
actions: actions,
|
|
215
|
+
columns: columns,
|
|
216
|
+
onPageChange: onPageChange
|
|
217
|
+
}))
|
|
218
|
+
})]
|
|
219
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
220
|
+
style: styles.footer,
|
|
221
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
222
|
+
onClick: onClose,
|
|
223
|
+
children: "Fermer"
|
|
224
|
+
})
|
|
225
|
+
})]
|
|
80
226
|
}));
|
|
81
227
|
});
|
|
82
228
|
PuiSearchDialog.propTypes = {
|
|
@@ -97,7 +243,9 @@ PuiSearchDialog.propTypes = {
|
|
|
97
243
|
actions: _propTypes.default.arrayOf(_propTypes.default.element),
|
|
98
244
|
tableProps: _propTypes.default.object,
|
|
99
245
|
onPageChange: _propTypes.default.func,
|
|
100
|
-
onClose: _propTypes.default.func
|
|
246
|
+
onClose: _propTypes.default.func,
|
|
247
|
+
onSearch: _propTypes.default.func,
|
|
248
|
+
onReset: _propTypes.default.func
|
|
101
249
|
};
|
|
102
250
|
PuiSearchDialog.defaultProps = {
|
|
103
251
|
fullWidth: true,
|
|
@@ -51,6 +51,16 @@ const styles = {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
// Styles CSS pour les boutons "Plus d'options" et "Moins d'options"
|
|
55
|
+
const toggleButtonStyle = {
|
|
56
|
+
color: '#1890ff',
|
|
57
|
+
fontWeight: 500,
|
|
58
|
+
padding: '4px 8px',
|
|
59
|
+
height: 'auto',
|
|
60
|
+
marginLeft: '8px',
|
|
61
|
+
pointerEvents: 'auto' // Assure que les événements sont capturés par le bouton
|
|
62
|
+
};
|
|
63
|
+
|
|
54
64
|
// Container pour le formulaire de recherche avec design Ant
|
|
55
65
|
const PuiStandardSearchPageContainer = _ref => {
|
|
56
66
|
let {
|
|
@@ -121,8 +131,46 @@ const PuiSearchPage = _ref2 => {
|
|
|
121
131
|
if (hasAlwaysVisibleFields) return true; // Si des champs sont toujours visibles, les afficher
|
|
122
132
|
return isSearchSectionExpanded; // Sinon, afficher seulement si la section est étendue
|
|
123
133
|
};
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
|
|
135
|
+
// Fonction dédiée pour gérer le clic sur les boutons "Plus d'options" et "Moins d'options"
|
|
136
|
+
// Utilisation d'une fonction de type mousedown au lieu de click pour éviter les problèmes de propagation
|
|
137
|
+
const handleToggleMouseDown = e => {
|
|
138
|
+
// Empêcher explicitement le comportement par défaut et la propagation
|
|
139
|
+
if (e) {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
if (e.nativeEvent) {
|
|
143
|
+
e.nativeEvent.preventDefault();
|
|
144
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Utiliser setTimeout pour s'assurer que l'action se produit après la gestion de l'événement
|
|
149
|
+
setTimeout(() => {
|
|
150
|
+
setSearchSectionExpanded(prev => !prev);
|
|
151
|
+
}, 0);
|
|
152
|
+
return false; // Retourner false pour empêcher le comportement par défaut
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// Fonction pour gérer le clic sur l'en-tête du panneau de recherche
|
|
156
|
+
const handleHeaderMouseDown = e => {
|
|
157
|
+
// Ne traiter le clic que s'il provient directement de l'en-tête
|
|
158
|
+
// et non d'un élément enfant comme un bouton
|
|
159
|
+
if (e.target === e.currentTarget || e.target.tagName === 'DIV' || e.target.tagName === 'SPAN') {
|
|
160
|
+
// Empêcher la propagation et le comportement par défaut
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
e.stopPropagation();
|
|
163
|
+
if (e.nativeEvent) {
|
|
164
|
+
e.nativeEvent.preventDefault();
|
|
165
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Utiliser setTimeout pour s'assurer que l'action se produit après la gestion de l'événement
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
setSearchSectionExpanded(prev => !prev);
|
|
171
|
+
}, 0);
|
|
172
|
+
}
|
|
173
|
+
return false; // Retourner false pour empêcher le comportement par défaut
|
|
126
174
|
};
|
|
127
175
|
|
|
128
176
|
// Fonction pour rendre le contenu des champs en fonction de leur visibilité
|
|
@@ -149,29 +197,89 @@ const PuiSearchPage = _ref2 => {
|
|
|
149
197
|
// Bouton pour étendre/réduire les champs additionnels
|
|
150
198
|
const renderToggleButton = () => {
|
|
151
199
|
if (!hasCollapsibleFields) return null;
|
|
200
|
+
|
|
201
|
+
// Utiliser un div au lieu d'un Button pour éviter les problèmes de propagation
|
|
152
202
|
if (isSearchSectionExpanded) {
|
|
153
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
203
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
204
|
+
role: "button",
|
|
205
|
+
tabIndex: 0,
|
|
206
|
+
onMouseDown: handleToggleMouseDown,
|
|
207
|
+
onClick: e => e.preventDefault(),
|
|
208
|
+
style: _objectSpread(_objectSpread({}, toggleButtonStyle), {}, {
|
|
209
|
+
display: 'inline-flex',
|
|
210
|
+
alignItems: 'center',
|
|
211
|
+
cursor: 'pointer'
|
|
212
|
+
}),
|
|
213
|
+
className: "toggle-options-button",
|
|
214
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.UpOutlined, {
|
|
215
|
+
style: {
|
|
216
|
+
marginRight: '4px'
|
|
217
|
+
}
|
|
218
|
+
}), " Moins d'options"]
|
|
158
219
|
});
|
|
159
220
|
} else {
|
|
160
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
221
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
222
|
+
role: "button",
|
|
223
|
+
tabIndex: 0,
|
|
224
|
+
onMouseDown: handleToggleMouseDown,
|
|
225
|
+
onClick: e => e.preventDefault(),
|
|
226
|
+
style: _objectSpread(_objectSpread({}, toggleButtonStyle), {}, {
|
|
227
|
+
display: 'inline-flex',
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
cursor: 'pointer'
|
|
230
|
+
}),
|
|
231
|
+
className: "toggle-options-button",
|
|
232
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.DownOutlined, {
|
|
233
|
+
style: {
|
|
234
|
+
marginRight: '4px'
|
|
235
|
+
}
|
|
236
|
+
}), " Plus d'options"]
|
|
165
237
|
});
|
|
166
238
|
}
|
|
167
239
|
};
|
|
168
240
|
|
|
169
|
-
// Fonction
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
241
|
+
// Fonction pour créer un gestionnaire d'événements sécurisé pour les boutons sans paramètre
|
|
242
|
+
const createSafeHandler = action => e => {
|
|
243
|
+
// Empêcher la propagation de l'événement et le comportement par défaut
|
|
244
|
+
if (e) {
|
|
245
|
+
e.preventDefault();
|
|
246
|
+
e.stopPropagation();
|
|
247
|
+
if (e.nativeEvent) {
|
|
248
|
+
e.nativeEvent.preventDefault();
|
|
249
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
250
|
+
}
|
|
173
251
|
}
|
|
174
|
-
|
|
252
|
+
|
|
253
|
+
// Utiliser setTimeout pour s'assurer que l'action se produit après la gestion de l'événement
|
|
254
|
+
setTimeout(() => {
|
|
255
|
+
if (typeof action === 'function') {
|
|
256
|
+
action();
|
|
257
|
+
}
|
|
258
|
+
}, 0);
|
|
259
|
+
return false; // Retourner false pour empêcher le comportement par défaut
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// Fonction pour créer un gestionnaire d'événements sécurisé pour les actions avec paramètre row
|
|
263
|
+
const createRowActionHandler = (action, row) => e => {
|
|
264
|
+
// Empêcher la propagation de l'événement et le comportement par défaut
|
|
265
|
+
if (e) {
|
|
266
|
+
e.preventDefault();
|
|
267
|
+
e.stopPropagation();
|
|
268
|
+
if (e.nativeEvent) {
|
|
269
|
+
e.nativeEvent.preventDefault();
|
|
270
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Utiliser setTimeout pour s'assurer que l'action se produit après la gestion de l'événement
|
|
275
|
+
setTimeout(() => {
|
|
276
|
+
if (typeof action === 'function') {
|
|
277
|
+
action(row);
|
|
278
|
+
} else {
|
|
279
|
+
console.warn('Action is not a function', action);
|
|
280
|
+
}
|
|
281
|
+
}, 0);
|
|
282
|
+
return false; // Retourner false pour empêcher le comportement par défaut
|
|
175
283
|
};
|
|
176
284
|
|
|
177
285
|
// Vérification de sécurité pour tableProps
|
|
@@ -182,7 +290,12 @@ const PuiSearchPage = _ref2 => {
|
|
|
182
290
|
|
|
183
291
|
// Calcul du titre du panel de recherche avec l'icône
|
|
184
292
|
const searchPanelHeader = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
185
|
-
|
|
293
|
+
onMouseDown: collapsibleSearchSection ? handleHeaderMouseDown : undefined,
|
|
294
|
+
onClick: e => e.preventDefault(),
|
|
295
|
+
style: {
|
|
296
|
+
cursor: collapsibleSearchSection ? 'pointer' : 'default',
|
|
297
|
+
userSelect: 'none' // Empêcher la sélection de texte
|
|
298
|
+
},
|
|
186
299
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Space, {
|
|
187
300
|
align: "center",
|
|
188
301
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SettingOutlined, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Text, {
|
|
@@ -226,7 +339,7 @@ const PuiSearchPage = _ref2 => {
|
|
|
226
339
|
title: "Effacer",
|
|
227
340
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
228
341
|
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ClearOutlined, {}),
|
|
229
|
-
onClick: resetForm,
|
|
342
|
+
onClick: createSafeHandler(resetForm),
|
|
230
343
|
children: "Effacer"
|
|
231
344
|
})
|
|
232
345
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
@@ -234,13 +347,13 @@ const PuiSearchPage = _ref2 => {
|
|
|
234
347
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
235
348
|
type: "primary",
|
|
236
349
|
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SearchOutlined, {}),
|
|
237
|
-
onClick: submitForm,
|
|
350
|
+
onClick: createSafeHandler(submitForm),
|
|
238
351
|
loading: loading,
|
|
239
352
|
children: "Rechercher"
|
|
240
353
|
})
|
|
241
354
|
}), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
242
355
|
icon: actionItem.icon,
|
|
243
|
-
onClick: () =>
|
|
356
|
+
onClick: createSafeHandler(() => actionItem.action()),
|
|
244
357
|
children: actionItem.name
|
|
245
358
|
}, index)), hasCollapsibleFields && renderToggleButton()]
|
|
246
359
|
}),
|
|
@@ -254,7 +367,7 @@ const PuiSearchPage = _ref2 => {
|
|
|
254
367
|
title: "Effacer",
|
|
255
368
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
256
369
|
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ClearOutlined, {}),
|
|
257
|
-
onClick: onReset,
|
|
370
|
+
onClick: createSafeHandler(onReset),
|
|
258
371
|
children: "Effacer"
|
|
259
372
|
})
|
|
260
373
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
@@ -262,13 +375,13 @@ const PuiSearchPage = _ref2 => {
|
|
|
262
375
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
263
376
|
type: "primary",
|
|
264
377
|
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SearchOutlined, {}),
|
|
265
|
-
onClick: onSubmit,
|
|
378
|
+
onClick: createSafeHandler(onSubmit),
|
|
266
379
|
loading: loading,
|
|
267
380
|
children: "Rechercher"
|
|
268
381
|
})
|
|
269
382
|
}), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
270
383
|
icon: actionItem.icon,
|
|
271
|
-
onClick: () =>
|
|
384
|
+
onClick: createSafeHandler(() => actionItem.action()),
|
|
272
385
|
children: actionItem.name
|
|
273
386
|
}, index)), hasCollapsibleFields && renderToggleButton()]
|
|
274
387
|
}),
|