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,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 NumberFormat 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(NumberFormat, 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 NumberFormat 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(undefined);
|
|
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(NumberFormat, 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 {};
|
|
@@ -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
|
+
import React from 'react';
|
|
9
|
+
import IconButton from '@mui/material/IconButton';
|
|
10
|
+
import Launch from '@mui/icons-material/Launch';
|
|
11
|
+
import SettingsOutlinedIcon from '@mui/icons-material/SettingsOutlined';
|
|
12
|
+
export const LinkAdornment = ({ link, linkColor = 'primary', linkHandler, clickHandler, className, disabled }) => {
|
|
13
|
+
const onClick = () => (clickHandler ? clickHandler() : linkHandler(link));
|
|
14
|
+
return (React.createElement("span", { className: className },
|
|
15
|
+
React.createElement(IconButton, { disabled: disabled || (!link && link !== 0), onClick: onClick, color: linkColor, classes: {
|
|
16
|
+
root: 'inputAdornmentButton'
|
|
17
|
+
} },
|
|
18
|
+
React.createElement(Launch, { className: "inputAdornmentIcon", color: "inherit" }))));
|
|
19
|
+
};
|
|
20
|
+
export const SettingsAdornment = ({ link, linkHandler, clickHandler, className, disabled }) => {
|
|
21
|
+
const onClick = e => (clickHandler ? clickHandler(e) : linkHandler(link));
|
|
22
|
+
return (React.createElement("span", { className: className },
|
|
23
|
+
React.createElement(IconButton, { disabled: disabled, onClick: onClick, classes: {
|
|
24
|
+
root: 'inputAdornmentButton ml-0-5'
|
|
25
|
+
}, color: "inherit", size: "small" },
|
|
26
|
+
React.createElement(SettingsOutlinedIcon, { color: "inherit" }))));
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
data: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
actions?: {
|
|
6
|
+
actionLabel?: string;
|
|
7
|
+
onAction?: any;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
icon?: any;
|
|
10
|
+
}[];
|
|
11
|
+
classes?: any;
|
|
12
|
+
iconPlacementRow?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
avatarSize?: number;
|
|
15
|
+
}
|
|
16
|
+
declare const _default: React.JSXElementConstructor<Omit<Props, "classes"> & import("@mui/styles").StyledComponentProps<"active" | "root" | "rounded" | "backdrop" | "actionButton" | "noValue" | "avatarRoot">>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright ish group pty ltd. All rights reserved. https://www.ish.com.au
|
|
3
|
+
* No copying or use of this code is allowed without permission in writing from ish.
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import Typography from '@mui/material/Typography';
|
|
7
|
+
import Button from '@mui/material/Button';
|
|
8
|
+
import { createStyles, withStyles } from '@mui/styles';
|
|
9
|
+
import { darken } from '@mui/material/styles';
|
|
10
|
+
import IconButton from '@mui/material/IconButton';
|
|
11
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
12
|
+
import Avatar from '@mui/material/Avatar';
|
|
13
|
+
import clsx from 'clsx';
|
|
14
|
+
const styles = (theme) => createStyles({
|
|
15
|
+
root: {
|
|
16
|
+
height: 'fit-content',
|
|
17
|
+
width: 'fit-content',
|
|
18
|
+
position: 'relative',
|
|
19
|
+
fontSize: 0,
|
|
20
|
+
'&:hover $backdrop$active': {
|
|
21
|
+
opacity: 1
|
|
22
|
+
},
|
|
23
|
+
color: '#fff',
|
|
24
|
+
},
|
|
25
|
+
backdrop: {
|
|
26
|
+
display: 'flex',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
justifyContent: 'center',
|
|
29
|
+
background: theme.palette.action.active,
|
|
30
|
+
position: 'absolute',
|
|
31
|
+
height: '100%',
|
|
32
|
+
width: '100%',
|
|
33
|
+
opacity: 0,
|
|
34
|
+
transition: theme.transitions.create('opacity', {
|
|
35
|
+
duration: theme.transitions.duration.complex,
|
|
36
|
+
easing: theme.transitions.easing.easeInOut
|
|
37
|
+
}),
|
|
38
|
+
zIndex: 1,
|
|
39
|
+
},
|
|
40
|
+
rounded: {
|
|
41
|
+
borderRadius: '100%',
|
|
42
|
+
},
|
|
43
|
+
actionButton: {
|
|
44
|
+
background: theme.palette.background.paper,
|
|
45
|
+
'&:hover': {
|
|
46
|
+
background: darken(theme.palette.background.paper, 0.2)
|
|
47
|
+
},
|
|
48
|
+
marginTop: theme.spacing(1)
|
|
49
|
+
},
|
|
50
|
+
noValue: {
|
|
51
|
+
color: theme.palette.divider,
|
|
52
|
+
marginTop: theme.spacing(-1)
|
|
53
|
+
},
|
|
54
|
+
active: {},
|
|
55
|
+
avatarRoot: {
|
|
56
|
+
maxWidth: '100%',
|
|
57
|
+
transition: theme.transitions.create('all', {
|
|
58
|
+
duration: theme.transitions.duration.complex,
|
|
59
|
+
easing: theme.transitions.easing.easeInOut
|
|
60
|
+
}),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const FilePreview = ({ label, actions, data, classes, iconPlacementRow, disabled, avatarSize }) => {
|
|
64
|
+
const size = avatarSize || 90;
|
|
65
|
+
return (React.createElement(React.Fragment, null,
|
|
66
|
+
label && (React.createElement(Typography, { variant: "caption", color: "textSecondary", component: "div", className: "pb-1" }, label)),
|
|
67
|
+
data ? (React.createElement("div", { className: classes.root },
|
|
68
|
+
!disabled && (React.createElement("div", { className: clsx(classes.backdrop, avatarSize && classes.rounded, actions && classes.active) },
|
|
69
|
+
React.createElement("div", { className: iconPlacementRow ? 'centeredFlex' : 'flex-column' }, actions
|
|
70
|
+
&& actions.map((a, i) => (a.icon ? (React.createElement(Tooltip, { key: i, title: a.actionLabel, placement: iconPlacementRow ? 'top' : 'right' },
|
|
71
|
+
React.createElement(IconButton, { color: "inherit", size: "medium", onClick: a.onAction, disabled: a.disabled }, a.icon))) : (React.createElement(Button, { key: i, size: "small", variant: "outlined", color: "secondary", classes: {
|
|
72
|
+
root: classes.actionButton
|
|
73
|
+
}, onClick: a.onAction, disabled: a.disabled }, a.actionLabel))))))),
|
|
74
|
+
avatarSize
|
|
75
|
+
? (React.createElement(Avatar, { alt: "FilePreview", src: `data:image/png;base64, ${data}`, sx: { width: size, height: size }, classes: { root: classes.avatarRoot } })) : (React.createElement("img", { alt: "FilePreview", src: `data:image/png;base64, ${data}`, className: classes.avatarRoot })))) : (React.createElement(Typography, { variant: "body1", className: classes.noValue }, "No Value"))));
|
|
76
|
+
};
|
|
77
|
+
export default withStyles(styles)(FilePreview);
|
|
@@ -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
|
+
import React from 'react';
|
|
9
|
+
import { withStyles } from '@mui/styles';
|
|
10
|
+
import { FormControl, FormControlLabel, Radio, RadioGroup } from '@mui/material';
|
|
11
|
+
import Typography from '@mui/material/Typography';
|
|
12
|
+
const styles = theme => ({
|
|
13
|
+
root: {
|
|
14
|
+
display: 'flex'
|
|
15
|
+
},
|
|
16
|
+
group: {
|
|
17
|
+
margin: theme.spacing(1, 0)
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const FormRadioButtons = props => {
|
|
21
|
+
const { classes, items, disabled, input: { value, onChange, name }, labelPath = 'label', valuePath = 'value', color = 'primary', row } = props;
|
|
22
|
+
return (React.createElement("div", { className: classes.root },
|
|
23
|
+
React.createElement(FormControl, { component: "fieldset" },
|
|
24
|
+
React.createElement(RadioGroup, { className: classes.group, value: value, onChange: (e) => onChange(e.target.value), row: row }, items
|
|
25
|
+
&& items.map((i, n) => (React.createElement(FormControlLabel, { key: n, value: i[valuePath], control: React.createElement(Radio, { color: color, id: `input-${n}-${name}`, name: name }), label: (React.createElement(Typography, { component: "span", variant: "body2" }, i[labelPath])), disabled: disabled, htmlFor: `input-${n}-${name}` })))))));
|
|
26
|
+
};
|
|
27
|
+
export default withStyles(styles)(FormRadioButtons);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const selectStyles: (theme: any) => import("@mui/styles").StyleRules<{}, "label" | "inline" | "multiple" | "error" | "root" | "expandIcon" | "menuItem" | "inputWrapper" | "readonly" | "inputEndAdornment" | "editIcon" | "bottomMargin" | "bottomPadding" | "topMargin" | "editable" | "valid" | "autoWidthSelect" | "emptySelect" | "validUnderline" | "menuItemActive" | "menuList" | "hasPopup" | "hasClear">;
|
|
3
|
+
export declare const ListRow: React.MemoExoticComponent<any>;
|
|
4
|
+
export declare const ListboxComponent: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<any>>;
|
|
5
|
+
export declare const NoWrapOption: (content: any, data: any, search: any, parentProps: any) => React.JSX.Element;
|