ish-ui 1.0.0-alpha.12
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/README.md +80 -0
- package/assets/fonts/inter/Inter-Italic.var.woff2 +0 -0
- package/assets/fonts/inter/Inter-Roman.var.woff2 +0 -0
- package/assets/fonts/inter/LICENSE.txt +92 -0
- package/assets/fonts/inter/index.d.ts +10 -0
- package/assets/fonts/inter/inter.scss +17 -0
- 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 +11 -0
- package/dist/colorPicker/ColorPicker.js +132 -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 +21 -0
- package/dist/dynamicSizeList/DynamicSizeList.js +169 -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 +100 -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 +250 -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 +11 -0
- package/dist/tagsInput/AddTagMenu.js +36 -0
- package/dist/tagsInput/AddTagMenuItem.d.ts +10 -0
- package/dist/tagsInput/AddTagMenuItem.js +26 -0
- package/dist/tagsInput/TagInputList.d.ts +2 -0
- package/dist/tagsInput/TagInputList.js +278 -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 +7 -0
- package/dist/utils/index.js +14 -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/index.ts +10 -0
- package/package.json +108 -0
|
@@ -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;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 } from 'react';
|
|
20
|
+
import { NumericFormat } from 'react-number-format';
|
|
21
|
+
import InputAdornment from '@mui/material/InputAdornment';
|
|
22
|
+
import clsx from 'clsx';
|
|
23
|
+
import EditInPlaceField from './EditInPlaceField';
|
|
24
|
+
import { formatCurrency, normalizeNumber } from '../utils';
|
|
25
|
+
const NumberFormatCustom = React.forwardRef((props, ref) => {
|
|
26
|
+
const { onChange, allowNegative = true } = props, other = __rest(props, ["onChange", "allowNegative"]);
|
|
27
|
+
const onValueChange = useCallback(values => {
|
|
28
|
+
onChange(normalizeNumber(values.value));
|
|
29
|
+
}, []);
|
|
30
|
+
return (React.createElement(NumericFormat, Object.assign({}, other, { getInputRef: ref, onValueChange: onValueChange, allowNegative: allowNegative, decimalScale: 2, thousandSeparator: true })));
|
|
31
|
+
});
|
|
32
|
+
const preformatDisplayValue = value => value || value === 0 ? formatCurrency(value, '') : value;
|
|
33
|
+
function EditInPlaceMoneyField(_a) {
|
|
34
|
+
var { InputProps, currencySymbol, dispatch, className } = _a, restProps = __rest(_a, ["InputProps", "currencySymbol", "dispatch", "className"]);
|
|
35
|
+
return (React.createElement(EditInPlaceField, Object.assign({}, restProps, { preformatDisplayValue: preformatDisplayValue, InputProps: Object.assign(Object.assign({}, InputProps), { startAdornment: React.createElement(InputAdornment, { position: "start" }, currencySymbol), inputComponent: NumberFormatCustom }), className: clsx('money', className) })));
|
|
36
|
+
}
|
|
37
|
+
export default EditInPlaceMoneyField;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EditInPlaceFieldProps, FieldInputProps, FieldMetaProps } from '../model';
|
|
3
|
+
declare function EditInPlacePhoneField<FP extends FieldInputProps, MP extends FieldMetaProps>({ InputProps, className, ...restProps }: EditInPlaceFieldProps<FP, MP>): React.JSX.Element;
|
|
4
|
+
export default EditInPlacePhoneField;
|
|
@@ -0,0 +1,69 @@
|
|
|
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, useRef, useState } from 'react';
|
|
20
|
+
import { PatternFormat } from 'react-number-format';
|
|
21
|
+
import InputAdornment from '@mui/material/InputAdornment';
|
|
22
|
+
import PhoneIcon from '@mui/icons-material/Phone';
|
|
23
|
+
import debounce from 'lodash.debounce';
|
|
24
|
+
import EditInPlaceField from './EditInPlaceField';
|
|
25
|
+
import { getPhoneMask } from '../utils';
|
|
26
|
+
const NumberFormatCustom = React.forwardRef((props, ref) => {
|
|
27
|
+
const { onChange } = props, other = __rest(props, ["onChange"]);
|
|
28
|
+
const inputRef = useRef();
|
|
29
|
+
const [format, setFormat] = useState(null);
|
|
30
|
+
const [prefix, setPrefix] = useState(undefined);
|
|
31
|
+
const processFormat = useCallback(debounce(data => {
|
|
32
|
+
setFormat(getPhoneMask(data.value));
|
|
33
|
+
if (!data.value) {
|
|
34
|
+
setPrefix(undefined);
|
|
35
|
+
}
|
|
36
|
+
if (data.formattedValue.startsWith('+') && prefix !== '+') {
|
|
37
|
+
setPrefix('+');
|
|
38
|
+
}
|
|
39
|
+
}, 500), []);
|
|
40
|
+
const onValueChange = useCallback(data => {
|
|
41
|
+
var _a;
|
|
42
|
+
onChange(((_a = data.formattedValue) === null || _a === void 0 ? void 0 : _a.replace(/[^0-9+]/g, '')) || null);
|
|
43
|
+
processFormat(data);
|
|
44
|
+
}, []);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (other.value) {
|
|
47
|
+
setFormat(getPhoneMask(other.value));
|
|
48
|
+
}
|
|
49
|
+
}, []);
|
|
50
|
+
const onKeyPress = e => {
|
|
51
|
+
if (e.key === '+') {
|
|
52
|
+
inputRef.current._valueTracker.setValue('+');
|
|
53
|
+
if (prefix !== '+') {
|
|
54
|
+
setPrefix('+');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const getInputRef = input => {
|
|
59
|
+
ref = input;
|
|
60
|
+
inputRef.current = input;
|
|
61
|
+
};
|
|
62
|
+
return (React.createElement(PatternFormat, Object.assign({}, other, { getInputRef: getInputRef, onKeyPress: onKeyPress, prefix: prefix, onValueChange: onValueChange, format: format, type: "text" })));
|
|
63
|
+
});
|
|
64
|
+
function EditInPlacePhoneField(_a) {
|
|
65
|
+
var { InputProps, className } = _a, restProps = __rest(_a, ["InputProps", "className"]);
|
|
66
|
+
return (React.createElement(EditInPlaceField, Object.assign({}, restProps, { InputProps: Object.assign(Object.assign({}, InputProps), { startAdornment: React.createElement(InputAdornment, { position: "start" },
|
|
67
|
+
React.createElement(PhoneIcon, null)), inputComponent: NumberFormatCustom }), className: className })));
|
|
68
|
+
}
|
|
69
|
+
export default EditInPlacePhoneField;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { EditInPlaceSearchSelectFieldProps, FieldInputProps, FieldMetaProps } from '../model';
|
|
3
|
+
declare function EditInPlaceSearchSelect<InputProps extends FieldInputProps, MetaProps extends FieldMetaProps>({ label, disabled, className, labelAdornment, inline, loading, creatable, allowEmpty, fieldClasses, selectAdornment, selectValueMark, selectLabelMark, selectLabelCondition, selectFilterCondition, defaultValue, disableUnderline, items, rowHeight, remoteRowCount, loadMoreRows, onCreateOption, itemRenderer, onInputChange, onClearRows, onInnerValueChange, hideMenuOnNoResults, hideEditIcon, remoteData, createLabel, returnType, alwaysDisplayDefault, valueRenderer, popperAnchor, input, meta: { error, invalid }, placeholder, sort, sortPropKey, inputRef, warning, multiple, rightAligned, hasError, categoryKey }: EditInPlaceSearchSelectFieldProps<InputProps, MetaProps>): React.JSX.Element;
|
|
4
|
+
export default EditInPlaceSearchSelect;
|
|
@@ -0,0 +1,321 @@
|
|
|
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 CircularProgress from '@mui/material/CircularProgress';
|
|
20
|
+
import Popper from '@mui/material/Popper';
|
|
21
|
+
import { Autocomplete, IconButton, InputAdornment, Select } from '@mui/material';
|
|
22
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
23
|
+
import CloseIcon from '@mui/icons-material//Close';
|
|
24
|
+
import clsx from 'clsx';
|
|
25
|
+
import ExpandMore from '@mui/icons-material/ExpandMore';
|
|
26
|
+
import { ListboxComponent, selectStyles } from './SelectCustomComponents';
|
|
27
|
+
import EditInPlaceFieldBase from './EditInPlaceFieldBase';
|
|
28
|
+
import { makeAppStyles } from '../styles';
|
|
29
|
+
import { getHighlightedPartLabel, stubComponent } from '../utils';
|
|
30
|
+
import { usePrevious } from '../utils/hooks';
|
|
31
|
+
const useStyles = makeAppStyles(theme => (Object.assign({ selectAdornment: {
|
|
32
|
+
marginBottom: '6px',
|
|
33
|
+
color: theme.palette.primary.main
|
|
34
|
+
}, popper: {
|
|
35
|
+
zIndex: 1400
|
|
36
|
+
} }, selectStyles(theme))));
|
|
37
|
+
const SelectContext = React.createContext({});
|
|
38
|
+
const ListBoxAdapter = React.forwardRef((_a, ref) => {
|
|
39
|
+
var { children } = _a, other = __rest(_a, ["children"]);
|
|
40
|
+
const { rowHeight, remoteRowCount, loadMoreRows, classes, fieldClasses = {}, loading, selectAdornment } = useContext(SelectContext);
|
|
41
|
+
return (React.createElement(ListboxComponent, Object.assign({ rowHeight: rowHeight, remoteRowCount: remoteRowCount, loadMoreRows: loadMoreRows, classes: classes, fieldClasses: fieldClasses, loading: loading, selectAdornment: selectAdornment, ref: ref }, other), children));
|
|
42
|
+
});
|
|
43
|
+
const PopperAdapter = React.memo(params => {
|
|
44
|
+
const { hideMenuOnNoResults, items, popperAnchor, inline } = useContext(SelectContext);
|
|
45
|
+
return (hideMenuOnNoResults && !items.length
|
|
46
|
+
? null
|
|
47
|
+
: popperAnchor
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
? React.createElement(Popper, Object.assign({}, params, { style: Object.assign(Object.assign({}, params.style), { width: popperAnchor.clientWidth }), anchorEl: popperAnchor }))
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
: React.createElement(Popper, Object.assign({}, params, { style: inline ? null : params.style })));
|
|
52
|
+
});
|
|
53
|
+
function EditInPlaceSearchSelect({ label, disabled, className, labelAdornment, inline, loading, creatable, allowEmpty, fieldClasses = {}, selectAdornment, selectValueMark = 'value', selectLabelMark = 'label', selectLabelCondition, selectFilterCondition, defaultValue, disableUnderline, items = [], rowHeight, remoteRowCount, loadMoreRows, onCreateOption, itemRenderer, onInputChange, onClearRows, onInnerValueChange, hideMenuOnNoResults, hideEditIcon, remoteData, createLabel, returnType = 'string', alwaysDisplayDefault, valueRenderer, popperAnchor, input, meta: { error, invalid }, placeholder, sort, sortPropKey, inputRef, warning, multiple, rightAligned, hasError, categoryKey }) {
|
|
54
|
+
const classes = useStyles();
|
|
55
|
+
const sortedItems = useMemo(() => {
|
|
56
|
+
const sorted = items && (sort
|
|
57
|
+
? [...items].sort(typeof sort === 'function'
|
|
58
|
+
? sort
|
|
59
|
+
: (aOption, bOption) => {
|
|
60
|
+
const aLabel = selectLabelCondition ? selectLabelCondition(aOption) : aOption[sortPropKey || selectLabelMark];
|
|
61
|
+
const bLabel = selectLabelCondition ? selectLabelCondition(bOption) : bOption[sortPropKey || selectLabelMark];
|
|
62
|
+
return (aLabel.toLowerCase()).localeCompare(bLabel.toLowerCase());
|
|
63
|
+
})
|
|
64
|
+
: [...items]);
|
|
65
|
+
if (categoryKey) {
|
|
66
|
+
sorted.sort((aOption, bOption) => (aOption[categoryKey].toLowerCase()).localeCompare(bOption[categoryKey].toLowerCase()));
|
|
67
|
+
}
|
|
68
|
+
return sorted;
|
|
69
|
+
}, [items, selectLabelCondition, selectLabelMark, sortPropKey, categoryKey]);
|
|
70
|
+
const inputNode = useRef(null);
|
|
71
|
+
const [searchValue, setSearchValue] = useState('');
|
|
72
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
73
|
+
const [formattedDisplayValue, setFormattedDisplayValue] = useState('');
|
|
74
|
+
const prevDefaultDisplayValue = usePrevious(defaultValue);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (formattedDisplayValue && !input.value) {
|
|
77
|
+
setFormattedDisplayValue(null);
|
|
78
|
+
}
|
|
79
|
+
}, [formattedDisplayValue, input.value, input.name]);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (selectLabelCondition && formattedDisplayValue && defaultValue !== prevDefaultDisplayValue) {
|
|
82
|
+
setFormattedDisplayValue(null);
|
|
83
|
+
}
|
|
84
|
+
if (selectLabelCondition && !defaultValue) {
|
|
85
|
+
const selected = sortedItems.find(i => getOptionSelected(i, input.value));
|
|
86
|
+
if (selected) {
|
|
87
|
+
setFormattedDisplayValue(selectLabelCondition(selected));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, [selectLabelCondition, formattedDisplayValue, defaultValue, sortedItems, input.value]);
|
|
91
|
+
const onBlur = () => {
|
|
92
|
+
setIsEditing(false);
|
|
93
|
+
if (!hideMenuOnNoResults) {
|
|
94
|
+
setSearchValue('');
|
|
95
|
+
}
|
|
96
|
+
if (remoteData) {
|
|
97
|
+
onInputChange('');
|
|
98
|
+
onClearRows();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const formatCreateLabel = inputValue => `${createLabel} "${inputValue}"`;
|
|
102
|
+
const filterItems = items => {
|
|
103
|
+
let filtered = [];
|
|
104
|
+
if (!Array.isArray(items))
|
|
105
|
+
return filtered;
|
|
106
|
+
if (!searchValue || remoteData)
|
|
107
|
+
return items;
|
|
108
|
+
const searchRegexp = new RegExp(searchValue.replace(',', '')
|
|
109
|
+
// eslint-disable-next-line no-useless-escape
|
|
110
|
+
.replace(/[\[\]\{\}\(\)\*]/g, '\\$&')
|
|
111
|
+
.trim().toLowerCase());
|
|
112
|
+
if (typeof selectFilterCondition === 'function') {
|
|
113
|
+
filtered = items.filter(item => {
|
|
114
|
+
const label = selectFilterCondition(item);
|
|
115
|
+
if (!label) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return searchRegexp.test(label.trim().toLowerCase());
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else if (typeof selectLabelCondition === 'function') {
|
|
122
|
+
filtered = items.filter(item => {
|
|
123
|
+
const label = selectLabelCondition(item);
|
|
124
|
+
if (!label) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return searchRegexp.test(label.trim().toLowerCase());
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
filtered = items.filter(item => item[selectLabelMark]
|
|
132
|
+
&& searchRegexp.test(item[selectLabelMark].toLowerCase().trim()));
|
|
133
|
+
}
|
|
134
|
+
if (creatable) {
|
|
135
|
+
filtered.push({
|
|
136
|
+
[selectLabelMark]: formatCreateLabel(searchValue),
|
|
137
|
+
[selectValueMark]: searchValue,
|
|
138
|
+
createdOption: true
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return filtered;
|
|
142
|
+
};
|
|
143
|
+
const edit = () => {
|
|
144
|
+
setIsEditing(true);
|
|
145
|
+
setTimeout(() => { var _a; return (_a = inputNode === null || inputNode === void 0 ? void 0 : inputNode.current) === null || _a === void 0 ? void 0 : _a.focus(); }, 50);
|
|
146
|
+
};
|
|
147
|
+
const onClear = () => {
|
|
148
|
+
if (remoteData) {
|
|
149
|
+
onInputChange('');
|
|
150
|
+
onClearRows();
|
|
151
|
+
}
|
|
152
|
+
if (typeof onInnerValueChange === 'function') {
|
|
153
|
+
onInnerValueChange(null);
|
|
154
|
+
}
|
|
155
|
+
if (input && input.onChange) {
|
|
156
|
+
input.onChange(null);
|
|
157
|
+
}
|
|
158
|
+
setSearchValue('');
|
|
159
|
+
setIsEditing(false);
|
|
160
|
+
setFormattedDisplayValue(null);
|
|
161
|
+
};
|
|
162
|
+
const onEditButtonFocus = () => {
|
|
163
|
+
if (disabled) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
edit();
|
|
167
|
+
};
|
|
168
|
+
const onCreateOptionInner = value => {
|
|
169
|
+
delete value.createdOption;
|
|
170
|
+
onCreateOption(value[selectValueMark]);
|
|
171
|
+
onBlur();
|
|
172
|
+
};
|
|
173
|
+
const handleChange = (e, value, reason) => {
|
|
174
|
+
if (reason === 'clear') {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (creatable && value && value.createdOption) {
|
|
178
|
+
onCreateOptionInner(value);
|
|
179
|
+
}
|
|
180
|
+
if (typeof onInnerValueChange === 'function') {
|
|
181
|
+
onInnerValueChange(value);
|
|
182
|
+
}
|
|
183
|
+
if (selectLabelCondition && returnType !== 'object') {
|
|
184
|
+
setFormattedDisplayValue(selectLabelCondition(value));
|
|
185
|
+
}
|
|
186
|
+
let newValue = value[selectValueMark];
|
|
187
|
+
if (returnType === 'object') {
|
|
188
|
+
newValue = (Object.keys(value).length ? value : null);
|
|
189
|
+
}
|
|
190
|
+
if (multiple) {
|
|
191
|
+
newValue = value.map(v => v[selectValueMark]);
|
|
192
|
+
if (!newValue.length) {
|
|
193
|
+
newValue = null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
input.onChange(newValue);
|
|
197
|
+
setTimeout(() => {
|
|
198
|
+
onBlur();
|
|
199
|
+
input === null || input === void 0 ? void 0 : input.onBlur(newValue);
|
|
200
|
+
}, 100);
|
|
201
|
+
};
|
|
202
|
+
const handleInputChange = e => {
|
|
203
|
+
setSearchValue(e.target.value);
|
|
204
|
+
if (onInputChange) {
|
|
205
|
+
onInputChange(e.target.value);
|
|
206
|
+
}
|
|
207
|
+
if (remoteData && !e.target.value) {
|
|
208
|
+
onClearRows();
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
const getOptionLabel = option => (selectLabelCondition ? selectLabelCondition(option) : option && option[selectLabelMark]) || '';
|
|
212
|
+
const getOptionSelected = (option, value) => {
|
|
213
|
+
if (multiple || returnType === 'object') {
|
|
214
|
+
return option[selectValueMark] === value[selectValueMark];
|
|
215
|
+
}
|
|
216
|
+
return option[selectValueMark] === value;
|
|
217
|
+
};
|
|
218
|
+
const renderOption = (optionProps, data) => {
|
|
219
|
+
if (typeof itemRenderer === 'function') {
|
|
220
|
+
return itemRenderer(getHighlightedPartLabel(getOptionLabel(data), searchValue), data, searchValue, optionProps);
|
|
221
|
+
}
|
|
222
|
+
return getHighlightedPartLabel(getOptionLabel(data), searchValue, optionProps);
|
|
223
|
+
};
|
|
224
|
+
const selectedOption = useMemo(() => sortedItems.find(i => multiple
|
|
225
|
+
? (input.value || []).includes(i[selectValueMark])
|
|
226
|
+
: getOptionSelected(i, input.value)), [sortedItems, multiple, selectValueMark, input.value]);
|
|
227
|
+
const displayedValue = useMemo(() => {
|
|
228
|
+
let response;
|
|
229
|
+
if (selectLabelCondition) {
|
|
230
|
+
response = returnType === 'object' ? selectLabelCondition(input.value) : formattedDisplayValue || defaultValue;
|
|
231
|
+
}
|
|
232
|
+
else if (returnType === 'object') {
|
|
233
|
+
response = input.value && input.value[selectLabelMark];
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
response = getOptionLabel(selectedOption) || defaultValue || input.value;
|
|
237
|
+
}
|
|
238
|
+
if (alwaysDisplayDefault) {
|
|
239
|
+
response = defaultValue;
|
|
240
|
+
}
|
|
241
|
+
return (![null, undefined].includes(input.value)
|
|
242
|
+
? response
|
|
243
|
+
: null);
|
|
244
|
+
}, [
|
|
245
|
+
formattedDisplayValue,
|
|
246
|
+
selectedOption,
|
|
247
|
+
selectLabelCondition,
|
|
248
|
+
alwaysDisplayDefault,
|
|
249
|
+
returnType,
|
|
250
|
+
defaultValue,
|
|
251
|
+
selectLabelMark,
|
|
252
|
+
input.value,
|
|
253
|
+
classes
|
|
254
|
+
]);
|
|
255
|
+
const renderValue = useMemo(() => {
|
|
256
|
+
const valueForRender = returnType === 'object'
|
|
257
|
+
? input.value
|
|
258
|
+
: selectedOption;
|
|
259
|
+
return valueRenderer
|
|
260
|
+
? valueRenderer(displayedValue, valueForRender, searchValue, { value: valueForRender && valueForRender[selectValueMark] })
|
|
261
|
+
: null;
|
|
262
|
+
}, [selectedOption, searchValue, displayedValue, selectValueMark, returnType, valueRenderer, input.value]);
|
|
263
|
+
const renderIcons = useMemo(() => !disabled && (loading
|
|
264
|
+
? React.createElement(CircularProgress, { size: 24, thickness: 4, className: fieldClasses.loading })
|
|
265
|
+
: (React.createElement("div", { className: classes.inputEndAdornment },
|
|
266
|
+
allowEmpty && input.value && (React.createElement(IconButton, { size: "small", onClick: onClear, color: "inherit" },
|
|
267
|
+
React.createElement(CloseIcon, { fontSize: "inherit" }))),
|
|
268
|
+
React.createElement(IconButton, { size: "small", color: "inherit", className: clsx(classes.expandIcon, 'pl-0 pr-0'), disableRipple: true },
|
|
269
|
+
React.createElement(ExpandMore, { className: inline && 'fsInherit' }))))), [disabled, loading, inline, allowEmpty, input.value]);
|
|
270
|
+
const inputValue = useMemo(() => {
|
|
271
|
+
if (multiple) {
|
|
272
|
+
return (input.value || []).map(v => sortedItems.find(s => s[selectValueMark] === v));
|
|
273
|
+
}
|
|
274
|
+
return input.value || null;
|
|
275
|
+
}, [input.value, multiple, selectValueMark, sortedItems]);
|
|
276
|
+
const renderedPlaceholder = useMemo(() => {
|
|
277
|
+
const rendered = placeholder || (!isEditing ? 'No value' : '');
|
|
278
|
+
return multiple && inputValue.length ? null : rendered;
|
|
279
|
+
}, [multiple, placeholder, isEditing, inputValue]);
|
|
280
|
+
return (React.createElement("div", { className: clsx(className, 'outline-none', inline && classes.inline), id: input === null || input === void 0 ? void 0 : input.name },
|
|
281
|
+
React.createElement(SelectContext.Provider, { value: {
|
|
282
|
+
rowHeight,
|
|
283
|
+
remoteRowCount,
|
|
284
|
+
loadMoreRows,
|
|
285
|
+
classes,
|
|
286
|
+
fieldClasses,
|
|
287
|
+
hideMenuOnNoResults,
|
|
288
|
+
inline,
|
|
289
|
+
items,
|
|
290
|
+
popperAnchor,
|
|
291
|
+
loading,
|
|
292
|
+
selectAdornment
|
|
293
|
+
} },
|
|
294
|
+
React.createElement(Autocomplete, { blurOnSelect: !multiple, disableCloseOnSelect: multiple, multiple: multiple, value: inputValue, options: sortedItems, loading: loading, freeSolo: creatable, disabled: disabled, disableClearable: !allowEmpty, isOptionEqualToValue: getOptionSelected, onChange: handleChange, classes: {
|
|
295
|
+
root: clsx('d-inline-flex', classes.root),
|
|
296
|
+
hasPopupIcon: classes.hasPopup,
|
|
297
|
+
hasClearIcon: classes.hasClear,
|
|
298
|
+
inputRoot: clsx(classes.inputWrapper, multiple && classes.multiple),
|
|
299
|
+
option: 'w-100 text-pre',
|
|
300
|
+
popper: classes.popper,
|
|
301
|
+
groupUl: 'm-0'
|
|
302
|
+
}, groupBy: categoryKey && (option => option[categoryKey]), renderOption: renderOption, getOptionLabel: getOptionLabel, filterOptions: filterItems, ListboxComponent: inline || categoryKey ? null : ListBoxAdapter, PopperComponent: categoryKey ? null : PopperAdapter, renderInput: (_a) => {
|
|
303
|
+
var { InputLabelProps, InputProps, inputProps } = _a, params = __rest(_a, ["InputLabelProps", "InputProps", "inputProps"]);
|
|
304
|
+
return (React.createElement(EditInPlaceFieldBase, Object.assign({}, params, { name: input.name, value: displayedValue, error: error, invalid: hasError || invalid, inline: inline, label: label, warning: warning, fieldClasses: fieldClasses, endAdornmentClass: classes.selectAdornment, rightAligned: rightAligned, shrink: Boolean(label || input.value), labelAdornment: labelAdornment, placeholder: renderedPlaceholder, editIcon: !hideEditIcon && renderIcons, InputProps: Object.assign(Object.assign({}, InputProps), { onChange: handleInputChange, onFocus: edit, onClick: onEditButtonFocus, onBlur,
|
|
305
|
+
disableUnderline, classes: {
|
|
306
|
+
underline: fieldClasses.underline,
|
|
307
|
+
input: clsx(disabled && classes.readonly, fieldClasses.text),
|
|
308
|
+
}, inputProps: Object.assign(Object.assign({}, inputProps), { className: clsx(fieldClasses.text, 'mr-auto'), ref: ref => {
|
|
309
|
+
inputProps.ref.current = ref;
|
|
310
|
+
inputNode.current = ref;
|
|
311
|
+
if (inputRef)
|
|
312
|
+
inputRef.current = ref;
|
|
313
|
+
}, value: (isEditing ? searchValue : multiple ? '' : (typeof displayedValue === 'string' ? displayedValue : '')) }) }), CustomInput: (valueRenderer && !multiple && !isEditing && input.value)
|
|
314
|
+
?
|
|
315
|
+
React.createElement(Select, Object.assign({}, InputProps, { inputRef: ref => {
|
|
316
|
+
inputProps.ref.current = ref === null || ref === void 0 ? void 0 : ref.node;
|
|
317
|
+
}, classes: { select: 'cursor-text' }, onFocus: edit, value: (returnType === 'object' ? input.value[selectValueMark] : input.value) || '', endAdornment: React.createElement(InputAdornment, { position: "end", className: clsx(classes.selectAdornment, 'd-none') }, renderIcons), IconComponent: stubComponent }), renderValue)
|
|
318
|
+
: null })));
|
|
319
|
+
}, disableListWrap: true, openOnFocus: true, fullWidth: true }))));
|
|
320
|
+
}
|
|
321
|
+
export default EditInPlaceSearchSelect;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconButtonTypeMap } from '@mui/material';
|
|
3
|
+
interface Props {
|
|
4
|
+
link?: string | number;
|
|
5
|
+
linkHandler?: (arg: string | number) => void;
|
|
6
|
+
linkColor?: IconButtonTypeMap['props']['color'];
|
|
7
|
+
clickHandler?: any;
|
|
8
|
+
className?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const LinkAdornment: ({ link, linkColor, linkHandler, clickHandler, className, disabled }: Props) => React.JSX.Element;
|
|
12
|
+
export declare const SettingsAdornment: ({ link, linkHandler, clickHandler, className, disabled }: Props) => React.JSX.Element;
|
|
13
|
+
export {};
|