@portnet/ui 0.1.55 → 0.1.56

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.
@@ -23,6 +23,7 @@ var _PuiButton = _interopRequireDefault(require("../buttons/PuiButton"));
23
23
  var _StyledMuiTextField = _interopRequireDefault(require("../common/StyledMuiTextField"));
24
24
  var _PuiDialog = _interopRequireDefault(require("../others/PuiDialog"));
25
25
  var _PuiTextField = _interopRequireDefault(require("./PuiTextField"));
26
+ var _DateTimePickerField = _interopRequireDefault(require("../others/DateTimePickerField"));
26
27
  var _jsxRuntime = require("react/jsx-runtime");
27
28
  const _excluded = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
28
29
  _excluded2 = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
@@ -288,9 +289,9 @@ const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
288
289
  }
289
290
  // eslint-disable-next-line react-hooks/exhaustive-deps
290
291
  }, [value]);
291
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardDateTimeField, _objectSpread({
292
- id: id,
292
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePickerField.default, _objectSpread({
293
293
  ref: ref,
294
+ id: id,
294
295
  className: className,
295
296
  sx: sx,
296
297
  label: label,
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.weak-map.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ require("core-js/modules/es.parse-int.js");
9
+ require("core-js/modules/es.regexp.exec.js");
10
+ require("core-js/modules/es.regexp.test.js");
11
+ require("core-js/modules/esnext.iterator.map.js");
12
+ require("core-js/modules/web.dom-collections.iterator.js");
13
+ var _AccessTime = _interopRequireDefault(require("@mui/icons-material/AccessTime"));
14
+ var _CalendarMonth = _interopRequireDefault(require("@mui/icons-material/CalendarMonth"));
15
+ var _material = require("@mui/material");
16
+ var _InputAdornment = _interopRequireDefault(require("@mui/material/InputAdornment"));
17
+ var _reactDatepicker = _interopRequireWildcard(require("@trendmicro/react-datepicker"));
18
+ var _formik = require("formik");
19
+ var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
20
+ var _react = _interopRequireWildcard(require("react"));
21
+ var _PuiButton = _interopRequireDefault(require("../buttons/PuiButton"));
22
+ var _StyledMuiTextField = _interopRequireDefault(require("../common/StyledMuiTextField"));
23
+ require("./custom-datepicker.css");
24
+ var _jsxRuntime = require("react/jsx-runtime");
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); }
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; }
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
+ const dateTimeRegex = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{2}\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT[+-]\d{4}\s\(UTC[+-]\d{2}:\d{2}\)$/;
29
+ const DATE_TIME_FORMATS = {
30
+ LONG: "YYYY-MM-DD HH:mm:ss",
31
+ SHORT: "YYYY-MM-DD HH:mm"
32
+ };
33
+ const DateTimePickerField = _ref => {
34
+ let {
35
+ label,
36
+ name,
37
+ format = "YYYY-MM-DD HH:mm",
38
+ onChange,
39
+ minDate,
40
+ maxDate,
41
+ value,
42
+ required = true,
43
+ error = false,
44
+ helperText = null,
45
+ fullWidth = true
46
+ } = _ref;
47
+ const [field] = (0, _formik.useField)(name);
48
+ const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
49
+ const [timeAnchorEl, setTimeAnchorEl] = (0, _react.useState)(null);
50
+ const [selectedDate, setSelectedDate] = (0, _react.useState)(null);
51
+ const [selectedTime, setSelectedTime] = (0, _react.useState)(null);
52
+ const openDatePopover = Boolean(anchorEl);
53
+ const openTimePopover = Boolean(timeAnchorEl);
54
+ const hasInitialized = (0, _react.useRef)(false);
55
+ const [canUpdate, setCanUpdate] = (0, _react.useState)(true);
56
+ (0, _react.useEffect)(() => {
57
+ const initialize = () => {
58
+ const initialValue = value || (field === null || field === void 0 ? void 0 : field.value);
59
+ setSelectedDate(initialValue ? (0, _momentTimezone.default)(initialValue).format("YYYY-MM-DD") : "");
60
+ setSelectedTime(initialValue ? (0, _momentTimezone.default)(initialValue).format("HH:mm") : "");
61
+ hasInitialized.current = true;
62
+ };
63
+ if (canUpdate && !hasInitialized.current && (value || field !== null && field !== void 0 && field.value)) {
64
+ initialize();
65
+ }
66
+ return () => {
67
+ hasInitialized.current = false;
68
+ };
69
+ }, [value, field === null || field === void 0 ? void 0 : field.value]);
70
+ const handleDateTimeClick = event => setAnchorEl(event.currentTarget);
71
+ const handleTimeClick = event => setTimeAnchorEl(event.currentTarget);
72
+ const handleDateChange = date => setSelectedDate((0, _momentTimezone.default)(date).format("YYYY-MM-DD"));
73
+ const handleTimeChange = time => setSelectedTime(time);
74
+ const handleDateClose = () => {
75
+ const combinedDateTime = "".concat(selectedDate, " ").concat(selectedTime);
76
+ console.log("🚀 ~ handleDateClose ~ combinedDateTime:", combinedDateTime);
77
+ const unixTimestamp = _momentTimezone.default.utc(combinedDateTime, "YYYY-MM-DD HH:mm").subtract(1, "hours");
78
+ console.log("🚀 ~ handleDateClose ~ unixTimestamp:", unixTimestamp);
79
+ setCanUpdate(false);
80
+ if (onChange) onChange(unixTimestamp);
81
+ setAnchorEl(null);
82
+ };
83
+ const handleTimeClose = () => setTimeAnchorEl(null);
84
+ const convertDateTimeFormat = dateStr => {
85
+ const regex = /^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}(:\d{2})?$/;
86
+ if (!regex.test(dateStr)) {
87
+ return null;
88
+ }
89
+ try {
90
+ const [datePart, timePart] = dateStr.split(" ");
91
+ const [year, month, day] = datePart.split("-");
92
+ return "".concat(day, "/").concat(month, "/").concat(year, " ").concat(timePart);
93
+ } catch (error) {
94
+ return null;
95
+ }
96
+ };
97
+ const renderTimeSelectors = () => {
98
+ const timeParts = selectedTime === null || selectedTime === void 0 ? void 0 : selectedTime.split(":");
99
+ const hours = timeParts === null || timeParts === void 0 ? void 0 : timeParts[0];
100
+ const minutes = timeParts === null || timeParts === void 0 ? void 0 : timeParts[1];
101
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
102
+ style: {
103
+ display: "flex",
104
+ gap: 4
105
+ },
106
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Select, {
107
+ value: hours,
108
+ onChange: e => handleTimeChange("".concat(e.target.value, ":").concat(minutes)),
109
+ style: {
110
+ width: "55px",
111
+ fontSize: 11.5
112
+ },
113
+ children: [...Array(24).keys()].map(hour => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
114
+ style: {
115
+ fontSize: 11.5
116
+ },
117
+ value: String(hour).padStart(2, "0"),
118
+ children: String(hour).padStart(2, "0")
119
+ }, hour))
120
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Select, {
121
+ value: minutes,
122
+ onChange: e => handleTimeChange("".concat(hours, ":").concat(e.target.value)),
123
+ style: {
124
+ width: "55px",
125
+ fontSize: 11.5
126
+ },
127
+ children: [...Array(60).keys()].map(minute => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
128
+ style: {
129
+ fontSize: 11.5
130
+ },
131
+ value: String(minute).padStart(2, "0"),
132
+ children: String(minute).padStart(2, "0")
133
+ }, minute))
134
+ })]
135
+ });
136
+ };
137
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
138
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_StyledMuiTextField.default, {
139
+ name: name,
140
+ label: label,
141
+ value: convertDateTimeFormat(selectedDate + " " + selectedTime),
142
+ fullWidth: fullWidth,
143
+ onClick: handleDateTimeClick,
144
+ readOnly: true,
145
+ error: error,
146
+ helperText: helperText,
147
+ required: required,
148
+ InputProps: {
149
+ endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputAdornment.default, {
150
+ position: "end",
151
+ style: {
152
+ marginLeft: -10,
153
+ marginTop: "-0.1px"
154
+ },
155
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CalendarMonth.default, {
156
+ fontSize: "small"
157
+ })
158
+ })
159
+ }
160
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popover, {
161
+ open: openDatePopover,
162
+ anchorEl: anchorEl,
163
+ onClose: handleDateClose,
164
+ anchorOrigin: {
165
+ vertical: "bottom",
166
+ horizontal: "left"
167
+ },
168
+ style: {
169
+ width: "310px"
170
+ },
171
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
172
+ style: {
173
+ padding: 16
174
+ },
175
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
176
+ sx: {
177
+ display: "flex",
178
+ alignItems: "center",
179
+ justifyContent: "space-around"
180
+ },
181
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactDatepicker.DateInput, {
182
+ value: selectedDate,
183
+ onChange: date => handleDateChange(date)
184
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
185
+ value: selectedTime,
186
+ onChange: event => {
187
+ const inputValue = event.target.value;
188
+ if (/^[0-9:]*$/.test(inputValue)) setSelectedTime(inputValue);
189
+ },
190
+ onBlur: () => {
191
+ const [hour, minute] = selectedTime === null || selectedTime === void 0 ? void 0 : selectedTime.split(":").map(val => parseInt(val, 10) || 0);
192
+ const validatedHour = String(Math.min(23, hour)).padStart(2, "0");
193
+ const validatedMinute = String(Math.min(59, minute)).padStart(2, "0");
194
+ setSelectedTime("".concat(validatedHour, ":").concat(validatedMinute));
195
+ },
196
+ sx: {
197
+ "& .MuiInputBase-root": {
198
+ width: "100%",
199
+ fontSize: 12.5
200
+ },
201
+ "& .MuiOutlinedInput-input": {
202
+ padding: "4px",
203
+ height: "23.5px"
204
+ }
205
+ },
206
+ InputProps: {
207
+ startAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputAdornment.default, {
208
+ onClick: handleTimeClick,
209
+ position: "start",
210
+ style: {
211
+ marginLeft: -10,
212
+ cursor: "pointer"
213
+ },
214
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AccessTime.default, {
215
+ fontSize: "small"
216
+ })
217
+ })
218
+ }
219
+ })]
220
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactDatepicker.default, {
221
+ date: selectedDate,
222
+ onSelect: date => handleDateChange(date),
223
+ minDate: minDate,
224
+ maxDate: maxDate
225
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
226
+ sx: {
227
+ textAlign: "right",
228
+ padding: 1
229
+ },
230
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
231
+ onClick: handleDateClose,
232
+ children: "Choisir"
233
+ })
234
+ })]
235
+ })
236
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popover, {
237
+ open: openTimePopover,
238
+ anchorEl: timeAnchorEl,
239
+ onClose: handleTimeClose,
240
+ anchorOrigin: {
241
+ vertical: "bottom",
242
+ horizontal: "left"
243
+ },
244
+ style: {
245
+ marginTop: 16,
246
+ marginLeft: -4
247
+ },
248
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
249
+ style: {
250
+ padding: 4,
251
+ display: "flex",
252
+ justifyContent: "center",
253
+ width: "120px",
254
+ height: "25px"
255
+ },
256
+ children: renderTimeSelectors()
257
+ })
258
+ })]
259
+ });
260
+ };
261
+ var _default = exports.default = DateTimePickerField;
@@ -0,0 +1,227 @@
1
+ .datepicker---date-picker-container---1kNBY {
2
+ -webkit-box-sizing: border-box;
3
+ -moz-box-sizing: border-box;
4
+ box-sizing: border-box;
5
+ line-height: 20px;
6
+ border: none;
7
+ border-radius: 0;
8
+ -webkit-box-shadow: none;
9
+ box-shadow: none;
10
+ padding: 0 5px;
11
+ position: relative;
12
+ display: inline-block;
13
+ }
14
+ .datepicker---date-picker-container---1kNBY *,
15
+ .datepicker---date-picker-container---1kNBY *:before,
16
+ .datepicker---date-picker-container---1kNBY *:after {
17
+ -webkit-box-sizing: inherit;
18
+ -moz-box-sizing: inherit;
19
+ box-sizing: inherit;
20
+ }
21
+ .datepicker---date-picker-container---1kNBY .react-datepicker__header {
22
+ text-align: center;
23
+ background-color: #fff;
24
+ border: none;
25
+ position: relative;
26
+ padding: 0;
27
+ }
28
+ .datepicker---date-picker-container---1kNBY .react-datepicker__month {
29
+ margin: 0;
30
+ text-align: center;
31
+ }
32
+ .datepicker---date-picker-container---1kNBY .react-datepicker__current-month {
33
+ color: #222;
34
+ font-family: "Roboto", sans-serif !important;
35
+ font-weight: bold;
36
+ font-size: 13px;
37
+ height: 20px;
38
+ margin: 8px 0;
39
+ }
40
+ .datepicker---date-picker-container---1kNBY .react-datepicker__navigation {
41
+ background: none;
42
+ line-height: 20px;
43
+ text-align: center;
44
+ cursor: pointer;
45
+ position: absolute;
46
+ top: 3px;
47
+ padding: 5px;
48
+ border: none;
49
+ z-index: 1;
50
+ outline: 0;
51
+ width: 30px;
52
+ height: 30px;
53
+ background-color: transparent;
54
+ background-position: center center;
55
+ background-repeat: no-repeat;
56
+ }
57
+ .datepicker---date-picker-container---1kNBY
58
+ .react-datepicker__navigation:hover {
59
+ border-radius: 3px;
60
+ background-color: #eee;
61
+ }
62
+ .datepicker---date-picker-container---1kNBY
63
+ .react-datepicker__navigation--previous {
64
+ left: 8px;
65
+ background-image: url(data:image/svg+xml;base64,PCEtLSBHZW5lcmF0ZWQgYnkgVHJlbmQgTWljcm8gU3R5bGUgUG9ydGFsIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiPg0KICA8dGl0bGU+YW5nbGUtbGVmdDwvdGl0bGU+DQogIDxwYXRoIGZpbGw9InJnYigzNCwzNCwzNCkiIGQ9Ik05LjUwMSAxMi41MDZsLTQuNDk5LTQuNTA2IDQuNDg4LTQuNDk0IDEgMS0zLjQ5IDMuNDk0IDMuNTAxIDMuNTA2eiI+PC9wYXRoPg0KPC9zdmc+);
66
+ }
67
+ .datepicker---date-picker-container---1kNBY
68
+ .react-datepicker__navigation--next {
69
+ right: 8px;
70
+ background-image: url(data:image/svg+xml;base64,PCEtLSBHZW5lcmF0ZWQgYnkgVHJlbmQgTWljcm8gU3R5bGUgUG9ydGFsIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiPg0KICA8dGl0bGU+YW5nbGUtcmlnaHQ8L3RpdGxlPg0KICA8cGF0aCBmaWxsPSJyZ2IoMzQsMzQsMzQpIiBkPSJNNi41MDEgMTIuNWwtMS0xIDMuNTAxLTMuNTA2LTMuNDktMy40OTQgMS0xIDQuNDg4IDQuNDk0eiI+PC9wYXRoPg0KPC9zdmc+);
71
+ }
72
+ .datepicker---date-picker-container---1kNBY .react-datepicker__day,
73
+ .datepicker---date-picker-container---1kNBY .react-datepicker__day-name {
74
+ color: #222;
75
+ display: inline-block;
76
+ text-align: center;
77
+ width: 30px;
78
+ line-height: 20px;
79
+ border: 0;
80
+ padding: 5px;
81
+ margin: 2px;
82
+ }
83
+ .datepicker---date-picker-container---1kNBY .react-datepicker__day {
84
+ cursor: pointer;
85
+ font-size: 13px;
86
+ font-family: "Roboto", sans-serif !important;
87
+ }
88
+ .datepicker---date-picker-container---1kNBY .react-datepicker__day:hover {
89
+ background: #eee;
90
+ cursor: pointer;
91
+ border-radius: 50%;
92
+ }
93
+ .datepicker---date-picker-container---1kNBY
94
+ .react-datepicker__day.react-datepicker__day--disabled,
95
+ .datepicker---date-picker-container---1kNBY
96
+ .react-datepicker__day:hover.react-datepicker__day--disabled {
97
+ background: inherit;
98
+ cursor: default;
99
+ color: #bbb;
100
+ }
101
+ .datepicker---date-picker-container---1kNBY .react-datepicker__day-name {
102
+ padding-top: 9px;
103
+ font-size: 12px;
104
+ font-weight: bold;
105
+ font-family: "Roboto", sans-serif !important;
106
+ }
107
+ .datepicker---date-picker-container---1kNBY .react-datepicker__day-names {
108
+ white-space: nowrap;
109
+ }
110
+ .datepicker---date-picker-container---1kNBY
111
+ .react-datepicker__day--outside-month {
112
+ color: #bbb;
113
+ }
114
+ .datepicker---date-picker-container---1kNBY .react-datepicker__day--today {
115
+ color: #888 !important;
116
+ }
117
+
118
+ .datepicker---date-picker-container---1kNBY
119
+ .react-datepicker__day--today.react-datepicker__day--selected {
120
+ color: #fff !important;
121
+ }
122
+
123
+ .datepicker---date-picker-container---1kNBY .react-datepicker__day--selected {
124
+ color: #fff;
125
+ font-weight: bold;
126
+ font-family: "Roboto", sans-serif !important;
127
+ background-color: #232f66 !important;
128
+ border-radius: 50%;
129
+ }
130
+ .datepicker---date-picker-container---1kNBY
131
+ .react-datepicker__day--selected:hover {
132
+ background-color: #232f66 !important;
133
+ }
134
+ @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
135
+ .datepicker---date-input---1vOyn > input {
136
+ height: 32px;
137
+ }
138
+ }
139
+ .datepicker---date-input-container---2zD9B {
140
+ -webkit-box-sizing: border-box;
141
+ -moz-box-sizing: border-box;
142
+ box-sizing: border-box;
143
+ line-height: 20px;
144
+ position: relative;
145
+ }
146
+ .datepicker---date-input-container---2zD9B *,
147
+ .datepicker---date-input-container---2zD9B *:before,
148
+ .datepicker---date-input-container---2zD9B *:after {
149
+ -webkit-box-sizing: inherit;
150
+ -moz-box-sizing: inherit;
151
+ box-sizing: inherit;
152
+ }
153
+ .datepicker---date-input---1vOyn {
154
+ width: 120px;
155
+ }
156
+ .datepicker---date-input---1vOyn > input {
157
+ display: block;
158
+ width: 100%;
159
+ height: auto;
160
+ line-height: inherit;
161
+ padding: 5px 12px;
162
+ padding-left: 30px;
163
+ font-size: 13px;
164
+ font-family: "Roboto", sans-serif !important;
165
+ color: #222;
166
+ border: 1px solid #ccc;
167
+ border-radius: 3px;
168
+ outline: none;
169
+ }
170
+ .datepicker---date-input---1vOyn > input:focus {
171
+ border-color: #232f66 !important;
172
+ }
173
+ .datepicker---date-input-icon---1UeQu {
174
+ position: absolute;
175
+ left: 9px;
176
+ top: 8px;
177
+ color: #666;
178
+ width: 14px;
179
+ height: 14px;
180
+ }
181
+ @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
182
+ .datepicker---time-input---2ICRB > input {
183
+ height: 32px;
184
+ }
185
+ }
186
+ .datepicker---time-input-container---s4Ikh {
187
+ -webkit-box-sizing: border-box;
188
+ -moz-box-sizing: border-box;
189
+ box-sizing: border-box;
190
+ line-height: 20px;
191
+ position: relative;
192
+ }
193
+ .datepicker---time-input-container---s4Ikh *,
194
+ .datepicker---time-input-container---s4Ikh *:before,
195
+ .datepicker---time-input-container---s4Ikh *:after {
196
+ -webkit-box-sizing: inherit;
197
+ -moz-box-sizing: inherit;
198
+ box-sizing: inherit;
199
+ }
200
+ .datepicker---time-input---2ICRB {
201
+ width: 120px;
202
+ }
203
+ .datepicker---time-input---2ICRB > input {
204
+ display: block;
205
+ width: 100%;
206
+ height: auto;
207
+ line-height: inherit;
208
+ padding: 5px 12px;
209
+ padding-left: 30px;
210
+ font-size: 13px;
211
+ font-family: "Roboto", sans-serif !important;
212
+ color: #222;
213
+ border: 1px solid #ccc;
214
+ border-radius: 3px;
215
+ outline: none;
216
+ }
217
+ .datepicker---time-input---2ICRB > input:focus {
218
+ border-color: #232f66 !important;
219
+ }
220
+ .datepicker---time-input-icon---3TeZ8 {
221
+ position: absolute;
222
+ left: 9px;
223
+ top: 8px;
224
+ color: #666;
225
+ width: 14px;
226
+ height: 14px;
227
+ }
@@ -30,8 +30,26 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
30
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; }
31
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; }
32
32
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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); }
34
- const PuiSearchPage = _ref => {
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
34
+ const PuiStandardSearchPageContainer = _ref => {
35
+ let {
36
+ actions,
37
+ children
38
+ } = _ref;
39
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
40
+ container: true,
41
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
42
+ item: true,
43
+ xs: 12,
44
+ children: children
45
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
46
+ item: true,
47
+ xs: 12,
48
+ children: actions
49
+ })]
50
+ });
51
+ };
52
+ const PuiSearchPage = _ref2 => {
35
53
  let {
36
54
  formik,
37
55
  formikProps,
@@ -47,21 +65,14 @@ const PuiSearchPage = _ref => {
47
65
  onRetour,
48
66
  onReset,
49
67
  onSubmit,
68
+ children: _children,
50
69
  additionalActions,
51
70
  collapsibleSearchSection = true // Collapsible by default
52
- } = _ref;
71
+ } = _ref2;
53
72
  const [isSearchSectionExpanded, setSearchSectionExpanded] = (0, _react.useState)(false);
54
73
  const toggleSearchSection = () => {
55
74
  setSearchSectionExpanded(prev => !prev);
56
75
  };
57
-
58
- // Extract columns from tableProps
59
- const {
60
- columns
61
- } = tableProps || [];
62
- const alwaysVisibleFields = columns.slice(0, 3); // First row fields
63
- const expandableFields = columns.slice(3); // Second row fields
64
-
65
76
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiDefaultPage.default, {
66
77
  title: title,
67
78
  titleIcon: titleIcon,
@@ -82,7 +93,7 @@ const PuiSearchPage = _ref => {
82
93
  },
83
94
  children: [collapsibleSearchSection && (isSearchSectionExpanded ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandLess.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandMore.default, {})), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
84
95
  style: {
85
- marginLeft: "8px"
96
+ marginLeft: collapsibleSearchSection ? "8px" : "0px"
86
97
  },
87
98
  children: "Param\xE8tres de recherche"
88
99
  })]
@@ -90,76 +101,95 @@ const PuiSearchPage = _ref => {
90
101
  sx: {
91
102
  marginBottom: 2
92
103
  },
93
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_formik.Formik, _objectSpread(_objectSpread({
94
- initialValues: formikProps.initialValues
104
+ children: isSearchSectionExpanded && (formik ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_formik.Formik, _objectSpread(_objectSpread({
105
+ initialValues: {}
95
106
  }, formikProps), {}, {
96
- children: _ref2 => {
107
+ children: _ref3 => {
97
108
  let {
98
109
  resetForm,
99
110
  submitForm
100
- } = _ref2;
101
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiFormikForm.default, {
102
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
103
- container: true,
104
- spacing: 2,
105
- children: [alwaysVisibleFields.map((column, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
106
- item: true,
107
- xs: 12,
108
- sm: 4,
109
- children: column.renderCell ? column.renderCell({
110
- row: {}
111
- }) // Render fields
112
- : column.headerName
113
- }, index)), isSearchSectionExpanded && expandableFields.map((column, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
114
- item: true,
115
- xs: 12,
116
- sm: 4,
117
- children: column.renderCell ? column.renderCell({
118
- row: {}
119
- }) : column.headerName
120
- }, index))]
121
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
122
- container: true,
123
- justifyContent: "end",
124
- spacing: 2,
125
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
126
- item: true,
127
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
128
- startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
129
- type: "effacer",
130
- size: "small"
131
- }),
132
- onClick: resetForm,
133
- color: "tertiary",
134
- children: "Effacer"
135
- })
136
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
137
- item: true,
138
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
139
- startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
140
- type: "rechercher",
141
- size: "small"
142
- }),
143
- onClick: submitForm,
144
- loadingPosition: "start",
145
- children: "Rechercher"
146
- })
147
- }), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
148
- item: true,
149
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
150
- startIcon: actionItem.icon,
151
- onClick: actionItem.action,
152
- children: actionItem.name
153
- })
154
- }, index))]
155
- })]
111
+ } = _ref3;
112
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiFormikForm.default, {
113
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardSearchPageContainer, {
114
+ actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
115
+ container: true,
116
+ justifyContent: "end",
117
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
118
+ item: true,
119
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
120
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
121
+ type: "effacer",
122
+ size: "small"
123
+ }),
124
+ onClick: resetForm,
125
+ color: "tertiary",
126
+ children: "Effacer"
127
+ })
128
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
129
+ item: true,
130
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
131
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
132
+ type: "rechercher",
133
+ size: "small"
134
+ }),
135
+ onClick: submitForm,
136
+ loadingPosition: "start",
137
+ children: "Rechercher"
138
+ })
139
+ }), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
140
+ item: true,
141
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
142
+ startIcon: actionItem.icon,
143
+ onClick: actionItem.action,
144
+ children: actionItem.name
145
+ })
146
+ }, index))]
147
+ }),
148
+ children: _children
149
+ })
156
150
  });
157
151
  }
152
+ })) : /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardSearchPageContainer, {
153
+ actions: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
154
+ container: true,
155
+ justifyContent: "end",
156
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
157
+ item: true,
158
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
159
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
160
+ type: "effacer",
161
+ size: "small"
162
+ }),
163
+ onClick: onReset,
164
+ color: "tertiary",
165
+ children: "Effacer"
166
+ })
167
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
168
+ item: true,
169
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
170
+ startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
171
+ type: "rechercher",
172
+ size: "small"
173
+ }),
174
+ onClick: onSubmit,
175
+ loadingPosition: "start",
176
+ children: "Rechercher"
177
+ })
178
+ }), additionalActions && additionalActions.map((actionItem, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
179
+ item: true,
180
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
181
+ startIcon: actionItem.icon,
182
+ onClick: actionItem.action,
183
+ children: actionItem.name
184
+ })
185
+ }, index))]
186
+ }),
187
+ children: _children
158
188
  }))
159
189
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTable.default, _objectSpread(_objectSpread({
160
190
  paginationMode: "server"
161
191
  }, tableProps), {}, {
162
- pinnedColumns: tableProps.pinnedColumns
192
+ pinnedColumns: tableProps.pinnedColumns // Added pinnedColumns
163
193
  }))]
164
194
  });
165
195
  };
@@ -167,19 +197,14 @@ PuiSearchPage.propTypes = {
167
197
  formik: _propTypes.default.bool,
168
198
  formikProps: _propTypes.default.object,
169
199
  title: _propTypes.default.string.isRequired,
170
- titleIcon: _propTypes.default.element,
200
+ titleIcon: _propTypes.default.element.isRequired,
171
201
  trace: _propTypes.default.arrayOf(_propTypes.default.string),
172
202
  navActions: _propTypes.default.element,
173
203
  topNav: _propTypes.default.bool,
174
204
  bottomNav: _propTypes.default.bool,
175
205
  loading: _propTypes.default.bool,
176
206
  tableProps: _propTypes.default.shape({
177
- columns: _propTypes.default.arrayOf(_propTypes.default.shape({
178
- field: _propTypes.default.string.isRequired,
179
- headerName: _propTypes.default.string.isRequired,
180
- renderCell: _propTypes.default.func
181
- })).isRequired,
182
- pinnedColumns: _propTypes.default.object
207
+ pinnedColumns: _propTypes.default.object // Added pinnedColumns prop type
183
208
  }),
184
209
  retour: _propTypes.default.bool,
185
210
  onRetour: _propTypes.default.func,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portnet/ui",
3
- "version": "0.1.55",
3
+ "version": "0.1.56",
4
4
  "description": "Portnet UI",
5
5
  "keywords": [
6
6
  "react",