@fixefy/fixefy-ui-components 0.2.8 → 0.2.10
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.
|
@@ -25,5 +25,7 @@ export type AsyncDropdownPropsType = {
|
|
|
25
25
|
[x: string]: any;
|
|
26
26
|
modal_type?: string;
|
|
27
27
|
query: string;
|
|
28
|
+
isInitialOpen?: boolean;
|
|
29
|
+
placeholder?: string;
|
|
28
30
|
};
|
|
29
31
|
export declare const FxAsyncDropdown: React.ForwardRefExoticComponent<Omit<AsyncDropdownPropsType, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -119,15 +119,15 @@ const icon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBoxOutlineBl
|
|
|
119
119
|
const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox, {
|
|
120
120
|
fontSize: "small"
|
|
121
121
|
});
|
|
122
|
-
const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props
|
|
123
|
-
|
|
124
|
-
const { onAdd, onRemoveOne, onRemoveAll, fetcher, disabled, type = 'text', variables, search_path, modal_type, multiple, name, query } = props;
|
|
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;
|
|
125
124
|
const ref = (0, _react.useRef)(null);
|
|
126
125
|
const theme = (0, _material.useTheme)();
|
|
127
126
|
const [displayed, setDisplayed] = (0, _react.useState)(multiple ? [] : '');
|
|
128
127
|
const [options, setOptions] = (0, _react.useState)([]);
|
|
129
128
|
const [reason, setReason] = (0, _react.useState)('init');
|
|
130
129
|
const [isLastPage, setIsLastPage] = (0, _react.useState)(false);
|
|
130
|
+
const [isOpen, setIOpen] = (0, _react.useState)(isInitialOpen);
|
|
131
131
|
const [searchValue, setSearchValue] = (0, _react.useState)(null);
|
|
132
132
|
const [page, setPage] = (0, _react.useState)(1);
|
|
133
133
|
const [prevPage, setPrevPage] = (0, _react.useState)(0);
|
|
@@ -305,7 +305,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
|
-
const
|
|
308
|
+
const displayListOptions = ()=>{
|
|
309
309
|
switch(type){
|
|
310
310
|
case 'checkbox':
|
|
311
311
|
{
|
|
@@ -329,7 +329,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
}),
|
|
332
|
-
|
|
332
|
+
getSingleValueByModalType(option, 'list')
|
|
333
333
|
]
|
|
334
334
|
}, option._id);
|
|
335
335
|
});
|
|
@@ -342,19 +342,12 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
342
342
|
onClick: ()=>{
|
|
343
343
|
handleOptionClick(option);
|
|
344
344
|
},
|
|
345
|
-
children:
|
|
345
|
+
children: getSingleValueByModalType(option, 'list')
|
|
346
346
|
}, option._id);
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
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
351
|
const loadMore = ()=>{
|
|
359
352
|
setPage((prevPage)=>prevPage + 1);
|
|
360
353
|
setPrevPage((prevPage)=>prevPage + 1);
|
|
@@ -370,17 +363,11 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
370
363
|
return null;
|
|
371
364
|
};
|
|
372
365
|
const getCurrentValues = ()=>{
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
break;
|
|
378
|
-
case false:
|
|
379
|
-
default:
|
|
380
|
-
rv = getValueByModalType(displayed, 'displayed');
|
|
381
|
-
break;
|
|
366
|
+
if (multiple) {
|
|
367
|
+
return getMultipleDisplayedValues();
|
|
368
|
+
} else {
|
|
369
|
+
return getSingleValueByModalType(displayed, 'displayed');
|
|
382
370
|
}
|
|
383
|
-
return rv;
|
|
384
371
|
};
|
|
385
372
|
const DeleteButton = ({ option })=>{
|
|
386
373
|
let rv = null;
|
|
@@ -409,12 +396,12 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
409
396
|
}
|
|
410
397
|
return rv;
|
|
411
398
|
};
|
|
412
|
-
const
|
|
399
|
+
const getSingleValueByModalType = (option, modal)=>{
|
|
413
400
|
let rv = null;
|
|
414
401
|
const clicked = getClicked(option);
|
|
415
402
|
switch(modal_type){
|
|
416
403
|
case 'chip':
|
|
417
|
-
rv =
|
|
404
|
+
rv = modal === 'displayed' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
418
405
|
status: clicked,
|
|
419
406
|
label: (0, _helpers.titleCase)(clicked),
|
|
420
407
|
variant: "outlined",
|
|
@@ -461,12 +448,12 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
461
448
|
color: theme.palette.typography.title,
|
|
462
449
|
children: (0, _helpers.titleCase)(clicked)
|
|
463
450
|
}),
|
|
464
|
-
|
|
451
|
+
modal === 'displayed' && /*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
|
|
465
452
|
option: option
|
|
466
453
|
})
|
|
467
454
|
]
|
|
468
455
|
}),
|
|
469
|
-
|
|
456
|
+
modal === 'list' && isChecked(option) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
470
457
|
width: 16,
|
|
471
458
|
height: 16,
|
|
472
459
|
icon: 'filters/chosen_icon.svg'
|
|
@@ -501,12 +488,12 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
501
488
|
color: theme.palette.typography.title,
|
|
502
489
|
children: (0, _helpers.titleCase)(clicked)
|
|
503
490
|
}),
|
|
504
|
-
|
|
491
|
+
modal === 'displayed' && /*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
|
|
505
492
|
option: option
|
|
506
493
|
})
|
|
507
494
|
]
|
|
508
495
|
}),
|
|
509
|
-
|
|
496
|
+
modal === 'list' && isChecked(option) && /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
510
497
|
width: 16,
|
|
511
498
|
height: 16,
|
|
512
499
|
icon: 'filters/chosen_icon.svg'
|
|
@@ -535,7 +522,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
535
522
|
gap: 1
|
|
536
523
|
},
|
|
537
524
|
children: displayed.map((item)=>{
|
|
538
|
-
return
|
|
525
|
+
return getSingleValueByModalType(item, 'displayed');
|
|
539
526
|
})
|
|
540
527
|
}),
|
|
541
528
|
(displayed === null || displayed === void 0 ? void 0 : displayed.length) > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
@@ -559,31 +546,26 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
559
546
|
});
|
|
560
547
|
};
|
|
561
548
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.Root, {
|
|
562
|
-
sx: {
|
|
563
|
-
background: '#FFFFFF',
|
|
564
|
-
padding: '0 16px'
|
|
565
|
-
},
|
|
566
549
|
children: [
|
|
567
550
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
568
551
|
children: [
|
|
569
552
|
getCurrentValues(),
|
|
570
553
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.InputWrapper, {
|
|
571
554
|
disabled: disabled,
|
|
572
|
-
sx: {
|
|
573
|
-
width: '100%',
|
|
574
|
-
border: 'none !important',
|
|
575
|
-
outline: 'none !important'
|
|
576
|
-
},
|
|
577
555
|
children: [
|
|
578
556
|
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
579
|
-
style: {
|
|
580
|
-
border: 'none',
|
|
581
|
-
outline: 'none'
|
|
582
|
-
},
|
|
583
557
|
autoFocus: true,
|
|
584
|
-
placeholder:
|
|
558
|
+
placeholder: placeholder || 'Select an option...',
|
|
585
559
|
onChange: (e)=>{
|
|
586
560
|
handleSearch(e);
|
|
561
|
+
},
|
|
562
|
+
onFocus: ()=>{
|
|
563
|
+
!isInitialOpen && setIOpen(true);
|
|
564
|
+
},
|
|
565
|
+
onBlur: ()=>{
|
|
566
|
+
setTimeout(()=>{
|
|
567
|
+
!isInitialOpen && setIOpen(false);
|
|
568
|
+
}, 200);
|
|
587
569
|
}
|
|
588
570
|
}),
|
|
589
571
|
loading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.Loading, {
|
|
@@ -593,25 +575,10 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props, parentRe
|
|
|
593
575
|
})
|
|
594
576
|
]
|
|
595
577
|
}),
|
|
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
|
-
}),
|
|
578
|
+
(isInitialOpen || isOpen) && options && (options === null || options === void 0 ? void 0 : options.length) > 0 && !disabled ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.StyledListBox, {
|
|
612
579
|
ref: ref,
|
|
613
580
|
children: [
|
|
614
|
-
|
|
581
|
+
displayListOptions(),
|
|
615
582
|
!isLastPage && /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
|
|
616
583
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
617
584
|
onClick: ()=>{
|
|
@@ -86,7 +86,10 @@ function _object_spread_props(target, source) {
|
|
|
86
86
|
}
|
|
87
87
|
const Root = (0, _styles.styled)('div')(()=>({
|
|
88
88
|
color: 'rgba(0,0,0,.85)',
|
|
89
|
-
fontSize: 14
|
|
89
|
+
fontSize: 14,
|
|
90
|
+
background: '#FFFFFF',
|
|
91
|
+
padding: '0 16px',
|
|
92
|
+
position: 'relative'
|
|
90
93
|
}));
|
|
91
94
|
const Label = (0, _styles.styled)('label')(()=>({
|
|
92
95
|
padding: '0 0 4px',
|
|
@@ -105,12 +108,9 @@ const Loading = (0, _styles.styled)('div')(()=>({
|
|
|
105
108
|
}
|
|
106
109
|
}));
|
|
107
110
|
const InputWrapper = (0, _styles.styled)('div')(({ theme, hasValue, disabled })=>{
|
|
108
|
-
const defaultBorder = `1px solid ${theme.palette.greyscale[200]}`;
|
|
109
|
-
const hasValueBorder = `1px solid ${theme.palette.primary[500]}`;
|
|
110
111
|
const disabledBorder = `1px solid ${theme.palette.greyscale[200]}`;
|
|
111
112
|
const activeBorder = `1px solid ${theme.palette.primary[500]}`;
|
|
112
113
|
return {
|
|
113
|
-
border: disabled ? disabledBorder : hasValue ? hasValueBorder : defaultBorder,
|
|
114
114
|
backgroundColor: theme.palette.common.white,
|
|
115
115
|
borderRadius: 4,
|
|
116
116
|
padding: 1,
|
|
@@ -118,6 +118,9 @@ const InputWrapper = (0, _styles.styled)('div')(({ theme, hasValue, disabled })=
|
|
|
118
118
|
alignItems: 'center',
|
|
119
119
|
flexWrap: 'wrap',
|
|
120
120
|
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
121
|
+
width: '100%',
|
|
122
|
+
border: 'none !important',
|
|
123
|
+
outline: 'none !important',
|
|
121
124
|
['&:hover']: {
|
|
122
125
|
border: disabled ? disabledBorder : activeBorder,
|
|
123
126
|
borderRadius: 4
|
|
@@ -131,6 +134,8 @@ const InputWrapper = (0, _styles.styled)('div')(({ theme, hasValue, disabled })=
|
|
|
131
134
|
marginRight: 8
|
|
132
135
|
},
|
|
133
136
|
['& input']: _object_spread_props(_object_spread({
|
|
137
|
+
border: 'none',
|
|
138
|
+
outline: 'none',
|
|
134
139
|
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
135
140
|
backgroundColor: theme.palette.common.white,
|
|
136
141
|
color: theme.palette.typography.title,
|
|
@@ -139,9 +144,7 @@ const InputWrapper = (0, _styles.styled)('div')(({ theme, hasValue, disabled })=
|
|
|
139
144
|
width: 0,
|
|
140
145
|
minWidth: 30,
|
|
141
146
|
flexGrow: 1,
|
|
142
|
-
|
|
143
|
-
margin: 0,
|
|
144
|
-
outline: 0
|
|
147
|
+
margin: 0
|
|
145
148
|
}, theme.typography.body1), {
|
|
146
149
|
lineHeight: '20px',
|
|
147
150
|
['& ::placeholder']: {
|
|
@@ -176,15 +179,12 @@ const StyledClose = (0, _styles.styled)('div')(()=>({
|
|
|
176
179
|
position: 'absolute',
|
|
177
180
|
bottom: 0
|
|
178
181
|
}));
|
|
179
|
-
const StyledListBox = (0, _styles.styled)('ul')(({ theme
|
|
180
|
-
// width: 300,
|
|
182
|
+
const StyledListBox = (0, _styles.styled)('ul')(({ theme })=>({
|
|
181
183
|
margin: 0,
|
|
182
184
|
padding: 0,
|
|
183
|
-
// position: 'absolute',
|
|
184
185
|
listStyle: 'none',
|
|
185
186
|
backgroundColor: theme.palette.common.white,
|
|
186
187
|
overflow: 'auto',
|
|
187
|
-
maxHeight: hasClearBtn ? 190 : 230,
|
|
188
188
|
zIndex: 1,
|
|
189
189
|
textOverflow: 'ellipsis',
|
|
190
190
|
whiteSpace: 'nowrap',
|
|
@@ -193,6 +193,19 @@ const StyledListBox = (0, _styles.styled)('ul')(({ theme, hasClearBtn })=>({
|
|
|
193
193
|
paddingBottom: 8,
|
|
194
194
|
maxWidth: 270,
|
|
195
195
|
minWidth: 270,
|
|
196
|
+
'&::-webkit-scrollbar': {
|
|
197
|
+
width: '8px',
|
|
198
|
+
backgroundColor: 'transparent'
|
|
199
|
+
},
|
|
200
|
+
'&::-webkit-scrollbar-thumb': {
|
|
201
|
+
backgroundColor: '#8B9092',
|
|
202
|
+
borderRadius: '8px'
|
|
203
|
+
},
|
|
204
|
+
// To support Firefox
|
|
205
|
+
scrollbarWidth: 'thin',
|
|
206
|
+
scrollbarColor: '#8B9092 transparent',
|
|
207
|
+
maxHeight: '300px',
|
|
208
|
+
overflowY: 'auto',
|
|
196
209
|
['& div']: {
|
|
197
210
|
textOverflow: 'ellipsis',
|
|
198
211
|
whiteSpace: 'nowrap',
|
package/package.json
CHANGED