@portnet/ui 1.1.9 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/inputs/PuiDateField.js +57 -131
- package/dist/components/inputs/PuiDateTimeField.js +297 -27
- package/dist/components/table/ActionPopover.js +56 -0
- package/dist/components/table/PuiTable.js +139 -24
- package/dist/components/ui/pages/general/PuiSearchPage.js +126 -37
- package/package.json +4 -4
- package/dist/components/others/DateTimePickerField.js +0 -213
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
9
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
|
+
var _Popover = _interopRequireDefault(require("@mui/material/Popover"));
|
|
11
|
+
var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
|
|
12
|
+
var _MoreVert = _interopRequireDefault(require("@mui/icons-material/MoreVert"));
|
|
13
|
+
var _system = require("@mui/system");
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
const ActionPopover = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
row,
|
|
20
|
+
actions
|
|
21
|
+
} = _ref;
|
|
22
|
+
const [anchorEl, setAnchorEl] = _react.default.useState(null);
|
|
23
|
+
const handleClick = event => {
|
|
24
|
+
setAnchorEl(event.currentTarget);
|
|
25
|
+
};
|
|
26
|
+
const handleClose = () => {
|
|
27
|
+
setAnchorEl(null);
|
|
28
|
+
};
|
|
29
|
+
const open = Boolean(anchorEl);
|
|
30
|
+
const id = open ? 'simple-popover' : undefined;
|
|
31
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
32
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
33
|
+
"aria-describedby": id,
|
|
34
|
+
onClick: handleClick,
|
|
35
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_MoreVert.default, {})
|
|
36
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popover.default, {
|
|
37
|
+
id: id,
|
|
38
|
+
open: open,
|
|
39
|
+
anchorEl: anchorEl,
|
|
40
|
+
onClose: handleClose,
|
|
41
|
+
anchorOrigin: {
|
|
42
|
+
vertical: 'bottom',
|
|
43
|
+
horizontal: 'left'
|
|
44
|
+
},
|
|
45
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_system.Box, {
|
|
46
|
+
p: 2,
|
|
47
|
+
children: actions.map((action, index) => /*#__PURE__*/_react.default.cloneElement(action, {
|
|
48
|
+
row,
|
|
49
|
+
key: index,
|
|
50
|
+
onClick: handleClose // Assuming you want to close the popover when an action is clicked
|
|
51
|
+
}))
|
|
52
|
+
})
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var _default = exports.default = ActionPopover;
|
|
@@ -7,6 +7,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.default = void 0;
|
|
10
|
+
require("core-js/modules/es.array.includes.js");
|
|
11
|
+
require("core-js/modules/es.array.sort.js");
|
|
12
|
+
require("core-js/modules/es.string.includes.js");
|
|
10
13
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
11
14
|
require("core-js/modules/esnext.iterator.map.js");
|
|
12
15
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
@@ -21,9 +24,10 @@ var _PuiCheckbox = _interopRequireDefault(require("../inputs/PuiCheckbox"));
|
|
|
21
24
|
var _PuiIcon = _interopRequireDefault(require("../others/PuiIcon"));
|
|
22
25
|
var _PuiTooltip = _interopRequireDefault(require("../others/PuiTooltip"));
|
|
23
26
|
var _PuiTableAction = _interopRequireDefault(require("./PuiTableAction"));
|
|
27
|
+
var _ActionPopover = _interopRequireDefault(require("./ActionPopover"));
|
|
24
28
|
var _system = require("@mui/system");
|
|
25
29
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
-
const _excluded = ["id", "className", "sx", "elevate", "rows", "rowCount", "columns", "paginationMode", "page", "pageSize", "checkboxSelection", "loading", "stripped", "actions", "oneActionOnly", "onSelect", "onPageChange", "onPageSizeChange", "rowDetailPanel"];
|
|
30
|
+
const _excluded = ["id", "className", "sx", "elevate", "rows", "rowCount", "columns", "paginationMode", "page", "pageSize", "checkboxSelection", "loading", "stripped", "actions", "oneActionOnly", "onSelect", "onPageChange", "onPageSizeChange", "rowDetailPanel", "stickyColumns"];
|
|
27
31
|
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); }
|
|
28
32
|
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; }
|
|
29
33
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -100,6 +104,27 @@ const StyledMuiTable = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((props,
|
|
|
100
104
|
},
|
|
101
105
|
"&:last-of-type .MuiDataGrid-columnSeparator": {
|
|
102
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
|
+
}
|
|
103
128
|
}
|
|
104
129
|
},
|
|
105
130
|
"& .MuiDataGrid-columnSeparator": {
|
|
@@ -113,7 +138,7 @@ const StyledMuiTable = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((props,
|
|
|
113
138
|
textOverflow: "ellipsis",
|
|
114
139
|
overflow: "hidden",
|
|
115
140
|
maxHeight: "none",
|
|
116
|
-
minWidth:
|
|
141
|
+
minWidth: 'maxWidth',
|
|
117
142
|
wordBreak: "break-word",
|
|
118
143
|
"&.tableAction": {
|
|
119
144
|
justifyContent: "center",
|
|
@@ -122,6 +147,17 @@ const StyledMuiTable = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((props,
|
|
|
122
147
|
},
|
|
123
148
|
"&:focus-within": {
|
|
124
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
|
+
}
|
|
125
161
|
}
|
|
126
162
|
},
|
|
127
163
|
"& .MuiDataGrid-row": {
|
|
@@ -277,6 +313,14 @@ const autosizeOptions = {
|
|
|
277
313
|
includeHeaders: true,
|
|
278
314
|
includeOutliers: true
|
|
279
315
|
};
|
|
316
|
+
|
|
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;
|
|
323
|
+
};
|
|
280
324
|
const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
281
325
|
let {
|
|
282
326
|
id,
|
|
@@ -297,12 +341,72 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
297
341
|
onSelect,
|
|
298
342
|
onPageChange,
|
|
299
343
|
onPageSizeChange,
|
|
300
|
-
rowDetailPanel
|
|
344
|
+
rowDetailPanel,
|
|
345
|
+
stickyColumns = []
|
|
301
346
|
} = _ref3,
|
|
302
347
|
rest = _objectWithoutProperties(_ref3, _excluded);
|
|
303
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;
|
|
353
|
+
|
|
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
|
+
}
|
|
370
|
+
|
|
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");
|
|
374
|
+
|
|
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
|
+
});
|
|
400
|
+
};
|
|
304
401
|
React.useEffect(() => {
|
|
305
|
-
|
|
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
|
+
|
|
408
|
+
// Ajouter la colonne d'actions après avoir calculé les positions sticky
|
|
409
|
+
const finalColumns = Boolean(actions.length) ? [...columnsWithSticky, {
|
|
306
410
|
field: "action",
|
|
307
411
|
headerName: "Actions",
|
|
308
412
|
sortable: false,
|
|
@@ -314,25 +418,20 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
314
418
|
} = _ref4;
|
|
315
419
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_system.Box, {
|
|
316
420
|
sx: {
|
|
317
|
-
display:
|
|
318
|
-
gap:
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
// Center the icons horizontally
|
|
324
|
-
alignItems: "center",
|
|
325
|
-
// Align icons vertically
|
|
326
|
-
minWidth: 0 // Prevent the flex container from stretching past its content width
|
|
421
|
+
display: 'flex',
|
|
422
|
+
gap: '8px',
|
|
423
|
+
flexWrap: 'wrap',
|
|
424
|
+
justifyContent: 'center',
|
|
425
|
+
alignItems: 'center',
|
|
426
|
+
minWidth: 0
|
|
327
427
|
},
|
|
328
428
|
children: actions.map((action, index) => /*#__PURE__*/React.cloneElement(action, {
|
|
329
429
|
row,
|
|
330
430
|
key: index,
|
|
331
431
|
sx: _objectSpread(_objectSpread({}, action.props.sx), {}, {
|
|
332
432
|
marginRight: 0,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
marginRight: 0 // Ensure the last item doesn't push the container width
|
|
433
|
+
'&:last-child': {
|
|
434
|
+
marginRight: 0
|
|
336
435
|
}
|
|
337
436
|
})
|
|
338
437
|
}))
|
|
@@ -340,8 +439,8 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
340
439
|
},
|
|
341
440
|
cellClassName: "tableAction",
|
|
342
441
|
headerClassName: "tableActionColumn"
|
|
343
|
-
}] :
|
|
344
|
-
setAppColumns(
|
|
442
|
+
}] : columnsWithSticky;
|
|
443
|
+
setAppColumns(finalColumns.map(column => {
|
|
345
444
|
const renderCell = Boolean(column.renderCell) ? column.renderCell : Boolean(column.valueGetter) ? columnData => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTooltip.default, {
|
|
346
445
|
title: Boolean(column.titleGetter) ? column.titleGetter(columnData.row) : String(column.valueGetter(columnData)),
|
|
347
446
|
children: column.valueGetter(columnData)
|
|
@@ -359,7 +458,7 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
359
458
|
});
|
|
360
459
|
}));
|
|
361
460
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
362
|
-
}, [actions, columns]);
|
|
461
|
+
}, [actions, columns, stickyColumns]);
|
|
363
462
|
const renderRowDetailPanel = params => {
|
|
364
463
|
const {
|
|
365
464
|
data
|
|
@@ -371,7 +470,9 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
371
470
|
};
|
|
372
471
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
373
472
|
style: {
|
|
374
|
-
width:
|
|
473
|
+
width: '100%',
|
|
474
|
+
overflow: 'auto',
|
|
475
|
+
position: 'relative'
|
|
375
476
|
},
|
|
376
477
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledMuiTable, _objectSpread({
|
|
377
478
|
ref: ref,
|
|
@@ -385,6 +486,18 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
385
486
|
sx: {
|
|
386
487
|
["& .".concat(_xDataGrid.gridClasses.cell)]: {
|
|
387
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'
|
|
496
|
+
},
|
|
497
|
+
// S'assurer que les titres des colonnes sont visibles
|
|
498
|
+
["& .".concat(_xDataGrid.gridClasses.columnHeaderTitle)]: {
|
|
499
|
+
overflow: 'visible',
|
|
500
|
+
whiteSpace: 'normal'
|
|
388
501
|
}
|
|
389
502
|
},
|
|
390
503
|
autoHeight: true,
|
|
@@ -406,7 +519,7 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
406
519
|
loading: loading,
|
|
407
520
|
paginationMode: paginationMode,
|
|
408
521
|
localeText: localeText,
|
|
409
|
-
getRowHeight: () =>
|
|
522
|
+
getRowHeight: () => 'auto',
|
|
410
523
|
onPageChange: onPageChange,
|
|
411
524
|
onPageSizeChange: onPageSizeChange,
|
|
412
525
|
onSelectionModelChange: onSelect,
|
|
@@ -435,7 +548,8 @@ PuiTable.propTypes = {
|
|
|
435
548
|
onPageChange: _propTypes.default.func,
|
|
436
549
|
onPageSizeChange: _propTypes.default.func,
|
|
437
550
|
onSelectionModelChange: _propTypes.default.func,
|
|
438
|
-
rowDetailPanel: _propTypes.default.element
|
|
551
|
+
rowDetailPanel: _propTypes.default.element,
|
|
552
|
+
stickyColumns: _propTypes.default.arrayOf(_propTypes.default.string)
|
|
439
553
|
};
|
|
440
554
|
PuiTable.defaultProps = {
|
|
441
555
|
oneActionOnly: false,
|
|
@@ -443,6 +557,7 @@ PuiTable.defaultProps = {
|
|
|
443
557
|
pageSize: 5,
|
|
444
558
|
paginationMode: "client",
|
|
445
559
|
stripped: false,
|
|
446
|
-
actions: []
|
|
560
|
+
actions: [],
|
|
561
|
+
stickyColumns: []
|
|
447
562
|
};
|
|
448
563
|
var _default = exports.default = PuiTable;
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
require("core-js/modules/es.weak-map.js");
|
|
4
4
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
5
5
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
6
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
7
6
|
Object.defineProperty(exports, "__esModule", {
|
|
8
7
|
value: true
|
|
9
8
|
});
|
|
10
9
|
exports.default = void 0;
|
|
11
10
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
12
11
|
require("core-js/modules/esnext.iterator.map.js");
|
|
13
|
-
|
|
12
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
var
|
|
15
|
+
var _formik = require("formik");
|
|
16
16
|
var _PuiButton = _interopRequireDefault(require("../../../buttons/PuiButton"));
|
|
17
17
|
var _PuiFormikForm = _interopRequireDefault(require("../../../others/PuiFormikForm"));
|
|
18
18
|
var _PuiGrid = _interopRequireDefault(require("../../../others/PuiGrid"));
|
|
@@ -20,15 +20,17 @@ var _PuiIcon = _interopRequireDefault(require("../../../others/PuiIcon"));
|
|
|
20
20
|
var _PuiSection = _interopRequireDefault(require("../../../others/PuiSection"));
|
|
21
21
|
var _PuiTable = _interopRequireDefault(require("../../../table/PuiTable"));
|
|
22
22
|
var _PuiDefaultPage = _interopRequireDefault(require("./PuiDefaultPage"));
|
|
23
|
+
var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
|
|
24
|
+
var _ExpandLess = _interopRequireDefault(require("@mui/icons-material/ExpandLess"));
|
|
23
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
27
|
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
28
|
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
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
29
|
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
30
|
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
31
|
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
32
|
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); }
|
|
33
|
+
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); } // Container for search form and actions
|
|
32
34
|
const PuiStandardSearchPageContainer = _ref => {
|
|
33
35
|
let {
|
|
34
36
|
actions,
|
|
@@ -63,9 +65,77 @@ const PuiSearchPage = _ref2 => {
|
|
|
63
65
|
onRetour,
|
|
64
66
|
onReset,
|
|
65
67
|
onSubmit,
|
|
66
|
-
children
|
|
67
|
-
additionalActions
|
|
68
|
+
children,
|
|
69
|
+
additionalActions,
|
|
70
|
+
collapsibleSearchSection = true,
|
|
71
|
+
// Collapsible by default
|
|
72
|
+
alwaysVisibleFields = null,
|
|
73
|
+
// Champs toujours visibles
|
|
74
|
+
collapsibleFields = null // Champs collapsibles
|
|
68
75
|
} = _ref2;
|
|
76
|
+
const [isSearchSectionExpanded, setSearchSectionExpanded] = (0, _react.useState)(false);
|
|
77
|
+
|
|
78
|
+
// Si des champs spécifiques sont définis comme collapsibles
|
|
79
|
+
const hasCollapsibleFields = collapsibleFields !== null;
|
|
80
|
+
// Si des champs sont toujours visibles
|
|
81
|
+
const hasAlwaysVisibleFields = alwaysVisibleFields !== null;
|
|
82
|
+
|
|
83
|
+
// Fonction qui détermine si la section de recherche a des champs à afficher même si collapsée
|
|
84
|
+
const shouldRenderSearchContent = () => {
|
|
85
|
+
if (!collapsibleSearchSection) return true; // Si non collapsible, toujours afficher
|
|
86
|
+
if (hasAlwaysVisibleFields) return true; // Si des champs sont toujours visibles, les afficher
|
|
87
|
+
return isSearchSectionExpanded; // Sinon, afficher seulement si la section est étendue
|
|
88
|
+
};
|
|
89
|
+
const toggleSearchSection = () => {
|
|
90
|
+
setSearchSectionExpanded(prev => !prev);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Fonction pour rendre le contenu des champs en fonction de leur visibilité
|
|
94
|
+
const renderSearchFields = () => {
|
|
95
|
+
// Si pas de champs collapsibles ou toujours visibles spécifiés, on affiche tous les enfants
|
|
96
|
+
if (!hasCollapsibleFields && !hasAlwaysVisibleFields) {
|
|
97
|
+
return children;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Si la section est étendue ou pas de champs collapsibles, on affiche tous les champs
|
|
101
|
+
if (isSearchSectionExpanded && hasCollapsibleFields) {
|
|
102
|
+
return collapsibleFields;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Si la section est collapsée et qu'on a des champs toujours visibles, on les affiche
|
|
106
|
+
if (hasAlwaysVisibleFields) {
|
|
107
|
+
return alwaysVisibleFields;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Par défaut, afficher les enfants
|
|
111
|
+
return children;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// Bouton pour étendre/réduire les champs additionnels
|
|
115
|
+
const renderToggleButton = () => {
|
|
116
|
+
if (!hasCollapsibleFields) return null;
|
|
117
|
+
if (isSearchSectionExpanded) {
|
|
118
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
|
|
119
|
+
item: true,
|
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
121
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandLess.default, {}),
|
|
122
|
+
onClick: toggleSearchSection,
|
|
123
|
+
color: "tertiary",
|
|
124
|
+
children: "Moins d'options"
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
} else {
|
|
128
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
|
|
129
|
+
item: true,
|
|
130
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
131
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandMore.default, {}),
|
|
132
|
+
onClick: toggleSearchSection,
|
|
133
|
+
color: "tertiary",
|
|
134
|
+
children: "Plus d'options"
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
69
139
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiDefaultPage.default, {
|
|
70
140
|
title: title,
|
|
71
141
|
titleIcon: titleIcon,
|
|
@@ -77,11 +147,24 @@ const PuiSearchPage = _ref2 => {
|
|
|
77
147
|
retour: retour,
|
|
78
148
|
onRetour: onRetour,
|
|
79
149
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiSection.default, {
|
|
80
|
-
title:
|
|
150
|
+
title: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
151
|
+
onClick: collapsibleSearchSection ? toggleSearchSection : undefined,
|
|
152
|
+
style: {
|
|
153
|
+
display: "flex",
|
|
154
|
+
alignItems: "center",
|
|
155
|
+
cursor: collapsibleSearchSection ? "pointer" : "default"
|
|
156
|
+
},
|
|
157
|
+
children: [collapsibleSearchSection && (isSearchSectionExpanded ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandLess.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandMore.default, {})), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
158
|
+
style: {
|
|
159
|
+
marginLeft: collapsibleSearchSection ? "8px" : "0px"
|
|
160
|
+
},
|
|
161
|
+
children: "Param\xE8tres de recherche"
|
|
162
|
+
})]
|
|
163
|
+
}),
|
|
81
164
|
sx: {
|
|
82
165
|
marginBottom: 2
|
|
83
166
|
},
|
|
84
|
-
children: formik ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_formik.Formik, _objectSpread(_objectSpread({
|
|
167
|
+
children: shouldRenderSearchContent() && (formik ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_formik.Formik, _objectSpread(_objectSpread({
|
|
85
168
|
initialValues: {}
|
|
86
169
|
}, formikProps), {}, {
|
|
87
170
|
children: _ref3 => {
|
|
@@ -116,18 +199,16 @@ const PuiSearchPage = _ref2 => {
|
|
|
116
199
|
loadingPosition: "start",
|
|
117
200
|
children: "Rechercher"
|
|
118
201
|
})
|
|
119
|
-
}), additionalActions && additionalActions.map((actionItem, index) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}, index);
|
|
128
|
-
})]
|
|
202
|
+
}), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
|
|
203
|
+
item: true,
|
|
204
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
205
|
+
startIcon: actionItem.icon,
|
|
206
|
+
onClick: actionItem.action,
|
|
207
|
+
children: actionItem.name
|
|
208
|
+
})
|
|
209
|
+
}, index)), hasCollapsibleFields && renderToggleButton()]
|
|
129
210
|
}),
|
|
130
|
-
children:
|
|
211
|
+
children: renderSearchFields()
|
|
131
212
|
})
|
|
132
213
|
});
|
|
133
214
|
}
|
|
@@ -157,22 +238,22 @@ const PuiSearchPage = _ref2 => {
|
|
|
157
238
|
loadingPosition: "start",
|
|
158
239
|
children: "Rechercher"
|
|
159
240
|
})
|
|
160
|
-
}), additionalActions && additionalActions.map((actionItem, index) => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}, index);
|
|
169
|
-
})]
|
|
241
|
+
}), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
|
|
242
|
+
item: true,
|
|
243
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
244
|
+
startIcon: actionItem.icon,
|
|
245
|
+
onClick: actionItem.action,
|
|
246
|
+
children: actionItem.name
|
|
247
|
+
})
|
|
248
|
+
}, index)), hasCollapsibleFields && renderToggleButton()]
|
|
170
249
|
}),
|
|
171
|
-
children:
|
|
172
|
-
})
|
|
173
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTable.default, _objectSpread({
|
|
250
|
+
children: renderSearchFields()
|
|
251
|
+
}))
|
|
252
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTable.default, _objectSpread(_objectSpread({
|
|
174
253
|
paginationMode: "server"
|
|
175
|
-
}, tableProps)
|
|
254
|
+
}, tableProps), {}, {
|
|
255
|
+
pinnedColumns: tableProps.pinnedColumns // Added pinnedColumns
|
|
256
|
+
}))]
|
|
176
257
|
});
|
|
177
258
|
};
|
|
178
259
|
PuiSearchPage.propTypes = {
|
|
@@ -185,7 +266,9 @@ PuiSearchPage.propTypes = {
|
|
|
185
266
|
topNav: _propTypes.default.bool,
|
|
186
267
|
bottomNav: _propTypes.default.bool,
|
|
187
268
|
loading: _propTypes.default.bool,
|
|
188
|
-
tableProps: _propTypes.default.
|
|
269
|
+
tableProps: _propTypes.default.shape({
|
|
270
|
+
pinnedColumns: _propTypes.default.object // Added pinnedColumns prop type
|
|
271
|
+
}),
|
|
189
272
|
retour: _propTypes.default.bool,
|
|
190
273
|
onRetour: _propTypes.default.func,
|
|
191
274
|
onReset: _propTypes.default.func,
|
|
@@ -194,11 +277,17 @@ PuiSearchPage.propTypes = {
|
|
|
194
277
|
name: _propTypes.default.string.isRequired,
|
|
195
278
|
action: _propTypes.default.func.isRequired,
|
|
196
279
|
icon: _propTypes.default.element
|
|
197
|
-
}))
|
|
280
|
+
})),
|
|
281
|
+
collapsibleSearchSection: _propTypes.default.bool,
|
|
282
|
+
alwaysVisibleFields: _propTypes.default.node,
|
|
283
|
+
collapsibleFields: _propTypes.default.node
|
|
198
284
|
};
|
|
199
285
|
PuiSearchPage.defaultProps = {
|
|
200
286
|
formik: true,
|
|
201
287
|
loading: false,
|
|
202
|
-
additionalActions: []
|
|
288
|
+
additionalActions: [],
|
|
289
|
+
collapsibleSearchSection: true,
|
|
290
|
+
alwaysVisibleFields: null,
|
|
291
|
+
collapsibleFields: null
|
|
203
292
|
};
|
|
204
293
|
var _default = exports.default = PuiSearchPage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portnet/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Portnet UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"@mui/material": "^5.10.16",
|
|
22
22
|
"@mui/x-data-grid": "^5.17.26",
|
|
23
23
|
"@mui/x-data-grid-pro": "^5.17.26",
|
|
24
|
-
"@mui/x-date-pickers": "^
|
|
24
|
+
"@mui/x-date-pickers": "^5.0.4",
|
|
25
25
|
"@testing-library/jest-dom": "^5.16.5",
|
|
26
26
|
"@testing-library/react": "^13.4.0",
|
|
27
27
|
"@testing-library/user-event": "^13.5.0",
|
|
28
|
-
"ajv": "^
|
|
28
|
+
"ajv": "^6.12.6",
|
|
29
|
+
"ajv-keywords": "^3.5.2",
|
|
29
30
|
"axios": "^0.27.2",
|
|
30
|
-
"dayjs": "^1.11.13",
|
|
31
31
|
"formik": "^2.2.9",
|
|
32
32
|
"lodash": "^4.17.21",
|
|
33
33
|
"moment": "^2.29.4",
|