@fixefy/fixefy-ui-components 0.2.14 → 0.2.16
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/FxAsyncDropdown/FxAsyncDropdown.js +112 -126
- package/package.json +1 -1
|
@@ -120,7 +120,7 @@ const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox,
|
|
|
120
120
|
fontSize: "small"
|
|
121
121
|
});
|
|
122
122
|
const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
123
|
-
const { onAdd, onRemoveOne, onRemoveAll, fetcher, disabled, type = 'text', variables, search_path, modal_type, multiple, name, query, isInitialOpen, placeholder } = props;
|
|
123
|
+
const { onAdd, onRemoveOne, onRemoveAll, fetcher, disabled, type = 'text', variables, search_path, modal_type, multiple, name, query, isInitialOpen, placeholder, title_path } = props;
|
|
124
124
|
const ref = (0, _react.useRef)(null);
|
|
125
125
|
const theme = (0, _material.useTheme)();
|
|
126
126
|
const [displayed, setDisplayed] = (0, _react.useState)(multiple ? [] : '');
|
|
@@ -234,11 +234,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
234
234
|
storedDisplayed = JSON.parse(storedDisplayed);
|
|
235
235
|
if (multiple) {
|
|
236
236
|
const newDisplayed = storedDisplayed[name].filter((opt)=>{
|
|
237
|
-
|
|
238
|
-
return opt['title'] !== option['title'];
|
|
239
|
-
} else {
|
|
240
|
-
return opt[search_path] !== option[search_path];
|
|
241
|
-
}
|
|
237
|
+
opt[title_path] !== option[title_path];
|
|
242
238
|
});
|
|
243
239
|
storedDisplayed[name] = newDisplayed;
|
|
244
240
|
} else {
|
|
@@ -252,11 +248,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
252
248
|
switch(multiple){
|
|
253
249
|
case true:
|
|
254
250
|
if (displayed.map((item)=>{
|
|
255
|
-
|
|
256
|
-
return item['title'];
|
|
257
|
-
} else {
|
|
258
|
-
return item[search_path];
|
|
259
|
-
}
|
|
251
|
+
return item[title_path];
|
|
260
252
|
}).includes(clicked)) {
|
|
261
253
|
deleteOneItem(option);
|
|
262
254
|
} else {
|
|
@@ -276,11 +268,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
276
268
|
};
|
|
277
269
|
const deleteOneItem = (item)=>{
|
|
278
270
|
if (multiple) {
|
|
279
|
-
|
|
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
|
-
}
|
|
271
|
+
setDisplayed((prev)=>prev.filter((val)=>val[title_path] !== item[title_path]));
|
|
284
272
|
} else {
|
|
285
273
|
setDisplayed('');
|
|
286
274
|
}
|
|
@@ -294,11 +282,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
294
282
|
} else {
|
|
295
283
|
if (multiple) {
|
|
296
284
|
return displayed.map((item)=>{
|
|
297
|
-
|
|
298
|
-
return item['title'];
|
|
299
|
-
} else {
|
|
300
|
-
return item[search_path];
|
|
301
|
-
}
|
|
285
|
+
return item[title_path];
|
|
302
286
|
}).includes(clicked);
|
|
303
287
|
} else {
|
|
304
288
|
return displayed[search_path] === clicked;
|
|
@@ -354,7 +338,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
354
338
|
};
|
|
355
339
|
const getOption = (option)=>{
|
|
356
340
|
if (option != '') {
|
|
357
|
-
let curOption = (0, _helpers.getJPart)(option,
|
|
341
|
+
let curOption = (0, _helpers.getJPart)(option, title_path, 0);
|
|
358
342
|
if (curOption !== null && (0, _helpers.isArrayValid)(curOption)) {
|
|
359
343
|
curOption = curOption[0];
|
|
360
344
|
}
|
|
@@ -397,112 +381,114 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
397
381
|
return rv;
|
|
398
382
|
};
|
|
399
383
|
const getSingleValueByModalType = (option, modal)=>{
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}),
|
|
437
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
438
|
-
sx: {
|
|
439
|
-
width: '170px',
|
|
440
|
-
overflow: 'hidden',
|
|
441
|
-
display: 'flex',
|
|
442
|
-
justifyContent: 'flex-start',
|
|
443
|
-
gap: 1
|
|
444
|
-
},
|
|
445
|
-
children: [
|
|
446
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
447
|
-
variant: "subtitle2",
|
|
448
|
-
color: theme.palette.typography.title,
|
|
449
|
-
children: (0, _helpers.titleCase)(clicked)
|
|
450
|
-
}),
|
|
451
|
-
modal === 'displayed' && /*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
|
|
452
|
-
option: option
|
|
453
|
-
})
|
|
454
|
-
]
|
|
455
|
-
}),
|
|
456
|
-
modal === 'list' && isChecked(option) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
457
|
-
width: 16,
|
|
458
|
-
height: 16,
|
|
459
|
-
icon: 'filters/chosen_icon.svg'
|
|
460
|
-
})
|
|
461
|
-
]
|
|
462
|
-
}, option._id);
|
|
463
|
-
break;
|
|
464
|
-
case 'text':
|
|
465
|
-
default:
|
|
466
|
-
rv = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
467
|
-
sx: {
|
|
468
|
-
display: 'flex',
|
|
469
|
-
justifyContent: 'space-between',
|
|
470
|
-
width: '100%',
|
|
471
|
-
maxWidth: '250px',
|
|
472
|
-
gap: 1,
|
|
473
|
-
color: 'grey',
|
|
474
|
-
cursor: 'pointer'
|
|
475
|
-
},
|
|
476
|
-
children: [
|
|
477
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
478
|
-
sx: {
|
|
479
|
-
width: '210px',
|
|
480
|
-
overflow: 'hidden',
|
|
481
|
-
display: 'flex',
|
|
482
|
-
justifyContent: 'flex-start',
|
|
483
|
-
gap: 1
|
|
484
|
-
},
|
|
485
|
-
children: [
|
|
486
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
487
|
-
variant: "subtitle2",
|
|
488
|
-
color: theme.palette.typography.title,
|
|
489
|
-
children: (0, _helpers.titleCase)(clicked)
|
|
490
|
-
}),
|
|
491
|
-
modal === 'displayed' && /*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
|
|
492
|
-
option: option
|
|
384
|
+
if (option) {
|
|
385
|
+
let rv = null;
|
|
386
|
+
const clicked = getOption(option);
|
|
387
|
+
switch(modal_type){
|
|
388
|
+
case 'chip':
|
|
389
|
+
rv = modal === 'displayed' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
390
|
+
status: clicked,
|
|
391
|
+
label: (0, _helpers.titleCase)(clicked),
|
|
392
|
+
variant: "outlined",
|
|
393
|
+
onDelete: ()=>{
|
|
394
|
+
deleteOneItem(option);
|
|
395
|
+
}
|
|
396
|
+
}, option._id) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
397
|
+
status: clicked,
|
|
398
|
+
label: (0, _helpers.titleCase)(clicked),
|
|
399
|
+
variant: "outlined"
|
|
400
|
+
}, option._id);
|
|
401
|
+
break;
|
|
402
|
+
case 'logo':
|
|
403
|
+
rv = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
404
|
+
sx: {
|
|
405
|
+
display: 'flex',
|
|
406
|
+
gap: 1,
|
|
407
|
+
color: 'grey',
|
|
408
|
+
cursor: 'pointer',
|
|
409
|
+
width: '100%'
|
|
410
|
+
},
|
|
411
|
+
children: [
|
|
412
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
413
|
+
style: {
|
|
414
|
+
width: '70px'
|
|
415
|
+
},
|
|
416
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
417
|
+
icon: `companies/${option.logo ? option.logo : 'logo_placeholder/logo_placeholder.svg'}`,
|
|
418
|
+
width: 70,
|
|
419
|
+
height: 16
|
|
493
420
|
})
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
421
|
+
}),
|
|
422
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
423
|
+
sx: {
|
|
424
|
+
width: '170px',
|
|
425
|
+
overflow: 'hidden',
|
|
426
|
+
display: 'flex',
|
|
427
|
+
justifyContent: 'flex-start',
|
|
428
|
+
gap: 1
|
|
429
|
+
},
|
|
430
|
+
children: [
|
|
431
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
432
|
+
variant: "subtitle2",
|
|
433
|
+
color: theme.palette.typography.title,
|
|
434
|
+
children: (0, _helpers.titleCase)(clicked)
|
|
435
|
+
}),
|
|
436
|
+
modal === 'displayed' && /*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
|
|
437
|
+
option: option
|
|
438
|
+
})
|
|
439
|
+
]
|
|
440
|
+
}),
|
|
441
|
+
modal === 'list' && isChecked(option) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
442
|
+
width: 16,
|
|
443
|
+
height: 16,
|
|
444
|
+
icon: 'filters/chosen_icon.svg'
|
|
445
|
+
})
|
|
446
|
+
]
|
|
447
|
+
}, option._id);
|
|
448
|
+
break;
|
|
449
|
+
case 'text':
|
|
450
|
+
default:
|
|
451
|
+
rv = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
452
|
+
sx: {
|
|
453
|
+
display: 'flex',
|
|
454
|
+
justifyContent: 'space-between',
|
|
455
|
+
width: '100%',
|
|
456
|
+
maxWidth: '250px',
|
|
457
|
+
gap: 1,
|
|
458
|
+
color: 'grey',
|
|
459
|
+
cursor: 'pointer'
|
|
460
|
+
},
|
|
461
|
+
children: [
|
|
462
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
463
|
+
sx: {
|
|
464
|
+
width: '210px',
|
|
465
|
+
overflow: 'hidden',
|
|
466
|
+
display: 'flex',
|
|
467
|
+
justifyContent: 'flex-start',
|
|
468
|
+
gap: 1
|
|
469
|
+
},
|
|
470
|
+
children: [
|
|
471
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
472
|
+
variant: "subtitle2",
|
|
473
|
+
color: theme.palette.typography.title,
|
|
474
|
+
children: (0, _helpers.titleCase)(clicked)
|
|
475
|
+
}),
|
|
476
|
+
modal === 'displayed' && /*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
|
|
477
|
+
option: option
|
|
478
|
+
})
|
|
479
|
+
]
|
|
480
|
+
}),
|
|
481
|
+
modal === 'list' && isChecked(option) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
482
|
+
width: 16,
|
|
483
|
+
height: 16,
|
|
484
|
+
icon: 'filters/chosen_icon.svg'
|
|
485
|
+
})
|
|
486
|
+
]
|
|
487
|
+
}, option._id);
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
return rv;
|
|
504
491
|
}
|
|
505
|
-
return rv;
|
|
506
492
|
};
|
|
507
493
|
const getMultipleDisplayedValues = ()=>{
|
|
508
494
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
package/package.json
CHANGED