ish-ui 1.0.19 → 1.0.21
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/actions/FieldProcessing.d.ts +10 -0
- package/dist/actions/FieldProcessing.js +17 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +8 -0
- package/dist/appBar/AppBarHelpMenu.d.ts +3 -0
- package/dist/appBar/AppBarHelpMenu.js +77 -0
- package/dist/appBar/index.d.ts +2 -0
- package/dist/appBar/index.js +9 -0
- package/dist/buttons/AddButton.d.ts +14 -0
- package/dist/buttons/AddButton.js +9 -0
- package/dist/buttons/TimetableButton.d.ts +3 -0
- package/dist/buttons/TimetableButton.js +12 -0
- package/dist/buttons/index.d.ts +4 -0
- package/dist/buttons/index.js +11 -0
- package/dist/colorPicker/ColorPicker.d.ts +4 -0
- package/dist/colorPicker/ColorPicker.js +138 -0
- package/dist/colorPicker/index.d.ts +2 -0
- package/dist/colorPicker/index.js +9 -0
- package/dist/dialog/BrowserWarning.d.ts +3 -0
- package/dist/dialog/BrowserWarning.js +16 -0
- package/dist/dialog/confirm/ConfirmBase.d.ts +7 -0
- package/dist/dialog/confirm/ConfirmBase.js +29 -0
- package/dist/dialog/index.d.ts +5 -0
- package/dist/dialog/index.js +12 -0
- package/dist/dialog/message/Message.d.ts +3 -0
- package/dist/dialog/message/Message.js +91 -0
- package/dist/documents/DocumentIconsChooser.d.ts +3 -0
- package/dist/documents/DocumentIconsChooser.js +51 -0
- package/dist/documents/index.d.ts +3 -0
- package/dist/documents/index.js +10 -0
- package/dist/documents/utils/index.d.ts +7 -0
- package/dist/documents/utils/index.js +61 -0
- package/dist/dynamicSizeList/DynamicSizeList.d.ts +17 -0
- package/dist/dynamicSizeList/DynamicSizeList.js +167 -0
- package/dist/dynamicSizeList/index.d.ts +2 -0
- package/dist/dynamicSizeList/index.js +9 -0
- package/dist/fieldMessage/ErrorMessage.d.ts +8 -0
- package/dist/fieldMessage/ErrorMessage.js +14 -0
- package/dist/fieldMessage/WarningMessage.d.ts +8 -0
- package/dist/fieldMessage/WarningMessage.js +14 -0
- package/dist/fieldMessage/index.d.ts +6 -0
- package/dist/fieldMessage/index.js +13 -0
- package/dist/fieldMessage/styles.d.ts +3 -0
- package/dist/fieldMessage/styles.js +18 -0
- package/dist/fileUploader/FileUploaderDialog.d.ts +15 -0
- package/dist/fileUploader/FileUploaderDialog.js +99 -0
- package/dist/fileUploader/index.d.ts +2 -0
- package/dist/fileUploader/index.js +9 -0
- package/dist/formFields/CheckboxField.d.ts +7 -0
- package/dist/formFields/CheckboxField.js +67 -0
- package/dist/formFields/CodeEditorField.d.ts +6 -0
- package/dist/formFields/CodeEditorField.js +69 -0
- package/dist/formFields/ColoredCheckBox.d.ts +3 -0
- package/dist/formFields/ColoredCheckBox.js +41 -0
- package/dist/formFields/DateTimeField.d.ts +2 -0
- package/dist/formFields/DateTimeField.js +27 -0
- package/dist/formFields/EditInPlaceDateTimeField.d.ts +10 -0
- package/dist/formFields/EditInPlaceDateTimeField.js +188 -0
- package/dist/formFields/EditInPlaceDurationField.d.ts +4 -0
- package/dist/formFields/EditInPlaceDurationField.js +63 -0
- package/dist/formFields/EditInPlaceField.d.ts +10 -0
- package/dist/formFields/EditInPlaceField.js +58 -0
- package/dist/formFields/EditInPlaceFieldBase.d.ts +28 -0
- package/dist/formFields/EditInPlaceFieldBase.js +123 -0
- package/dist/formFields/EditInPlaceFileField.d.ts +7 -0
- package/dist/formFields/EditInPlaceFileField.js +60 -0
- package/dist/formFields/EditInPlaceMoneyField.d.ts +9 -0
- package/dist/formFields/EditInPlaceMoneyField.js +37 -0
- package/dist/formFields/EditInPlacePhoneField.d.ts +4 -0
- package/dist/formFields/EditInPlacePhoneField.js +69 -0
- package/dist/formFields/EditInPlaceSearchSelect.d.ts +4 -0
- package/dist/formFields/EditInPlaceSearchSelect.js +321 -0
- package/dist/formFields/FieldAdornments.d.ts +13 -0
- package/dist/formFields/FieldAdornments.js +27 -0
- package/dist/formFields/FilePreview.d.ts +17 -0
- package/dist/formFields/FilePreview.js +77 -0
- package/dist/formFields/FormRadioButtons.d.ts +3 -0
- package/dist/formFields/FormRadioButtons.js +27 -0
- package/dist/formFields/SelectCustomComponents.d.ts +5 -0
- package/dist/formFields/SelectCustomComponents.js +182 -0
- package/dist/formFields/Switch.d.ts +7 -0
- package/dist/formFields/Switch.js +116 -0
- package/dist/formFields/TextField.d.ts +6 -0
- package/dist/formFields/TextField.js +42 -0
- package/dist/formFields/UneditableBase.d.ts +17 -0
- package/dist/formFields/UneditableBase.js +48 -0
- package/dist/formFields/index.d.ts +31 -0
- package/dist/formFields/index.js +38 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +25 -0
- package/dist/layout/InfoPill.d.ts +7 -0
- package/dist/layout/InfoPill.js +26 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +11 -0
- package/dist/layout/resizable/ResizableWrapper.d.ts +14 -0
- package/dist/layout/resizable/ResizableWrapper.js +42 -0
- package/dist/markdownEditor/HtmlEditor.d.ts +15 -0
- package/dist/markdownEditor/HtmlEditor.js +18 -0
- package/dist/markdownEditor/WysiwygEditor.d.ts +8 -0
- package/dist/markdownEditor/WysiwygEditor.js +98 -0
- package/dist/markdownEditor/index.d.ts +5 -0
- package/dist/markdownEditor/index.js +12 -0
- package/dist/markdownEditor/utils/index.d.ts +9 -0
- package/dist/markdownEditor/utils/index.js +38 -0
- package/dist/model/AppBar.d.ts +11 -0
- package/dist/model/AppBar.js +8 -0
- package/dist/model/CommomObjects.d.ts +5 -0
- package/dist/model/CommomObjects.js +1 -0
- package/dist/model/CommonFunctions.d.ts +8 -0
- package/dist/model/CommonFunctions.js +5 -0
- package/dist/model/Confirm.d.ts +16 -0
- package/dist/model/Confirm.js +8 -0
- package/dist/model/Fields.d.ts +258 -0
- package/dist/model/Fields.js +8 -0
- package/dist/model/NestedEntity.d.ts +9 -0
- package/dist/model/NestedEntity.js +5 -0
- package/dist/model/Theme.d.ts +34 -0
- package/dist/model/Theme.js +18 -0
- package/dist/model/index.d.ts +7 -0
- package/dist/model/index.js +14 -0
- package/dist/styles/GlobalStylesProvider.d.ts +3 -0
- package/dist/styles/GlobalStylesProvider.js +417 -0
- package/dist/styles/StylesProviderCustom.d.ts +3 -0
- package/dist/styles/StylesProviderCustom.js +6 -0
- package/dist/styles/animateStyles.d.ts +3 -0
- package/dist/styles/animateStyles.js +33 -0
- package/dist/styles/bootstrap.d.ts +491 -0
- package/dist/styles/bootstrap.js +496 -0
- package/dist/styles/hooks.d.ts +6 -0
- package/dist/styles/hooks.js +38 -0
- package/dist/styles/index.d.ts +11 -0
- package/dist/styles/index.js +18 -0
- package/dist/styles/makeStyles.d.ts +3 -0
- package/dist/styles/makeStyles.js +9 -0
- package/dist/styles/mixins/common.d.ts +8 -0
- package/dist/styles/mixins/common.js +32 -0
- package/dist/styles/mixins/keyframes.d.ts +3 -0
- package/dist/styles/mixins/keyframes.js +9 -0
- package/dist/styles/mixins/prefixer.d.ts +1 -0
- package/dist/styles/mixins/prefixer.js +23 -0
- package/dist/tagsInput/AddTagMenu.d.ts +12 -0
- package/dist/tagsInput/AddTagMenu.js +36 -0
- package/dist/tagsInput/AddTagMenuItem.d.ts +11 -0
- package/dist/tagsInput/AddTagMenuItem.js +29 -0
- package/dist/tagsInput/TagInputList.d.ts +4 -0
- package/dist/tagsInput/TagInputList.js +273 -0
- package/dist/tagsInput/index.d.ts +6 -0
- package/dist/tagsInput/index.js +6 -0
- package/dist/themes/appTheme.d.ts +4 -0
- package/dist/themes/appTheme.js +322 -0
- package/dist/themes/index.d.ts +2 -0
- package/dist/themes/index.js +9 -0
- package/dist/themes/ishTheme.d.ts +8 -0
- package/dist/themes/ishTheme.js +351 -0
- package/dist/timetable/datePeriodFilter/DayPeriodIcons.d.ts +8 -0
- package/dist/timetable/datePeriodFilter/DayPeriodIcons.js +27 -0
- package/dist/timetable/datePeriodFilter/index.d.ts +1 -0
- package/dist/timetable/datePeriodFilter/index.js +8 -0
- package/dist/timetable/index.d.ts +2 -0
- package/dist/timetable/index.js +9 -0
- package/dist/timetable/miniCalendar/CalendarDay.d.ts +15 -0
- package/dist/timetable/miniCalendar/CalendarDay.js +64 -0
- package/dist/timetable/miniCalendar/CalendarHeader.d.ts +10 -0
- package/dist/timetable/miniCalendar/CalendarHeader.js +22 -0
- package/dist/timetable/miniCalendar/CalendarWeekPanel.d.ts +8 -0
- package/dist/timetable/miniCalendar/CalendarWeekPanel.js +18 -0
- package/dist/timetable/miniCalendar/WeekDay.d.ts +10 -0
- package/dist/timetable/miniCalendar/WeekDay.js +25 -0
- package/dist/timetable/miniCalendar/index.d.ts +8 -0
- package/dist/timetable/miniCalendar/index.js +15 -0
- package/dist/utils/DOM/Links.d.ts +1 -0
- package/dist/utils/DOM/Links.js +12 -0
- package/dist/utils/DOM/getCaretCoordinates.d.ts +6 -0
- package/dist/utils/DOM/getCaretCoordinates.js +109 -0
- package/dist/utils/DOM/getOS.d.ts +2 -0
- package/dist/utils/DOM/getOS.js +32 -0
- package/dist/utils/DOM/index.d.ts +5 -0
- package/dist/utils/DOM/index.js +32 -0
- package/dist/utils/dates/datesNormalizing.d.ts +1 -0
- package/dist/utils/dates/datesNormalizing.js +3 -0
- package/dist/utils/dates/format.d.ts +24 -0
- package/dist/utils/dates/format.js +28 -0
- package/dist/utils/dates/formatRelative.d.ts +1 -0
- package/dist/utils/dates/formatRelative.js +14 -0
- package/dist/utils/dates/formatString.d.ts +2 -0
- package/dist/utils/dates/formatString.js +195 -0
- package/dist/utils/dates/formatTimezone.d.ts +2 -0
- package/dist/utils/dates/formatTimezone.js +35 -0
- package/dist/utils/dates/index.d.ts +6 -0
- package/dist/utils/dates/index.js +13 -0
- package/dist/utils/dates/timetable.d.ts +5 -0
- package/dist/utils/dates/timetable.js +38 -0
- package/dist/utils/events/index.d.ts +2 -0
- package/dist/utils/events/index.js +6 -0
- package/dist/utils/fields/index.d.ts +1 -0
- package/dist/utils/fields/index.js +20 -0
- package/dist/utils/formatting/PhoneMasks.d.ts +304 -0
- package/dist/utils/formatting/PhoneMasks.js +318 -0
- package/dist/utils/formatting/index.d.ts +2 -0
- package/dist/utils/formatting/index.js +10 -0
- package/dist/utils/hooks/index.d.ts +1 -0
- package/dist/utils/hooks/index.js +15 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/numbers/decimalCalculation.d.ts +4 -0
- package/dist/utils/numbers/decimalCalculation.js +21 -0
- package/dist/utils/numbers/index.d.ts +2 -0
- package/dist/utils/numbers/index.js +9 -0
- package/dist/utils/numbers/numbersNormalizing.d.ts +10 -0
- package/dist/utils/numbers/numbersNormalizing.js +44 -0
- package/dist/utils/stubs/index.d.ts +3 -0
- package/dist/utils/stubs/index.js +10 -0
- package/dist/utils/tags/index.d.ts +3 -0
- package/dist/utils/tags/index.js +42 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
import React, { useCallback, useRef } from 'react';
|
|
9
|
+
import { ButtonBase, Typography } from '@mui/material';
|
|
10
|
+
import clsx from 'clsx';
|
|
11
|
+
import { alpha } from '@mui/material/styles';
|
|
12
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
13
|
+
import { useAppTheme } from '../themes';
|
|
14
|
+
import { rgbToHex } from '@mui/system/colorManipulator';
|
|
15
|
+
import { getCheckboxValue } from '../utils';
|
|
16
|
+
export function ColoredCheckBox({ input, label, color, className, disabled }) {
|
|
17
|
+
const theme = useAppTheme();
|
|
18
|
+
const inputRef = useRef();
|
|
19
|
+
const onClick = useCallback(() => {
|
|
20
|
+
inputRef.current.click();
|
|
21
|
+
}, [inputRef.current]);
|
|
22
|
+
if (disabled) {
|
|
23
|
+
color = rgbToHex(theme.palette.divider);
|
|
24
|
+
}
|
|
25
|
+
return (React.createElement("div", { className: clsx('centeredFlex cursor-pointer', className), onClick: onClick },
|
|
26
|
+
React.createElement("input", Object.assign({ ref: inputRef, type: "checkbox" }, input, { checked: getCheckboxValue(input.value, false), hidden: true })),
|
|
27
|
+
React.createElement(ButtonBase, { component: "div", disabled: disabled, sx: {
|
|
28
|
+
width: theme => theme.spacing(3),
|
|
29
|
+
height: theme => theme.spacing(3),
|
|
30
|
+
border: `2px solid ${color}`,
|
|
31
|
+
borderRadius: '50%',
|
|
32
|
+
fontSize: '10px',
|
|
33
|
+
backgroundColor: input.value ? `${color}` : alpha(`${color}`, 0.1),
|
|
34
|
+
color: theme => theme.palette.getContrastText(`${color}`)
|
|
35
|
+
} }, input.value && React.createElement(FontAwesomeIcon, { fixedWidth: true, icon: "check" })),
|
|
36
|
+
label && React.createElement(Typography, { variant: "caption", fontWeight: "400", sx: {
|
|
37
|
+
marginLeft: 1,
|
|
38
|
+
textDecoration: input.value ? 'line-through' : 'unset',
|
|
39
|
+
color: theme => (input.value ? theme.palette.text.disabled : 'unset'),
|
|
40
|
+
} }, label)));
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
9
|
+
var t = {};
|
|
10
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
11
|
+
t[p] = s[p];
|
|
12
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
13
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
15
|
+
t[p[i]] = s[p[i]];
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
};
|
|
19
|
+
import * as React from 'react';
|
|
20
|
+
import TextField from '@mui/material/TextField';
|
|
21
|
+
import { MobileDatePicker, MobileDateTimePicker, MobileTimePicker } from '@mui/x-date-pickers';
|
|
22
|
+
import { DD_MM_YYYY_HH_MM_SPECIAL, DD_MMM_YYYY_MINUSED, HH_MM_COLONED } from '../utils';
|
|
23
|
+
export const DateTimeField = props => {
|
|
24
|
+
const { onChange, type, ampm, value, setPickerRef, formatDate, maxDate, minDate } = props, rest = __rest(props, ["onChange", "type", "ampm", "value", "setPickerRef", "formatDate", "maxDate", "minDate"]);
|
|
25
|
+
const picker = type === 'date' ? (React.createElement(MobileDatePicker, Object.assign({ ref: setPickerRef, onChange: onChange, ampm: ampm || false, value: value, format: formatDate || DD_MMM_YYYY_MINUSED, maxDate: maxDate || undefined, minDate: minDate || undefined, renderInput: props => React.createElement(TextField, Object.assign({}, props)), variant: "standard" }, rest))) : type === 'time' ? (React.createElement(MobileTimePicker, Object.assign({ ref: setPickerRef, onChange: onChange, ampm: ampm || false, value: value, format: formatDate || HH_MM_COLONED, maxDate: maxDate || undefined, minDate: minDate || undefined, renderInput: props => React.createElement(TextField, Object.assign({}, props)), variant: "standard" }, rest))) : type === 'datetime' ? (React.createElement(MobileDateTimePicker, Object.assign({ ref: setPickerRef, onChange: onChange, ampm: ampm || false, value: value, format: formatDate || DD_MM_YYYY_HH_MM_SPECIAL, maxDate: maxDate || undefined, minDate: minDate || undefined, renderInput: props => React.createElement(TextField, Object.assign({}, props)), variant: "standard" }, rest))) : null;
|
|
26
|
+
return picker || null;
|
|
27
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper component for DateTimeField with edit in place functional
|
|
3
|
+
* */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { EditInPlaceDateTimeFieldProps, FieldInputProps, FieldMetaProps } from '../model';
|
|
6
|
+
interface InputTypes {
|
|
7
|
+
type?: 'date' | 'time' | 'datetime';
|
|
8
|
+
}
|
|
9
|
+
declare function EditInPlaceDateTimeField<IP extends FieldInputProps, MP extends FieldMetaProps>({ type, formatDate, formatTime, formatDateTime, timezone, input, fieldClasses, inline, meta: { error, invalid, active, dispatch }, labelAdornment, label, disabled, formatValue, className, onKeyPress, placeholder, persistValue, warning, defaultValue, rightAligned, processActionId }: EditInPlaceDateTimeFieldProps<IP, MP> & InputTypes): React.JSX.Element;
|
|
10
|
+
export default EditInPlaceDateTimeField;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Wrapper component for DateTimeField with edit in place functional
|
|
10
|
+
* */
|
|
11
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
12
|
+
import clsx from 'clsx';
|
|
13
|
+
import DateRange from '@mui/icons-material/DateRange';
|
|
14
|
+
import QueryBuilder from '@mui/icons-material/QueryBuilder';
|
|
15
|
+
import { format, isValid } from 'date-fns';
|
|
16
|
+
import IconButton from '@mui/material/IconButton';
|
|
17
|
+
import { DateTimeField } from './DateTimeField';
|
|
18
|
+
import { makeAppStyles } from '../styles';
|
|
19
|
+
import EditInPlaceFieldBase from './EditInPlaceFieldBase';
|
|
20
|
+
import { appendTimezone, formatStringDate, HH_MM_COLONED, III_DD_MMM_YYYY, III_DD_MMM_YYYY_HH_MM, prependTimezone, YYYY_MM_DD_MINUSED } from '../utils';
|
|
21
|
+
import { endFieldProcessingAction, startFieldProcessingAction } from '../actions/FieldProcessing';
|
|
22
|
+
const useStyles = makeAppStyles(theme => ({
|
|
23
|
+
inlinePickerButton: {
|
|
24
|
+
padding: '2px',
|
|
25
|
+
marginBottom: '-4px',
|
|
26
|
+
fontSize: '1.3em',
|
|
27
|
+
'&:hover': {
|
|
28
|
+
color: theme.palette.primary.main,
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
pickerButton: {
|
|
32
|
+
width: theme.spacing(4),
|
|
33
|
+
height: theme.spacing(4),
|
|
34
|
+
bottom: theme.spacing(-0.5)
|
|
35
|
+
},
|
|
36
|
+
inlineContainer: {
|
|
37
|
+
display: 'inline-block',
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
function EditInPlaceDateTimeField({ type, formatDate, formatTime, formatDateTime, timezone, input, fieldClasses = {}, inline, meta: { error, invalid, active, dispatch }, labelAdornment, label, disabled, formatValue, className, onKeyPress, placeholder = 'No value', persistValue, warning, defaultValue, rightAligned, processActionId }) {
|
|
41
|
+
const [textValue, setTextValue] = useState(defaultValue || '');
|
|
42
|
+
const [pickerOpened, setPickerOpened] = useState(false);
|
|
43
|
+
const inputNode = useRef(null);
|
|
44
|
+
const classes = useStyles();
|
|
45
|
+
const formatDateInner = dateObj => {
|
|
46
|
+
if (!dateObj) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
if (dateObj.toString() === 'Invalid Date')
|
|
50
|
+
return '';
|
|
51
|
+
switch (type) {
|
|
52
|
+
case 'date':
|
|
53
|
+
return format(dateObj, formatDate || III_DD_MMM_YYYY);
|
|
54
|
+
case 'time':
|
|
55
|
+
return format(dateObj, formatTime || HH_MM_COLONED);
|
|
56
|
+
case 'datetime':
|
|
57
|
+
return format(dateObj, formatDateTime || III_DD_MMM_YYYY_HH_MM);
|
|
58
|
+
default:
|
|
59
|
+
return dateObj.toString();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const dateValue = useMemo(() => {
|
|
63
|
+
let base = input.value ? new Date(input.value) : null;
|
|
64
|
+
if (base && timezone) {
|
|
65
|
+
base = appendTimezone(base, timezone);
|
|
66
|
+
}
|
|
67
|
+
return base;
|
|
68
|
+
}, [input.value, timezone]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
setTextValue(formatDateInner(dateValue));
|
|
71
|
+
}, [dateValue]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!active && processActionId) {
|
|
74
|
+
dispatch(endFieldProcessingAction(input.name));
|
|
75
|
+
}
|
|
76
|
+
}, [input.value, input.name, active, processActionId]);
|
|
77
|
+
const onInputChange = e => {
|
|
78
|
+
if (e)
|
|
79
|
+
setTextValue(e.target.value);
|
|
80
|
+
};
|
|
81
|
+
const openPicker = e => {
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
setPickerOpened(true);
|
|
84
|
+
};
|
|
85
|
+
const onChange = (v) => {
|
|
86
|
+
var _a;
|
|
87
|
+
if (v) {
|
|
88
|
+
let formatted;
|
|
89
|
+
if (formatValue) {
|
|
90
|
+
formatted = format(v, formatValue);
|
|
91
|
+
}
|
|
92
|
+
else if (type === 'date') {
|
|
93
|
+
if (isValid(v)) {
|
|
94
|
+
formatted = format(v, YYYY_MM_DD_MINUSED);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
formatted = null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
try {
|
|
102
|
+
formatted = v.toISOString();
|
|
103
|
+
}
|
|
104
|
+
catch (_b) {
|
|
105
|
+
formatted = null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (timezone && formatted) {
|
|
109
|
+
formatted = (_a = prependTimezone(formatted, timezone)) === null || _a === void 0 ? void 0 : _a.toISOString();
|
|
110
|
+
}
|
|
111
|
+
input.onChange(formatted);
|
|
112
|
+
input.onBlur(formatted);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
setTextValue('');
|
|
116
|
+
input.onChange(null);
|
|
117
|
+
input.onBlur(null);
|
|
118
|
+
};
|
|
119
|
+
const onBlur = () => {
|
|
120
|
+
dispatch(startFieldProcessingAction(input.name));
|
|
121
|
+
if (persistValue && !textValue) {
|
|
122
|
+
input.onChange(input.value);
|
|
123
|
+
input.onBlur(input.value);
|
|
124
|
+
setTextValue(formatDateInner(dateValue));
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const parsed = textValue
|
|
128
|
+
? formatStringDate(textValue, type, dateValue || new Date(), formatDate || formatDateTime || formatTime)
|
|
129
|
+
: null;
|
|
130
|
+
if (parsed) {
|
|
131
|
+
let formatted;
|
|
132
|
+
if (formatValue) {
|
|
133
|
+
formatted = format(parsed, formatValue);
|
|
134
|
+
}
|
|
135
|
+
else if (type === 'date' && isValid(parsed)) {
|
|
136
|
+
formatted = format(parsed, YYYY_MM_DD_MINUSED);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
try {
|
|
140
|
+
formatted = parsed.toISOString();
|
|
141
|
+
}
|
|
142
|
+
catch (_a) {
|
|
143
|
+
formatted = null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
setTextValue(formatDateInner(parsed));
|
|
147
|
+
if (timezone && formatted) {
|
|
148
|
+
formatted = prependTimezone(formatted, timezone).toISOString();
|
|
149
|
+
}
|
|
150
|
+
input.onChange(formatted);
|
|
151
|
+
input.onBlur(formatted);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
setTextValue(null);
|
|
155
|
+
input.onChange(null);
|
|
156
|
+
input.onBlur(null);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const onClose = () => {
|
|
160
|
+
setPickerOpened(false);
|
|
161
|
+
};
|
|
162
|
+
const onEnterPress = e => {
|
|
163
|
+
if (e.keyCode === 13 && inputNode.current) {
|
|
164
|
+
inputNode.current.blur();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
return (React.createElement("div", { className: clsx(className, 'outline-none', {
|
|
168
|
+
[classes.inlineContainer]: inline,
|
|
169
|
+
'pointer-events-none': disabled
|
|
170
|
+
}) },
|
|
171
|
+
React.createElement("div", { id: input.name, className: "w-100" },
|
|
172
|
+
React.createElement(DateTimeField, { type: type, toolbarTitle: label, open: pickerOpened, value: dateValue, onChange: onChange, onClose: onClose, renderInput: () => (React.createElement(EditInPlaceFieldBase, { name: input.name, value: textValue, error: error, invalid: invalid, inline: inline, label: label, warning: warning, fieldClasses: fieldClasses, rightAligned: rightAligned, shrink: Boolean(label || input.value), disabled: disabled, labelAdornment: labelAdornment, placeholder: placeholder, editIcon: React.createElement(IconButton, { tabIndex: -1, onClick: openPicker, classes: {
|
|
173
|
+
root: clsx(fieldClasses.text, inline ? classes.inlinePickerButton : classes.pickerButton)
|
|
174
|
+
} }, type === 'time'
|
|
175
|
+
? React.createElement(QueryBuilder, { fontSize: "inherit", color: "inherit" })
|
|
176
|
+
: React.createElement(DateRange, { color: "inherit", fontSize: "inherit" })), InputProps: {
|
|
177
|
+
type: 'text',
|
|
178
|
+
onFocus: input.onFocus,
|
|
179
|
+
inputRef: inputNode,
|
|
180
|
+
value: textValue,
|
|
181
|
+
onKeyPress,
|
|
182
|
+
disabled,
|
|
183
|
+
onBlur,
|
|
184
|
+
onKeyDown: onEnterPress,
|
|
185
|
+
onChange: onInputChange
|
|
186
|
+
} })) }))));
|
|
187
|
+
}
|
|
188
|
+
export default EditInPlaceDateTimeField;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EditInPlaceFieldProps, FieldInputProps, FieldMetaProps } from '../model';
|
|
3
|
+
declare function EditInPlaceDurationField<FP extends FieldInputProps, MP extends FieldMetaProps>({ input, ...restProps }: EditInPlaceFieldProps<FP, MP>): React.JSX.Element;
|
|
4
|
+
export default EditInPlaceDurationField;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
9
|
+
var t = {};
|
|
10
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
11
|
+
t[p] = s[p];
|
|
12
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
13
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
15
|
+
t[p[i]] = s[p[i]];
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
};
|
|
19
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
20
|
+
import EditInPlaceField from './EditInPlaceField';
|
|
21
|
+
import { formatDurationMinutes } from '../utils/dates/formatString';
|
|
22
|
+
const parseDurationString = (duration) => {
|
|
23
|
+
if (duration.indexOf('.') > -1) {
|
|
24
|
+
return Math.round(parseFloat(duration) * 60);
|
|
25
|
+
}
|
|
26
|
+
let min = 0;
|
|
27
|
+
const hoursMatch = duration.match(/(\d+)h/);
|
|
28
|
+
const minutesMatch = duration.match(/(\d+)m/);
|
|
29
|
+
const plainHours = parseFloat(duration);
|
|
30
|
+
if (hoursMatch) {
|
|
31
|
+
min += Number(hoursMatch[1]) * 60;
|
|
32
|
+
}
|
|
33
|
+
if (minutesMatch) {
|
|
34
|
+
min += Number(minutesMatch[1]);
|
|
35
|
+
}
|
|
36
|
+
if (!hoursMatch && !minutesMatch && !isNaN(plainHours)) {
|
|
37
|
+
min += Math.round(plainHours) * 60;
|
|
38
|
+
}
|
|
39
|
+
return min;
|
|
40
|
+
};
|
|
41
|
+
function EditInPlaceDurationField(_a) {
|
|
42
|
+
var { input } = _a, restProps = __rest(_a, ["input"]);
|
|
43
|
+
const [textValue, setTextValue] = useState(formatDurationMinutes(input.value || 0));
|
|
44
|
+
const onChange = useCallback(e => {
|
|
45
|
+
setTextValue(e.target.value);
|
|
46
|
+
}, [input.onChange]);
|
|
47
|
+
const onBlur = useCallback(value => {
|
|
48
|
+
const parsed = parseDurationString(value);
|
|
49
|
+
input.onBlur(parsed);
|
|
50
|
+
setTextValue(formatDurationMinutes(parsed || 0));
|
|
51
|
+
}, [input.onBlur]);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
setTextValue(formatDurationMinutes(input.value || 0));
|
|
54
|
+
}, [input.value]);
|
|
55
|
+
return (React.createElement(EditInPlaceField, Object.assign({}, restProps, { input: {
|
|
56
|
+
value: textValue,
|
|
57
|
+
onBlur,
|
|
58
|
+
onChange,
|
|
59
|
+
onFocus: input.onFocus,
|
|
60
|
+
name: input.name
|
|
61
|
+
} })));
|
|
62
|
+
}
|
|
63
|
+
export default EditInPlaceDurationField;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper component for Material Select and Text Field with edit in plaxce functional
|
|
3
|
+
* */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { EditInPlaceFieldProps, FieldInputProps, FieldMetaProps } from '../model';
|
|
6
|
+
interface InputTypes {
|
|
7
|
+
type?: 'password' | 'number' | 'text';
|
|
8
|
+
}
|
|
9
|
+
declare function EditInPlaceField<IP extends FieldInputProps, MP extends FieldMetaProps>({ inputRef, input, label, maxLength, disabled, min, max, step, className, onKeyPress, labelAdornment, truncateLines, rightAligned, defaultValue, onKeyDown, multiline, inline, warning, preformatDisplayValue, type, meta: { error, invalid }, placeholder, fieldClasses, InputProps }: EditInPlaceFieldProps<IP, MP> & InputTypes): React.JSX.Element;
|
|
10
|
+
export default EditInPlaceField;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Wrapper component for Material Select and Text Field with edit in plaxce functional
|
|
10
|
+
* */
|
|
11
|
+
import React, { useMemo } from 'react';
|
|
12
|
+
import clsx from 'clsx';
|
|
13
|
+
import { Edit } from '@mui/icons-material';
|
|
14
|
+
import EditInPlaceFieldBase from './EditInPlaceFieldBase';
|
|
15
|
+
import { makeAppStyles } from '../styles';
|
|
16
|
+
const useStyles = makeAppStyles(theme => ({
|
|
17
|
+
rightAligned: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'flex-end'
|
|
21
|
+
},
|
|
22
|
+
inlineContainer: {
|
|
23
|
+
display: 'inline-block',
|
|
24
|
+
},
|
|
25
|
+
editIcon: {
|
|
26
|
+
fontSize: '24px',
|
|
27
|
+
color: theme.palette.divider,
|
|
28
|
+
verticalAlign: 'middle',
|
|
29
|
+
},
|
|
30
|
+
endAdornment: {
|
|
31
|
+
opacity: 0.5
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
function EditInPlaceField({ inputRef, input, label, maxLength, disabled, min, max, step, className, onKeyPress, labelAdornment, truncateLines, rightAligned, defaultValue, onKeyDown, multiline, inline, warning, preformatDisplayValue, type = 'text', meta: { error, invalid }, placeholder = 'No value', fieldClasses = {}, InputProps = {} }) {
|
|
35
|
+
const classes = useStyles();
|
|
36
|
+
const onBlur = () => {
|
|
37
|
+
(input === null || input === void 0 ? void 0 : input.onBlur) && input.onBlur(input.value);
|
|
38
|
+
};
|
|
39
|
+
const inputValue = useMemo(() => preformatDisplayValue
|
|
40
|
+
? preformatDisplayValue(input.value === 0 ? input.value : input.value || defaultValue)
|
|
41
|
+
: (input.value === 0 ? String(input.value) : input.value) || defaultValue || '', [preformatDisplayValue, input.value, defaultValue]);
|
|
42
|
+
return (React.createElement("div", { id: input.name, className: clsx(className, 'outline-none', {
|
|
43
|
+
[classes.rightAligned]: rightAligned,
|
|
44
|
+
[classes.inlineContainer]: inline
|
|
45
|
+
}) },
|
|
46
|
+
React.createElement(EditInPlaceFieldBase, { name: input.name, value: inputValue, error: error, invalid: invalid, inline: inline, label: label, warning: warning, fieldClasses: fieldClasses, endAdornmentClass: classes.endAdornment, rightAligned: rightAligned, shrink: Boolean(label || input.value), disabled: disabled, labelAdornment: labelAdornment, placeholder: placeholder, hideArrows: ['percentage', 'number'].includes(type), editIcon: React.createElement(Edit, { fontSize: "inherit" }), InputProps: Object.assign({ multiline,
|
|
47
|
+
onKeyPress,
|
|
48
|
+
onBlur, onFocus: input.onFocus, maxRows: truncateLines, inputProps: {
|
|
49
|
+
ref: inputRef,
|
|
50
|
+
maxLength,
|
|
51
|
+
step,
|
|
52
|
+
min,
|
|
53
|
+
max,
|
|
54
|
+
onKeyDown,
|
|
55
|
+
type,
|
|
56
|
+
}, value: inputValue, onChange: v => (type === 'number' && max && Number(v) > Number(max) ? null : input.onChange(v)) }, InputProps) })));
|
|
57
|
+
}
|
|
58
|
+
export default EditInPlaceField;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputProps } from '@mui/material/Input/Input';
|
|
3
|
+
import { FieldClasses } from '../model';
|
|
4
|
+
import { FormControlTypeMap } from '@mui/material/FormControl/FormControl';
|
|
5
|
+
interface Props {
|
|
6
|
+
name: string;
|
|
7
|
+
value: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
endAdornmentClass?: string;
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
labelAdornment?: React.ReactNode;
|
|
12
|
+
editIcon?: React.ReactNode;
|
|
13
|
+
CustomInput?: React.ReactNode;
|
|
14
|
+
InputProps?: Partial<InputProps>;
|
|
15
|
+
fieldClasses?: FieldClasses;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
warning?: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
rightAligned?: boolean;
|
|
20
|
+
inline?: boolean;
|
|
21
|
+
invalid?: boolean;
|
|
22
|
+
shrink?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
hideArrows?: boolean;
|
|
25
|
+
variant?: FormControlTypeMap['props']['variant'];
|
|
26
|
+
}
|
|
27
|
+
declare const EditInPlaceFieldBase: ({ value, invalid, className, inline, label, fieldClasses, rightAligned, shrink, name, disabled, labelAdornment, editIcon, error, placeholder, hideArrows, warning, endAdornmentClass, CustomInput, InputProps, variant }: Props) => React.JSX.Element;
|
|
28
|
+
export default EditInPlaceFieldBase;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { FilledInput, FormControl, FormHelperText, Input, InputAdornment, InputLabel, OutlinedInput } from '@mui/material';
|
|
11
|
+
import { makeAppStyles } from '../styles';
|
|
12
|
+
import WarningMessage from '../fieldMessage/WarningMessage';
|
|
13
|
+
import { countWidth } from '../utils';
|
|
14
|
+
const useStyles = makeAppStyles(theme => ({
|
|
15
|
+
label: {
|
|
16
|
+
whiteSpace: 'nowrap',
|
|
17
|
+
overflow: 'hidden',
|
|
18
|
+
textOverflow: 'ellipsis',
|
|
19
|
+
maxWidth: '100%',
|
|
20
|
+
marginRight: theme.spacing(0.5)
|
|
21
|
+
},
|
|
22
|
+
rightLabel: {
|
|
23
|
+
left: 'unset',
|
|
24
|
+
right: theme.spacing(-2),
|
|
25
|
+
'& $label': {
|
|
26
|
+
marginRight: 0
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
inputWrapper: {
|
|
30
|
+
paddingBottom: 0,
|
|
31
|
+
'&:hover .d-none': {
|
|
32
|
+
display: 'flex',
|
|
33
|
+
},
|
|
34
|
+
'&:hover .invisible': {
|
|
35
|
+
visibility: 'visible',
|
|
36
|
+
},
|
|
37
|
+
'& .Mui-focused $inputEndAdornment': {
|
|
38
|
+
opacity: 1,
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
hideArrows: {
|
|
42
|
+
'&::-webkit-outer-spin-button': {
|
|
43
|
+
'-webkit-appearance': 'none',
|
|
44
|
+
margin: 0
|
|
45
|
+
},
|
|
46
|
+
'&::-webkit-inner-spin-button': {
|
|
47
|
+
'-webkit-appearance': 'none',
|
|
48
|
+
margin: 0
|
|
49
|
+
},
|
|
50
|
+
'-moz-appearance': 'textfield'
|
|
51
|
+
},
|
|
52
|
+
inlineInput: {
|
|
53
|
+
padding: 0,
|
|
54
|
+
fontSize: 'inherit',
|
|
55
|
+
},
|
|
56
|
+
readonly: {
|
|
57
|
+
fontWeight: 300,
|
|
58
|
+
pointerEvents: 'none'
|
|
59
|
+
},
|
|
60
|
+
inputEndAdornment: {
|
|
61
|
+
display: 'flex',
|
|
62
|
+
fontSize: '24px',
|
|
63
|
+
color: theme.palette.primary.main,
|
|
64
|
+
alignItems: 'flex-end',
|
|
65
|
+
alignSelf: 'flex-end',
|
|
66
|
+
marginBottom: '5px'
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
const EditInPlaceFieldBase = ({ value, invalid, className, inline, label, fieldClasses = {}, rightAligned, shrink, name, disabled, labelAdornment, editIcon, error, placeholder, hideArrows, warning, endAdornmentClass, CustomInput, InputProps, variant = 'standard' }) => {
|
|
70
|
+
const [inputWidth, setInputWidth] = useState();
|
|
71
|
+
const classes = useStyles();
|
|
72
|
+
const inputNode = useRef();
|
|
73
|
+
const onAdornmentClick = () => {
|
|
74
|
+
inputNode.current.focus();
|
|
75
|
+
};
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (inline && inputNode.current) {
|
|
78
|
+
setInputWidth(countWidth(value || placeholder, inputNode.current) + 1);
|
|
79
|
+
}
|
|
80
|
+
}, [value]);
|
|
81
|
+
const InputComp = useMemo(() => {
|
|
82
|
+
switch (variant) {
|
|
83
|
+
default:
|
|
84
|
+
case 'standard':
|
|
85
|
+
return Input;
|
|
86
|
+
case 'filled':
|
|
87
|
+
return FilledInput;
|
|
88
|
+
case 'outlined':
|
|
89
|
+
return OutlinedInput;
|
|
90
|
+
}
|
|
91
|
+
}, [variant]);
|
|
92
|
+
return (React.createElement(FormControl, { fullWidth: true, error: invalid, variant: variant, margin: "none", className: clsx(className, classes.inputWrapper) },
|
|
93
|
+
label && (React.createElement(InputLabel, { classes: {
|
|
94
|
+
root: clsx(fieldClasses.label, 'd-flex', 'overflow-visible', rightAligned && classes.rightLabel),
|
|
95
|
+
}, shrink: shrink, htmlFor: `input-${name}` },
|
|
96
|
+
React.createElement("span", { className: classes.label }, label),
|
|
97
|
+
labelAdornment)),
|
|
98
|
+
CustomInput ||
|
|
99
|
+
React.createElement(InputComp, Object.assign({}, InputProps || {}, { label: label, inputRef: inputNode, inputProps: Object.assign({ placeholder,
|
|
100
|
+
disabled, className: clsx(fieldClasses.text, {
|
|
101
|
+
[classes.inlineInput]: inline,
|
|
102
|
+
[classes.readonly]: disabled,
|
|
103
|
+
[classes.hideArrows]: hideArrows,
|
|
104
|
+
'text-end': rightAligned
|
|
105
|
+
}), style: {
|
|
106
|
+
width: inline && !invalid ? inputWidth : undefined
|
|
107
|
+
} }, (InputProps === null || InputProps === void 0 ? void 0 : InputProps.inputProps) || {}), classes: {
|
|
108
|
+
root: clsx(fieldClasses.text, inline && classes.inlineInput),
|
|
109
|
+
underline: fieldClasses.underline
|
|
110
|
+
}, disabled: disabled, endAdornment: !disabled &&
|
|
111
|
+
React.createElement(InputAdornment, { position: "end", onClick: onAdornmentClick, className: clsx(classes.inputEndAdornment, endAdornmentClass, {
|
|
112
|
+
['fsInherit']: inline,
|
|
113
|
+
['d-none']: (rightAligned || inline),
|
|
114
|
+
['invisible']: !(rightAligned || inline)
|
|
115
|
+
}) }, editIcon), id: `input-${name}`, name: name })),
|
|
116
|
+
React.createElement(FormHelperText, { classes: {
|
|
117
|
+
root: clsx(rightAligned && 'text-end'),
|
|
118
|
+
error: 'shakingError'
|
|
119
|
+
} },
|
|
120
|
+
error,
|
|
121
|
+
warning && React.createElement(WarningMessage, { warning: warning }))));
|
|
122
|
+
};
|
|
123
|
+
export default EditInPlaceFieldBase;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wrapper component for Material Select and Text Field with edit in plaxce functional
|
|
3
|
+
* */
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { EditInPlaceFieldProps, FieldInputProps, FieldMetaProps } from '../model';
|
|
6
|
+
declare function EditInPlaceFileField<InputProps extends FieldInputProps, MetaProps extends FieldMetaProps>({ input, ...restProps }: EditInPlaceFieldProps<InputProps, MetaProps>): React.JSX.Element;
|
|
7
|
+
export default EditInPlaceFileField;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd 2023.
|
|
3
|
+
*
|
|
4
|
+
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation.
|
|
5
|
+
*
|
|
6
|
+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
|
7
|
+
*/
|
|
8
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
9
|
+
var t = {};
|
|
10
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
11
|
+
t[p] = s[p];
|
|
12
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
13
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
15
|
+
t[p[i]] = s[p[i]];
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Wrapper component for Material Select and Text Field with edit in plaxce functional
|
|
21
|
+
* */
|
|
22
|
+
import React, { useRef } from 'react';
|
|
23
|
+
import AttachmentIcon from '@mui/icons-material/Attachment';
|
|
24
|
+
import InputAdornment from '@mui/material/InputAdornment';
|
|
25
|
+
import EditInPlaceField from './EditInPlaceField';
|
|
26
|
+
import { stubFunction } from '../utils';
|
|
27
|
+
function EditInPlaceFileField(_a) {
|
|
28
|
+
var { input } = _a, restProps = __rest(_a, ["input"]);
|
|
29
|
+
const inputRef = useRef();
|
|
30
|
+
const fileRef = useRef();
|
|
31
|
+
const handleFileSelect = e => {
|
|
32
|
+
if (e.target.files[0]) {
|
|
33
|
+
input.onChange(e.target.files[0]);
|
|
34
|
+
fileRef.current.value = null;
|
|
35
|
+
inputRef.current.blur();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const onFocus = () => {
|
|
39
|
+
fileRef.current.click();
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
inputRef.current.blur();
|
|
42
|
+
}, 200);
|
|
43
|
+
};
|
|
44
|
+
return (React.createElement(React.Fragment, null,
|
|
45
|
+
React.createElement("input", { type: "file", ref: fileRef, onChange: handleFileSelect, className: "d-none" }),
|
|
46
|
+
React.createElement(EditInPlaceField, Object.assign({}, restProps, { input: {
|
|
47
|
+
onChange: stubFunction,
|
|
48
|
+
onFocus: stubFunction,
|
|
49
|
+
onBlur: stubFunction
|
|
50
|
+
}, InputProps: {
|
|
51
|
+
startAdornment: React.createElement(InputAdornment, { position: "start" },
|
|
52
|
+
React.createElement(AttachmentIcon, null)),
|
|
53
|
+
onFocus,
|
|
54
|
+
inputProps: {
|
|
55
|
+
ref: inputRef
|
|
56
|
+
},
|
|
57
|
+
value: input.value ? input.value.name : '',
|
|
58
|
+
} }))));
|
|
59
|
+
}
|
|
60
|
+
export default EditInPlaceFileField;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EditInPlaceFieldProps } from '../model';
|
|
3
|
+
import { Dispatch } from 'redux';
|
|
4
|
+
interface Props<InputProps, MetaProps> extends EditInPlaceFieldProps<InputProps, MetaProps> {
|
|
5
|
+
currencySymbol: string;
|
|
6
|
+
dispatch?: Dispatch;
|
|
7
|
+
}
|
|
8
|
+
declare function EditInPlaceMoneyField<IP, MP>({ InputProps, currencySymbol, dispatch, className, ...restProps }: Props<IP, MP>): React.JSX.Element;
|
|
9
|
+
export default EditInPlaceMoneyField;
|