@portnet/ui 0.1.21 → 0.1.23
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,6 +7,7 @@ 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");
|
|
10
11
|
var _styles = require("@mui/material/styles");
|
|
11
12
|
var _DatePicker = require("@mui/x-date-pickers/DatePicker");
|
|
12
13
|
var _formik = require("formik");
|
|
@@ -14,10 +15,10 @@ var _moment = _interopRequireDefault(require("moment"));
|
|
|
14
15
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
16
|
var React = _interopRequireWildcard(require("react"));
|
|
16
17
|
var _apperance = require("../../config/apperance");
|
|
17
|
-
var _StyledMuiTextField = _interopRequireDefault(require("../common/StyledMuiTextField"));
|
|
18
|
-
var _PuiTextField = _interopRequireDefault(require("./PuiTextField"));
|
|
19
18
|
var _PuiButton = _interopRequireDefault(require("../buttons/PuiButton"));
|
|
19
|
+
var _StyledMuiTextField = _interopRequireDefault(require("../common/StyledMuiTextField"));
|
|
20
20
|
var _PuiDialog = _interopRequireDefault(require("../others/PuiDialog"));
|
|
21
|
+
var _PuiTextField = _interopRequireDefault(require("./PuiTextField"));
|
|
21
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
23
|
const _excluded = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
|
|
23
24
|
_excluded2 = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
|
|
@@ -48,11 +49,13 @@ const StyledDateMuiTextField = (0, _styles.styled)( /*#__PURE__*/React.forwardRe
|
|
|
48
49
|
}
|
|
49
50
|
}));
|
|
50
51
|
const TimePickerDialog = _ref => {
|
|
52
|
+
var _ref2, _position$top, _ref3, _ref4;
|
|
51
53
|
let {
|
|
52
54
|
open,
|
|
53
55
|
selectedDate,
|
|
54
56
|
onTimeSelected,
|
|
55
|
-
onClose
|
|
57
|
+
onClose,
|
|
58
|
+
position
|
|
56
59
|
} = _ref;
|
|
57
60
|
const defaultTime = (0, _moment.default)(selectedDate).isValid() ? (0, _moment.default)(selectedDate).format("HH:mm") : (0, _moment.default)().format("HH:mm");
|
|
58
61
|
const [selectedTime, setSelectedTime] = React.useState(defaultTime);
|
|
@@ -63,7 +66,7 @@ const TimePickerDialog = _ref => {
|
|
|
63
66
|
onTimeSelected(selectedTime);
|
|
64
67
|
onClose();
|
|
65
68
|
};
|
|
66
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
69
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiDialog.default, {
|
|
67
70
|
open: open,
|
|
68
71
|
onClose: onClose,
|
|
69
72
|
slotProps: {
|
|
@@ -78,49 +81,64 @@ const TimePickerDialog = _ref => {
|
|
|
78
81
|
PaperProps: {
|
|
79
82
|
elevation: 5,
|
|
80
83
|
sx: {
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
83
94
|
}
|
|
84
95
|
},
|
|
85
|
-
|
|
86
|
-
display: "flex",
|
|
87
|
-
alignItems: "center",
|
|
88
|
-
gap: 2,
|
|
89
|
-
width: 340,
|
|
90
|
-
justifyContent: "center",
|
|
91
|
-
alignSelf: "center"
|
|
92
|
-
},
|
|
93
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTextField.default, {
|
|
94
|
-
id: "time",
|
|
95
|
-
type: "time",
|
|
96
|
-
value: selectedTime,
|
|
97
|
-
onChange: handleTimeChange,
|
|
98
|
-
InputLabelProps: {
|
|
99
|
-
shrink: true
|
|
100
|
-
},
|
|
101
|
-
inputProps: {
|
|
102
|
-
step: 60
|
|
103
|
-
},
|
|
104
|
-
formik: false,
|
|
105
|
-
sx: {
|
|
106
|
-
width: 150
|
|
107
|
-
}
|
|
108
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
109
|
-
onClick: onClose,
|
|
96
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
110
97
|
sx: {
|
|
111
|
-
|
|
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"
|
|
112
109
|
},
|
|
113
|
-
children:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
+
})
|
|
121
139
|
});
|
|
122
140
|
};
|
|
123
|
-
const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((
|
|
141
|
+
const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
124
142
|
let {
|
|
125
143
|
id,
|
|
126
144
|
className,
|
|
@@ -142,13 +160,15 @@ const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
142
160
|
helperText,
|
|
143
161
|
onChange,
|
|
144
162
|
onBlur
|
|
145
|
-
} =
|
|
146
|
-
rest = _objectWithoutProperties(
|
|
163
|
+
} = _ref5,
|
|
164
|
+
rest = _objectWithoutProperties(_ref5, _excluded);
|
|
165
|
+
const textFieldRef = React.useRef(null);
|
|
147
166
|
const [dateTime, setDateTime] = React.useState(value || null);
|
|
148
167
|
const minDateObj = minDate ? (0, _moment.default)(minDate, format).toDate() : undefined;
|
|
149
168
|
const maxDateObj = maxDate ? (0, _moment.default)(maxDate, format).toDate() : undefined;
|
|
150
169
|
const [displayedDateTime, setDisplayedDateTime] = React.useState(value || null);
|
|
151
170
|
const [openTimePicker, setOpenTimePicker] = React.useState(false);
|
|
171
|
+
const [dialogPosition, setDialogPosition] = React.useState();
|
|
152
172
|
const handleDateChange = date => {
|
|
153
173
|
if (date) {
|
|
154
174
|
setDateTime((0, _moment.default)(date).format(format));
|
|
@@ -162,6 +182,24 @@ const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
162
182
|
setDisplayedDateTime(updatedDateTime);
|
|
163
183
|
onChange(updatedDateTime);
|
|
164
184
|
};
|
|
185
|
+
React.useEffect(() => {
|
|
186
|
+
const updatePosition = () => {
|
|
187
|
+
if (textFieldRef.current) {
|
|
188
|
+
const rect = textFieldRef.current.getBoundingClientRect();
|
|
189
|
+
setDialogPosition({
|
|
190
|
+
left: rect.left + rect.width / 2 + window.scrollX,
|
|
191
|
+
top: rect.top > 310 ? rect.top - 80 : rect.top + 80
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
updatePosition();
|
|
196
|
+
window.addEventListener("resize", updatePosition);
|
|
197
|
+
window.addEventListener("scroll", updatePosition);
|
|
198
|
+
return () => {
|
|
199
|
+
window.removeEventListener("resize", updatePosition);
|
|
200
|
+
window.removeEventListener("scroll", updatePosition);
|
|
201
|
+
};
|
|
202
|
+
}, []);
|
|
165
203
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
166
204
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker.DatePicker, _objectSpread({
|
|
167
205
|
ref: ref,
|
|
@@ -185,6 +223,7 @@ const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
185
223
|
}
|
|
186
224
|
},
|
|
187
225
|
renderInput: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledDateMuiTextField, _objectSpread(_objectSpread({}, params), {}, {
|
|
226
|
+
ref: textFieldRef,
|
|
188
227
|
id: id,
|
|
189
228
|
className: className,
|
|
190
229
|
label: label,
|
|
@@ -202,11 +241,12 @@ const PuiStandardDateTimeField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
202
241
|
open: openTimePicker,
|
|
203
242
|
selectedDate: dateTime,
|
|
204
243
|
onTimeSelected: handleTimeSelected,
|
|
205
|
-
onClose: () => setOpenTimePicker(false)
|
|
244
|
+
onClose: () => setOpenTimePicker(false),
|
|
245
|
+
position: dialogPosition
|
|
206
246
|
})]
|
|
207
247
|
});
|
|
208
248
|
});
|
|
209
|
-
const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((
|
|
249
|
+
const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((_ref6, ref) => {
|
|
210
250
|
let {
|
|
211
251
|
id,
|
|
212
252
|
className,
|
|
@@ -228,8 +268,8 @@ const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
228
268
|
helperText,
|
|
229
269
|
onChange,
|
|
230
270
|
onBlur
|
|
231
|
-
} =
|
|
232
|
-
rest = _objectWithoutProperties(
|
|
271
|
+
} = _ref6,
|
|
272
|
+
rest = _objectWithoutProperties(_ref6, _excluded2);
|
|
233
273
|
const [field, meta] = (0, _formik.useField)(name);
|
|
234
274
|
const formikContext = (0, _formik.useFormikContext)();
|
|
235
275
|
const [hasError, setHasError] = React.useState(false);
|
|
@@ -276,7 +316,7 @@ const PuiFormikDateTimeField = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
276
316
|
onBlur: handleBlur
|
|
277
317
|
}, rest));
|
|
278
318
|
});
|
|
279
|
-
const PuiDateTimeField = /*#__PURE__*/React.forwardRef((
|
|
319
|
+
const PuiDateTimeField = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
|
|
280
320
|
let {
|
|
281
321
|
formik,
|
|
282
322
|
id,
|
|
@@ -299,8 +339,8 @@ const PuiDateTimeField = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
|
299
339
|
helperText,
|
|
300
340
|
onChange,
|
|
301
341
|
onBlur
|
|
302
|
-
} =
|
|
303
|
-
rest = _objectWithoutProperties(
|
|
342
|
+
} = _ref7,
|
|
343
|
+
rest = _objectWithoutProperties(_ref7, _excluded3);
|
|
304
344
|
return /*#__PURE__*/React.createElement(formik ? PuiFormikDateTimeField : PuiStandardDateTimeField, _objectSpread({
|
|
305
345
|
ref,
|
|
306
346
|
id,
|