@fixefy/fixefy-ui-components 0.3.38 → 0.3.40
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/FxObjStaticDropdown/FxObjStaticDropdown.d.ts +34 -0
- package/dist/FxObjStaticDropdown/FxObjStaticDropdown.js +532 -0
- package/dist/FxObjStaticDropdown/index.d.ts +1 -0
- package/dist/FxObjStaticDropdown/index.js +25 -0
- package/dist/FxObjStaticDropdown/styles/dropdown.styles.d.ts +4 -0
- package/dist/FxObjStaticDropdown/styles/dropdown.styles.js +211 -0
- package/dist/FxStrStaticDropdown/FxStrStaticDropdown.d.ts +24 -0
- package/dist/FxStrStaticDropdown/FxStrStaticDropdown.js +368 -0
- package/dist/FxStrStaticDropdown/helpers/helpers.d.ts +2 -0
- package/dist/FxStrStaticDropdown/helpers/helpers.js +22 -0
- package/dist/FxStrStaticDropdown/index.d.ts +1 -0
- package/dist/FxStrStaticDropdown/index.js +11 -0
- package/dist/FxStrStaticDropdown/styles/dropdown.styles.d.ts +3 -0
- package/dist/FxStrStaticDropdown/styles/dropdown.styles.js +190 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface Option {
|
|
3
|
+
title: string;
|
|
4
|
+
value: string | number | boolean;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export interface StylesOptions {
|
|
8
|
+
width?: string | number;
|
|
9
|
+
maxWidth?: string | number;
|
|
10
|
+
inputSx?: object;
|
|
11
|
+
menuSx?: object;
|
|
12
|
+
}
|
|
13
|
+
export type AsyncDropdownPropsType = {
|
|
14
|
+
initialValue?: Option | any;
|
|
15
|
+
styles?: StylesOptions;
|
|
16
|
+
multiple?: boolean;
|
|
17
|
+
name: any;
|
|
18
|
+
onAdd: (value: any) => void;
|
|
19
|
+
onRemoveOne: (value: any) => void;
|
|
20
|
+
onRemoveAll: () => void;
|
|
21
|
+
onUnselectAll?: () => void;
|
|
22
|
+
type?: 'checkbox' | 'text';
|
|
23
|
+
renderOptions?: (option: Option, index: number) => void;
|
|
24
|
+
[x: string]: any;
|
|
25
|
+
modal_type?: string;
|
|
26
|
+
query: string;
|
|
27
|
+
isInitialOpen?: boolean;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
rootStylesOverride?: any;
|
|
30
|
+
defaultValue?: any;
|
|
31
|
+
data: string[];
|
|
32
|
+
_id: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const FxObjStaticDropdown: (props: AsyncDropdownPropsType) => React.JSX.Element;
|
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "FxObjStaticDropdown", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return FxObjStaticDropdown;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
+
const _iconsmaterial = require("@mui/icons-material");
|
|
14
|
+
const _material = require("@mui/material");
|
|
15
|
+
const _FxChip = require("../FxChip");
|
|
16
|
+
const _FxIcon = require("../FxIcon");
|
|
17
|
+
const _dropdownstyles = require("./styles/dropdown.styles");
|
|
18
|
+
const _fixefyuiutils = require("@fixefy/fixefy-ui-utils");
|
|
19
|
+
const _fixefyhooks = require("@fixefy/fixefy-hooks");
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function") return null;
|
|
22
|
+
var cacheBabelInterop = new WeakMap();
|
|
23
|
+
var cacheNodeInterop = new WeakMap();
|
|
24
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
25
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
|
+
})(nodeInterop);
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
29
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
38
|
+
if (cache && cache.has(obj)) {
|
|
39
|
+
return cache.get(obj);
|
|
40
|
+
}
|
|
41
|
+
var newObj = {
|
|
42
|
+
__proto__: null
|
|
43
|
+
};
|
|
44
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
45
|
+
for(var key in obj){
|
|
46
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
47
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
48
|
+
if (desc && (desc.get || desc.set)) {
|
|
49
|
+
Object.defineProperty(newObj, key, desc);
|
|
50
|
+
} else {
|
|
51
|
+
newObj[key] = obj[key];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
newObj.default = obj;
|
|
56
|
+
if (cache) {
|
|
57
|
+
cache.set(obj, newObj);
|
|
58
|
+
}
|
|
59
|
+
return newObj;
|
|
60
|
+
}
|
|
61
|
+
const uncheckedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBoxOutlineBlank, {
|
|
62
|
+
fontSize: "small"
|
|
63
|
+
});
|
|
64
|
+
const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox, {
|
|
65
|
+
fontSize: "small"
|
|
66
|
+
});
|
|
67
|
+
const FxObjStaticDropdown = (props)=>{
|
|
68
|
+
const { onAdd, onRemoveOne, onRemoveAll, onUnselectAll, disabled, type = 'text', search_path, modal_type, multiple, name, query, isInitialOpen, placeholder, title_path, rootStylesOverride, logo_placeholder, logo_folder_name, _id, data, defaultValue } = props;
|
|
69
|
+
const ref = (0, _react.useRef)(null);
|
|
70
|
+
const theme = (0, _material.useTheme)();
|
|
71
|
+
const [displayed, setDisplayed] = (0, _react.useState)(multiple ? [] : '');
|
|
72
|
+
const [options, setOptions] = (0, _react.useState)([]);
|
|
73
|
+
const [reason, setReason] = (0, _react.useState)('init');
|
|
74
|
+
const [isLastPage, setIsLastPage] = (0, _react.useState)(false);
|
|
75
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(isInitialOpen);
|
|
76
|
+
const [searchValue, setSearchValue] = (0, _react.useState)(null);
|
|
77
|
+
const [page, setPage] = (0, _react.useState)(1);
|
|
78
|
+
const [prevPage, setPrevPage] = (0, _react.useState)(0);
|
|
79
|
+
const pageSize = 20;
|
|
80
|
+
(0, _react.useEffect)(()=>{
|
|
81
|
+
const storedData = sessionStorage.getItem(`dropdown-${query}-${name}-${_id}`);
|
|
82
|
+
if (storedData) {
|
|
83
|
+
const parsedData = JSON.parse(storedData);
|
|
84
|
+
const items = parsedData[name];
|
|
85
|
+
if (items) {
|
|
86
|
+
switch(multiple){
|
|
87
|
+
case true:
|
|
88
|
+
setDisplayed([
|
|
89
|
+
...items
|
|
90
|
+
]);
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
setDisplayed(items[0]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, [
|
|
98
|
+
query,
|
|
99
|
+
name
|
|
100
|
+
]);
|
|
101
|
+
(0, _react.useEffect)(()=>{
|
|
102
|
+
if (data && !isLastPage && prevPage < page) {
|
|
103
|
+
if (data == null || data.length < pageSize) {
|
|
104
|
+
setIsLastPage(true);
|
|
105
|
+
}
|
|
106
|
+
if (reason !== 'loaded more') {
|
|
107
|
+
setOptions(data);
|
|
108
|
+
} else {
|
|
109
|
+
setOptions((prevOptions)=>[
|
|
110
|
+
...prevOptions,
|
|
111
|
+
...data
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, [
|
|
116
|
+
data,
|
|
117
|
+
reason
|
|
118
|
+
]);
|
|
119
|
+
(0, _react.useEffect)(()=>{
|
|
120
|
+
if (searchValue) {
|
|
121
|
+
setOptions(data.filter((option)=>option[title_path].toLowerCase().includes(searchValue.toLowerCase())));
|
|
122
|
+
} else {
|
|
123
|
+
setOptions(data);
|
|
124
|
+
}
|
|
125
|
+
}, [
|
|
126
|
+
searchValue
|
|
127
|
+
]);
|
|
128
|
+
const handleSearch = (e)=>{
|
|
129
|
+
setSearchValue(e.target.value);
|
|
130
|
+
setReason('searched');
|
|
131
|
+
setPage(1);
|
|
132
|
+
setPrevPage(0);
|
|
133
|
+
setIsLastPage(false);
|
|
134
|
+
};
|
|
135
|
+
const addToStoredDisplayed = (option)=>{
|
|
136
|
+
const prevStored = sessionStorage.getItem(`dropdown-${query}-${name}-${_id}`);
|
|
137
|
+
const data = prevStored ? JSON.parse(prevStored) : {};
|
|
138
|
+
if (data[name]) {
|
|
139
|
+
if (multiple) {
|
|
140
|
+
data[name] = [
|
|
141
|
+
...data[name],
|
|
142
|
+
option
|
|
143
|
+
];
|
|
144
|
+
} else {
|
|
145
|
+
data[name] = [
|
|
146
|
+
option
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
data[name] = [
|
|
151
|
+
option
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify(data));
|
|
155
|
+
};
|
|
156
|
+
const removeOneFromStoredDisplayed = (option)=>{
|
|
157
|
+
let storedDisplayed = sessionStorage.getItem(`dropdown-${query}-${name}-${_id}`);
|
|
158
|
+
if (storedDisplayed) {
|
|
159
|
+
storedDisplayed = JSON.parse(storedDisplayed);
|
|
160
|
+
if (multiple) {
|
|
161
|
+
const newDisplayed = storedDisplayed[name].filter((opt)=>opt[title_path] !== option[title_path]);
|
|
162
|
+
storedDisplayed[name] = newDisplayed;
|
|
163
|
+
} else {
|
|
164
|
+
delete storedDisplayed[name];
|
|
165
|
+
}
|
|
166
|
+
sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify(storedDisplayed));
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const handleOptionClick = (option)=>{
|
|
170
|
+
switch(multiple){
|
|
171
|
+
case true:
|
|
172
|
+
if (displayed.map((item)=>{
|
|
173
|
+
return item[title_path];
|
|
174
|
+
}).includes(option)) {
|
|
175
|
+
deleteOneItem(option);
|
|
176
|
+
} else {
|
|
177
|
+
onAdd(option);
|
|
178
|
+
setDisplayed((prev)=>[
|
|
179
|
+
...prev,
|
|
180
|
+
option
|
|
181
|
+
]);
|
|
182
|
+
addToStoredDisplayed(option);
|
|
183
|
+
if (!multiple) {
|
|
184
|
+
setIsOpen(false);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
default:
|
|
189
|
+
setDisplayed(option);
|
|
190
|
+
onAdd(option);
|
|
191
|
+
addToStoredDisplayed(option);
|
|
192
|
+
if (!multiple && !defaultValue) {
|
|
193
|
+
setIsOpen(false);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const deleteOneItem = (item)=>{
|
|
198
|
+
if (multiple) {
|
|
199
|
+
setDisplayed((prev)=>prev.filter((val)=>val[title_path] !== item[title_path]));
|
|
200
|
+
} else {
|
|
201
|
+
setDisplayed('');
|
|
202
|
+
}
|
|
203
|
+
onRemoveOne(item);
|
|
204
|
+
removeOneFromStoredDisplayed(item);
|
|
205
|
+
};
|
|
206
|
+
const isChecked = (option)=>{
|
|
207
|
+
if (typeof displayed === 'string') {
|
|
208
|
+
return false;
|
|
209
|
+
} else {
|
|
210
|
+
if (multiple) {
|
|
211
|
+
return displayed.map((item)=>{
|
|
212
|
+
return item[title_path];
|
|
213
|
+
}).includes(option);
|
|
214
|
+
} else {
|
|
215
|
+
return displayed[search_path] === option[title_path];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const selectAll = ()=>{
|
|
220
|
+
setDisplayed((prev)=>{
|
|
221
|
+
const unselectedOptions = options.filter((option)=>{
|
|
222
|
+
return !prev.map((item)=>item[title_path]).includes(option);
|
|
223
|
+
});
|
|
224
|
+
const opts = [
|
|
225
|
+
...prev,
|
|
226
|
+
...unselectedOptions
|
|
227
|
+
];
|
|
228
|
+
onAdd(opts);
|
|
229
|
+
sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify({
|
|
230
|
+
[name]: opts
|
|
231
|
+
}));
|
|
232
|
+
return opts;
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
const unSelectAll = ()=>{
|
|
236
|
+
if (onUnselectAll) {
|
|
237
|
+
onUnselectAll();
|
|
238
|
+
setDisplayed([]);
|
|
239
|
+
sessionStorage.removeItem(`dropdown-${query}-${name}-${_id}`);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const displayListOptions = ()=>{
|
|
243
|
+
switch(type){
|
|
244
|
+
case 'checkbox':
|
|
245
|
+
{
|
|
246
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
247
|
+
children: [
|
|
248
|
+
multiple && onUnselectAll && /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
|
|
249
|
+
onClick: ()=>{
|
|
250
|
+
if (displayed.length === options.length) {
|
|
251
|
+
unSelectAll();
|
|
252
|
+
} else {
|
|
253
|
+
selectAll();
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
children: [
|
|
257
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
|
|
258
|
+
icon: uncheckedIcon,
|
|
259
|
+
checked: displayed.length === options.length,
|
|
260
|
+
checkedIcon: checkedIcon,
|
|
261
|
+
sx: {
|
|
262
|
+
mr: 1,
|
|
263
|
+
minWidth: 24,
|
|
264
|
+
minHeight: 24,
|
|
265
|
+
p: 0,
|
|
266
|
+
['& svg']: {
|
|
267
|
+
fill: theme.palette.primary.light
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}),
|
|
271
|
+
(0, _fixefyuiutils.titleCase)('select all')
|
|
272
|
+
]
|
|
273
|
+
}),
|
|
274
|
+
options.map((option, i)=>{
|
|
275
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
|
|
276
|
+
onClick: ()=>{
|
|
277
|
+
handleOptionClick(option);
|
|
278
|
+
},
|
|
279
|
+
children: [
|
|
280
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
|
|
281
|
+
icon: uncheckedIcon,
|
|
282
|
+
checked: isChecked(option),
|
|
283
|
+
checkedIcon: checkedIcon,
|
|
284
|
+
sx: {
|
|
285
|
+
mr: 1,
|
|
286
|
+
minWidth: 24,
|
|
287
|
+
minHeight: 24,
|
|
288
|
+
p: 0,
|
|
289
|
+
['& svg']: {
|
|
290
|
+
fill: theme.palette.primary.light
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}),
|
|
294
|
+
getSingleOptionFromListOrDisplayed(option, 'list')
|
|
295
|
+
]
|
|
296
|
+
}, i);
|
|
297
|
+
}),
|
|
298
|
+
' '
|
|
299
|
+
]
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
case 'text':
|
|
303
|
+
default:
|
|
304
|
+
{
|
|
305
|
+
return options.map((option, i)=>{
|
|
306
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
|
|
307
|
+
onClick: ()=>{
|
|
308
|
+
handleOptionClick(option);
|
|
309
|
+
},
|
|
310
|
+
children: getSingleOptionFromListOrDisplayed(option, 'list')
|
|
311
|
+
}, i);
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
const loadMore = ()=>{
|
|
317
|
+
setPage((prevPage)=>prevPage + 1);
|
|
318
|
+
setPrevPage((prevPage)=>prevPage + 1);
|
|
319
|
+
};
|
|
320
|
+
const getCurrentValues = ()=>{
|
|
321
|
+
if (multiple) {
|
|
322
|
+
return getDisplayedValuesMultiple();
|
|
323
|
+
} else {
|
|
324
|
+
return getSingleOptionFromListOrDisplayed(displayed, 'displayed');
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
const OneOption = ({ option, curValue, modal, modal_type })=>{
|
|
328
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
329
|
+
sx: {
|
|
330
|
+
display: 'flex',
|
|
331
|
+
justifyContent: 'space-between',
|
|
332
|
+
width: '100%',
|
|
333
|
+
gap: 1,
|
|
334
|
+
color: 'grey',
|
|
335
|
+
cursor: 'pointer'
|
|
336
|
+
},
|
|
337
|
+
children: [
|
|
338
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
339
|
+
sx: {
|
|
340
|
+
width: '100%',
|
|
341
|
+
display: 'flex',
|
|
342
|
+
justifyContent: 'flex-start',
|
|
343
|
+
gap: 1
|
|
344
|
+
},
|
|
345
|
+
children: [
|
|
346
|
+
modal_type == 'logo' && /*#__PURE__*/ (0, _jsxruntime.jsx)(Logo, {
|
|
347
|
+
option: option
|
|
348
|
+
}),
|
|
349
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
350
|
+
variant: "subtitle2",
|
|
351
|
+
color: theme.palette.typography.title,
|
|
352
|
+
children: (0, _fixefyuiutils.titleCase)(curValue)
|
|
353
|
+
}),
|
|
354
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
|
|
355
|
+
option: option,
|
|
356
|
+
isDisplay: modal == 'displayed'
|
|
357
|
+
})
|
|
358
|
+
]
|
|
359
|
+
}),
|
|
360
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(ChosenIcon, {
|
|
361
|
+
option: option,
|
|
362
|
+
isDisplay: modal == 'list'
|
|
363
|
+
})
|
|
364
|
+
]
|
|
365
|
+
}, option === null || option === void 0 ? void 0 : option._id);
|
|
366
|
+
};
|
|
367
|
+
const DeleteButton = ({ option, isDisplay })=>{
|
|
368
|
+
const isDisplayButton = isDisplay && (multiple && (displayed === null || displayed === void 0 ? void 0 : displayed.length) > 0 || !multiple && displayed[search_path] === option[title_path]);
|
|
369
|
+
switch(isDisplayButton){
|
|
370
|
+
case true:
|
|
371
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
372
|
+
onClick: ()=>{
|
|
373
|
+
deleteOneItem(option);
|
|
374
|
+
},
|
|
375
|
+
children: "x"
|
|
376
|
+
});
|
|
377
|
+
default:
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
const ChosenIcon = ({ option, isDisplay })=>{
|
|
382
|
+
if (isDisplay && isChecked(option)) {
|
|
383
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
384
|
+
width: 16,
|
|
385
|
+
height: 16,
|
|
386
|
+
icon: 'filters/chosen_icon.svg'
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return null;
|
|
390
|
+
};
|
|
391
|
+
const Logo = ({ option })=>{
|
|
392
|
+
var _option_name;
|
|
393
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
394
|
+
style: {
|
|
395
|
+
width: '70px'
|
|
396
|
+
},
|
|
397
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
398
|
+
icon: `${option.logo ? `${logo_folder_name}/${option.logo}` : logo_placeholder ? logo_placeholder : (_option_name = option === null || option === void 0 ? void 0 : option[name]) !== null && _option_name !== void 0 ? _option_name : 'x'}`,
|
|
399
|
+
width: 70,
|
|
400
|
+
height: 16,
|
|
401
|
+
variant: "rounded",
|
|
402
|
+
fontSize: 17,
|
|
403
|
+
background: (0, _fixefyhooks.useRandomColor)()
|
|
404
|
+
})
|
|
405
|
+
});
|
|
406
|
+
};
|
|
407
|
+
const Chip = ({ option, curValue, modal })=>{
|
|
408
|
+
return modal == 'displayed' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
409
|
+
status: curValue,
|
|
410
|
+
label: (0, _fixefyuiutils.titleCase)(curValue),
|
|
411
|
+
variant: "outlined",
|
|
412
|
+
onDelete: ()=>{
|
|
413
|
+
deleteOneItem(option);
|
|
414
|
+
}
|
|
415
|
+
}, option === null || option === void 0 ? void 0 : option._id) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
416
|
+
status: curValue,
|
|
417
|
+
label: (0, _fixefyuiutils.titleCase)(curValue),
|
|
418
|
+
variant: "outlined"
|
|
419
|
+
}, option === null || option === void 0 ? void 0 : option._id);
|
|
420
|
+
};
|
|
421
|
+
const getSingleOptionFromListOrDisplayed = (option, modal)=>{
|
|
422
|
+
if (option) {
|
|
423
|
+
let rv = null;
|
|
424
|
+
switch(modal_type){
|
|
425
|
+
case 'chip':
|
|
426
|
+
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(Chip, {
|
|
427
|
+
option: option,
|
|
428
|
+
curValue: option[title_path],
|
|
429
|
+
modal: modal
|
|
430
|
+
});
|
|
431
|
+
break;
|
|
432
|
+
case 'logo':
|
|
433
|
+
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(OneOption, {
|
|
434
|
+
option: option,
|
|
435
|
+
curValue: option[title_path],
|
|
436
|
+
modal: modal,
|
|
437
|
+
modal_type: modal_type
|
|
438
|
+
});
|
|
439
|
+
break;
|
|
440
|
+
case 'text':
|
|
441
|
+
default:
|
|
442
|
+
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(OneOption, {
|
|
443
|
+
option: option,
|
|
444
|
+
curValue: option[title_path],
|
|
445
|
+
modal: modal
|
|
446
|
+
});
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
return rv;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
const getDisplayedValuesMultiple = ()=>{
|
|
453
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
454
|
+
direction: 'row',
|
|
455
|
+
sx: {
|
|
456
|
+
display: 'flex',
|
|
457
|
+
justifyContent: 'space-between'
|
|
458
|
+
},
|
|
459
|
+
children: [
|
|
460
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
461
|
+
direction: 'row',
|
|
462
|
+
sx: {
|
|
463
|
+
overflow: 'hidden',
|
|
464
|
+
flexWrap: 'wrap',
|
|
465
|
+
gap: 1
|
|
466
|
+
},
|
|
467
|
+
children: displayed.map((item)=>{
|
|
468
|
+
return getSingleOptionFromListOrDisplayed(item, 'displayed');
|
|
469
|
+
})
|
|
470
|
+
}),
|
|
471
|
+
(displayed === null || displayed === void 0 ? void 0 : displayed.length) > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
472
|
+
sx: {
|
|
473
|
+
minWidth: '20px',
|
|
474
|
+
maxWidth: '20px',
|
|
475
|
+
cursor: 'pointer',
|
|
476
|
+
paddingLeft: '3px'
|
|
477
|
+
},
|
|
478
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
479
|
+
onClick: ()=>{
|
|
480
|
+
setDisplayed([]);
|
|
481
|
+
onRemoveAll();
|
|
482
|
+
sessionStorage.removeItem(`dropdown-${query}-${name}-${_id}`);
|
|
483
|
+
},
|
|
484
|
+
icon: 'filters/remove_all_button.svg',
|
|
485
|
+
width: 16,
|
|
486
|
+
height: 16
|
|
487
|
+
})
|
|
488
|
+
})
|
|
489
|
+
]
|
|
490
|
+
});
|
|
491
|
+
};
|
|
492
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.Root, {
|
|
493
|
+
style: rootStylesOverride,
|
|
494
|
+
children: [
|
|
495
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
496
|
+
children: [
|
|
497
|
+
getCurrentValues(),
|
|
498
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.InputWrapper, {
|
|
499
|
+
disabled: disabled,
|
|
500
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
501
|
+
autoFocus: true,
|
|
502
|
+
placeholder: placeholder || 'Select an option...',
|
|
503
|
+
onChange: (e)=>{
|
|
504
|
+
handleSearch(e);
|
|
505
|
+
},
|
|
506
|
+
onFocus: ()=>{
|
|
507
|
+
if (!isInitialOpen) {
|
|
508
|
+
setIsOpen(true);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
})
|
|
512
|
+
})
|
|
513
|
+
]
|
|
514
|
+
}),
|
|
515
|
+
(isInitialOpen || isOpen) && options && (options === null || options === void 0 ? void 0 : options.length) > 0 && !disabled ? /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dropdownstyles.StyledListBox, {
|
|
516
|
+
ref: ref,
|
|
517
|
+
children: [
|
|
518
|
+
displayListOptions(),
|
|
519
|
+
!isLastPage && /*#__PURE__*/ (0, _jsxruntime.jsx)("li", {
|
|
520
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
521
|
+
onClick: ()=>{
|
|
522
|
+
setReason('loaded more');
|
|
523
|
+
loadMore();
|
|
524
|
+
},
|
|
525
|
+
children: "load more"
|
|
526
|
+
})
|
|
527
|
+
})
|
|
528
|
+
]
|
|
529
|
+
}) : null
|
|
530
|
+
]
|
|
531
|
+
});
|
|
532
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FxObjStaticDropdown, Option, StylesOptions, AsyncDropdownPropsType } from './FxObjStaticDropdown';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
AsyncDropdownPropsType: function() {
|
|
13
|
+
return _FxObjStaticDropdown.AsyncDropdownPropsType;
|
|
14
|
+
},
|
|
15
|
+
FxObjStaticDropdown: function() {
|
|
16
|
+
return _FxObjStaticDropdown.FxObjStaticDropdown;
|
|
17
|
+
},
|
|
18
|
+
Option: function() {
|
|
19
|
+
return _FxObjStaticDropdown.Option;
|
|
20
|
+
},
|
|
21
|
+
StylesOptions: function() {
|
|
22
|
+
return _FxObjStaticDropdown.StylesOptions;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const _FxObjStaticDropdown = require("./FxObjStaticDropdown");
|