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.
Files changed (215) hide show
  1. package/dist/actions/FieldProcessing.d.ts +10 -0
  2. package/dist/actions/FieldProcessing.js +17 -0
  3. package/dist/actions/index.d.ts +1 -0
  4. package/dist/actions/index.js +8 -0
  5. package/dist/appBar/AppBarHelpMenu.d.ts +3 -0
  6. package/dist/appBar/AppBarHelpMenu.js +77 -0
  7. package/dist/appBar/index.d.ts +2 -0
  8. package/dist/appBar/index.js +9 -0
  9. package/dist/buttons/AddButton.d.ts +14 -0
  10. package/dist/buttons/AddButton.js +9 -0
  11. package/dist/buttons/TimetableButton.d.ts +3 -0
  12. package/dist/buttons/TimetableButton.js +12 -0
  13. package/dist/buttons/index.d.ts +4 -0
  14. package/dist/buttons/index.js +11 -0
  15. package/dist/colorPicker/ColorPicker.d.ts +4 -0
  16. package/dist/colorPicker/ColorPicker.js +138 -0
  17. package/dist/colorPicker/index.d.ts +2 -0
  18. package/dist/colorPicker/index.js +9 -0
  19. package/dist/dialog/BrowserWarning.d.ts +3 -0
  20. package/dist/dialog/BrowserWarning.js +16 -0
  21. package/dist/dialog/confirm/ConfirmBase.d.ts +7 -0
  22. package/dist/dialog/confirm/ConfirmBase.js +29 -0
  23. package/dist/dialog/index.d.ts +5 -0
  24. package/dist/dialog/index.js +12 -0
  25. package/dist/dialog/message/Message.d.ts +3 -0
  26. package/dist/dialog/message/Message.js +91 -0
  27. package/dist/documents/DocumentIconsChooser.d.ts +3 -0
  28. package/dist/documents/DocumentIconsChooser.js +51 -0
  29. package/dist/documents/index.d.ts +3 -0
  30. package/dist/documents/index.js +10 -0
  31. package/dist/documents/utils/index.d.ts +7 -0
  32. package/dist/documents/utils/index.js +61 -0
  33. package/dist/dynamicSizeList/DynamicSizeList.d.ts +17 -0
  34. package/dist/dynamicSizeList/DynamicSizeList.js +167 -0
  35. package/dist/dynamicSizeList/index.d.ts +2 -0
  36. package/dist/dynamicSizeList/index.js +9 -0
  37. package/dist/fieldMessage/ErrorMessage.d.ts +8 -0
  38. package/dist/fieldMessage/ErrorMessage.js +14 -0
  39. package/dist/fieldMessage/WarningMessage.d.ts +8 -0
  40. package/dist/fieldMessage/WarningMessage.js +14 -0
  41. package/dist/fieldMessage/index.d.ts +6 -0
  42. package/dist/fieldMessage/index.js +13 -0
  43. package/dist/fieldMessage/styles.d.ts +3 -0
  44. package/dist/fieldMessage/styles.js +18 -0
  45. package/dist/fileUploader/FileUploaderDialog.d.ts +15 -0
  46. package/dist/fileUploader/FileUploaderDialog.js +99 -0
  47. package/dist/fileUploader/index.d.ts +2 -0
  48. package/dist/fileUploader/index.js +9 -0
  49. package/dist/formFields/CheckboxField.d.ts +7 -0
  50. package/dist/formFields/CheckboxField.js +67 -0
  51. package/dist/formFields/CodeEditorField.d.ts +6 -0
  52. package/dist/formFields/CodeEditorField.js +69 -0
  53. package/dist/formFields/ColoredCheckBox.d.ts +3 -0
  54. package/dist/formFields/ColoredCheckBox.js +41 -0
  55. package/dist/formFields/DateTimeField.d.ts +2 -0
  56. package/dist/formFields/DateTimeField.js +27 -0
  57. package/dist/formFields/EditInPlaceDateTimeField.d.ts +10 -0
  58. package/dist/formFields/EditInPlaceDateTimeField.js +188 -0
  59. package/dist/formFields/EditInPlaceDurationField.d.ts +4 -0
  60. package/dist/formFields/EditInPlaceDurationField.js +63 -0
  61. package/dist/formFields/EditInPlaceField.d.ts +10 -0
  62. package/dist/formFields/EditInPlaceField.js +58 -0
  63. package/dist/formFields/EditInPlaceFieldBase.d.ts +28 -0
  64. package/dist/formFields/EditInPlaceFieldBase.js +123 -0
  65. package/dist/formFields/EditInPlaceFileField.d.ts +7 -0
  66. package/dist/formFields/EditInPlaceFileField.js +60 -0
  67. package/dist/formFields/EditInPlaceMoneyField.d.ts +9 -0
  68. package/dist/formFields/EditInPlaceMoneyField.js +37 -0
  69. package/dist/formFields/EditInPlacePhoneField.d.ts +4 -0
  70. package/dist/formFields/EditInPlacePhoneField.js +69 -0
  71. package/dist/formFields/EditInPlaceSearchSelect.d.ts +4 -0
  72. package/dist/formFields/EditInPlaceSearchSelect.js +321 -0
  73. package/dist/formFields/FieldAdornments.d.ts +13 -0
  74. package/dist/formFields/FieldAdornments.js +27 -0
  75. package/dist/formFields/FilePreview.d.ts +17 -0
  76. package/dist/formFields/FilePreview.js +77 -0
  77. package/dist/formFields/FormRadioButtons.d.ts +3 -0
  78. package/dist/formFields/FormRadioButtons.js +27 -0
  79. package/dist/formFields/SelectCustomComponents.d.ts +5 -0
  80. package/dist/formFields/SelectCustomComponents.js +182 -0
  81. package/dist/formFields/Switch.d.ts +7 -0
  82. package/dist/formFields/Switch.js +116 -0
  83. package/dist/formFields/TextField.d.ts +6 -0
  84. package/dist/formFields/TextField.js +42 -0
  85. package/dist/formFields/UneditableBase.d.ts +17 -0
  86. package/dist/formFields/UneditableBase.js +48 -0
  87. package/dist/formFields/index.d.ts +31 -0
  88. package/dist/formFields/index.js +38 -0
  89. package/dist/index.d.ts +18 -0
  90. package/dist/index.js +25 -0
  91. package/dist/layout/InfoPill.d.ts +7 -0
  92. package/dist/layout/InfoPill.js +26 -0
  93. package/dist/layout/index.d.ts +4 -0
  94. package/dist/layout/index.js +11 -0
  95. package/dist/layout/resizable/ResizableWrapper.d.ts +14 -0
  96. package/dist/layout/resizable/ResizableWrapper.js +42 -0
  97. package/dist/markdownEditor/HtmlEditor.d.ts +15 -0
  98. package/dist/markdownEditor/HtmlEditor.js +18 -0
  99. package/dist/markdownEditor/WysiwygEditor.d.ts +8 -0
  100. package/dist/markdownEditor/WysiwygEditor.js +98 -0
  101. package/dist/markdownEditor/index.d.ts +5 -0
  102. package/dist/markdownEditor/index.js +12 -0
  103. package/dist/markdownEditor/utils/index.d.ts +9 -0
  104. package/dist/markdownEditor/utils/index.js +38 -0
  105. package/dist/model/AppBar.d.ts +11 -0
  106. package/dist/model/AppBar.js +8 -0
  107. package/dist/model/CommomObjects.d.ts +5 -0
  108. package/dist/model/CommomObjects.js +1 -0
  109. package/dist/model/CommonFunctions.d.ts +8 -0
  110. package/dist/model/CommonFunctions.js +5 -0
  111. package/dist/model/Confirm.d.ts +16 -0
  112. package/dist/model/Confirm.js +8 -0
  113. package/dist/model/Fields.d.ts +258 -0
  114. package/dist/model/Fields.js +8 -0
  115. package/dist/model/NestedEntity.d.ts +9 -0
  116. package/dist/model/NestedEntity.js +5 -0
  117. package/dist/model/Theme.d.ts +34 -0
  118. package/dist/model/Theme.js +18 -0
  119. package/dist/model/index.d.ts +7 -0
  120. package/dist/model/index.js +14 -0
  121. package/dist/styles/GlobalStylesProvider.d.ts +3 -0
  122. package/dist/styles/GlobalStylesProvider.js +417 -0
  123. package/dist/styles/StylesProviderCustom.d.ts +3 -0
  124. package/dist/styles/StylesProviderCustom.js +6 -0
  125. package/dist/styles/animateStyles.d.ts +3 -0
  126. package/dist/styles/animateStyles.js +33 -0
  127. package/dist/styles/bootstrap.d.ts +491 -0
  128. package/dist/styles/bootstrap.js +496 -0
  129. package/dist/styles/hooks.d.ts +6 -0
  130. package/dist/styles/hooks.js +38 -0
  131. package/dist/styles/index.d.ts +11 -0
  132. package/dist/styles/index.js +18 -0
  133. package/dist/styles/makeStyles.d.ts +3 -0
  134. package/dist/styles/makeStyles.js +9 -0
  135. package/dist/styles/mixins/common.d.ts +8 -0
  136. package/dist/styles/mixins/common.js +32 -0
  137. package/dist/styles/mixins/keyframes.d.ts +3 -0
  138. package/dist/styles/mixins/keyframes.js +9 -0
  139. package/dist/styles/mixins/prefixer.d.ts +1 -0
  140. package/dist/styles/mixins/prefixer.js +23 -0
  141. package/dist/tagsInput/AddTagMenu.d.ts +12 -0
  142. package/dist/tagsInput/AddTagMenu.js +36 -0
  143. package/dist/tagsInput/AddTagMenuItem.d.ts +11 -0
  144. package/dist/tagsInput/AddTagMenuItem.js +29 -0
  145. package/dist/tagsInput/TagInputList.d.ts +4 -0
  146. package/dist/tagsInput/TagInputList.js +273 -0
  147. package/dist/tagsInput/index.d.ts +6 -0
  148. package/dist/tagsInput/index.js +6 -0
  149. package/dist/themes/appTheme.d.ts +4 -0
  150. package/dist/themes/appTheme.js +322 -0
  151. package/dist/themes/index.d.ts +2 -0
  152. package/dist/themes/index.js +9 -0
  153. package/dist/themes/ishTheme.d.ts +8 -0
  154. package/dist/themes/ishTheme.js +351 -0
  155. package/dist/timetable/datePeriodFilter/DayPeriodIcons.d.ts +8 -0
  156. package/dist/timetable/datePeriodFilter/DayPeriodIcons.js +27 -0
  157. package/dist/timetable/datePeriodFilter/index.d.ts +1 -0
  158. package/dist/timetable/datePeriodFilter/index.js +8 -0
  159. package/dist/timetable/index.d.ts +2 -0
  160. package/dist/timetable/index.js +9 -0
  161. package/dist/timetable/miniCalendar/CalendarDay.d.ts +15 -0
  162. package/dist/timetable/miniCalendar/CalendarDay.js +64 -0
  163. package/dist/timetable/miniCalendar/CalendarHeader.d.ts +10 -0
  164. package/dist/timetable/miniCalendar/CalendarHeader.js +22 -0
  165. package/dist/timetable/miniCalendar/CalendarWeekPanel.d.ts +8 -0
  166. package/dist/timetable/miniCalendar/CalendarWeekPanel.js +18 -0
  167. package/dist/timetable/miniCalendar/WeekDay.d.ts +10 -0
  168. package/dist/timetable/miniCalendar/WeekDay.js +25 -0
  169. package/dist/timetable/miniCalendar/index.d.ts +8 -0
  170. package/dist/timetable/miniCalendar/index.js +15 -0
  171. package/dist/utils/DOM/Links.d.ts +1 -0
  172. package/dist/utils/DOM/Links.js +12 -0
  173. package/dist/utils/DOM/getCaretCoordinates.d.ts +6 -0
  174. package/dist/utils/DOM/getCaretCoordinates.js +109 -0
  175. package/dist/utils/DOM/getOS.d.ts +2 -0
  176. package/dist/utils/DOM/getOS.js +32 -0
  177. package/dist/utils/DOM/index.d.ts +5 -0
  178. package/dist/utils/DOM/index.js +32 -0
  179. package/dist/utils/dates/datesNormalizing.d.ts +1 -0
  180. package/dist/utils/dates/datesNormalizing.js +3 -0
  181. package/dist/utils/dates/format.d.ts +24 -0
  182. package/dist/utils/dates/format.js +28 -0
  183. package/dist/utils/dates/formatRelative.d.ts +1 -0
  184. package/dist/utils/dates/formatRelative.js +14 -0
  185. package/dist/utils/dates/formatString.d.ts +2 -0
  186. package/dist/utils/dates/formatString.js +195 -0
  187. package/dist/utils/dates/formatTimezone.d.ts +2 -0
  188. package/dist/utils/dates/formatTimezone.js +35 -0
  189. package/dist/utils/dates/index.d.ts +6 -0
  190. package/dist/utils/dates/index.js +13 -0
  191. package/dist/utils/dates/timetable.d.ts +5 -0
  192. package/dist/utils/dates/timetable.js +38 -0
  193. package/dist/utils/events/index.d.ts +2 -0
  194. package/dist/utils/events/index.js +6 -0
  195. package/dist/utils/fields/index.d.ts +1 -0
  196. package/dist/utils/fields/index.js +20 -0
  197. package/dist/utils/formatting/PhoneMasks.d.ts +304 -0
  198. package/dist/utils/formatting/PhoneMasks.js +318 -0
  199. package/dist/utils/formatting/index.d.ts +2 -0
  200. package/dist/utils/formatting/index.js +10 -0
  201. package/dist/utils/hooks/index.d.ts +1 -0
  202. package/dist/utils/hooks/index.js +15 -0
  203. package/dist/utils/index.d.ts +9 -0
  204. package/dist/utils/index.js +16 -0
  205. package/dist/utils/numbers/decimalCalculation.d.ts +4 -0
  206. package/dist/utils/numbers/decimalCalculation.js +21 -0
  207. package/dist/utils/numbers/index.d.ts +2 -0
  208. package/dist/utils/numbers/index.js +9 -0
  209. package/dist/utils/numbers/numbersNormalizing.d.ts +10 -0
  210. package/dist/utils/numbers/numbersNormalizing.js +44 -0
  211. package/dist/utils/stubs/index.d.ts +3 -0
  212. package/dist/utils/stubs/index.js +10 -0
  213. package/dist/utils/tags/index.d.ts +3 -0
  214. package/dist/utils/tags/index.js +42 -0
  215. package/package.json +1 -1
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import withStyles from '@mui/styles/withStyles';
4
+ import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft';
5
+ import MenuItem from '@mui/material/MenuItem';
6
+ import List from '@mui/material/List';
7
+ import AddTagMenuItem from './AddTagMenuItem';
8
+ const styles = theme => ({
9
+ listItem: {
10
+ padding: theme.spacing(0, 0.5, 0, 2)
11
+ },
12
+ proceedIcon: {
13
+ marginTop: '2px'
14
+ },
15
+ backContainer: {
16
+ marginLeft: '-6px'
17
+ },
18
+ tagColorDotSmall: {
19
+ width: theme.spacing(2),
20
+ height: theme.spacing(2),
21
+ background: 'red',
22
+ borderRadius: '100%'
23
+ }
24
+ });
25
+ function AddTagMenu({ classes, tags, handleAdd, activeTag, setActiveTag, allowParentSelect }) {
26
+ const handleBack = () => {
27
+ setActiveTag(prev => prev.parent);
28
+ };
29
+ return (React.createElement(List, { className: classes.rootMenu },
30
+ activeTag && (React.createElement(MenuItem, { onClick: handleBack, className: classes.listItem },
31
+ React.createElement("span", { className: clsx('d-flex textSecondaryColor', classes.backContainer) },
32
+ React.createElement(KeyboardArrowLeft, { color: "inherit" }),
33
+ "Back"))),
34
+ (activeTag ? activeTag.children : tags).map(t => (React.createElement(AddTagMenuItem, { key: t.tagBody.id, tag: t, classes: classes, setActiveTag: setActiveTag, handleAdd: handleAdd, allowParentSelect: allowParentSelect })))));
35
+ }
36
+ export default withStyles(styles)(AddTagMenu);
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { MenuTag, TagLike } from '../model';
3
+ interface Props<T> {
4
+ classes: any;
5
+ setActiveTag: (tag: MenuTag<T>) => void;
6
+ handleAdd: (tag: MenuTag<T>) => void;
7
+ tag: MenuTag<T>;
8
+ allowParentSelect?: boolean;
9
+ }
10
+ declare function AddTagMenuItem<T extends TagLike>({ setActiveTag, tag, classes, handleAdd, allowParentSelect }: Props<T>): React.JSX.Element;
11
+ export default AddTagMenuItem;
@@ -0,0 +1,29 @@
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 clsx from 'clsx';
10
+ import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight';
11
+ import Checkbox from '@mui/material/Checkbox';
12
+ import MenuItem from '@mui/material/MenuItem';
13
+ import { IconButton } from '@mui/material';
14
+ function AddTagMenuItem({ setActiveTag, tag, classes, handleAdd, allowParentSelect }) {
15
+ const openSubmenu = () => {
16
+ setActiveTag(tag);
17
+ };
18
+ const toggleChecked = () => {
19
+ handleAdd(tag);
20
+ };
21
+ const hasChildren = Boolean(tag.children.length);
22
+ return (React.createElement(MenuItem, { classes: { root: classes.listItem }, onClick: allowParentSelect ? null : (hasChildren ? openSubmenu : toggleChecked), disableRipple: allowParentSelect },
23
+ React.createElement("div", { className: clsx(classes.tagColorDotSmall, 'mr-1'), style: { background: '#' + tag.tagBody.color } }),
24
+ React.createElement("span", { className: "mr-2 flex-fill" }, tag.tagBody.name),
25
+ (allowParentSelect || !hasChildren) && React.createElement(Checkbox, { onClick: toggleChecked, classes: { root: 'smallIconButton' }, checked: tag.active }),
26
+ hasChildren && React.createElement(IconButton, { size: "small", onClick: openSubmenu },
27
+ React.createElement(KeyboardArrowRight, { className: clsx('d-flex textSecondaryColor', classes.proceedIcon) }))));
28
+ }
29
+ export default AddTagMenuItem;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { FieldInputProps, FieldMetaProps, TagLike, TagsFieldProps } from '../model';
3
+ declare function TagInputList<T extends TagLike, IP extends FieldInputProps, MP extends FieldMetaProps>({ input, tags, placeholder, labelAdornment, meta, label, disabled, className, warning, allowParentSelect, fieldClasses }: TagsFieldProps<T, IP, MP>): React.JSX.Element;
4
+ export default TagInputList;
@@ -0,0 +1,273 @@
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, useMemo, useRef, useState } from 'react';
20
+ import { InputAdornment, MenuItem, Select } from '@mui/material';
21
+ import { ClickAwayListener } from '@mui/base';
22
+ import Autocomplete from '@mui/material/Autocomplete';
23
+ import clsx from 'clsx';
24
+ import { Edit } from '@mui/icons-material';
25
+ import { selectStyles } from '../formFields';
26
+ import AddTagMenu from './AddTagMenu';
27
+ import EditInPlaceFieldBase from '../formFields/EditInPlaceFieldBase';
28
+ import { getAllMenuTags, getHighlightedPartLabel, getMenuTags } from '../utils';
29
+ import { stubComponent } from '../utils/stubs';
30
+ import getCaretCoordinates from '../utils/DOM/getCaretCoordinates';
31
+ import { makeAppStyles } from '../styles';
32
+ const useStyles = makeAppStyles((theme) => (Object.assign(Object.assign({}, selectStyles(theme)), { inputEndAdornment: {
33
+ visibility: 'hidden',
34
+ display: 'flex',
35
+ color: theme.palette.primary.main,
36
+ alignItems: 'flex-end',
37
+ alignSelf: 'flex-end',
38
+ marginBottom: '4px',
39
+ opacity: 0.5
40
+ }, tagColorDotSmall: {
41
+ width: theme.spacing(2),
42
+ minWidth: theme.spacing(2),
43
+ height: theme.spacing(2),
44
+ minHeight: theme.spacing(2),
45
+ background: 'red',
46
+ borderRadius: '100%'
47
+ }, listbox: {
48
+ whiteSpace: 'break-spaces'
49
+ }, invalid: {} })));
50
+ const endTagRegex = /#\s*[^\w\d]*$/;
51
+ const getCurrentInputString = (input, formTagIds = [], allMenuTags = []) => {
52
+ let substr = input;
53
+ formTagIds === null || formTagIds === void 0 ? void 0 : formTagIds.forEach(id => {
54
+ const tag = allMenuTags.find(t => t.tagBody.id === id);
55
+ if (tag) {
56
+ substr = substr.replace('#' + tag.tagBody.name, '').trim();
57
+ }
58
+ });
59
+ if (substr) {
60
+ return substr.trim().replace(/#/g, '');
61
+ }
62
+ return substr;
63
+ };
64
+ const getFullTag = (tagId, tags) => {
65
+ let i = 0;
66
+ let result;
67
+ while (i < tags.length) {
68
+ if (tagId === tags[i].id) {
69
+ return tags[i];
70
+ }
71
+ if (result)
72
+ break;
73
+ if (tags[i].childTags.length) {
74
+ result = getFullTag(tagId, tags[i].childTags);
75
+ if (result)
76
+ return result;
77
+ }
78
+ ++i;
79
+ }
80
+ };
81
+ const getInputString = (tagIds, allTags) => ((tagIds === null || tagIds === void 0 ? void 0 : tagIds.length) && (allTags === null || allTags === void 0 ? void 0 : allTags.length)
82
+ ? tagIds.reduce((acc, id) => {
83
+ const tag = getFullTag(id, allTags);
84
+ return (tag ? `${acc}#${tag.name} ` : acc);
85
+ }, '')
86
+ : '');
87
+ function TagInputList({ input, tags, placeholder, labelAdornment, meta, label = 'Tags', disabled, className, warning, allowParentSelect, fieldClasses = {} }) {
88
+ const [menuIsOpen, setMenuIsOpen] = useState(false);
89
+ const [activeTag, setActiveTag] = useState(null);
90
+ const [isEditing, setIsEditing] = useState(false);
91
+ const [inputValue, setInputValue] = useState('');
92
+ const [currentInputString, setCurrentInputString] = useState('');
93
+ const classes = useStyles();
94
+ const InputValueForRender = useMemo(() => {
95
+ var _a;
96
+ if (!inputValue || !tags || !tags.length)
97
+ return '';
98
+ const arrayOfTags = ((_a = input === null || input === void 0 ? void 0 : input.value) === null || _a === void 0 ? void 0 : _a.length)
99
+ && input.value.map(id => getFullTag(id, tags)).filter(t => t);
100
+ if (!(arrayOfTags === null || arrayOfTags === void 0 ? void 0 : arrayOfTags.length))
101
+ return '';
102
+ return arrayOfTags.map((tag, index) => (React.createElement("span", { key: tag.id, className: clsx('centeredFlex', index !== arrayOfTags.length - 1 ? 'pr-1' : '') },
103
+ React.createElement("div", { key: tag.id, className: clsx(classes.tagColorDotSmall, 'mr-0-5'), style: { background: '#' + tag.color } }),
104
+ React.createElement("span", { className: "text-nowrap" }, `#${tag.name} `))));
105
+ }, [tags, input.value, inputValue]);
106
+ const inputNode = useRef();
107
+ const tagMenuNode = useRef();
108
+ const menuTags = useMemo(() => (tags && input.value ? getMenuTags(tags.filter(t => t.childrenCount > 0), input.value.map(id => getFullTag(id, tags)).filter(t => t)) : []), [tags, input.value]);
109
+ const allMenuTags = useMemo(() => getAllMenuTags(menuTags), [menuTags]);
110
+ const synchronizeTags = () => {
111
+ const inputString = getInputString(input.value, tags);
112
+ if (inputString.trim() === inputValue.replace(endTagRegex, '').trim()) {
113
+ return;
114
+ }
115
+ const updated = [];
116
+ const current = inputValue.split('#').filter(i => i).map(i => i.trim());
117
+ allMenuTags.forEach(t => {
118
+ if (!t.children.length) {
119
+ const index = current.findIndex(c => c === t.tagBody.name);
120
+ if (index !== -1) {
121
+ const addedTagsMatch = input.value.find(id => { var _a; return ((_a = getFullTag(id, tags)) === null || _a === void 0 ? void 0 : _a.name) === t.tagBody.name; });
122
+ if (addedTagsMatch && addedTagsMatch !== t.tagBody.id) {
123
+ return;
124
+ }
125
+ updated.push(t.tagBody.id);
126
+ current.splice(index, 1);
127
+ }
128
+ }
129
+ });
130
+ input.onChange(updated);
131
+ setInputValue(getInputString(updated, tags));
132
+ };
133
+ const onTagAdd = (tag) => {
134
+ const updated = [...input.value];
135
+ const index = updated.findIndex(id => id === tag.tagBody.id);
136
+ if (index !== -1) {
137
+ updated.splice(index, 1);
138
+ }
139
+ else {
140
+ updated.push(tag.tagBody.id);
141
+ }
142
+ input.onChange(updated);
143
+ setTimeout(() => {
144
+ var _a;
145
+ (_a = inputNode === null || inputNode === void 0 ? void 0 : inputNode.current) === null || _a === void 0 ? void 0 : _a.focus();
146
+ }, 100);
147
+ };
148
+ const filterOptions = item => !item.children.length && !input.value.some(id => id === item.tagBody.id) && item.tagBody.name
149
+ .toLowerCase()
150
+ .trim()
151
+ .startsWith(currentInputString.toLowerCase().trim());
152
+ const filterOptionsInner = options => options.filter(filterOptions);
153
+ const filteredOptions = allMenuTags.filter(filterOptions);
154
+ const getOptionText = (option, optionProps, label) => (React.createElement("div", Object.assign({}, optionProps),
155
+ `${option.path ? option.path + ' /' : ''}`,
156
+ ' ',
157
+ label));
158
+ const getOptionLabel = op => op.path;
159
+ const renderOption = (optionProps, option) => {
160
+ var _a;
161
+ const label = (_a = option === null || option === void 0 ? void 0 : option.tagBody) === null || _a === void 0 ? void 0 : _a.name;
162
+ const highlightedLabel = getHighlightedPartLabel(label, currentInputString);
163
+ return getOptionText(option, optionProps, highlightedLabel);
164
+ };
165
+ const handleInputChange = e => {
166
+ setInputValue(e.target.value);
167
+ };
168
+ const edit = () => {
169
+ setIsEditing(true);
170
+ setTimeout(() => {
171
+ var _a;
172
+ (_a = inputNode === null || inputNode === void 0 ? void 0 : inputNode.current) === null || _a === void 0 ? void 0 : _a.focus();
173
+ }, 50);
174
+ };
175
+ const exit = () => {
176
+ setMenuIsOpen(false);
177
+ setIsEditing(false);
178
+ setActiveTag(null);
179
+ if (endTagRegex.test(inputValue)) {
180
+ setTimeout(() => {
181
+ setInputValue(inputValue.replace(endTagRegex, '').trim());
182
+ }, 100);
183
+ }
184
+ };
185
+ const onFocus = () => {
186
+ setMenuIsOpen(true);
187
+ if (!endTagRegex.test(inputValue)) {
188
+ setInputValue(inputValue + ' #');
189
+ }
190
+ };
191
+ const onBlur = () => {
192
+ if (currentInputString) {
193
+ exit();
194
+ synchronizeTags();
195
+ }
196
+ };
197
+ const onTagListBlur = () => {
198
+ setTimeout(() => {
199
+ if (document.activeElement !== inputNode.current) {
200
+ exit();
201
+ synchronizeTags();
202
+ }
203
+ }, 60);
204
+ };
205
+ const handleChange = (e, value, action) => {
206
+ if (action === 'selectOption') {
207
+ onTagAdd(value);
208
+ }
209
+ };
210
+ useEffect(() => {
211
+ let inputString = getInputString(input.value, tags);
212
+ if (document.activeElement === inputNode.current && !endTagRegex.test(inputString)) {
213
+ inputString += ' #';
214
+ }
215
+ setInputValue(inputString);
216
+ }, [input.value, tags]);
217
+ useEffect(() => {
218
+ setCurrentInputString(getCurrentInputString(inputValue, input.value || [], allMenuTags));
219
+ }, [inputValue, input.value, allMenuTags]);
220
+ useEffect(() => {
221
+ if (meta.invalid && !isEditing) {
222
+ setIsEditing(true);
223
+ }
224
+ }, [meta.invalid]);
225
+ useEffect(() => {
226
+ if (activeTag) {
227
+ const activeUpdated = allMenuTags.find(t => t.tagBody.id === activeTag.tagBody.id);
228
+ if (activeUpdated) {
229
+ setActiveTag(activeUpdated);
230
+ }
231
+ }
232
+ }, [allMenuTags]);
233
+ const popperAdapter = useCallback(params => {
234
+ if (currentInputString || !inputNode.current) {
235
+ return React.createElement("div", Object.assign({}, params));
236
+ }
237
+ const coords = getCaretCoordinates(inputNode.current, inputValue.length);
238
+ const position = tagMenuNode.current
239
+ && coords.left > inputNode.current.clientWidth - tagMenuNode.current.clientWidth
240
+ ? { right: 0 }
241
+ : { left: coords.left };
242
+ return (React.createElement("div", { id: "popper", style: Object.assign(Object.assign({}, position), { position: 'absolute', zIndex: 2 }) },
243
+ React.createElement(ClickAwayListener, { onClickAway: onTagListBlur }, params.children)));
244
+ }, [allMenuTags, inputValue, currentInputString, inputNode.current, tagMenuNode.current, input.value]);
245
+ const listboxAdapter = useCallback(params => (React.createElement("div", { className: params.className, ref: tagMenuNode },
246
+ React.createElement(AddTagMenu, { tags: menuTags, handleAdd: onTagAdd, activeTag: activeTag, setActiveTag: setActiveTag, allowParentSelect: allowParentSelect }))), [menuTags, activeTag, setActiveTag, onTagAdd]);
247
+ return (React.createElement("div", { className: className, id: input.name },
248
+ React.createElement("div", { className: clsx('relative', {
249
+ 'pointer-events-none': disabled
250
+ }) },
251
+ React.createElement(Autocomplete, { value: null, open: menuIsOpen, options: filteredOptions, onChange: handleChange, renderOption: renderOption, filterOptions: filterOptionsInner, getOptionLabel: getOptionLabel, PopperComponent: currentInputString ? undefined : popperAdapter, ListboxComponent: currentInputString ? undefined : listboxAdapter, classes: {
252
+ root: classes.root,
253
+ hasPopupIcon: classes.hasPopup,
254
+ hasClearIcon: classes.hasClear,
255
+ listbox: clsx(classes.listbox, fieldClasses.listbox),
256
+ inputRoot: classes.inputWrapper,
257
+ noOptions: 'd-none'
258
+ }, renderInput: (_a) => {
259
+ var { InputLabelProps, InputProps, inputProps } = _a, params = __rest(_a, ["InputLabelProps", "InputProps", "inputProps"]);
260
+ return (React.createElement(EditInPlaceFieldBase, Object.assign({}, params, { name: input.name, value: input.value, error: meta.error, invalid: meta === null || meta === void 0 ? void 0 : meta.invalid, label: label, warning: warning, disabled: disabled, fieldClasses: fieldClasses, shrink: Boolean(label || input.value), labelAdornment: labelAdornment, placeholder: placeholder || 'No value', editIcon: React.createElement(Edit, { fontSize: "inherit" }), InputProps: Object.assign(Object.assign({}, InputProps), { onChange: handleInputChange, onFocus,
261
+ onBlur, inputProps: Object.assign(Object.assign({}, inputProps), { ref: ref => {
262
+ inputProps.ref.current = ref;
263
+ inputNode.current = ref;
264
+ }, value: inputValue }) }), CustomInput: !isEditing
265
+ ? React.createElement(Select, { inputRef: ref => {
266
+ inputProps.ref.current = ref === null || ref === void 0 ? void 0 : ref.node;
267
+ }, onFocus: edit, value: "stub", className: classes.inputWrapper, classes: { select: 'd-flex flex-wrap cursor-text' }, endAdornment: React.createElement(InputAdornment, { position: "end", className: classes.inputEndAdornment },
268
+ React.createElement(Edit, null)), IconComponent: stubComponent },
269
+ React.createElement(MenuItem, { value: "stub" }, InputValueForRender || React.createElement("span", { className: "placeholderContent" }, placeholder || 'No value')))
270
+ : null })));
271
+ }, popupIcon: stubComponent(), disableListWrap: true, openOnFocus: true }))));
272
+ }
273
+ export default TagInputList;
@@ -0,0 +1,6 @@
1
+ export * from './AddTagMenuItem';
2
+ export * from './AddTagMenu';
3
+ export * from './TagInputList';
4
+ export { default as AddTagMenuItem } from './AddTagMenuItem';
5
+ export { default as AddTagMenu } from './AddTagMenu';
6
+ export { default as TagInputList } from './TagInputList';
@@ -0,0 +1,6 @@
1
+ export * from './AddTagMenuItem';
2
+ export * from './AddTagMenu';
3
+ export * from './TagInputList';
4
+ export { default as AddTagMenuItem } from './AddTagMenuItem';
5
+ export { default as AddTagMenu } from './AddTagMenu';
6
+ export { default as TagInputList } from './TagInputList';
@@ -0,0 +1,4 @@
1
+ import { ThemeValues, AppTheme } from '../model';
2
+ export declare const theme: {
3
+ [K in ThemeValues]: Partial<AppTheme>;
4
+ };