@fixefy/fixefy-ui-components 0.3.31 → 0.3.33

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 (118) hide show
  1. package/dist/FxActionButton/FxActionButton.d.ts +7 -0
  2. package/dist/FxActionButton/FxActionButton.js +82 -0
  3. package/dist/FxActionButton/index.d.ts +1 -0
  4. package/dist/FxActionButton/index.js +11 -0
  5. package/dist/FxActionsTray/styles/actions_tray.styles.d.ts +8 -0
  6. package/dist/FxActionsTray/styles/actions_tray.styles.js +159 -0
  7. package/dist/FxFilterActionButton/FxFilterActionButton.d.ts +7 -0
  8. package/dist/FxFilterActionButton/FxFilterActionButton.js +82 -0
  9. package/dist/FxFilterActionButton/index.d.ts +1 -0
  10. package/dist/FxFilterActionButton/index.js +11 -0
  11. package/dist/FxFilterSortButton/FxFilterSortButton.d.ts +7 -0
  12. package/dist/FxFilterSortButton/FxFilterSortButton.js +82 -0
  13. package/dist/FxFilterSortButton/index.d.ts +1 -0
  14. package/dist/FxFilterSortButton/index.js +11 -0
  15. package/dist/FxModalWithButton/FxModalWithButton.d.ts +10 -0
  16. package/dist/FxModalWithButton/FxModalWithButton.js +131 -0
  17. package/dist/FxModalWithButton/index.d.ts +1 -0
  18. package/dist/FxModalWithButton/index.js +11 -0
  19. package/dist/FxModalWithComponent/FxModalWithComponent.d.ts +11 -0
  20. package/dist/FxModalWithComponent/FxModalWithComponent.js +102 -0
  21. package/dist/FxModalWithComponent/index.d.ts +1 -0
  22. package/dist/FxModalWithComponent/index.js +11 -0
  23. package/dist/FxModalWithMenu/FxModalWithMenu.d.ts +14 -0
  24. package/dist/FxModalWithMenu/FxModalWithMenu.js +114 -0
  25. package/dist/FxModalWithMenu/index.d.ts +1 -0
  26. package/dist/FxModalWithMenu/index.js +11 -0
  27. package/dist/FxPopper/styles/makeStyles.d.ts +16 -0
  28. package/dist/FxPopper/styles/makeStyles.js +23 -0
  29. package/dist/FxWizard/FxWizard/FxWizard.d.ts +6 -0
  30. package/dist/FxWizard/FxWizard/FxWizard.js +42 -0
  31. package/dist/FxWizard/FxWizard/index.d.ts +2 -0
  32. package/dist/FxWizard/FxWizard/index.js +19 -0
  33. package/dist/FxWizard/FxWizard/utils/envHelpers.d.ts +1 -0
  34. package/dist/FxWizard/FxWizard/utils/envHelpers.js +35 -0
  35. package/dist/FxWizard/FxWizard/utils/index.d.ts +1 -0
  36. package/dist/FxWizard/FxWizard/utils/index.js +18 -0
  37. package/dist/FxWizard/pages/wizard/[step].d.ts +9 -0
  38. package/dist/FxWizard/pages/wizard/[step].js +112 -0
  39. package/dist/FxWizard/pages/wizard/index.d.ts +1 -0
  40. package/dist/FxWizard/pages/wizard/index.js +18 -0
  41. package/dist/index.d.ts +0 -1
  42. package/dist/index.js +0 -4
  43. package/dist/src/FxActionsTray/FxActionsTray.js +351 -0
  44. package/dist/src/FxActionsTray/index.js +19 -0
  45. package/dist/src/FxActionsTray/styles/actions_tray.styles.js +159 -0
  46. package/dist/src/FxAggregationsBar/FxAggregations.js +41 -0
  47. package/dist/src/FxAggregationsBar/helpers/structureReader.js +78 -0
  48. package/dist/src/FxAggregationsBar/index.js +22 -0
  49. package/dist/src/FxAggregationsBar/operations/query.js +73 -0
  50. package/dist/src/FxAsyncDropdown/FxAsyncDropdown.js +628 -0
  51. package/dist/src/FxAsyncDropdown/helpers/helpers.js +161 -0
  52. package/dist/src/FxAsyncDropdown/index.js +25 -0
  53. package/dist/src/FxAsyncDropdown/styles/dropdown.styles.js +228 -0
  54. package/dist/src/FxAvatar/FxAvatar.js +145 -0
  55. package/dist/src/FxAvatar/helpers/stringToColor.js +23 -0
  56. package/dist/src/FxAvatar/index.js +22 -0
  57. package/dist/src/FxAvatar/styles/avatar.styles.js +192 -0
  58. package/dist/src/FxButton/FxButton.js +106 -0
  59. package/dist/src/FxButton/index.js +19 -0
  60. package/dist/src/FxButton/styles/button.styles.js +23 -0
  61. package/dist/src/FxChip/FxChip.js +45 -0
  62. package/dist/src/FxChip/index.js +19 -0
  63. package/dist/src/FxChip/styles/chip.styles.js +61 -0
  64. package/dist/src/FxFilterSortButton/FxFilterSortButton.js +82 -0
  65. package/dist/src/FxFilterSortButton/index.js +11 -0
  66. package/dist/src/FxIcon/FxIcon.js +107 -0
  67. package/dist/src/FxIcon/content/dynamic_icon.js +20 -0
  68. package/dist/src/FxIcon/content/index.js +20 -0
  69. package/dist/src/FxIcon/content/lazy_icon.js +137 -0
  70. package/dist/{FxCheckbox → src/FxIcon}/index.js +3 -3
  71. package/dist/src/FxModal/FxModal.js +170 -0
  72. package/dist/src/FxModal/index.js +19 -0
  73. package/dist/src/FxModal/styles/modal.style.js +59 -0
  74. package/dist/src/FxModalWithButton/FxModalWithButton.js +94 -0
  75. package/dist/src/FxModalWithButton/index.js +11 -0
  76. package/dist/src/FxNotes/FxNotes.js +216 -0
  77. package/dist/src/FxNotes/helpers/stringToColor.js +26 -0
  78. package/dist/src/FxNotes/index.js +22 -0
  79. package/dist/src/FxNotes/operations/queries.js +35 -0
  80. package/dist/src/FxNotes/styles/notes.styles.js +168 -0
  81. package/dist/src/FxNumberField/FxNumberField.js +109 -0
  82. package/dist/src/FxNumberField/index.js +19 -0
  83. package/dist/src/FxNumberField/styles/number_field.styles.js +94 -0
  84. package/dist/src/FxProgressCircle/FxProgressCircle.js +65 -0
  85. package/dist/src/FxProgressCircle/index.js +19 -0
  86. package/dist/src/FxProgressCircle/styles/progress_circle.styles.js +106 -0
  87. package/dist/src/FxProgressCounter/ProgressCounter.js +168 -0
  88. package/dist/src/FxProgressCounter/index.js +19 -0
  89. package/dist/src/FxProgressCounter/styles/progress_counter.styles.js +61 -0
  90. package/dist/src/FxScore/FxScore.js +207 -0
  91. package/dist/src/FxScore/index.js +19 -0
  92. package/dist/src/FxScore/styles/score.styles.js +97 -0
  93. package/dist/src/FxShowMore/FxShowMore.js +80 -0
  94. package/dist/src/FxShowMore/index.js +19 -0
  95. package/dist/src/FxShowMore/styles/show_more.styles.js +134 -0
  96. package/dist/src/FxSlider/FxSlider.js +49 -0
  97. package/dist/src/FxSlider/index.js +19 -0
  98. package/dist/src/FxStatisticsBar/FxStatisticsBar.js +191 -0
  99. package/dist/src/FxStatisticsBar/index.js +19 -0
  100. package/dist/src/FxStatisticsBar/styles/statistics.styles.js +98 -0
  101. package/dist/src/FxStatusBar/FxStatusBar.js +143 -0
  102. package/dist/src/FxStatusBar/helpers/constants.js +22 -0
  103. package/dist/src/FxStatusBar/index.js +22 -0
  104. package/dist/src/FxStatusBar/styles/statusBar.styles.js +131 -0
  105. package/dist/src/FxStyledComponents/index.js +310 -0
  106. package/dist/src/FxTag/FxTag.js +41 -0
  107. package/dist/src/FxTag/index.js +19 -0
  108. package/dist/src/FxTag/styles/tag.styles.js +100 -0
  109. package/dist/src/FxTextField/FxTextField.js +208 -0
  110. package/dist/src/FxTextField/index.js +19 -0
  111. package/dist/src/FxTodo/FxTodo.js +95 -0
  112. package/dist/src/FxTodo/index.js +22 -0
  113. package/dist/src/FxTodo/styles/todo.styles.js +183 -0
  114. package/dist/src/index.js +215 -0
  115. package/package.json +1 -1
  116. package/dist/FxCheckbox/FxCheckbox.d.ts +0 -9
  117. package/dist/FxCheckbox/FxCheckbox.js +0 -76
  118. package/dist/FxCheckbox/index.d.ts +0 -1
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "STRUCTURES", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return STRUCTURES;
9
+ }
10
+ });
11
+ const _graphqltag = require("graphql-tag");
12
+ const STRUCTURES = (0, _graphqltag.gql)`
13
+ query STRUCTURES {
14
+ structure(where: { name: "aggregations_invoice" }) {
15
+ _id
16
+ bundle_name
17
+ name
18
+ title
19
+ type
20
+ input_type {
21
+ name
22
+ value
23
+ }
24
+ readable_id
25
+ extended {
26
+ format
27
+ gql_operation
28
+ title_path
29
+ object_path
30
+ filter
31
+ variables
32
+ }
33
+ children(sort: { index: 1 }) {
34
+ _id
35
+ name
36
+ title
37
+ type
38
+ input_type {
39
+ name
40
+ value
41
+ }
42
+ readable_id
43
+ extended {
44
+ format
45
+ gql_operation
46
+ title_path
47
+ object_path
48
+ filter
49
+ variables
50
+ }
51
+ children(sort: { index: 1 }) {
52
+ _id
53
+ name
54
+ title
55
+ type
56
+ input_type {
57
+ name
58
+ value
59
+ }
60
+ readable_id
61
+ extended {
62
+ format
63
+ gql_operation
64
+ title_path
65
+ object_path
66
+ filter
67
+ variables
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ `;
@@ -0,0 +1,628 @@
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
+ });