@portnet/ui 2.0.1 → 2.0.4

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,320 +8,148 @@ Object.defineProperty(exports, "__esModule", {
8
8
  });
9
9
  exports.default = void 0;
10
10
  require("core-js/modules/es.array.includes.js");
11
- require("core-js/modules/es.array.sort.js");
11
+ require("core-js/modules/es.regexp.to-string.js");
12
12
  require("core-js/modules/es.string.includes.js");
13
13
  require("core-js/modules/esnext.iterator.constructor.js");
14
14
  require("core-js/modules/esnext.iterator.map.js");
15
15
  require("core-js/modules/web.dom-collections.iterator.js");
16
- var _MoreVert = _interopRequireDefault(require("@mui/icons-material/MoreVert"));
17
- var _material = require("@mui/material");
18
- var _styles = require("@mui/material/styles");
19
- var _xDataGrid = require("@mui/x-data-grid");
20
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
21
17
  var React = _interopRequireWildcard(require("react"));
22
18
  var _apperance = require("../../config/apperance");
23
- var _PuiCheckbox = _interopRequireDefault(require("../inputs/PuiCheckbox"));
24
- var _PuiIcon = _interopRequireDefault(require("../others/PuiIcon"));
25
19
  var _PuiTooltip = _interopRequireDefault(require("../others/PuiTooltip"));
26
- var _PuiTableAction = _interopRequireDefault(require("./PuiTableAction"));
27
- var _ActionPopover = _interopRequireDefault(require("./ActionPopover"));
28
- var _system = require("@mui/system");
20
+ var _antd = require("antd");
21
+ var _icons = require("@ant-design/icons");
29
22
  var _jsxRuntime = require("react/jsx-runtime");
30
- const _excluded = ["id", "className", "sx", "elevate", "rows", "rowCount", "columns", "paginationMode", "page", "pageSize", "checkboxSelection", "loading", "stripped", "actions", "oneActionOnly", "onSelect", "onPageChange", "onPageSizeChange", "rowDetailPanel", "stickyColumns"];
23
+ const _excluded = ["id", "className", "sx", "elevate", "rows", "rowCount", "columns", "paginationMode", "page", "pageSize", "checkboxSelection", "loading", "stripped", "actions", "oneActionOnly", "onSelect", "onPageChange", "onPageSizeChange", "stickyColumns", "pinnedColumns"]; // Styles personnalisés pour le tableau
31
24
  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); }
32
25
  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; }
33
26
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
34
- 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; }
35
- 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; }
36
27
  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; }
37
28
  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; }
38
29
  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; }
39
30
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
40
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); }
41
- const StyledMuiTable = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_xDataGrid.DataGrid, _objectSpread({
42
- ref: ref
43
- }, props))))(() => {
44
- return {
45
- "&.MuiDataGrid-root": {
46
- fontSize: ".8em",
47
- "& .tableActionColumn": {
48
- "& .MuiDataGrid-columnHeaderTitle": {
49
- justifyContent: "center",
50
- display: "flex"
51
- },
52
- "& .MuiDataGrid-columnHeaderTitleContainer": {
53
- justifyContent: "center"
54
- }
55
- },
56
- "&.elevate": {
57
- boxShadow: "0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%)"
58
- },
59
- backgroundColor: _apperance.palette.gray.light,
60
- border: "2px solid ".concat(_apperance.palette.gray.dark),
61
- "& .MuiPaginationItem-root": {
62
- "&.Mui-selected": {
63
- color: _apperance.palette.white,
64
- backgroundColor: _apperance.palette.primary
65
- }
66
- },
67
- "&.table-loading .MuiDataGrid-virtualScroller, &.table-loading .MuiDataGrid-footerContainer": {
68
- filter: "blur(1px)",
69
- "&::before": {
70
- content: "''",
71
- width: "100%",
72
- height: "100%",
73
- backgroundColor: _apperance.palette.white,
74
- position: "absolute",
75
- zIndex: 1,
76
- display: "block",
77
- opacity: 0
78
- }
79
- },
80
- "&.table-stripped .MuiDataGrid-row": {
81
- "&:nth-of-type(even)": {
82
- backgroundColor: _apperance.palette.gray.light
83
- }
84
- },
85
- "& .MuiLinearProgress-root": {
86
- zIndex: 1,
87
- backgroundColor: _apperance.palette.info,
88
- "& .MuiLinearProgress-bar": {
89
- backgroundColor: _apperance.palette.primary
90
- }
91
- },
92
- "& .MuiDataGrid-columnHeaders": {
93
- "& .MuiDataGrid-columnHeader": {
94
- "& .MuiDataGrid-columnHeaderTitle": {
95
- display: "flex",
96
- alignItems: "center",
97
- fontWeight: "600",
98
- color: _apperance.palette.primary,
99
- whiteSpace: "normal",
100
- lineHeight: "1.2em"
101
- },
102
- "&:focus-within": {
103
- outline: "none"
104
- },
105
- "&:last-of-type .MuiDataGrid-columnSeparator": {
106
- display: "none"
107
- },
108
- // Colonne sticky - styles améliorés
109
- "&.sticky-column": {
110
- position: "sticky",
111
- zIndex: 3,
112
- // Valeur supérieure pour s'assurer qu'elle reste au-dessus lors du défilement
113
- "&.sticky-column-left": {
114
- left: 0
115
- },
116
- "&.sticky-column-right": {
117
- right: 0
118
- },
119
- // S'assurer que le contenu est visible
120
- "& .MuiDataGrid-columnHeaderTitleContainer": {
121
- visibility: "visible",
122
- overflow: "visible"
123
- },
124
- "& .MuiDataGrid-columnHeaderTitle": {
125
- visibility: "visible",
126
- overflow: "visible"
127
- }
128
- }
129
- },
130
- "& .MuiDataGrid-columnSeparator": {
131
- color: _apperance.palette.gray.dark
132
- }
133
- },
134
- "& .MuiDataGrid-cell": {
135
- paddingTop: "2px",
136
- paddingBottom: "2px",
137
- whiteSpace: "normal",
138
- textOverflow: "ellipsis",
139
- overflow: "hidden",
140
- maxHeight: "none",
141
- minWidth: 'maxWidth',
142
- wordBreak: "break-word",
143
- "&.tableAction": {
144
- justifyContent: "center",
145
- position: "relative",
146
- overflow: "initial !important"
147
- },
148
- "&:focus-within": {
149
- outline: "none"
150
- },
151
- // Cellules sticky - styles améliorés
152
- "&.sticky-column": {
153
- position: "sticky",
154
- zIndex: 2,
155
- "&.sticky-column-left": {
156
- left: 0
157
- },
158
- "&.sticky-column-right": {
159
- right: 0
160
- }
161
- }
162
- },
163
- "& .MuiDataGrid-row": {
164
- maxHeight: "none !important",
165
- "&:nth-of-type(odd)": {
166
- backgroundColor: "#ffffff" // color for odd rows
167
- },
168
- "&:nth-of-type(even)": {
169
- backgroundColor: "#F6F9FF" // color for even rows
170
- },
171
- "&:hover": {
172
- backgroundColor: "#95C7FC"
173
- }
174
- },
175
- "& .MuiDataGrid-virtualScrollerContent": {
176
- "& .MuiDataGrid-row": {
177
- maxHeight: "none !important"
178
- }
179
- },
180
- "& .MuiDataGrid-virtualScroller": {
181
- backgroundColor: _apperance.palette.white
182
- },
183
- "& .MuiDataGrid-footerContainer": {
184
- backgroundColor: _apperance.palette.white,
185
- height: "28px",
186
- minHeight: "28px"
187
- }
188
- }
189
- };
190
- });
191
- const localeText = {
192
- noRowsLabel: "Aucune ligne",
193
- footerRowSelected: count => count !== 1 ? "".concat(count.toLocaleString(), " lignes s\xE9lectionn\xE9es") : "".concat(count.toLocaleString(), " ligne s\xE9lectionn\xE9e"),
194
- footerTotalVisibleRows: (visibleCount, totalCount) => "".concat(visibleCount.toLocaleString(), " de ").concat(totalCount.toLocaleString()),
195
- MuiTablePagination: {
196
- labelDisplayedRows: _ref => {
197
- let {
198
- from,
199
- to,
200
- count
201
- } = _ref;
202
- return "".concat(from, "\u2013").concat(to, " de ").concat(count !== -1 ? count : "plus que ".concat(to));
203
- },
204
- labelRowsPerPage: "Lignes par page"
32
+ 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; }
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";
35
+
36
+ // Injection des styles dans le document
37
+ const injectStyles = () => {
38
+ const styleId = 'pui-table-custom-styles';
39
+
40
+ // Vérifie si les styles existent déjà
41
+ if (!document.getElementById(styleId)) {
42
+ const styleElement = document.createElement('style');
43
+ styleElement.id = styleId;
44
+ styleElement.innerHTML = tableCustomStyles;
45
+ document.head.appendChild(styleElement);
46
+ }
47
+ };
48
+
49
+ // Suppression des styles lors du démontage
50
+ const removeStyles = () => {
51
+ const styleElement = document.getElementById('pui-table-custom-styles');
52
+ if (styleElement) {
53
+ document.head.removeChild(styleElement);
205
54
  }
206
55
  };
207
- const TableActions = _ref2 => {
56
+
57
+ // Composant pour les actions du tableau
58
+ const TableActions = _ref => {
208
59
  let {
209
60
  row,
210
61
  actions
211
- } = _ref2;
62
+ } = _ref;
212
63
  const [isOpen, setIsOpen] = React.useState(false);
213
- const actionsRef = React.useRef();
214
- const outsideClickHandler = React.useCallback(event => {
215
- if (Boolean(actionsRef.current) && !actionsRef.current.contains(event.target)) {
216
- closeHandler();
217
- }
218
- if (!Boolean(actionsRef.current)) {
219
- document.removeEventListener("mouseup", outsideClickHandler, false);
64
+ const handleActionClick = action => {
65
+ if (typeof action === 'function') {
66
+ action(row);
220
67
  }
221
- // eslint-disable-next-line react-hooks/exhaustive-deps
222
- }, []);
223
- const openHandler = () => {
224
- document.addEventListener("mouseup", outsideClickHandler, false);
225
- setIsOpen(true);
226
- };
227
- const closeHandler = () => {
228
- document.removeEventListener("mouseup", outsideClickHandler, false);
229
- setIsOpen(false);
230
68
  };
231
- React.useEffect(() => {
232
- return () => {
233
- document.removeEventListener("mouseup", outsideClickHandler, false);
234
- };
235
- // eslint-disable-next-line react-hooks/exhaustive-deps
236
- }, []);
237
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
238
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTableAction.default, {
239
- title: "Voir plus",
240
- color: "primary",
241
- onClick: openHandler,
242
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
243
- type: "voir-plus"
244
- })
245
- }), Boolean(isOpen) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Paper, {
246
- ref: actionsRef,
247
- elevation: 1,
248
- sx: {
249
- borderRadius: "5px",
250
- position: "absolute",
251
- right: "0",
252
- top: "50%",
253
- transform: "translate(0, -50%)",
254
- display: "flex",
255
- alignItems: "center",
256
- gap: "8px",
257
- paddingX: "11px",
258
- height: "calc(100% - 4px)",
259
- backgroundColor: _apperance.palette.gray.light,
260
- border: "2px solid ".concat(_apperance.palette.gray.dark)
261
- },
262
- children: [actions.map((action, index) => /*#__PURE__*/React.cloneElement(action, {
263
- row,
264
- key: index
265
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTableAction.default, {
266
- size: "small",
267
- title: "Fermer",
268
- color: "primary",
269
- onClick: closeHandler,
270
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
271
- type: "voir-plus"
272
- })
273
- })]
274
- })]
275
- });
276
- };
277
- const TablePagination = () => {
278
- const apiRef = (0, _xDataGrid.useGridApiContext)();
279
- const page = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridPageSelector);
280
- const pageCount = (0, _xDataGrid.useGridSelector)(apiRef, _xDataGrid.gridPageCountSelector);
281
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Pagination, {
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Space, {
282
70
  size: "small",
283
- sx: {
284
- position: "absolute",
285
- left: "50%",
286
- transform: "translateX(-50%)",
287
- "& .MuiButtonBase-root": {
288
- lineHeight: "1em",
289
- fontSize: "1em",
290
- minWidth: "20px",
291
- height: "20px"
292
- }
293
- },
294
- count: pageCount,
295
- page: page + 1,
296
- onChange: (event, value) => apiRef.current.setPage(value - 1),
297
- showFirstButton: true,
298
- showLastButton: true
71
+ children: actions.map((action, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
72
+ title: action.title || '',
73
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
74
+ type: "text",
75
+ icon: action.icon,
76
+ size: "small",
77
+ onClick: () => handleActionClick(action.action)
78
+ })
79
+ }, index))
299
80
  });
300
81
  };
301
- const TableCheckbox = /*#__PURE__*/React.forwardRef((props, ref) => {
302
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiCheckbox.default, _objectSpread(_objectSpread({
303
- ref: ref
304
- }, props), {}, {
305
- formik: false,
306
- sx: {
307
- transform: "scale(.6)",
308
- marginTop: "-4px"
309
- }
310
- }));
82
+
83
+ // Personnalisation des éléments vides
84
+ const customRenderEmpty = () => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
85
+ style: {
86
+ textAlign: 'center',
87
+ padding: '20px 0'
88
+ },
89
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
90
+ children: "Aucune donn\xE9e \xE0 afficher"
91
+ })
311
92
  });
312
- const autosizeOptions = {
313
- includeHeaders: true,
314
- includeOutliers: true
315
- };
316
93
 
317
- // Ordre de priorité pour les colonnes sticky: -1 = début gauche), 0 = ne pas figer, 1 = fin (à droite)
318
- const calculateStickyOrder = (field, stickyColumns) => {
319
- if (!stickyColumns.includes(field)) return 0;
320
- const idx = stickyColumns.indexOf(field);
321
- if (idx === -1) return 0;
322
- return idx;
94
+ // Convertir les colonnes du format DataGrid au format Ant Design
95
+ const convertColumns = (columns, actions, handleSort) => {
96
+ const processedColumns = columns.map(column => {
97
+ const antColumn = {
98
+ title: column.headerName,
99
+ dataIndex: column.field,
100
+ key: column.field,
101
+ width: column.width,
102
+ sorter: column.sortable !== false,
103
+ ellipsis: true,
104
+ className: column.cellClassName
105
+ };
106
+
107
+ // Gestion du rendu personnalisé
108
+ if (column.renderCell) {
109
+ antColumn.render = (text, record) => column.renderCell({
110
+ row: record,
111
+ value: text
112
+ });
113
+ } else if (column.valueGetter) {
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;
133
+ });
134
+
135
+ // Ajouter la colonne d'actions si nécessaire
136
+ if (actions && actions.length > 0) {
137
+ processedColumns.push({
138
+ title: 'Actions',
139
+ key: 'action',
140
+ width: 100,
141
+ align: 'center',
142
+ render: (_, record) => /*#__PURE__*/(0, _jsxRuntime.jsx)(TableActions, {
143
+ row: record,
144
+ actions: actions
145
+ })
146
+ });
147
+ }
148
+ return processedColumns;
323
149
  };
324
- const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
150
+
151
+ // Composant principal PuiTable avec Ant Design
152
+ const PuiTable = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
325
153
  let {
326
154
  id,
327
155
  className,
@@ -341,191 +169,113 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
341
169
  onSelect,
342
170
  onPageChange,
343
171
  onPageSizeChange,
344
- rowDetailPanel,
345
- stickyColumns = []
346
- } = _ref3,
347
- rest = _objectWithoutProperties(_ref3, _excluded);
348
- const [appColumns, setAppColumns] = React.useState(columns);
349
-
350
- // Calcule les positions sticky pour les colonnes figées - logique améliorée
351
- const calculateStickyPositions = columns => {
352
- let leftOffset = 0;
172
+ stickyColumns = [],
173
+ pinnedColumns
174
+ } = _ref2,
175
+ rest = _objectWithoutProperties(_ref2, _excluded);
176
+ // Convertir les colonnes au format Ant Design
177
+ const antColumns = React.useMemo(() => convertColumns(columns, actions), [columns, actions]);
353
178
 
354
- // Trier les colonnes sticky par ordre d'apparition dans le tableau stickyColumns
355
- const sortedColumns = [...columns].sort((a, b) => {
356
- const aOrder = calculateStickyOrder(a.field, stickyColumns);
357
- const bOrder = calculateStickyOrder(b.field, stickyColumns);
358
- if (aOrder === 0 && bOrder === 0) return 0;
359
- if (aOrder === 0) return 1;
360
- if (bOrder === 0) return -1;
361
- return aOrder - bOrder;
362
- });
363
-
364
- // Pour chaque colonne, calculer sa position sticky si nécessaire
365
- return sortedColumns.map(column => {
366
- // Si la colonne n'est pas figée, retournez-la telle quelle
367
- if (!stickyColumns.includes(column.field)) {
368
- return column;
369
- }
179
+ // Gérer la sélection
180
+ const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
181
+ const onSelectChange = newSelectedRowKeys => {
182
+ setSelectedRowKeys(newSelectedRowKeys);
183
+ if (onSelect) {
184
+ onSelect(newSelectedRowKeys);
185
+ }
186
+ };
370
187
 
371
- // Toutes les colonnes sticky sont alignées à gauche pour plus de clarté
372
- const headerClassName = "".concat(column.headerClassName || '', " sticky-column sticky-column-left");
373
- const cellClassName = "".concat(column.cellClassName || '', " sticky-column sticky-column-left");
188
+ // Configuration des lignes sélectionnables
189
+ const rowSelection = checkboxSelection ? {
190
+ selectedRowKeys,
191
+ onChange: onSelectChange
192
+ } : undefined;
374
193
 
375
- // Définir le style pour positionner la colonne
376
- const headerStyle = _objectSpread(_objectSpread({}, column.headerStyle || {}), {}, {
377
- left: "".concat(leftOffset, "px"),
378
- // Assurer que le fond correspond à celui de la ligne
379
- backgroundColor: 'inherit',
380
- // Appliquer un léger effet d'ombre pour indiquer la position sticky
381
- boxShadow: '2px 0 4px -2px rgba(0, 0, 0, 0.15)'
382
- });
383
- const cellStyle = _objectSpread(_objectSpread({}, column.cellStyle || {}), {}, {
384
- left: "".concat(leftOffset, "px"),
385
- // Assurer que le fond correspond à celui de la ligne
386
- backgroundColor: 'inherit',
387
- // Appliquer un léger effet d'ombre pour indiquer la position sticky
388
- boxShadow: '2px 0 4px -2px rgba(0, 0, 0, 0.15)'
389
- });
390
-
391
- // Mettre à jour l'offset pour la prochaine colonne figée
392
- leftOffset += column.width || 100;
393
- return _objectSpread(_objectSpread({}, column), {}, {
394
- headerClassName,
395
- cellClassName,
396
- headerStyle,
397
- cellStyle
398
- });
399
- });
194
+ // Gérer le changement de page
195
+ const handlePageChange = (newPage, newPageSize) => {
196
+ if (onPageChange) {
197
+ // Ant Design utilise une pagination 1-indexed, mais nous gardons notre convention 0-indexed
198
+ onPageChange(newPage - 1);
199
+ }
200
+ if (onPageSizeChange && pageSize !== newPageSize) {
201
+ onPageSizeChange(newPageSize);
202
+ }
400
203
  };
401
- React.useEffect(() => {
402
- // Assurez-vous que les colonnes d'action sont ajoutées après le calcul des positions sticky
403
- let columnsToProcess = columns;
404
-
405
- // Appliquer les positions sticky
406
- const columnsWithSticky = stickyColumns.length > 0 ? calculateStickyPositions(columnsToProcess) : columnsToProcess;
407
204
 
408
- // Ajouter la colonne d'actions après avoir calculé les positions sticky
409
- const finalColumns = Boolean(actions.length) ? [...columnsWithSticky, {
410
- field: "action",
411
- headerName: "Actions",
412
- sortable: false,
413
- filterable: false,
414
- width: 100,
415
- renderCell: _ref4 => {
416
- let {
417
- row
418
- } = _ref4;
419
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_system.Box, {
420
- sx: {
421
- display: 'flex',
422
- gap: '8px',
423
- flexWrap: 'wrap',
424
- justifyContent: 'center',
425
- alignItems: 'center',
426
- minWidth: 0
427
- },
428
- children: actions.map((action, index) => /*#__PURE__*/React.cloneElement(action, {
429
- row,
430
- key: index,
431
- sx: _objectSpread(_objectSpread({}, action.props.sx), {}, {
432
- marginRight: 0,
433
- '&:last-child': {
434
- marginRight: 0
435
- }
436
- })
437
- }))
205
+ // Configurer les colonnes sticky
206
+ const configuredColumns = React.useMemo(() => {
207
+ if (!stickyColumns || stickyColumns.length === 0) return antColumns;
208
+ return antColumns.map(column => {
209
+ if (stickyColumns.includes(column.dataIndex) || stickyColumns.includes(column.key)) {
210
+ return _objectSpread(_objectSpread({}, column), {}, {
211
+ fixed: 'left'
438
212
  });
439
- },
440
- cellClassName: "tableAction",
441
- headerClassName: "tableActionColumn"
442
- }] : columnsWithSticky;
443
- setAppColumns(finalColumns.map(column => {
444
- const renderCell = Boolean(column.renderCell) ? column.renderCell : Boolean(column.valueGetter) ? columnData => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTooltip.default, {
445
- title: Boolean(column.titleGetter) ? column.titleGetter(columnData.row) : String(column.valueGetter(columnData)),
446
- children: column.valueGetter(columnData)
447
- }) : Boolean(column.field) ? _ref5 => {
448
- let {
449
- row
450
- } = _ref5;
451
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTooltip.default, {
452
- title: Boolean(column.titleGetter) ? column.titleGetter(row) : String(row[column.field]),
453
- children: row[column.field]
454
- });
455
- } : undefined;
456
- return _objectSpread(_objectSpread({}, column), {}, {
457
- renderCell
458
- });
459
- }));
460
- // eslint-disable-next-line react-hooks/exhaustive-deps
461
- }, [actions, columns, stickyColumns]);
462
- const renderRowDetailPanel = params => {
463
- const {
464
- data
465
- } = params;
466
- // Render the passed rowDetailPanel component with the row data
467
- return /*#__PURE__*/React.cloneElement(rowDetailPanel, {
468
- rowData: data
213
+ }
214
+ return column;
469
215
  });
470
- };
471
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
472
- style: {
473
- width: '100%',
474
- overflow: 'auto',
475
- position: 'relative'
476
- },
477
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledMuiTable, _objectSpread({
478
- ref: ref,
479
- id: id,
480
- components: {
481
- BaseCheckbox: TableCheckbox,
482
- LoadingOverlay: _material.LinearProgress,
483
- Pagination: TablePagination
484
- },
485
- className: "".concat(className, " ").concat(stripped ? "table-stripped" : "", " ").concat(loading ? "table-loading" : "", " ").concat(elevate ? "elevate" : ""),
486
- sx: {
487
- ["& .".concat(_xDataGrid.gridClasses.cell)]: {
488
- py: 0.5
489
- },
490
- // Assurer la cohérence visuelle pour les cellules sticky
491
- ["& .".concat(_xDataGrid.gridClasses.cell, ".sticky-column")]: {
492
- backgroundColor: 'inherit !important'
493
- },
494
- ["& .".concat(_xDataGrid.gridClasses.columnHeader, ".sticky-column")]: {
495
- backgroundColor: 'inherit !important'
216
+ }, [antColumns, stickyColumns]);
217
+
218
+ // Style du tableau
219
+ const tableStyle = _objectSpread(_objectSpread({
220
+ fontSize: '0.85em'
221
+ }, elevate ? {
222
+ boxShadow: '0 2px 8px rgba(0,0,0,0.07)'
223
+ } : {}), sx || {});
224
+
225
+ // Injection des styles CSS personnalisés
226
+ React.useEffect(() => {
227
+ injectStyles();
228
+ return () => removeStyles();
229
+ }, []);
230
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.ConfigProvider, {
231
+ renderEmpty: customRenderEmpty,
232
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Spin, {
233
+ spinning: loading,
234
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Table, _objectSpread({
235
+ ref: ref,
236
+ id: id,
237
+ className: "pui-table ".concat(className || '', " ").concat(stripped ? 'table-stripped' : ''),
238
+ columns: configuredColumns,
239
+ dataSource: rows.map(row => _objectSpread(_objectSpread({}, row), {}, {
240
+ key: row.id || row.key || Math.random().toString(36).substr(2, 9)
241
+ })),
242
+ pagination: false,
243
+ rowSelection: rowSelection,
244
+ size: "small",
245
+ bordered: true,
246
+ style: tableStyle,
247
+ scroll: {
248
+ x: 'max-content'
496
249
  },
497
- // S'assurer que les titres des colonnes sont visibles
498
- ["& .".concat(_xDataGrid.gridClasses.columnHeaderTitle)]: {
499
- overflow: 'visible',
500
- whiteSpace: 'normal'
250
+ rowClassName: (record, index) => {
251
+ let className = index % 2 === 0 ? 'ant-table-row-light' : 'ant-table-row-dark';
252
+ if (record.isEditing) className += ' ant-table-row-editing';
253
+ return className;
501
254
  }
502
- },
503
- autoHeight: true,
504
- headerHeight: 60,
505
- footerHeight: 40,
506
- rowHeight: 40,
507
- rows: rows,
508
- rowCount: rowCount,
509
- columns: appColumns,
510
- page: page,
511
- pageSize: pageSize,
512
- checkboxSelection: checkboxSelection,
513
- disableSelectionOnClick: true,
514
- disableColumnMenu: true,
515
- disableColumnFilter: true,
516
- disableColumnSelector: true,
517
- disableVirtualization: true,
518
- density: "compact",
519
- loading: loading,
520
- paginationMode: paginationMode,
521
- localeText: localeText,
522
- getRowHeight: () => 'auto',
523
- onPageChange: onPageChange,
524
- onPageSizeChange: onPageSizeChange,
525
- onSelectionModelChange: onSelect,
526
- autosizeOptions: autosizeOptions,
527
- rowDetailPanel: renderRowDetailPanel
528
- }, rest))
255
+ }, rest)), paginationMode !== 'none' && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
256
+ className: "pui-table-pagination",
257
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
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, {
263
+ current: page + 1,
264
+ pageSize: pageSize,
265
+ total: rowCount || rows.length,
266
+ onChange: handlePageChange,
267
+ showSizeChanger: true,
268
+ showQuickJumper: true,
269
+ showTotal: total => "".concat(total, " \xE9l\xE9ments"),
270
+ size: "default",
271
+ onShowSizeChange: (current, size) => {
272
+ if (onPageSizeChange) {
273
+ onPageSizeChange(size);
274
+ }
275
+ }
276
+ })]
277
+ })]
278
+ })
529
279
  });
530
280
  });
531
281
  PuiTable.propTypes = {
@@ -540,24 +290,29 @@ PuiTable.propTypes = {
540
290
  columns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
541
291
  page: _propTypes.default.number,
542
292
  pageSize: _propTypes.default.number,
543
- actions: _propTypes.default.arrayOf(_propTypes.default.element),
293
+ actions: _propTypes.default.arrayOf(_propTypes.default.shape({
294
+ title: _propTypes.default.string,
295
+ icon: _propTypes.default.element,
296
+ action: _propTypes.default.func.isRequired
297
+ })),
544
298
  checkboxSelection: _propTypes.default.bool,
545
- paginationMode: _propTypes.default.oneOf(["client", "server"]),
299
+ paginationMode: _propTypes.default.oneOf(["client", "server", "none"]),
546
300
  loading: _propTypes.default.bool,
547
301
  onSelect: _propTypes.default.func,
548
302
  onPageChange: _propTypes.default.func,
549
303
  onPageSizeChange: _propTypes.default.func,
550
- onSelectionModelChange: _propTypes.default.func,
551
- rowDetailPanel: _propTypes.default.element,
552
- stickyColumns: _propTypes.default.arrayOf(_propTypes.default.string)
304
+ stickyColumns: _propTypes.default.arrayOf(_propTypes.default.string),
305
+ pinnedColumns: _propTypes.default.object
553
306
  };
554
307
  PuiTable.defaultProps = {
555
308
  oneActionOnly: false,
556
309
  elevate: true,
557
310
  pageSize: 5,
311
+ page: 0,
558
312
  paginationMode: "client",
559
313
  stripped: false,
560
314
  actions: [],
561
- stickyColumns: []
315
+ stickyColumns: [],
316
+ rows: []
562
317
  };
563
318
  var _default = exports.default = PuiTable;