@portnet/ui 0.1.23 → 0.1.24
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.
|
@@ -7,18 +7,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
9
|
require("core-js/modules/es.symbol.description.js");
|
|
10
|
-
var _material = require("@mui/material");
|
|
11
10
|
var _styles = require("@mui/material/styles");
|
|
12
|
-
var
|
|
11
|
+
var _DateTimePicker = require("@mui/x-date-pickers/DateTimePicker");
|
|
13
12
|
var _formik = require("formik");
|
|
14
13
|
var _moment = _interopRequireDefault(require("moment"));
|
|
15
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
15
|
var React = _interopRequireWildcard(require("react"));
|
|
17
16
|
var _apperance = require("../../config/apperance");
|
|
18
|
-
var _PuiButton = _interopRequireDefault(require("../buttons/PuiButton"));
|
|
19
17
|
var _StyledMuiTextField = _interopRequireDefault(require("../common/StyledMuiTextField"));
|
|
20
|
-
var _PuiDialog = _interopRequireDefault(require("../others/PuiDialog"));
|
|
21
|
-
var _PuiTextField = _interopRequireDefault(require("./PuiTextField"));
|
|
22
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
19
|
const _excluded = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
|
|
24
20
|
_excluded2 = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
|
|
@@ -35,110 +31,22 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
35
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); }
|
|
36
32
|
const StyledDateMuiTextField = (0, _styles.styled)( /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_StyledMuiTextField.default, _objectSpread({
|
|
37
33
|
ref: ref
|
|
38
|
-
}, props))))(() =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
}, props))))(() => {
|
|
35
|
+
return {
|
|
36
|
+
"&.MuiFormControl-root": {
|
|
37
|
+
display: "block",
|
|
38
|
+
"& .MuiInputAdornment-root .MuiButtonBase-root": {
|
|
39
|
+
padding: "6px",
|
|
40
|
+
marginRight: "-8px",
|
|
41
|
+
"& .MuiSvgIcon-root": {
|
|
42
|
+
width: "16px",
|
|
43
|
+
height: "16px"
|
|
44
|
+
}
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
|
-
}
|
|
50
|
-
}));
|
|
51
|
-
const TimePickerDialog = _ref => {
|
|
52
|
-
var _ref2, _position$top, _ref3, _ref4;
|
|
53
|
-
let {
|
|
54
|
-
open,
|
|
55
|
-
selectedDate,
|
|
56
|
-
onTimeSelected,
|
|
57
|
-
onClose,
|
|
58
|
-
position
|
|
59
|
-
} = _ref;
|
|
60
|
-
const defaultTime = (0, _moment.default)(selectedDate).isValid() ? (0, _moment.default)(selectedDate).format("HH:mm") : (0, _moment.default)().format("HH:mm");
|
|
61
|
-
const [selectedTime, setSelectedTime] = React.useState(defaultTime);
|
|
62
|
-
const handleTimeChange = event => {
|
|
63
|
-
setSelectedTime(event.target.value);
|
|
64
|
-
};
|
|
65
|
-
const handleOk = () => {
|
|
66
|
-
onTimeSelected(selectedTime);
|
|
67
|
-
onClose();
|
|
68
47
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
onClose: onClose,
|
|
72
|
-
slotProps: {
|
|
73
|
-
backdrop: {
|
|
74
|
-
style: {
|
|
75
|
-
backgroundColor: "transparent",
|
|
76
|
-
boxShadow: "none"
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
hideBackdrop: true,
|
|
81
|
-
PaperProps: {
|
|
82
|
-
elevation: 5,
|
|
83
|
-
sx: {
|
|
84
|
-
backgroundColor: "white",
|
|
85
|
-
alignItems: "center",
|
|
86
|
-
display: "flex",
|
|
87
|
-
width: 340,
|
|
88
|
-
maxWidth: "720px!important",
|
|
89
|
-
position: "fixed",
|
|
90
|
-
height: 48,
|
|
91
|
-
left: (_ref2 = (position === null || position === void 0 ? void 0 : position.left) - 420 / 2) !== null && _ref2 !== void 0 ? _ref2 : 0,
|
|
92
|
-
top: (_position$top = position === null || position === void 0 ? void 0 : position.top) !== null && _position$top !== void 0 ? _position$top : 0,
|
|
93
|
-
paddingLeft: 0
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
97
|
-
sx: {
|
|
98
|
-
display: "flex",
|
|
99
|
-
alignItems: "center",
|
|
100
|
-
alignContent: "center",
|
|
101
|
-
marginTop: 1,
|
|
102
|
-
gap: 2,
|
|
103
|
-
width: 340,
|
|
104
|
-
justifyContent: "center",
|
|
105
|
-
left: (_ref3 = (position === null || position === void 0 ? void 0 : position.left) - 380 / 2) !== null && _ref3 !== void 0 ? _ref3 : 0,
|
|
106
|
-
top: (_ref4 = (position === null || position === void 0 ? void 0 : position.top) + 36) !== null && _ref4 !== void 0 ? _ref4 : 36,
|
|
107
|
-
paddingLeft: 1.5,
|
|
108
|
-
position: "fixed"
|
|
109
|
-
},
|
|
110
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTextField.default, {
|
|
111
|
-
id: "time",
|
|
112
|
-
type: "time",
|
|
113
|
-
value: selectedTime,
|
|
114
|
-
onChange: handleTimeChange,
|
|
115
|
-
InputLabelProps: {
|
|
116
|
-
shrink: true
|
|
117
|
-
},
|
|
118
|
-
inputProps: {
|
|
119
|
-
step: 60
|
|
120
|
-
},
|
|
121
|
-
formik: false,
|
|
122
|
-
sx: {
|
|
123
|
-
width: 150
|
|
124
|
-
}
|
|
125
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
126
|
-
onClick: onClose,
|
|
127
|
-
sx: {
|
|
128
|
-
color: _apperance.palette.primary
|
|
129
|
-
},
|
|
130
|
-
children: "Cancel"
|
|
131
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
132
|
-
onClick: handleOk,
|
|
133
|
-
sx: {
|
|
134
|
-
color: _apperance.palette.primary
|
|
135
|
-
},
|
|
136
|
-
children: "OK"
|
|
137
|
-
})]
|
|
138
|
-
})
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
48
|
+
});
|
|
49
|
+
const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
142
50
|
let {
|
|
143
51
|
id,
|
|
144
52
|
className,
|
|
@@ -149,8 +57,8 @@ const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
149
57
|
value,
|
|
150
58
|
minDate,
|
|
151
59
|
maxDate,
|
|
152
|
-
inputFormat
|
|
153
|
-
format
|
|
60
|
+
inputFormat,
|
|
61
|
+
format,
|
|
154
62
|
disablePast,
|
|
155
63
|
disableFuture,
|
|
156
64
|
error,
|
|
@@ -160,93 +68,50 @@ const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
|
160
68
|
helperText,
|
|
161
69
|
onChange,
|
|
162
70
|
onBlur
|
|
163
|
-
} =
|
|
164
|
-
rest = _objectWithoutProperties(
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const maxDateObj = maxDate ? (0, _moment.default)(maxDate, format).toDate() : undefined;
|
|
169
|
-
const [displayedDateTime, setDisplayedDateTime] = React.useState(value || null);
|
|
170
|
-
const [openTimePicker, setOpenTimePicker] = React.useState(false);
|
|
171
|
-
const [dialogPosition, setDialogPosition] = React.useState();
|
|
172
|
-
const handleDateChange = date => {
|
|
173
|
-
if (date) {
|
|
174
|
-
setDateTime((0, _moment.default)(date).format(format));
|
|
175
|
-
setOpenTimePicker(true);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
const handleTimeSelected = time => {
|
|
179
|
-
const newDateTime = (0, _moment.default)(dateTime).format("YYYY-MM-DD") + "T" + time;
|
|
180
|
-
const updatedDateTime = (0, _moment.default)(newDateTime, "YYYY-MM-DDTHH:mm").format(format);
|
|
181
|
-
setDateTime(updatedDateTime);
|
|
182
|
-
setDisplayedDateTime(updatedDateTime);
|
|
183
|
-
onChange(updatedDateTime);
|
|
71
|
+
} = _ref,
|
|
72
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
73
|
+
const handleChange = value => {
|
|
74
|
+
const formattedValue = format ? value.format(format) : value.toISOString();
|
|
75
|
+
onChange(formattedValue);
|
|
184
76
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
204
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker.DatePicker, _objectSpread({
|
|
205
|
-
ref: ref,
|
|
206
|
-
sx: sx,
|
|
207
|
-
ampm: false,
|
|
208
|
-
label: label,
|
|
209
|
-
inputFormat: "DD/MM/yyyy HH:mm",
|
|
210
|
-
value: displayedDateTime,
|
|
211
|
-
onChange: handleDateChange,
|
|
212
|
-
disablePast: disablePast,
|
|
213
|
-
disableFuture: disableFuture,
|
|
214
|
-
disabled: disabled,
|
|
215
|
-
maxDate: maxDateObj,
|
|
216
|
-
minDate: minDateObj,
|
|
217
|
-
readOnly: readOnly,
|
|
218
|
-
PopperProps: {
|
|
219
|
-
sx: {
|
|
220
|
-
"& .MuiButtonBase-root.Mui-selected, & .MuiButtonBase-root.Mui-selected:focus, & .MuiButtonBase-root.Mui-selected:hover": {
|
|
221
|
-
backgroundColor: _apperance.palette.primary
|
|
222
|
-
}
|
|
77
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker.DateTimePicker, _objectSpread({
|
|
78
|
+
ref: ref,
|
|
79
|
+
sx: sx,
|
|
80
|
+
ampm: false,
|
|
81
|
+
label: label,
|
|
82
|
+
inputFormat: inputFormat,
|
|
83
|
+
value: value,
|
|
84
|
+
onChange: handleChange,
|
|
85
|
+
disablePast: disablePast,
|
|
86
|
+
disableFuture: disableFuture,
|
|
87
|
+
disabled: disabled,
|
|
88
|
+
maxDate: maxDate,
|
|
89
|
+
minDate: minDate,
|
|
90
|
+
readOnly: readOnly,
|
|
91
|
+
PopperProps: {
|
|
92
|
+
sx: {
|
|
93
|
+
"& .MuiButtonBase-root.Mui-selected, & .MuiButtonBase-root.Mui-selected:focus, & .MuiButtonBase-root.Mui-selected:hover": {
|
|
94
|
+
backgroundColor: _apperance.palette.primary
|
|
223
95
|
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
open: openTimePicker,
|
|
242
|
-
selectedDate: dateTime,
|
|
243
|
-
onTimeSelected: handleTimeSelected,
|
|
244
|
-
onClose: () => setOpenTimePicker(false),
|
|
245
|
-
position: dialogPosition
|
|
246
|
-
})]
|
|
247
|
-
});
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
renderInput: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledDateMuiTextField, _objectSpread(_objectSpread({
|
|
99
|
+
id: id,
|
|
100
|
+
className: className,
|
|
101
|
+
name: name,
|
|
102
|
+
required: required,
|
|
103
|
+
fullWidth: fullWidth,
|
|
104
|
+
onBlur: onBlur,
|
|
105
|
+
helperText: helperText
|
|
106
|
+
}, params), {}, {
|
|
107
|
+
error: params.error || error,
|
|
108
|
+
inputProps: {
|
|
109
|
+
name
|
|
110
|
+
}
|
|
111
|
+
}))
|
|
112
|
+
}, rest));
|
|
248
113
|
});
|
|
249
|
-
const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((
|
|
114
|
+
const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
250
115
|
let {
|
|
251
116
|
id,
|
|
252
117
|
className,
|
|
@@ -268,13 +133,11 @@ const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
268
133
|
helperText,
|
|
269
134
|
onChange,
|
|
270
135
|
onBlur
|
|
271
|
-
} =
|
|
272
|
-
rest = _objectWithoutProperties(
|
|
136
|
+
} = _ref2,
|
|
137
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
273
138
|
const [field, meta] = (0, _formik.useField)(name);
|
|
274
139
|
const formikContext = (0, _formik.useFormikContext)();
|
|
275
140
|
const [hasError, setHasError] = React.useState(false);
|
|
276
|
-
const minDateObj = minDate ? (0, _moment.default)(minDate, format).toDate() : undefined;
|
|
277
|
-
const maxDateObj = maxDate ? (0, _moment.default)(maxDate, format).toDate() : undefined;
|
|
278
141
|
const handleChange = value => {
|
|
279
142
|
formikContext.setFieldValue(name, value);
|
|
280
143
|
onChange(value);
|
|
@@ -302,8 +165,7 @@ const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
302
165
|
required: required,
|
|
303
166
|
value: Boolean(field.value) ? format ? _moment.default.utc(field.value, format) : _moment.default.utc(field.value) : null,
|
|
304
167
|
format: format,
|
|
305
|
-
minDate:
|
|
306
|
-
maxDate: maxDateObj,
|
|
168
|
+
minDate: minDate,
|
|
307
169
|
inputFormat: inputFormat,
|
|
308
170
|
disableFuture: disableFuture,
|
|
309
171
|
disablePast: disablePast,
|
|
@@ -316,7 +178,7 @@ const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
|
316
178
|
onBlur: handleBlur
|
|
317
179
|
}, rest));
|
|
318
180
|
});
|
|
319
|
-
const PuiDateTimeField = /*#__PURE__*/React.forwardRef((
|
|
181
|
+
const PuiDateTimeField = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
320
182
|
let {
|
|
321
183
|
formik,
|
|
322
184
|
id,
|
|
@@ -339,8 +201,8 @@ const PuiDateTimeField = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
|
|
|
339
201
|
helperText,
|
|
340
202
|
onChange,
|
|
341
203
|
onBlur
|
|
342
|
-
} =
|
|
343
|
-
rest = _objectWithoutProperties(
|
|
204
|
+
} = _ref3,
|
|
205
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
344
206
|
return /*#__PURE__*/React.createElement(formik ? PuiFormikDateTimeField : PuiStandardDateTimeField, _objectSpread({
|
|
345
207
|
ref,
|
|
346
208
|
id,
|
|
@@ -314,14 +314,14 @@ const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
314
314
|
sx: {
|
|
315
315
|
display: 'flex',
|
|
316
316
|
gap: '8px',
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
// Keep icons on the same line; remove if you want them to wrap
|
|
317
|
+
flexWrap: 'rap',
|
|
318
|
+
// Ensure actions stay on the same line
|
|
320
319
|
justifyContent: 'center',
|
|
321
|
-
// Center the icons horizontally
|
|
322
320
|
alignItems: 'center',
|
|
323
|
-
|
|
324
|
-
|
|
321
|
+
overflow: 'hidden',
|
|
322
|
+
// Ensure content doesn't overflow
|
|
323
|
+
textOverflow: 'ellipsis',
|
|
324
|
+
whiteSpace: 'nowrap'
|
|
325
325
|
},
|
|
326
326
|
children: actions.map((action, index) => /*#__PURE__*/React.cloneElement(action, {
|
|
327
327
|
row,
|