@portnet/ui 4.0.0 → 4.0.2
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/buttons/PuiButton.js +18 -10
- package/dist/components/common/StyledMuiTextField.js +12 -4
- package/dist/components/inputs/PuiDateField.js +144 -84
- package/dist/components/inputs/PuiDateTimeField.js +302 -24
- package/dist/components/inputs/PuiSelect.js +116 -34
- package/dist/components/others/PuiSection.js +24 -30
- package/dist/components/table/PuiTable.js +22 -17
- package/dist/components/table/PuiTableAction.js +12 -2
- package/dist/components/typography/PuiMainTitle.js +70 -34
- package/dist/components/ui/pages/general/PuiSearchPage.js +19 -7
- package/package.json +3 -3
|
@@ -12,9 +12,14 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
var _formik = require("formik");
|
|
14
14
|
var _moment = _interopRequireDefault(require("moment"));
|
|
15
|
-
var
|
|
15
|
+
var _AdapterDayjs = require("@mui/x-date-pickers/AdapterDayjs");
|
|
16
|
+
var _DateTimePicker = require("@mui/x-date-pickers/DateTimePicker");
|
|
17
|
+
var _LocalizationProvider = require("@mui/x-date-pickers/LocalizationProvider");
|
|
18
|
+
var _apperance = require("../../config/apperance");
|
|
16
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
const _excluded = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"]
|
|
20
|
+
const _excluded = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
|
|
21
|
+
_excluded2 = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
|
|
22
|
+
_excluded3 = ["formik", "id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"]; // Helper function to get palette from theme or fallback to appearance
|
|
18
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
24
|
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; }
|
|
20
25
|
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; }
|
|
@@ -23,7 +28,143 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
23
28
|
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); }
|
|
24
29
|
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; }
|
|
25
30
|
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; }
|
|
26
|
-
const
|
|
31
|
+
const getPalette = theme => {
|
|
32
|
+
// Check if theme has our custom palette properties
|
|
33
|
+
if (theme && theme.palette && theme.palette.gray && theme.palette.gray.darker) {
|
|
34
|
+
// Theme has our custom structure, now normalize it
|
|
35
|
+
return {
|
|
36
|
+
primary: theme.palette.primary.main || theme.palette.primary,
|
|
37
|
+
secondary: theme.palette.secondary.main || theme.palette.secondary,
|
|
38
|
+
error: theme.palette.error ? theme.palette.error.main || theme.palette.error : _apperance.palette.error,
|
|
39
|
+
warning: theme.palette.warning ? theme.palette.warning.main || theme.palette.warning : _apperance.palette.warning,
|
|
40
|
+
success: theme.palette.success ? theme.palette.success.main || theme.palette.success : _apperance.palette.success,
|
|
41
|
+
info: theme.palette.info ? theme.palette.info.main || theme.palette.info : _apperance.palette.info,
|
|
42
|
+
white: theme.palette.white || _apperance.palette.white,
|
|
43
|
+
dark: theme.palette.dark || _apperance.palette.dark,
|
|
44
|
+
gray: theme.palette.gray,
|
|
45
|
+
blue: theme.palette.blue || _apperance.palette.blue,
|
|
46
|
+
background: theme.palette.background || _apperance.palette.background,
|
|
47
|
+
border: theme.palette.border || _apperance.palette.border,
|
|
48
|
+
shadow: theme.palette.shadow || _apperance.palette.shadow
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Check if theme object itself has gray (root level)
|
|
52
|
+
if (theme && theme.gray && theme.gray.darker) {
|
|
53
|
+
return {
|
|
54
|
+
primary: theme.primary,
|
|
55
|
+
secondary: theme.secondary,
|
|
56
|
+
error: theme.error || _apperance.palette.error,
|
|
57
|
+
warning: theme.warning || _apperance.palette.warning,
|
|
58
|
+
success: theme.success || _apperance.palette.success,
|
|
59
|
+
info: theme.info || _apperance.palette.info,
|
|
60
|
+
white: theme.white || _apperance.palette.white,
|
|
61
|
+
dark: theme.dark || _apperance.palette.dark,
|
|
62
|
+
gray: theme.gray,
|
|
63
|
+
blue: theme.blue || _apperance.palette.blue,
|
|
64
|
+
background: theme.background || _apperance.palette.background,
|
|
65
|
+
border: theme.border || _apperance.palette.border,
|
|
66
|
+
shadow: theme.shadow || _apperance.palette.shadow
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return _apperance.palette;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Helper function to get DateTimeField styles from theme
|
|
73
|
+
const getDateTimeFieldStyles = theme => {
|
|
74
|
+
if (theme && theme.components && theme.components.PuiDateTimeField) {
|
|
75
|
+
return theme.components.PuiDateTimeField;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
inputRoot: {
|
|
79
|
+
backgroundColor: _apperance.palette.white,
|
|
80
|
+
border: "2px solid ".concat(_apperance.palette.gray.dark),
|
|
81
|
+
borderRadius: "5px",
|
|
82
|
+
height: "auto",
|
|
83
|
+
lineHeight: "1"
|
|
84
|
+
},
|
|
85
|
+
label: {
|
|
86
|
+
color: _apperance.palette.gray.darker,
|
|
87
|
+
marginBottom: "4px",
|
|
88
|
+
fontSize: "0.8rem"
|
|
89
|
+
},
|
|
90
|
+
disabled: {
|
|
91
|
+
backgroundColor: "#f5f5f5",
|
|
92
|
+
border: "1px solid #cecdd3",
|
|
93
|
+
labelColor: "#97969b"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
const getTextFieldStyles = (theme, required) => {
|
|
98
|
+
var _themePalette$backgro, _palette$background, _dateTimeFieldStyles$, _themePalette$backgro2, _palette$background2, _dateTimeFieldStyles$2, _dateTimeFieldStyles$3;
|
|
99
|
+
const themePalette = getPalette(theme);
|
|
100
|
+
const dateTimeFieldStyles = getDateTimeFieldStyles(theme);
|
|
101
|
+
return {
|
|
102
|
+
"&.MuiFormControl-root": {
|
|
103
|
+
"&.required .MuiInputBase-root": {
|
|
104
|
+
backgroundColor: required ? ((_themePalette$backgro = themePalette.background) === null || _themePalette$backgro === void 0 ? void 0 : _themePalette$backgro.required) || ((_palette$background = _apperance.palette.background) === null || _palette$background === void 0 ? void 0 : _palette$background.required) : dateTimeFieldStyles.inputRoot.backgroundColor
|
|
105
|
+
},
|
|
106
|
+
"& .MuiFormLabel-root": {
|
|
107
|
+
zIndex: 0,
|
|
108
|
+
lineSpacing: "-0.03em",
|
|
109
|
+
position: "initial",
|
|
110
|
+
transform: "none",
|
|
111
|
+
fontSize: "".concat(dateTimeFieldStyles.label.fontSize, " !important"),
|
|
112
|
+
fontWeight: "600",
|
|
113
|
+
marginBottom: "".concat(dateTimeFieldStyles.label.marginBottom, " !important"),
|
|
114
|
+
color: "".concat(dateTimeFieldStyles.label.color, " !important"),
|
|
115
|
+
"&.Mui-focused ": {
|
|
116
|
+
color: "".concat(themePalette.primary, " !important")
|
|
117
|
+
},
|
|
118
|
+
"&.Mui-disabled": {
|
|
119
|
+
color: "".concat(((_dateTimeFieldStyles$ = dateTimeFieldStyles.disabled) === null || _dateTimeFieldStyles$ === void 0 ? void 0 : _dateTimeFieldStyles$.labelColor) || "#97969b", " !important")
|
|
120
|
+
},
|
|
121
|
+
"&.Mui-error": {
|
|
122
|
+
color: "".concat(themePalette.error, " !important")
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"& .MuiInputBase-root": {
|
|
126
|
+
backgroundColor: "".concat(dateTimeFieldStyles.inputRoot.backgroundColor, " !important"),
|
|
127
|
+
border: "".concat(dateTimeFieldStyles.inputRoot.border, " !important"),
|
|
128
|
+
borderRadius: "".concat(dateTimeFieldStyles.inputRoot.borderRadius, " !important"),
|
|
129
|
+
height: "".concat(dateTimeFieldStyles.inputRoot.height, " !important"),
|
|
130
|
+
"&.MuiInputBase-multiline": {
|
|
131
|
+
padding: "8px 0",
|
|
132
|
+
height: "auto !important"
|
|
133
|
+
},
|
|
134
|
+
"&.Mui-focused ": {
|
|
135
|
+
border: "2px solid ".concat(themePalette.primary, " !important")
|
|
136
|
+
},
|
|
137
|
+
"&.Mui-error ": {
|
|
138
|
+
border: "2px solid ".concat(themePalette.error, " !important"),
|
|
139
|
+
backgroundColor: "".concat(((_themePalette$backgro2 = themePalette.background) === null || _themePalette$backgro2 === void 0 ? void 0 : _themePalette$backgro2.error) || ((_palette$background2 = _apperance.palette.background) === null || _palette$background2 === void 0 ? void 0 : _palette$background2.error), " !important")
|
|
140
|
+
},
|
|
141
|
+
"&.Mui-disabled ": {
|
|
142
|
+
backgroundColor: "".concat(((_dateTimeFieldStyles$2 = dateTimeFieldStyles.disabled) === null || _dateTimeFieldStyles$2 === void 0 ? void 0 : _dateTimeFieldStyles$2.backgroundColor) || "#f5f5f5", " !important"),
|
|
143
|
+
border: "".concat(((_dateTimeFieldStyles$3 = dateTimeFieldStyles.disabled) === null || _dateTimeFieldStyles$3 === void 0 ? void 0 : _dateTimeFieldStyles$3.border) || "1px solid #cecdd3", " !important"),
|
|
144
|
+
borderRadius: "".concat(dateTimeFieldStyles.inputRoot.borderRadius, " !important"),
|
|
145
|
+
"& input": {
|
|
146
|
+
color: "".concat(themePalette.gray.darker),
|
|
147
|
+
WebkitTextFillColor: "".concat(themePalette.gray.darker)
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
"& .MuiInputBase-input": {
|
|
151
|
+
lineHeight: "".concat(dateTimeFieldStyles.inputRoot.lineHeight, " !important"),
|
|
152
|
+
padding: "1px 6px",
|
|
153
|
+
fontSize: "0.7rem"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"& .MuiFormHelperText-root": {
|
|
157
|
+
fontWeight: "bold",
|
|
158
|
+
fontSize: ".7rem",
|
|
159
|
+
color: "red"
|
|
160
|
+
},
|
|
161
|
+
"& fieldset": {
|
|
162
|
+
display: "none"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
const PuiStandardDateTimeField = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
27
168
|
let {
|
|
28
169
|
id,
|
|
29
170
|
className,
|
|
@@ -47,62 +188,197 @@ const PuiDateTimeField = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
47
188
|
onBlur
|
|
48
189
|
} = _ref,
|
|
49
190
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
191
|
+
const handleChange = value => {
|
|
192
|
+
if (value) {
|
|
193
|
+
const formattedValue = format ? value.format(format) : value.toISOString();
|
|
194
|
+
onChange(formattedValue);
|
|
195
|
+
} else {
|
|
196
|
+
onChange(null);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LocalizationProvider.LocalizationProvider, {
|
|
200
|
+
dateAdapter: _AdapterDayjs.AdapterDayjs,
|
|
201
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DateTimePicker.DateTimePicker, _objectSpread({
|
|
202
|
+
ref: ref,
|
|
203
|
+
sx: sx,
|
|
204
|
+
label: label,
|
|
205
|
+
inputFormat: inputFormat,
|
|
206
|
+
value: value,
|
|
207
|
+
onChange: handleChange,
|
|
208
|
+
disablePast: disablePast,
|
|
209
|
+
disableFuture: disableFuture,
|
|
210
|
+
disabled: disabled,
|
|
211
|
+
maxDate: maxDate,
|
|
212
|
+
minDate: minDate,
|
|
213
|
+
readOnly: readOnly,
|
|
214
|
+
slotProps: {
|
|
215
|
+
textField: {
|
|
216
|
+
name,
|
|
217
|
+
sx: theme => getTextFieldStyles(theme, required),
|
|
218
|
+
fullWidth,
|
|
219
|
+
required,
|
|
220
|
+
error,
|
|
221
|
+
helperText,
|
|
222
|
+
className: required ? "required" : ""
|
|
223
|
+
},
|
|
224
|
+
popper: {
|
|
225
|
+
sx: theme => {
|
|
226
|
+
const themePalette = getPalette(theme);
|
|
227
|
+
return {
|
|
228
|
+
"& .MuiPaper-root": {
|
|
229
|
+
boxShadow: "none !important",
|
|
230
|
+
border: "1px solid #e0e0e0",
|
|
231
|
+
backgroundColor: "white"
|
|
232
|
+
},
|
|
233
|
+
"& .MuiPickersDay-root.Mui-selected": {
|
|
234
|
+
backgroundColor: "".concat(themePalette.primary, " !important")
|
|
235
|
+
},
|
|
236
|
+
"& .Mui-selected": {
|
|
237
|
+
backgroundColor: "".concat(themePalette.primary, " !important")
|
|
238
|
+
},
|
|
239
|
+
"& .MuiClockNumber-root.Mui-selected": {
|
|
240
|
+
backgroundColor: "".concat(themePalette.primary, " !important")
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}, rest))
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
const PuiFormikDateTimeField = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
250
|
+
let {
|
|
251
|
+
id,
|
|
252
|
+
className,
|
|
253
|
+
sx,
|
|
254
|
+
label,
|
|
255
|
+
name,
|
|
256
|
+
required,
|
|
257
|
+
value,
|
|
258
|
+
minDate,
|
|
259
|
+
maxDate,
|
|
260
|
+
inputFormat,
|
|
261
|
+
format,
|
|
262
|
+
disablePast,
|
|
263
|
+
disableFuture,
|
|
264
|
+
error,
|
|
265
|
+
readOnly,
|
|
266
|
+
fullWidth,
|
|
267
|
+
disabled,
|
|
268
|
+
helperText,
|
|
269
|
+
onChange,
|
|
270
|
+
onBlur
|
|
271
|
+
} = _ref2,
|
|
272
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
50
273
|
const [field, meta] = (0, _formik.useField)(name);
|
|
51
274
|
const formikContext = (0, _formik.useFormikContext)();
|
|
52
275
|
const [hasError, setHasError] = _react.default.useState(false);
|
|
53
|
-
const minDateObj = minDate ? (0, _moment.default)(minDate, format).toDate() : undefined;
|
|
54
|
-
const maxDateObj = maxDate ? (0, _moment.default)(maxDate, format).toDate() : undefined;
|
|
55
276
|
const handleChange = value => {
|
|
56
|
-
|
|
57
|
-
|
|
277
|
+
if (value) {
|
|
278
|
+
formikContext.setFieldValue(name, value);
|
|
279
|
+
onChange(value);
|
|
280
|
+
} else {
|
|
281
|
+
formikContext.setFieldValue(name, null);
|
|
282
|
+
onChange(null);
|
|
283
|
+
}
|
|
58
284
|
};
|
|
59
285
|
const handleBlur = event => {
|
|
60
286
|
onBlur(event);
|
|
61
287
|
field.onBlur(event);
|
|
62
288
|
};
|
|
63
289
|
_react.default.useEffect(() => {
|
|
64
|
-
setHasError(meta.touched && meta.error);
|
|
290
|
+
setHasError(Boolean(meta) && Boolean(meta.touched) && Boolean(meta.error));
|
|
65
291
|
}, [meta]);
|
|
66
292
|
_react.default.useEffect(() => {
|
|
67
|
-
if (value) {
|
|
293
|
+
if (Boolean(value)) {
|
|
68
294
|
formikContext.setFieldValue(name, value);
|
|
69
295
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
296
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
297
|
+
}, [value]);
|
|
298
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardDateTimeField, _objectSpread({
|
|
73
299
|
id: id,
|
|
300
|
+
ref: ref,
|
|
74
301
|
className: className,
|
|
75
302
|
sx: sx,
|
|
76
303
|
label: label,
|
|
77
304
|
name: name,
|
|
78
305
|
required: required,
|
|
79
|
-
value: value,
|
|
306
|
+
value: Boolean(field.value) ? format ? (0, _moment.default)(field.value, format) : (0, _moment.default)(field.value) : null,
|
|
80
307
|
format: format,
|
|
81
|
-
minDate:
|
|
82
|
-
maxDate: maxDateObj,
|
|
308
|
+
minDate: minDate,
|
|
83
309
|
inputFormat: inputFormat,
|
|
84
310
|
disableFuture: disableFuture,
|
|
85
311
|
disablePast: disablePast,
|
|
86
|
-
error:
|
|
312
|
+
error: error || hasError,
|
|
87
313
|
readOnly: readOnly,
|
|
88
314
|
fullWidth: fullWidth,
|
|
89
315
|
disabled: disabled,
|
|
90
|
-
helperText:
|
|
316
|
+
helperText: hasError && Boolean(meta.error) ? meta.error : helperText !== null && helperText !== void 0 ? helperText : "",
|
|
91
317
|
onChange: handleChange,
|
|
92
318
|
onBlur: handleBlur
|
|
93
319
|
}, rest));
|
|
94
320
|
});
|
|
321
|
+
const PuiDateTimeField = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
322
|
+
let {
|
|
323
|
+
formik,
|
|
324
|
+
id,
|
|
325
|
+
className,
|
|
326
|
+
sx,
|
|
327
|
+
label,
|
|
328
|
+
name,
|
|
329
|
+
required,
|
|
330
|
+
value,
|
|
331
|
+
minDate,
|
|
332
|
+
maxDate,
|
|
333
|
+
inputFormat,
|
|
334
|
+
format,
|
|
335
|
+
disablePast,
|
|
336
|
+
disableFuture,
|
|
337
|
+
error,
|
|
338
|
+
readOnly,
|
|
339
|
+
fullWidth,
|
|
340
|
+
disabled,
|
|
341
|
+
helperText,
|
|
342
|
+
onChange,
|
|
343
|
+
onBlur
|
|
344
|
+
} = _ref3,
|
|
345
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
346
|
+
return /*#__PURE__*/_react.default.createElement(formik ? PuiFormikDateTimeField : PuiStandardDateTimeField, _objectSpread({
|
|
347
|
+
ref,
|
|
348
|
+
id,
|
|
349
|
+
className,
|
|
350
|
+
sx,
|
|
351
|
+
label,
|
|
352
|
+
name,
|
|
353
|
+
required,
|
|
354
|
+
value,
|
|
355
|
+
minDate,
|
|
356
|
+
maxDate,
|
|
357
|
+
inputFormat,
|
|
358
|
+
format,
|
|
359
|
+
disablePast,
|
|
360
|
+
disableFuture,
|
|
361
|
+
error,
|
|
362
|
+
readOnly,
|
|
363
|
+
fullWidth,
|
|
364
|
+
disabled,
|
|
365
|
+
helperText,
|
|
366
|
+
onChange,
|
|
367
|
+
onBlur
|
|
368
|
+
}, rest));
|
|
369
|
+
});
|
|
95
370
|
PuiDateTimeField.propTypes = {
|
|
96
371
|
id: _propTypes.default.string,
|
|
97
372
|
className: _propTypes.default.string,
|
|
98
373
|
sx: _propTypes.default.object,
|
|
99
374
|
label: _propTypes.default.string,
|
|
100
|
-
name: _propTypes.default.string
|
|
375
|
+
name: _propTypes.default.string,
|
|
101
376
|
helperText: _propTypes.default.string,
|
|
102
377
|
inputFormat: _propTypes.default.string,
|
|
103
378
|
format: _propTypes.default.string,
|
|
104
379
|
minDate: _propTypes.default.string,
|
|
105
380
|
maxDate: _propTypes.default.string,
|
|
381
|
+
formik: _propTypes.default.bool,
|
|
106
382
|
disabled: _propTypes.default.bool,
|
|
107
383
|
required: _propTypes.default.bool,
|
|
108
384
|
error: _propTypes.default.bool,
|
|
@@ -111,16 +387,18 @@ PuiDateTimeField.propTypes = {
|
|
|
111
387
|
readOnly: _propTypes.default.bool,
|
|
112
388
|
fullWidth: _propTypes.default.bool,
|
|
113
389
|
onChange: _propTypes.default.func,
|
|
114
|
-
onBlur: _propTypes.default.func
|
|
115
|
-
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.instanceOf(Date)])
|
|
390
|
+
onBlur: _propTypes.default.func
|
|
116
391
|
};
|
|
117
392
|
PuiDateTimeField.defaultProps = {
|
|
118
|
-
inputFormat: "YYYY
|
|
119
|
-
|
|
393
|
+
inputFormat: "DD/MM/YYYY HH:mm",
|
|
394
|
+
formik: true,
|
|
395
|
+
disabled: false,
|
|
396
|
+
required: false,
|
|
397
|
+
error: false,
|
|
398
|
+
fullWidth: true,
|
|
399
|
+
readOnly: false,
|
|
120
400
|
disablePast: false,
|
|
121
401
|
disableFuture: false,
|
|
122
|
-
readOnly: false,
|
|
123
|
-
fullWidth: true,
|
|
124
402
|
onChange: () => {},
|
|
125
403
|
onBlur: () => {}
|
|
126
404
|
};
|
|
@@ -33,54 +33,130 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
33
33
|
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; }
|
|
34
34
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
35
35
|
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
|
+
const getPalette = theme => {
|
|
37
|
+
// Check if theme has our custom palette properties
|
|
38
|
+
if (theme && theme.palette && theme.palette.gray && theme.palette.gray.darker) {
|
|
39
|
+
// Theme has our custom structure, now normalize it
|
|
40
|
+
return {
|
|
41
|
+
primary: theme.palette.primary.main || theme.palette.primary,
|
|
42
|
+
secondary: theme.palette.secondary.main || theme.palette.secondary,
|
|
43
|
+
error: theme.palette.error ? theme.palette.error.main || theme.palette.error : _apperance.palette.error,
|
|
44
|
+
warning: theme.palette.warning ? theme.palette.warning.main || theme.palette.warning : _apperance.palette.warning,
|
|
45
|
+
success: theme.palette.success ? theme.palette.success.main || theme.palette.success : _apperance.palette.success,
|
|
46
|
+
info: theme.palette.info ? theme.palette.info.main || theme.palette.info : _apperance.palette.info,
|
|
47
|
+
white: theme.palette.white || _apperance.palette.white,
|
|
48
|
+
dark: theme.palette.dark || _apperance.palette.dark,
|
|
49
|
+
gray: theme.palette.gray,
|
|
50
|
+
blue: theme.palette.blue || _apperance.palette.blue,
|
|
51
|
+
background: theme.palette.background || _apperance.palette.background,
|
|
52
|
+
border: theme.palette.border || _apperance.palette.border,
|
|
53
|
+
shadow: theme.palette.shadow || _apperance.palette.shadow
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// Check if theme object itself has gray (root level)
|
|
57
|
+
if (theme && theme.gray && theme.gray.darker) {
|
|
58
|
+
return {
|
|
59
|
+
primary: theme.primary,
|
|
60
|
+
secondary: theme.secondary,
|
|
61
|
+
error: theme.error || _apperance.palette.error,
|
|
62
|
+
warning: theme.warning || _apperance.palette.warning,
|
|
63
|
+
success: theme.success || _apperance.palette.success,
|
|
64
|
+
info: theme.info || _apperance.palette.info,
|
|
65
|
+
white: theme.white || _apperance.palette.white,
|
|
66
|
+
dark: theme.dark || _apperance.palette.dark,
|
|
67
|
+
gray: theme.gray,
|
|
68
|
+
blue: theme.blue || _apperance.palette.blue,
|
|
69
|
+
background: theme.background || _apperance.palette.background,
|
|
70
|
+
border: theme.border || _apperance.palette.border,
|
|
71
|
+
shadow: theme.shadow || _apperance.palette.shadow
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return _apperance.palette;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// Helper function to get Select styles from theme
|
|
78
|
+
const getSelectStyles = theme => {
|
|
79
|
+
if (theme && theme.components && theme.components.PuiSelect) {
|
|
80
|
+
return theme.components.PuiSelect;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
inputRoot: {
|
|
84
|
+
backgroundColor: "#fafafa",
|
|
85
|
+
border: "1px solid #cecdd3",
|
|
86
|
+
borderRadius: "5px",
|
|
87
|
+
height: "33px",
|
|
88
|
+
lineHeight: "2em"
|
|
89
|
+
},
|
|
90
|
+
label: {
|
|
91
|
+
color: "#97969b",
|
|
92
|
+
marginBottom: "13px",
|
|
93
|
+
fontSize: "0.9rem"
|
|
94
|
+
},
|
|
95
|
+
disabled: {
|
|
96
|
+
backgroundColor: "#f5f5f5",
|
|
97
|
+
border: "1px solid #cecdd3",
|
|
98
|
+
labelColor: "#97969b"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
};
|
|
36
102
|
const StyledMuiFormControl = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, _objectSpread(_objectSpread({}, props), {}, {
|
|
37
103
|
ref: ref
|
|
38
|
-
}))))(
|
|
104
|
+
}))))(props => {
|
|
105
|
+
var _themePalette$backgro, _selectStyles$disable, _themePalette$backgro2, _selectStyles$disable2, _selectStyles$disable3;
|
|
106
|
+
const themePalette = getPalette(props.theme);
|
|
107
|
+
const selectStyles = getSelectStyles(props.theme);
|
|
39
108
|
return {
|
|
40
109
|
"&.MuiFormControl-root": {
|
|
41
110
|
"& .MuiSelect-select": {
|
|
42
111
|
minHeight: "auto",
|
|
43
|
-
height: "1.4375em",
|
|
112
|
+
height: selectStyles.inputRoot.height || "1.4375em",
|
|
113
|
+
lineHeight: selectStyles.inputRoot.lineHeight || "1",
|
|
44
114
|
display: "flex",
|
|
45
|
-
alignItems: "center"
|
|
46
|
-
lineHeight: "1"
|
|
115
|
+
alignItems: "center"
|
|
47
116
|
},
|
|
48
117
|
"&.required .MuiInputBase-root": {
|
|
49
|
-
backgroundColor: _apperance.palette.background.required
|
|
118
|
+
backgroundColor: ((_themePalette$backgro = themePalette.background) === null || _themePalette$backgro === void 0 ? void 0 : _themePalette$backgro.required) || _apperance.palette.background.required
|
|
50
119
|
},
|
|
51
120
|
"& .MuiFormLabel-root": {
|
|
52
121
|
zIndex: 0,
|
|
53
122
|
lineSpacing: "-0.03em",
|
|
54
123
|
position: "initial",
|
|
55
124
|
transform: "none",
|
|
56
|
-
fontSize: "
|
|
125
|
+
fontSize: "".concat(selectStyles.label.fontSize, " !important"),
|
|
57
126
|
fontWeight: "600",
|
|
58
|
-
marginBottom: "
|
|
59
|
-
color:
|
|
127
|
+
marginBottom: "".concat(selectStyles.label.marginBottom, " !important"),
|
|
128
|
+
color: "".concat(selectStyles.label.color, " !important"),
|
|
60
129
|
"&.Mui-focused ": {
|
|
61
130
|
lineHeight: "1.4375em",
|
|
62
|
-
color:
|
|
131
|
+
color: "".concat(themePalette.primary, " !important")
|
|
63
132
|
},
|
|
64
133
|
"&.Mui-disabled": {
|
|
65
|
-
color:
|
|
134
|
+
color: "".concat(((_selectStyles$disable = selectStyles.disabled) === null || _selectStyles$disable === void 0 ? void 0 : _selectStyles$disable.labelColor) || "#97969b", " !important")
|
|
66
135
|
},
|
|
67
136
|
"&.Mui-error": {
|
|
68
|
-
color:
|
|
137
|
+
color: "".concat(themePalette.error, " !important")
|
|
69
138
|
}
|
|
70
139
|
},
|
|
71
140
|
"& .MuiInputBase-root": {
|
|
72
|
-
backgroundColor:
|
|
73
|
-
border: "
|
|
74
|
-
borderRadius: "
|
|
141
|
+
backgroundColor: "".concat(selectStyles.inputRoot.backgroundColor, " !important"),
|
|
142
|
+
border: "".concat(selectStyles.inputRoot.border, " !important"),
|
|
143
|
+
borderRadius: "".concat(selectStyles.inputRoot.borderRadius, " !important"),
|
|
144
|
+
height: selectStyles.inputRoot.height || "auto",
|
|
75
145
|
"&.Mui-focused ": {
|
|
76
|
-
border: "2px solid ".concat(
|
|
146
|
+
border: "2px solid ".concat(themePalette.primary, " !important")
|
|
77
147
|
},
|
|
78
148
|
"&.Mui-error ": {
|
|
79
|
-
border: "2px solid ".concat(
|
|
80
|
-
backgroundColor: _apperance.palette.background.error
|
|
149
|
+
border: "2px solid ".concat(themePalette.error, " !important"),
|
|
150
|
+
backgroundColor: "".concat(((_themePalette$backgro2 = themePalette.background) === null || _themePalette$backgro2 === void 0 ? void 0 : _themePalette$backgro2.error) || _apperance.palette.background.error, " !important")
|
|
81
151
|
},
|
|
82
152
|
"&.Mui-disabled ": {
|
|
83
|
-
backgroundColor: "".concat(
|
|
153
|
+
backgroundColor: "".concat(((_selectStyles$disable2 = selectStyles.disabled) === null || _selectStyles$disable2 === void 0 ? void 0 : _selectStyles$disable2.backgroundColor) || "#f5f5f5", " !important"),
|
|
154
|
+
border: "".concat(((_selectStyles$disable3 = selectStyles.disabled) === null || _selectStyles$disable3 === void 0 ? void 0 : _selectStyles$disable3.border) || "1px solid #cecdd3", " !important"),
|
|
155
|
+
borderRadius: "".concat(selectStyles.inputRoot.borderRadius, " !important"),
|
|
156
|
+
"& .MuiSelect-select": {
|
|
157
|
+
color: "".concat(themePalette.gray.darker),
|
|
158
|
+
WebkitTextFillColor: "".concat(themePalette.gray.darker)
|
|
159
|
+
}
|
|
84
160
|
},
|
|
85
161
|
"& .MuiInputBase-input": {
|
|
86
162
|
padding: "1px 6px",
|
|
@@ -93,7 +169,7 @@ const StyledMuiFormControl = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((
|
|
|
93
169
|
"& .MuiFormHelperText-root": {
|
|
94
170
|
fontWeight: "bold",
|
|
95
171
|
fontSize: ".7rem",
|
|
96
|
-
color:
|
|
172
|
+
color: themePalette.gray.darker
|
|
97
173
|
},
|
|
98
174
|
"& fieldset": {
|
|
99
175
|
display: "none"
|
|
@@ -104,10 +180,13 @@ const StyledMuiFormControl = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((
|
|
|
104
180
|
const LoadingProgress = () => {
|
|
105
181
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
|
|
106
182
|
size: 16,
|
|
107
|
-
sx: {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
183
|
+
sx: theme => {
|
|
184
|
+
const themePalette = getPalette(theme);
|
|
185
|
+
return {
|
|
186
|
+
color: themePalette.primary,
|
|
187
|
+
position: "absolute",
|
|
188
|
+
right: "14px"
|
|
189
|
+
};
|
|
111
190
|
}
|
|
112
191
|
});
|
|
113
192
|
};
|
|
@@ -167,18 +246,21 @@ const PuiStandardSelect = _ref => {
|
|
|
167
246
|
name
|
|
168
247
|
},
|
|
169
248
|
MenuProps: {
|
|
170
|
-
sx: {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"& .
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
249
|
+
sx: theme => {
|
|
250
|
+
const themePalette = getPalette(theme);
|
|
251
|
+
return {
|
|
252
|
+
"& .MuiMenu-list": {
|
|
253
|
+
padding: 0,
|
|
254
|
+
"& .MuiMenuItem-root:not(:last-child)": {
|
|
255
|
+
borderBottom: "1px solid ".concat(themePalette.gray.light)
|
|
256
|
+
},
|
|
257
|
+
"& .MuiMenuItem-root": {
|
|
258
|
+
fontSize: 13,
|
|
259
|
+
height: "fit-content",
|
|
260
|
+
minHeight: "auto"
|
|
261
|
+
}
|
|
180
262
|
}
|
|
181
|
-
}
|
|
263
|
+
};
|
|
182
264
|
}
|
|
183
265
|
}
|
|
184
266
|
}, rest), {}, {
|