@fixefy/fixefy-ui-components 0.3.73 → 0.3.75

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 (197) hide show
  1. package/dist/FxActionsTray/FxActionsTray.js +17 -12
  2. package/dist/FxAggregationsBar/helpers/structureReader.js +6 -4
  3. package/dist/FxAsyncDropdown/FxAsyncDropdown.js +18 -10
  4. package/dist/FxAsyncDropdown/components/CheckboxIcon.js +8 -6
  5. package/dist/FxAsyncDropdown/components/ChipOption.d.ts +1 -1
  6. package/dist/FxAsyncDropdown/components/DeleteButton.js +2 -2
  7. package/dist/FxAsyncDropdown/components/LogoOption.d.ts +1 -1
  8. package/dist/FxAsyncDropdown/components/LogoOption.js +7 -6
  9. package/dist/FxAsyncDropdown/components/TextOption.d.ts +1 -1
  10. package/dist/FxAsyncDropdown/components/TextOption.js +7 -6
  11. package/dist/FxAsyncDropdown/styles/dropdown.styles.js +2 -2
  12. package/dist/FxAvatar/helpers/stringToColor.js +2 -2
  13. package/dist/FxAvatar/styles/avatar.styles.js +77 -36
  14. package/dist/FxButton/styles/button.styles.js +8 -3
  15. package/dist/FxButtonModalWithComponent/FxButtonModalWithComponent.d.ts +1 -1
  16. package/dist/FxButtonModalWithComponent/FxButtonModalWithComponent.js +18 -4
  17. package/dist/FxButtonModalWithMenu/FxButtonModalWithMenu.d.ts +1 -1
  18. package/dist/FxButtonModalWithMenu/FxButtonModalWithMenu.js +11 -4
  19. package/dist/FxChip/FxChip.js +2 -2
  20. package/dist/FxChip/styles/chip.styles.js +11 -6
  21. package/dist/FxDatesProgress/FxDatesProgress.js +8 -7
  22. package/dist/FxDatesProgress/styles/progress.styles.js +8 -2
  23. package/dist/FxGeneralModal/FxGeneralModal.js +12 -5
  24. package/dist/FxGridEmptyState/FxGridEmptyState.js +7 -6
  25. package/dist/FxGridError/FxGridError.js +8 -7
  26. package/dist/FxIcon/FxIcon.d.ts +1 -1
  27. package/dist/FxIcon/FxIcon.js +5 -4
  28. package/dist/FxIcon/content/index.d.ts +2 -2
  29. package/dist/FxIcon/content/lazy_icon.d.ts +1 -1
  30. package/dist/FxIcon/content/lazy_icon.js +4 -3
  31. package/dist/FxMenuItemWithIcon/FxMenuItemWithIcon.js +6 -4
  32. package/dist/FxModal/FxModal.js +4 -3
  33. package/dist/FxModal/styles/modal.style.js +12 -5
  34. package/dist/FxNotes/FxNotes.js +2 -2
  35. package/dist/FxNotes/helpers/stringToColor.js +2 -2
  36. package/dist/FxNotes/styles/notes.styles.js +2 -2
  37. package/dist/FxNumberField/FxNumberField.js +1 -2
  38. package/dist/FxNumberField/styles/number_field.styles.js +7 -2
  39. package/dist/FxObjStaticDropdown/FxObjStaticDropdown.js +27 -16
  40. package/dist/FxObjStaticDropdown/styles/dropdown.styles.js +2 -2
  41. package/dist/FxPopper/Popper.d.ts +2 -1
  42. package/dist/FxPopper/Popper.js +11 -6
  43. package/dist/FxPopper/PopperWithOutside.d.ts +1 -1
  44. package/dist/FxPopper/PopperWithOutside.js +4 -3
  45. package/dist/FxPopper/styles/popper.styles.js +1 -1
  46. package/dist/FxProgressCircle/styles/progress_circle.styles.js +12 -12
  47. package/dist/FxProgressCounter/ProgressCounter.js +10 -9
  48. package/dist/FxProgressCounter/styles/progress_counter.styles.js +12 -7
  49. package/dist/FxScore/FxScore.js +19 -11
  50. package/dist/FxScore/styles/score.styles.js +7 -2
  51. package/dist/FxShowMore/FxShowMore.js +2 -2
  52. package/dist/FxShowMore/styles/show_more.styles.js +16 -7
  53. package/dist/FxSlider/FxSlider.js +2 -2
  54. package/dist/FxStatisticsBar/FxStatisticsBar.js +12 -6
  55. package/dist/FxStatisticsBar/styles/statistics.styles.js +7 -2
  56. package/dist/FxStatusBar/FxStatusBar.js +7 -2
  57. package/dist/FxStatusBar/styles/statusBar.styles.js +22 -15
  58. package/dist/FxStrStaticDropdown/FxStrStaticDropdown.js +26 -16
  59. package/dist/FxStrStaticDropdown/styles/dropdown.styles.js +2 -2
  60. package/dist/FxStyledButton/FxStyledButton.d.ts +2 -2
  61. package/dist/FxStyledButton/FxStyledButton.js +4 -3
  62. package/dist/FxStyledComponents/index.d.ts +1 -1
  63. package/dist/FxStyledComponents/index.js +32 -23
  64. package/dist/FxTabs/FxTabs.js +13 -9
  65. package/dist/FxTag/FxTag.js +2 -2
  66. package/dist/FxTag/index.d.ts +1 -1
  67. package/dist/FxTag/styles/tag.styles.js +10 -4
  68. package/dist/FxTextField/FxTextField.d.ts +1 -1
  69. package/dist/FxTextField/FxTextField.js +10 -7
  70. package/dist/FxTodo/FxTodo.js +5 -5
  71. package/dist/FxToggleButtons/FxToggleButtons.js +6 -5
  72. package/dist/FxUserImage/FxUserImage.js +7 -3
  73. package/dist/index.d.ts +1 -1
  74. package/dist/index.js +3 -3
  75. package/package.json +31 -30
  76. package/dist/FxActionButton/FxActionButton.d.ts +0 -7
  77. package/dist/FxActionButton/FxActionButton.js +0 -82
  78. package/dist/FxActionButton/index.d.ts +0 -1
  79. package/dist/FxActionButton/index.js +0 -11
  80. package/dist/FxActionsTray/styles/actions_tray.styles.d.ts +0 -8
  81. package/dist/FxActionsTray/styles/actions_tray.styles.js +0 -159
  82. package/dist/FxAsyncDropdown/useDropdownStore.d.ts +0 -2
  83. package/dist/FxAsyncDropdown/useDropdownStore.js +0 -57
  84. package/dist/FxFilterActionButton/FxFilterActionButton.d.ts +0 -7
  85. package/dist/FxFilterActionButton/FxFilterActionButton.js +0 -82
  86. package/dist/FxFilterActionButton/index.d.ts +0 -1
  87. package/dist/FxFilterActionButton/index.js +0 -11
  88. package/dist/FxFilterSortButton/FxFilterSortButton.d.ts +0 -7
  89. package/dist/FxFilterSortButton/FxFilterSortButton.js +0 -82
  90. package/dist/FxFilterSortButton/index.d.ts +0 -1
  91. package/dist/FxFilterSortButton/index.js +0 -11
  92. package/dist/FxModalWithButton/FxModalWithButton.d.ts +0 -10
  93. package/dist/FxModalWithButton/FxModalWithButton.js +0 -131
  94. package/dist/FxModalWithButton/index.d.ts +0 -1
  95. package/dist/FxModalWithButton/index.js +0 -11
  96. package/dist/FxModalWithComponent/FxModalWithComponent.d.ts +0 -11
  97. package/dist/FxModalWithComponent/FxModalWithComponent.js +0 -102
  98. package/dist/FxModalWithComponent/index.d.ts +0 -1
  99. package/dist/FxModalWithComponent/index.js +0 -11
  100. package/dist/FxModalWithMenu/FxModalWithMenu.d.ts +0 -14
  101. package/dist/FxModalWithMenu/FxModalWithMenu.js +0 -114
  102. package/dist/FxModalWithMenu/index.d.ts +0 -1
  103. package/dist/FxModalWithMenu/index.js +0 -11
  104. package/dist/FxPopper/styles/makeStyles.d.ts +0 -16
  105. package/dist/FxPopper/styles/makeStyles.js +0 -23
  106. package/dist/FxStaticDropdown/FxStaticDropdown.d.ts +0 -24
  107. package/dist/FxStaticDropdown/FxStaticDropdown.js +0 -368
  108. package/dist/FxStaticDropdown/helpers/helpers.d.ts +0 -2
  109. package/dist/FxStaticDropdown/helpers/helpers.js +0 -22
  110. package/dist/FxStaticDropdown/index.d.ts +0 -1
  111. package/dist/FxStaticDropdown/index.js +0 -11
  112. package/dist/FxStaticDropdown/styles/dropdown.styles.d.ts +0 -3
  113. package/dist/FxStaticDropdown/styles/dropdown.styles.js +0 -190
  114. package/dist/FxWizard/FxWizard/FxWizard.d.ts +0 -6
  115. package/dist/FxWizard/FxWizard/FxWizard.js +0 -42
  116. package/dist/FxWizard/FxWizard/index.d.ts +0 -2
  117. package/dist/FxWizard/FxWizard/index.js +0 -19
  118. package/dist/FxWizard/FxWizard/utils/envHelpers.d.ts +0 -1
  119. package/dist/FxWizard/FxWizard/utils/envHelpers.js +0 -35
  120. package/dist/FxWizard/FxWizard/utils/index.d.ts +0 -1
  121. package/dist/FxWizard/FxWizard/utils/index.js +0 -18
  122. package/dist/FxWizard/pages/wizard/[step].d.ts +0 -9
  123. package/dist/FxWizard/pages/wizard/[step].js +0 -112
  124. package/dist/FxWizard/pages/wizard/index.d.ts +0 -1
  125. package/dist/FxWizard/pages/wizard/index.js +0 -18
  126. package/dist/src/FxActionsTray/FxActionsTray.js +0 -351
  127. package/dist/src/FxActionsTray/index.js +0 -19
  128. package/dist/src/FxActionsTray/styles/actions_tray.styles.js +0 -159
  129. package/dist/src/FxAggregationsBar/FxAggregations.js +0 -41
  130. package/dist/src/FxAggregationsBar/helpers/structureReader.js +0 -78
  131. package/dist/src/FxAggregationsBar/index.js +0 -22
  132. package/dist/src/FxAggregationsBar/operations/query.js +0 -73
  133. package/dist/src/FxAsyncDropdown/FxAsyncDropdown.js +0 -628
  134. package/dist/src/FxAsyncDropdown/helpers/helpers.js +0 -161
  135. package/dist/src/FxAsyncDropdown/index.js +0 -25
  136. package/dist/src/FxAsyncDropdown/styles/dropdown.styles.js +0 -228
  137. package/dist/src/FxAvatar/FxAvatar.js +0 -145
  138. package/dist/src/FxAvatar/helpers/stringToColor.js +0 -23
  139. package/dist/src/FxAvatar/index.js +0 -22
  140. package/dist/src/FxAvatar/styles/avatar.styles.js +0 -192
  141. package/dist/src/FxButton/FxButton.js +0 -106
  142. package/dist/src/FxButton/index.js +0 -19
  143. package/dist/src/FxButton/styles/button.styles.js +0 -23
  144. package/dist/src/FxChip/FxChip.js +0 -45
  145. package/dist/src/FxChip/index.js +0 -19
  146. package/dist/src/FxChip/styles/chip.styles.js +0 -61
  147. package/dist/src/FxFilterSortButton/FxFilterSortButton.js +0 -82
  148. package/dist/src/FxFilterSortButton/index.js +0 -11
  149. package/dist/src/FxIcon/FxIcon.js +0 -107
  150. package/dist/src/FxIcon/content/dynamic_icon.js +0 -20
  151. package/dist/src/FxIcon/content/index.js +0 -20
  152. package/dist/src/FxIcon/content/lazy_icon.js +0 -137
  153. package/dist/src/FxIcon/index.js +0 -11
  154. package/dist/src/FxModal/FxModal.js +0 -170
  155. package/dist/src/FxModal/index.js +0 -19
  156. package/dist/src/FxModal/styles/modal.style.js +0 -59
  157. package/dist/src/FxModalWithButton/FxModalWithButton.js +0 -94
  158. package/dist/src/FxModalWithButton/index.js +0 -11
  159. package/dist/src/FxNotes/FxNotes.js +0 -216
  160. package/dist/src/FxNotes/helpers/stringToColor.js +0 -26
  161. package/dist/src/FxNotes/index.js +0 -22
  162. package/dist/src/FxNotes/operations/queries.js +0 -35
  163. package/dist/src/FxNotes/styles/notes.styles.js +0 -168
  164. package/dist/src/FxNumberField/FxNumberField.js +0 -109
  165. package/dist/src/FxNumberField/index.js +0 -19
  166. package/dist/src/FxNumberField/styles/number_field.styles.js +0 -94
  167. package/dist/src/FxProgressCircle/FxProgressCircle.js +0 -65
  168. package/dist/src/FxProgressCircle/index.js +0 -19
  169. package/dist/src/FxProgressCircle/styles/progress_circle.styles.js +0 -106
  170. package/dist/src/FxProgressCounter/ProgressCounter.js +0 -168
  171. package/dist/src/FxProgressCounter/index.js +0 -19
  172. package/dist/src/FxProgressCounter/styles/progress_counter.styles.js +0 -61
  173. package/dist/src/FxScore/FxScore.js +0 -207
  174. package/dist/src/FxScore/index.js +0 -19
  175. package/dist/src/FxScore/styles/score.styles.js +0 -97
  176. package/dist/src/FxShowMore/FxShowMore.js +0 -80
  177. package/dist/src/FxShowMore/index.js +0 -19
  178. package/dist/src/FxShowMore/styles/show_more.styles.js +0 -134
  179. package/dist/src/FxSlider/FxSlider.js +0 -49
  180. package/dist/src/FxSlider/index.js +0 -19
  181. package/dist/src/FxStatisticsBar/FxStatisticsBar.js +0 -191
  182. package/dist/src/FxStatisticsBar/index.js +0 -19
  183. package/dist/src/FxStatisticsBar/styles/statistics.styles.js +0 -98
  184. package/dist/src/FxStatusBar/FxStatusBar.js +0 -143
  185. package/dist/src/FxStatusBar/helpers/constants.js +0 -22
  186. package/dist/src/FxStatusBar/index.js +0 -22
  187. package/dist/src/FxStatusBar/styles/statusBar.styles.js +0 -131
  188. package/dist/src/FxStyledComponents/index.js +0 -310
  189. package/dist/src/FxTag/FxTag.js +0 -41
  190. package/dist/src/FxTag/index.js +0 -19
  191. package/dist/src/FxTag/styles/tag.styles.js +0 -100
  192. package/dist/src/FxTextField/FxTextField.js +0 -208
  193. package/dist/src/FxTextField/index.js +0 -19
  194. package/dist/src/FxTodo/FxTodo.js +0 -95
  195. package/dist/src/FxTodo/index.js +0 -22
  196. package/dist/src/FxTodo/styles/todo.styles.js +0 -183
  197. package/dist/src/index.js +0 -215
@@ -1,628 +0,0 @@
1
- // @ts-ignore
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "FxAsyncDropdown", {
7
- enumerable: true,
8
- get: function() {
9
- return FxAsyncDropdown;
10
- }
11
- });
12
- const _jsxruntime = require("react/jsx-runtime");
13
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
14
- const _iconsmaterial = require("@mui/icons-material");
15
- const _material = require("@mui/material");
16
- const _FxChip = require("../FxChip");
17
- const _FxIcon = require("../FxIcon");
18
- const _graphqltag = require("graphql-tag");
19
- const _dropdownstyles = require("./styles/dropdown.styles");
20
- const _helpers = require("./helpers/helpers");
21
- const _client = require("@apollo/client");
22
- const _nookies = require("nookies");
23
- function _define_property(obj, key, value) {
24
- if (key in obj) {
25
- Object.defineProperty(obj, key, {
26
- value: value,
27
- enumerable: true,
28
- configurable: true,
29
- writable: true
30
- });
31
- } else {
32
- obj[key] = value;
33
- }
34
- return obj;
35
- }
36
- function _getRequireWildcardCache(nodeInterop) {
37
- if (typeof WeakMap !== "function") return null;
38
- var cacheBabelInterop = new WeakMap();
39
- var cacheNodeInterop = new WeakMap();
40
- return (_getRequireWildcardCache = function(nodeInterop) {
41
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
- })(nodeInterop);
43
- }
44
- function _interop_require_wildcard(obj, nodeInterop) {
45
- if (!nodeInterop && obj && obj.__esModule) {
46
- return obj;
47
- }
48
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
- return {
50
- default: obj
51
- };
52
- }
53
- var cache = _getRequireWildcardCache(nodeInterop);
54
- if (cache && cache.has(obj)) {
55
- return cache.get(obj);
56
- }
57
- var newObj = {
58
- __proto__: null
59
- };
60
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
- for(var key in obj){
62
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
- if (desc && (desc.get || desc.set)) {
65
- Object.defineProperty(newObj, key, desc);
66
- } else {
67
- newObj[key] = obj[key];
68
- }
69
- }
70
- }
71
- newObj.default = obj;
72
- if (cache) {
73
- cache.set(obj, newObj);
74
- }
75
- return newObj;
76
- }
77
- function _object_spread(target) {
78
- for(var i = 1; i < arguments.length; i++){
79
- var source = arguments[i] != null ? arguments[i] : {};
80
- var ownKeys = Object.keys(source);
81
- if (typeof Object.getOwnPropertySymbols === "function") {
82
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
83
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
84
- }));
85
- }
86
- ownKeys.forEach(function(key) {
87
- _define_property(target, key, source[key]);
88
- });
89
- }
90
- return target;
91
- }
92
- function ownKeys(object, enumerableOnly) {
93
- var keys = Object.keys(object);
94
- if (Object.getOwnPropertySymbols) {
95
- var symbols = Object.getOwnPropertySymbols(object);
96
- if (enumerableOnly) {
97
- symbols = symbols.filter(function(sym) {
98
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
99
- });
100
- }
101
- keys.push.apply(keys, symbols);
102
- }
103
- return keys;
104
- }
105
- function _object_spread_props(target, source) {
106
- source = source != null ? source : {};
107
- if (Object.getOwnPropertyDescriptors) {
108
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
109
- } else {
110
- ownKeys(Object(source)).forEach(function(key) {
111
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
112
- });
113
- }
114
- return target;
115
- }
116
- const icon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBoxOutlineBlank, {
117
- fontSize: "small"
118
- });
119
- const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox, {
120
- fontSize: "small"
121
- });
122
- const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRef)=>{
123
- var _props_styles;
124
- const { onAdd, onRemoveOne, onRemoveAll, fetcher, disabled, type = 'text', variables, search_path, modal_type, multiple, name, query } = props;
125
- const ref = (0, _react.useRef)(null);
126
- const theme = (0, _material.useTheme)();
127
- const [displayed, setDisplayed] = (0, _react.useState)(multiple ? [] : '');
128
- const [options, setOptions] = (0, _react.useState)([]);
129
- const [reason, setReason] = (0, _react.useState)('init');
130
- const [isLastPage, setIsLastPage] = (0, _react.useState)(false);
131
- const [searchValue, setSearchValue] = (0, _react.useState)(null);
132
- const [page, setPage] = (0, _react.useState)(1);
133
- const [prevPage, setPrevPage] = (0, _react.useState)(0);
134
- const pageSize = 20;
135
- const { method_name } = variables;
136
- const ws = (0, _nookies.parseCookies)().ws;
137
- const isLocal = fetcher.query.loc;
138
- const getWhere = ()=>{
139
- if (variables.method_name == 'workspace') {
140
- return searchValue ? _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
141
- _id: ws,
142
- [search_path]: {
143
- $regex: searchValue
144
- }
145
- }) : _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
146
- _id: ws
147
- });
148
- } else {
149
- return searchValue ? _object_spread_props(_object_spread({}, fetcher.queryOptions.variables.where), {
150
- [search_path]: {
151
- $regex: searchValue
152
- }
153
- }) : _object_spread({}, fetcher.queryOptions.variables.where);
154
- }
155
- };
156
- const [fetch, { data, loading }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(isLocal ? fetcher.query.loc.source.body : fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
157
- variables: _object_spread_props(_object_spread({}, fetcher.queryOptions.variables), {
158
- where: getWhere(),
159
- skip: page * pageSize - pageSize,
160
- limit: pageSize
161
- })
162
- }));
163
- (0, _react.useEffect)(()=>{
164
- if (!disabled) {
165
- fetch();
166
- }
167
- }, []);
168
- (0, _react.useEffect)(()=>{
169
- const storedData = sessionStorage.getItem(`dropdown-${query}`);
170
- if (storedData) {
171
- const parsedData = JSON.parse(storedData);
172
- const items = parsedData[name];
173
- if (items) {
174
- multiple ? setDisplayed([
175
- ...items
176
- ]) : setDisplayed(items[0]);
177
- }
178
- }
179
- }, [
180
- query,
181
- name
182
- ]);
183
- (0, _react.useEffect)(()=>{
184
- if (data && !isLastPage && prevPage < page) {
185
- //raaya todo: this is too messy clean it
186
- const newOptions = variables.method_name == 'workspace' ? data.workspace[search_path === null || search_path === void 0 ? void 0 : search_path.split('.')[1]] : data[method_name];
187
- if (newOptions == null || newOptions.length < pageSize) {
188
- setIsLastPage(true);
189
- }
190
- if (reason === 'searched' || reason === 'init') {
191
- setOptions(newOptions);
192
- } else if (reason === 'loaded more') {
193
- setOptions((prevOptions)=>[
194
- ...prevOptions,
195
- ...newOptions
196
- ]);
197
- }
198
- }
199
- }, [
200
- data,
201
- reason
202
- ]);
203
- const handleSearch = (e)=>{
204
- setSearchValue(e.target.value);
205
- setReason('searched');
206
- setPage(1);
207
- setPrevPage(0);
208
- setIsLastPage(false);
209
- };
210
- const addToStoredDisplayed = (option)=>{
211
- const prevStored = sessionStorage.getItem(`dropdown-${query}`);
212
- let data = prevStored ? JSON.parse(prevStored) : {};
213
- if (data[name]) {
214
- if (multiple) {
215
- data[name] = [
216
- ...data[name],
217
- option
218
- ];
219
- } else {
220
- data[name] = [
221
- option
222
- ];
223
- }
224
- } else {
225
- data[name] = [
226
- option
227
- ];
228
- }
229
- sessionStorage.setItem(`dropdown-${query}`, JSON.stringify(data));
230
- };
231
- const removeOneFromStoredDisplayed = (option)=>{
232
- let storedDisplayed = sessionStorage.getItem(`dropdown-${query}`);
233
- if (storedDisplayed) {
234
- storedDisplayed = JSON.parse(storedDisplayed);
235
- if (multiple) {
236
- const newDisplayed = storedDisplayed[name].filter((opt)=>{
237
- if (search_path.includes('workspace')) {
238
- return opt['title'] !== option['title'];
239
- } else {
240
- return opt[search_path] !== option[search_path];
241
- }
242
- });
243
- storedDisplayed[name] = newDisplayed;
244
- } else {
245
- delete storedDisplayed[name];
246
- }
247
- sessionStorage.setItem(`dropdown-${query}`, JSON.stringify(storedDisplayed));
248
- }
249
- };
250
- const handleOptionClick = (option)=>{
251
- let clicked = getClicked(option);
252
- switch(multiple){
253
- case true:
254
- if (displayed.map((item)=>{
255
- if (search_path.includes('workspace')) {
256
- return item['title'];
257
- } else {
258
- return item[search_path];
259
- }
260
- }).includes(clicked)) {
261
- deleteOneItem(option);
262
- } else {
263
- onAdd && onAdd(option);
264
- setDisplayed((prev)=>[
265
- ...prev,
266
- option
267
- ]);
268
- addToStoredDisplayed(option);
269
- }
270
- break;
271
- default:
272
- setDisplayed(option);
273
- onAdd && onAdd(option);
274
- addToStoredDisplayed(option);
275
- }
276
- };
277
- const deleteOneItem = (item)=>{
278
- if (multiple) {
279
- if (search_path.includes('workspace')) {
280
- setDisplayed((prev)=>prev.filter((val)=>val['title'] !== item['title']));
281
- } else {
282
- setDisplayed((prev)=>prev.filter((val)=>val[search_path] !== item[search_path]));
283
- }
284
- } else {
285
- setDisplayed('');
286
- }
287
- onRemoveOne && onRemoveOne(item);
288
- removeOneFromStoredDisplayed(item);
289
- };
290
- const isChecked = (option)=>{
291
- const clicked = getClicked(option);
292
- if (typeof displayed === 'string') {
293
- return false;
294
- } else {
295
- if (multiple) {
296
- return displayed.map((item)=>{
297
- if (search_path.includes('workspace')) {
298
- return item['title'];
299
- } else {
300
- return item[search_path];
301
- }
302
- }).includes(clicked);
303
- } else {
304
- return displayed[search_path] === clicked;
305
- }
306
- }
307
- };
308
- const handleListOptions = ()=>{
309
- switch(type){
310
- case 'checkbox':
311
- {
312
- return options.map((option)=>{
313
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
314
- onClick: ()=>{
315
- handleOptionClick(option);
316
- },
317
- children: [
318
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
319
- icon: icon,
320
- checked: isChecked(option),
321
- checkedIcon: checkedIcon,
322
- sx: {
323
- mr: 1,
324
- minWidth: 24,
325
- minHeight: 24,
326
- p: 0,
327
- ['& svg']: {
328
- fill: theme.palette.primary.light
329
- }
330
- }
331
- }),
332
- getValueByModalType(option, 'list')
333
- ]
334
- }, option._id);
335
- });
336
- }
337
- case 'text':
338
- default:
339
- {
340
- return options.map((option)=>{
341
- return /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
342
- onClick: ()=>{
343
- handleOptionClick(option);
344
- },
345
- children: getValueByModalType(option, 'list')
346
- }, option._id);
347
- });
348
- }
349
- }
350
- };
351
- (0, _react.useImperativeHandle)(parentRef, ()=>({
352
- clearDDL: ()=>{
353
- var //@ts-ignore
354
- _getClearProps;
355
- (_getClearProps = getClearProps()) === null || _getClearProps === void 0 ? void 0 : _getClearProps.onClick(null);
356
- }
357
- }));
358
- const loadMore = ()=>{
359
- setPage((prevPage)=>prevPage + 1);
360
- setPrevPage((prevPage)=>prevPage + 1);
361
- };
362
- const getClicked = (option)=>{
363
- if (option != '') {
364
- let clicked = (0, _helpers.getJPart)(option, search_path, 0) || option.title;
365
- if (clicked !== null && typeof clicked === 'object') {
366
- clicked = clicked[0];
367
- }
368
- return clicked;
369
- }
370
- return null;
371
- };
372
- const getCurrentValues = ()=>{
373
- let rv = null;
374
- switch(multiple){
375
- case true:
376
- rv = getMultipleDisplayedValues();
377
- break;
378
- case false:
379
- default:
380
- rv = getValueByModalType(displayed, 'displayed');
381
- break;
382
- }
383
- return rv;
384
- };
385
- const DeleteButton = ({ option })=>{
386
- let rv = null;
387
- switch(multiple){
388
- case true:
389
- if ((displayed === null || displayed === void 0 ? void 0 : displayed.length) > 0) {
390
- rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
391
- onClick: ()=>{
392
- deleteOneItem(option);
393
- },
394
- children: "x"
395
- });
396
- }
397
- break;
398
- case false:
399
- default:
400
- if (displayed[search_path] === getClicked(option)) {
401
- rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
402
- onClick: ()=>{
403
- deleteOneItem(option);
404
- },
405
- children: "x"
406
- });
407
- }
408
- break;
409
- }
410
- return rv;
411
- };
412
- const getValueByModalType = (option, location)=>{
413
- let rv = null;
414
- const clicked = getClicked(option);
415
- switch(modal_type){
416
- case 'chip':
417
- rv = location === 'displayed' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
418
- status: clicked,
419
- label: (0, _helpers.titleCase)(clicked),
420
- variant: "outlined",
421
- onDelete: ()=>{
422
- deleteOneItem(option);
423
- }
424
- }, option._id) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
425
- status: clicked,
426
- label: (0, _helpers.titleCase)(clicked),
427
- variant: "outlined"
428
- }, option._id);
429
- break;
430
- case 'logo':
431
- rv = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
432
- sx: {
433
- display: 'flex',
434
- gap: 1,
435
- color: 'grey',
436
- cursor: 'pointer',
437
- width: '100%'
438
- },
439
- children: [
440
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
441
- style: {
442
- width: '70px'
443
- },
444
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
445
- icon: `companies/${option.logo}`,
446
- width: 70,
447
- height: 16
448
- })
449
- }),
450
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
451
- sx: {
452
- width: '170px',
453
- overflow: 'hidden',
454
- display: 'flex',
455
- justifyContent: 'flex-start',
456
- gap: 1
457
- },
458
- children: [
459
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
460
- variant: "subtitle2",
461
- color: theme.palette.typography.title,
462
- children: (0, _helpers.titleCase)(clicked)
463
- }),
464
- location === 'displayed' && /*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
465
- option: option
466
- })
467
- ]
468
- }),
469
- location === 'list' && isChecked(option) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
470
- width: 16,
471
- height: 16,
472
- icon: 'filters/chosen_icon.svg'
473
- })
474
- ]
475
- }, option._id);
476
- break;
477
- case 'text':
478
- default:
479
- rv = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
480
- sx: {
481
- display: 'flex',
482
- justifyContent: 'space-between',
483
- width: '100%',
484
- maxWidth: '250px',
485
- gap: 1,
486
- color: 'grey',
487
- cursor: 'pointer'
488
- },
489
- children: [
490
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
491
- sx: {
492
- width: '210px',
493
- overflow: 'hidden',
494
- display: 'flex',
495
- justifyContent: 'flex-start',
496
- gap: 1
497
- },
498
- children: [
499
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
500
- variant: "subtitle2",
501
- color: theme.palette.typography.title,
502
- children: (0, _helpers.titleCase)(clicked)
503
- }),
504
- location === 'displayed' && /*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
505
- option: option
506
- })
507
- ]
508
- }),
509
- location === 'list' && isChecked(option) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
510
- width: 16,
511
- height: 16,
512
- icon: 'filters/chosen_icon.svg'
513
- })
514
- ]
515
- }, option._id);
516
- break;
517
- }
518
- return rv;
519
- };
520
- const getMultipleDisplayedValues = ()=>{
521
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
522
- direction: 'row',
523
- sx: {
524
- maxWidth: 270,
525
- minWidth: 270,
526
- display: 'flex',
527
- justifyContent: 'space-between'
528
- },
529
- children: [
530
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
531
- direction: 'row',
532
- sx: {
533
- overflow: 'hidden',
534
- flexWrap: 'wrap',
535
- gap: 1
536
- },
537
- children: displayed.map((item)=>{
538
- return getValueByModalType(item, 'displayed');
539
- })
540
- }),
541
- (displayed === null || displayed === void 0 ? void 0 : displayed.length) > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
542
- sx: {
543
- minWidth: '20px',
544
- maxWidth: '20px',
545
- cursor: 'pointer'
546
- },
547
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
548
- onClick: ()=>{
549
- setDisplayed([]);
550
- onRemoveAll && onRemoveAll();
551
- sessionStorage.removeItem(`dropdown-${query}`);
552
- },
553
- icon: `filters/remove_all_button.svg`,
554
- width: 16,
555
- height: 16
556
- })
557
- })
558
- ]
559
- });
560
- };
561
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.Root, {
562
- sx: {
563
- background: '#FFFFFF',
564
- padding: '0 16px'
565
- },
566
- children: [
567
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
568
- children: [
569
- getCurrentValues(),
570
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.InputWrapper, {
571
- disabled: disabled,
572
- sx: {
573
- width: '100%',
574
- border: 'none !important',
575
- outline: 'none !important'
576
- },
577
- children: [
578
- /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
579
- style: {
580
- border: 'none',
581
- outline: 'none'
582
- },
583
- autoFocus: true,
584
- placeholder: "Select an option...",
585
- onChange: (e)=>{
586
- handleSearch(e);
587
- }
588
- }),
589
- loading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.Loading, {
590
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {})
591
- })
592
- ]
593
- })
594
- ]
595
- }),
596
- options && (options === null || options === void 0 ? void 0 : options.length) > 0 && !disabled ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.StyledListBox, {
597
- sx: _object_spread_props(_object_spread({}, (_props_styles = props.styles) === null || _props_styles === void 0 ? void 0 : _props_styles.menuSx), {
598
- '&::-webkit-scrollbar': {
599
- width: '8px',
600
- backgroundColor: 'transparent'
601
- },
602
- '&::-webkit-scrollbar-thumb': {
603
- backgroundColor: '#8B9092',
604
- borderRadius: '8px'
605
- },
606
- // To support Firefox
607
- scrollbarWidth: 'thin',
608
- scrollbarColor: '#8B9092 transparent',
609
- maxHeight: '300px',
610
- overflowY: 'auto'
611
- }),
612
- ref: ref,
613
- children: [
614
- handleListOptions(),
615
- !isLastPage && /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
616
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
617
- onClick: ()=>{
618
- setReason('loaded more');
619
- loadMore();
620
- },
621
- children: "load more"
622
- })
623
- })
624
- ]
625
- }) : null
626
- ]
627
- });
628
- });