@fixefy/fixefy-ui-components 0.3.50 → 0.3.52
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.d.ts +2 -34
- package/dist/FxAsyncDropdown/FxAsyncDropdown.js +97 -255
- package/dist/FxAsyncDropdown/components/CheckboxIcon.d.ts +4 -0
- package/dist/FxAsyncDropdown/components/CheckboxIcon.js +42 -0
- package/dist/FxAsyncDropdown/components/ChipOption.d.ts +6 -0
- package/dist/FxAsyncDropdown/components/ChipOption.js +35 -0
- package/dist/FxAsyncDropdown/components/ChosenIcon.d.ts +5 -0
- package/dist/FxAsyncDropdown/components/ChosenIcon.js +46 -0
- package/dist/FxAsyncDropdown/components/DeleteButton.d.ts +5 -0
- package/dist/FxAsyncDropdown/components/DeleteButton.js +39 -0
- package/dist/FxAsyncDropdown/components/LogoOption.d.ts +6 -0
- package/dist/FxAsyncDropdown/components/LogoOption.js +95 -0
- package/dist/FxAsyncDropdown/components/TextOption.d.ts +6 -0
- package/dist/FxAsyncDropdown/components/TextOption.js +68 -0
- package/dist/FxAsyncDropdown/components/index.d.ts +6 -0
- package/dist/FxAsyncDropdown/components/index.js +36 -0
- package/dist/FxAsyncDropdown/helpers/helpers.d.ts +4 -0
- package/dist/FxAsyncDropdown/helpers/helpers.js +76 -0
- package/dist/FxAsyncDropdown/index.d.ts +1 -1
- package/dist/FxAsyncDropdown/index.js +3 -17
- package/dist/FxAsyncDropdown/types.d.ts +40 -0
- package/dist/FxAsyncDropdown/types.js +4 -0
- package/dist/FxAsyncDropdown/useDropdownStore.d.ts +2 -0
- package/dist/FxAsyncDropdown/useDropdownStore.js +57 -0
- package/dist/FxGeneralModal/FxGeneralModal.d.ts +2 -1
- package/dist/FxGeneralModal/FxGeneralModal.js +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -9
- package/package.json +3 -2
|
@@ -1,35 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
method_name: string;
|
|
17
|
-
multiple?: boolean;
|
|
18
|
-
name: any;
|
|
19
|
-
variables: any;
|
|
20
|
-
onAdd?: (value: any) => void;
|
|
21
|
-
onRemoveOne?: (value: any) => void;
|
|
22
|
-
onRemoveAll?: () => void;
|
|
23
|
-
onUnselectAll?: () => void;
|
|
24
|
-
type?: 'checkbox' | 'text';
|
|
25
|
-
renderOptions?: (option: Option, index: number) => void;
|
|
26
|
-
[x: string]: any;
|
|
27
|
-
modal_type?: string;
|
|
28
|
-
query: string;
|
|
29
|
-
isInitialOpen?: boolean;
|
|
30
|
-
placeholder?: string;
|
|
31
|
-
rootStylesOverride?: any;
|
|
32
|
-
options_path?: string;
|
|
33
|
-
defaultValue?: any;
|
|
34
|
-
};
|
|
35
|
-
export declare const FxAsyncDropdown: React.ForwardRefExoticComponent<Omit<AsyncDropdownPropsType, "ref"> & React.RefAttributes<unknown>>;
|
|
2
|
+
import { AsyncDropdownPropsType } from './types';
|
|
3
|
+
export declare const FxAsyncDropdown: (props: AsyncDropdownPropsType) => React.JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
3
|
value: true
|
|
@@ -11,15 +10,15 @@ Object.defineProperty(exports, "FxAsyncDropdown", {
|
|
|
11
10
|
});
|
|
12
11
|
const _jsxruntime = require("react/jsx-runtime");
|
|
13
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
14
|
-
const _iconsmaterial = require("@mui/icons-material");
|
|
15
13
|
const _material = require("@mui/material");
|
|
16
|
-
const _FxChip = require("../FxChip");
|
|
17
14
|
const _FxIcon = require("../FxIcon");
|
|
18
15
|
const _graphqltag = require("graphql-tag");
|
|
19
16
|
const _dropdownstyles = require("./styles/dropdown.styles");
|
|
20
17
|
const _helpers = require("./helpers/helpers");
|
|
21
18
|
const _client = require("@apollo/client");
|
|
22
19
|
const _nookies = require("nookies");
|
|
20
|
+
const _components = require("./components");
|
|
21
|
+
const _useDropdownStore = /*#__PURE__*/ _interop_require_default(require("./useDropdownStore"));
|
|
23
22
|
function _define_property(obj, key, value) {
|
|
24
23
|
if (key in obj) {
|
|
25
24
|
Object.defineProperty(obj, key, {
|
|
@@ -33,6 +32,11 @@ function _define_property(obj, key, value) {
|
|
|
33
32
|
}
|
|
34
33
|
return obj;
|
|
35
34
|
}
|
|
35
|
+
function _interop_require_default(obj) {
|
|
36
|
+
return obj && obj.__esModule ? obj : {
|
|
37
|
+
default: obj
|
|
38
|
+
};
|
|
39
|
+
}
|
|
36
40
|
function _getRequireWildcardCache(nodeInterop) {
|
|
37
41
|
if (typeof WeakMap !== "function") return null;
|
|
38
42
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -113,30 +117,15 @@ function _object_spread_props(target, source) {
|
|
|
113
117
|
}
|
|
114
118
|
return target;
|
|
115
119
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox, {
|
|
120
|
-
fontSize: "small"
|
|
121
|
-
});
|
|
122
|
-
const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
123
|
-
const { onAdd, onRemoveOne, onRemoveAll, onUnselectAll, fetcher, disabled, type = 'text', variables, search_path, modal_type, multiple, name, query, isInitialOpen, placeholder, title_path, rootStylesOverride, logo_placeholder, logo_folder_name, options_path, _id } = props;
|
|
124
|
-
let { defaultValue } = props;
|
|
120
|
+
const FxAsyncDropdown = (props)=>{
|
|
121
|
+
const { fetchedProps, setFetchedProps, displayed, setDisplayed, options, setOptions, reason, setReason, isLastPage, setIsLastPage, isOpen, setIsOpen, searchValue, setSearchValue, page, setPage, prevPage, setPrevPage, pageSize, loadMore } = (0, _useDropdownStore.default)();
|
|
122
|
+
const { onAdd, onRemoveAll, onUnselectAll, fetcher, disabled, defaultValue, type = 'text', variables, search_path, modal_type, multiple, name, query, isInitialOpen, placeholder, title_path, rootStylesOverride, options_path, _id } = props;
|
|
125
123
|
const ref = (0, _react.useRef)(null);
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
const [isOpen, setIsOpen] = (0, _react.useState)(isInitialOpen);
|
|
132
|
-
const [searchValue, setSearchValue] = (0, _react.useState)(null);
|
|
133
|
-
const [page, setPage] = (0, _react.useState)(1);
|
|
134
|
-
const [prevPage, setPrevPage] = (0, _react.useState)(0);
|
|
135
|
-
const pageSize = 20;
|
|
136
|
-
const { method_name } = variables;
|
|
137
|
-
const { where, sort } = fetcher.queryOptions.variables;
|
|
138
|
-
const ws = (0, _nookies.parseCookies)().ws;
|
|
139
|
-
const isLocal = fetcher.query.loc;
|
|
124
|
+
const { method_name } = variables !== null && variables !== void 0 ? variables : {};
|
|
125
|
+
var _fetcher_queryOptions_variables;
|
|
126
|
+
const { where, sort } = (_fetcher_queryOptions_variables = fetcher.queryOptions.variables) !== null && _fetcher_queryOptions_variables !== void 0 ? _fetcher_queryOptions_variables : {};
|
|
127
|
+
var _parseCookies;
|
|
128
|
+
const { ws } = (_parseCookies = (0, _nookies.parseCookies)()) !== null && _parseCookies !== void 0 ? _parseCookies : {};
|
|
140
129
|
const [defaultValueWhere, setDefaultValueWhere] = (0, _react.useState)(where);
|
|
141
130
|
const getWhere = ()=>{
|
|
142
131
|
if (method_name == 'workspace') {
|
|
@@ -158,7 +147,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
158
147
|
}) : _object_spread({}, where);
|
|
159
148
|
}
|
|
160
149
|
};
|
|
161
|
-
const [fetch, { data, loading }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(
|
|
150
|
+
const [fetch, { data, loading }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
|
|
162
151
|
variables: {
|
|
163
152
|
where: getWhere(),
|
|
164
153
|
skip: page * pageSize - pageSize,
|
|
@@ -166,7 +155,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
166
155
|
sort: sort || {}
|
|
167
156
|
}
|
|
168
157
|
}));
|
|
169
|
-
const [defaultValueFetch, { data: defaultValueData }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(
|
|
158
|
+
const [defaultValueFetch, { data: defaultValueData }] = (0, _client.useLazyQuery)((0, _graphqltag.gql)(fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
|
|
170
159
|
variables: {
|
|
171
160
|
where: defaultValueWhere,
|
|
172
161
|
sort: sort || {}
|
|
@@ -188,9 +177,13 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
188
177
|
const parsedData = JSON.parse(storedData);
|
|
189
178
|
const items = parsedData[name];
|
|
190
179
|
if (items) {
|
|
191
|
-
multiple
|
|
192
|
-
|
|
193
|
-
|
|
180
|
+
if (multiple) {
|
|
181
|
+
setDisplayed([
|
|
182
|
+
...items
|
|
183
|
+
]);
|
|
184
|
+
} else {
|
|
185
|
+
setDisplayed(items[0]);
|
|
186
|
+
}
|
|
194
187
|
}
|
|
195
188
|
}
|
|
196
189
|
}, [
|
|
@@ -203,10 +196,14 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
203
196
|
if (newOptions == null || newOptions.length < pageSize) {
|
|
204
197
|
setIsLastPage(true);
|
|
205
198
|
}
|
|
206
|
-
reason !== 'loaded more'
|
|
207
|
-
|
|
199
|
+
if (reason !== 'loaded more') {
|
|
200
|
+
setOptions(newOptions);
|
|
201
|
+
} else {
|
|
202
|
+
setOptions([
|
|
203
|
+
...options,
|
|
208
204
|
...newOptions
|
|
209
205
|
]);
|
|
206
|
+
}
|
|
210
207
|
}
|
|
211
208
|
}, [
|
|
212
209
|
data,
|
|
@@ -224,12 +221,18 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
224
221
|
if (defaultValue && (defaultValueData === null || defaultValueData === void 0 ? void 0 : (_defaultValueData_method_name = defaultValueData[method_name]) === null || _defaultValueData_method_name === void 0 ? void 0 : _defaultValueData_method_name.length) == 1) {
|
|
225
222
|
//choose default value
|
|
226
223
|
handleOptionClick(defaultValueData === null || defaultValueData === void 0 ? void 0 : defaultValueData[method_name][0]);
|
|
227
|
-
|
|
224
|
+
if (onAdd) {
|
|
225
|
+
onAdd(defaultValueData === null || defaultValueData === void 0 ? void 0 : defaultValueData[method_name][0]);
|
|
226
|
+
}
|
|
228
227
|
}
|
|
229
228
|
}, [
|
|
230
229
|
defaultValue,
|
|
231
230
|
defaultValueData
|
|
232
231
|
]);
|
|
232
|
+
(0, _react.useEffect)(()=>{
|
|
233
|
+
setFetchedProps(props);
|
|
234
|
+
setDisplayed(multiple ? [] : '');
|
|
235
|
+
}, []);
|
|
233
236
|
const handleSearch = (e)=>{
|
|
234
237
|
setSearchValue(e.target.value);
|
|
235
238
|
setReason('searched');
|
|
@@ -237,103 +240,55 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
237
240
|
setPrevPage(0);
|
|
238
241
|
setIsLastPage(false);
|
|
239
242
|
};
|
|
240
|
-
const addToStoredDisplayed = (option)=>{
|
|
241
|
-
const prevStored = sessionStorage.getItem(`dropdown-${query}-${name}-${_id}`);
|
|
242
|
-
let data = prevStored ? JSON.parse(prevStored) : {};
|
|
243
|
-
if (data[name]) {
|
|
244
|
-
if (multiple) {
|
|
245
|
-
data[name] = [
|
|
246
|
-
...data[name],
|
|
247
|
-
option
|
|
248
|
-
];
|
|
249
|
-
} else {
|
|
250
|
-
data[name] = [
|
|
251
|
-
option
|
|
252
|
-
];
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
data[name] = [
|
|
256
|
-
option
|
|
257
|
-
];
|
|
258
|
-
}
|
|
259
|
-
sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify(data));
|
|
260
|
-
};
|
|
261
|
-
const removeOneFromStoredDisplayed = (option)=>{
|
|
262
|
-
let storedDisplayed = sessionStorage.getItem(`dropdown-${query}-${name}-${_id}`);
|
|
263
|
-
if (storedDisplayed) {
|
|
264
|
-
storedDisplayed = JSON.parse(storedDisplayed);
|
|
265
|
-
if (multiple) {
|
|
266
|
-
const newDisplayed = storedDisplayed[name].filter((opt)=>opt[title_path] !== option[title_path]);
|
|
267
|
-
storedDisplayed[name] = newDisplayed;
|
|
268
|
-
} else {
|
|
269
|
-
delete storedDisplayed[name];
|
|
270
|
-
}
|
|
271
|
-
sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify(storedDisplayed));
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
243
|
const handleOptionClick = (option)=>{
|
|
275
|
-
|
|
244
|
+
const clicked = (0, _helpers.getOption)(option, title_path);
|
|
276
245
|
switch(multiple){
|
|
277
246
|
case true:
|
|
278
247
|
if (displayed.map((item)=>{
|
|
279
248
|
return item[title_path];
|
|
280
249
|
}).includes(clicked)) {
|
|
281
|
-
deleteOneItem(option);
|
|
250
|
+
(0, _helpers.deleteOneItem)(option, fetchedProps, displayed, setDisplayed);
|
|
282
251
|
} else {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
252
|
+
if (onAdd) {
|
|
253
|
+
onAdd(option);
|
|
254
|
+
}
|
|
255
|
+
if (!multiple) {
|
|
256
|
+
setIsOpen(false);
|
|
257
|
+
}
|
|
258
|
+
const opts = [
|
|
259
|
+
...displayed,
|
|
260
|
+
option
|
|
261
|
+
];
|
|
262
|
+
setDisplayed(opts);
|
|
263
|
+
(0, _helpers.addToStoredDisplayed)(option, fetchedProps);
|
|
290
264
|
}
|
|
291
265
|
break;
|
|
292
266
|
default:
|
|
293
267
|
setDisplayed(option);
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
setDisplayed((prev)=>prev.filter((val)=>val[title_path] !== item[title_path]));
|
|
302
|
-
} else {
|
|
303
|
-
setDisplayed('');
|
|
304
|
-
}
|
|
305
|
-
onRemoveOne && onRemoveOne(item);
|
|
306
|
-
removeOneFromStoredDisplayed(item);
|
|
307
|
-
};
|
|
308
|
-
const isChecked = (option)=>{
|
|
309
|
-
const clicked = (0, _helpers.getOption)(option, title_path);
|
|
310
|
-
if (typeof displayed === 'string') {
|
|
311
|
-
return false;
|
|
312
|
-
} else {
|
|
313
|
-
if (multiple) {
|
|
314
|
-
return displayed.map((item)=>{
|
|
315
|
-
return item[title_path];
|
|
316
|
-
}).includes(clicked);
|
|
317
|
-
} else {
|
|
318
|
-
return displayed[search_path] === clicked;
|
|
319
|
-
}
|
|
268
|
+
if (onAdd) {
|
|
269
|
+
onAdd(option);
|
|
270
|
+
}
|
|
271
|
+
(0, _helpers.addToStoredDisplayed)(option, fetchedProps);
|
|
272
|
+
if (!multiple && !defaultValue) {
|
|
273
|
+
setIsOpen(false);
|
|
274
|
+
}
|
|
320
275
|
}
|
|
321
276
|
};
|
|
322
277
|
const selectAll = ()=>{
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
return !prev.map((item)=>item[title_path]).includes((0, _helpers.getOption)(option, title_path));
|
|
326
|
-
});
|
|
327
|
-
const opts = [
|
|
328
|
-
...prev,
|
|
329
|
-
...unselectedOptions
|
|
330
|
-
];
|
|
331
|
-
onAdd && onAdd(opts);
|
|
332
|
-
sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify({
|
|
333
|
-
[name]: opts
|
|
334
|
-
}));
|
|
335
|
-
return opts;
|
|
278
|
+
const unselectedOptions = options.filter((option)=>{
|
|
279
|
+
return !displayed.map((item)=>item[title_path]).includes((0, _helpers.getOption)(option, title_path));
|
|
336
280
|
});
|
|
281
|
+
const opts = [
|
|
282
|
+
...displayed,
|
|
283
|
+
...unselectedOptions
|
|
284
|
+
];
|
|
285
|
+
setDisplayed(opts);
|
|
286
|
+
if (onAdd) {
|
|
287
|
+
onAdd(opts);
|
|
288
|
+
}
|
|
289
|
+
sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify({
|
|
290
|
+
[name]: opts
|
|
291
|
+
}));
|
|
337
292
|
};
|
|
338
293
|
const unSelectAll = ()=>{
|
|
339
294
|
if (onUnselectAll) {
|
|
@@ -357,19 +312,8 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
357
312
|
}
|
|
358
313
|
},
|
|
359
314
|
children: [
|
|
360
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
361
|
-
|
|
362
|
-
checked: displayed.length === options.length,
|
|
363
|
-
checkedIcon: checkedIcon,
|
|
364
|
-
sx: {
|
|
365
|
-
mr: 1,
|
|
366
|
-
minWidth: 24,
|
|
367
|
-
minHeight: 24,
|
|
368
|
-
p: 0,
|
|
369
|
-
['& svg']: {
|
|
370
|
-
fill: theme.palette.primary.light
|
|
371
|
-
}
|
|
372
|
-
}
|
|
315
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.CheckboxIcon, {
|
|
316
|
+
checked: displayed.length === options.length
|
|
373
317
|
}),
|
|
374
318
|
(0, _helpers.titleCase)('select all')
|
|
375
319
|
]
|
|
@@ -380,25 +324,13 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
380
324
|
handleOptionClick(option);
|
|
381
325
|
},
|
|
382
326
|
children: [
|
|
383
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
384
|
-
|
|
385
|
-
checked: isChecked(option),
|
|
386
|
-
checkedIcon: checkedIcon,
|
|
387
|
-
sx: {
|
|
388
|
-
mr: 1,
|
|
389
|
-
minWidth: 24,
|
|
390
|
-
minHeight: 24,
|
|
391
|
-
p: 0,
|
|
392
|
-
['& svg']: {
|
|
393
|
-
fill: theme.palette.primary.light
|
|
394
|
-
}
|
|
395
|
-
}
|
|
327
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.CheckboxIcon, {
|
|
328
|
+
checked: (0, _helpers.isChecked)(option, displayed, fetchedProps)
|
|
396
329
|
}),
|
|
397
330
|
getSingleOptionFromListOrDisplayed(option, 'list')
|
|
398
331
|
]
|
|
399
332
|
}, option._id);
|
|
400
|
-
})
|
|
401
|
-
' '
|
|
333
|
+
})
|
|
402
334
|
]
|
|
403
335
|
});
|
|
404
336
|
}
|
|
@@ -416,10 +348,10 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
416
348
|
}
|
|
417
349
|
}
|
|
418
350
|
};
|
|
419
|
-
const loadMore = ()=>{
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
351
|
+
// const loadMore = () => {
|
|
352
|
+
// setPage( ( prevPage ) => prevPage + 1 )
|
|
353
|
+
// setPrevPage( ( prevPage ) => prevPage + 1 )
|
|
354
|
+
// }
|
|
423
355
|
const getCurrentValues = ()=>{
|
|
424
356
|
if (multiple) {
|
|
425
357
|
return getDisplayedValuesMultiple();
|
|
@@ -427,123 +359,28 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
427
359
|
return getSingleOptionFromListOrDisplayed(displayed, 'displayed');
|
|
428
360
|
}
|
|
429
361
|
};
|
|
430
|
-
const OneOption = ({ option, curValue, modal, modal_type })=>{
|
|
431
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
432
|
-
sx: {
|
|
433
|
-
display: 'flex',
|
|
434
|
-
justifyContent: 'space-between',
|
|
435
|
-
width: '100%',
|
|
436
|
-
gap: 1,
|
|
437
|
-
color: 'grey',
|
|
438
|
-
cursor: 'pointer'
|
|
439
|
-
},
|
|
440
|
-
children: [
|
|
441
|
-
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
442
|
-
sx: {
|
|
443
|
-
width: '100%',
|
|
444
|
-
display: 'flex',
|
|
445
|
-
justifyContent: 'flex-start',
|
|
446
|
-
gap: 1
|
|
447
|
-
},
|
|
448
|
-
children: [
|
|
449
|
-
modal_type == 'logo' && /*#__PURE__*/ (0, _jsxruntime.jsx)(Logo, {
|
|
450
|
-
option: option
|
|
451
|
-
}),
|
|
452
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
453
|
-
variant: "subtitle2",
|
|
454
|
-
color: theme.palette.typography.title,
|
|
455
|
-
children: (0, _helpers.titleCase)(curValue)
|
|
456
|
-
}),
|
|
457
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(DeleteButton, {
|
|
458
|
-
option: option,
|
|
459
|
-
isDisplay: modal == 'displayed'
|
|
460
|
-
})
|
|
461
|
-
]
|
|
462
|
-
}),
|
|
463
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(ChosenIcon, {
|
|
464
|
-
option: option,
|
|
465
|
-
isDisplay: modal == 'list'
|
|
466
|
-
})
|
|
467
|
-
]
|
|
468
|
-
}, option._id);
|
|
469
|
-
};
|
|
470
|
-
const DeleteButton = ({ option, isDisplay })=>{
|
|
471
|
-
const isDisplayButton = isDisplay && (multiple && (displayed === null || displayed === void 0 ? void 0 : displayed.length) > 0 || !multiple && displayed[search_path] === (0, _helpers.getOption)(option, title_path));
|
|
472
|
-
switch(isDisplayButton){
|
|
473
|
-
case true:
|
|
474
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
475
|
-
onClick: ()=>{
|
|
476
|
-
deleteOneItem(option);
|
|
477
|
-
},
|
|
478
|
-
children: "x"
|
|
479
|
-
});
|
|
480
|
-
default:
|
|
481
|
-
return null;
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
const ChosenIcon = ({ option, isDisplay })=>{
|
|
485
|
-
if (isDisplay && isChecked(option)) {
|
|
486
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
487
|
-
width: 16,
|
|
488
|
-
height: 16,
|
|
489
|
-
icon: 'filters/chosen_icon.svg'
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
return null;
|
|
493
|
-
};
|
|
494
|
-
const Logo = ({ option })=>{
|
|
495
|
-
var _option_name;
|
|
496
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
|
|
497
|
-
style: {
|
|
498
|
-
width: '70px'
|
|
499
|
-
},
|
|
500
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
501
|
-
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'}`,
|
|
502
|
-
width: 70,
|
|
503
|
-
height: 16,
|
|
504
|
-
variant: "rounded",
|
|
505
|
-
fontSize: 17,
|
|
506
|
-
background: (0, _helpers.useRandomColor)(theme)
|
|
507
|
-
})
|
|
508
|
-
});
|
|
509
|
-
};
|
|
510
|
-
const Chip = ({ option, curValue, modal })=>{
|
|
511
|
-
return modal == 'displayed' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
512
|
-
status: curValue,
|
|
513
|
-
label: (0, _helpers.titleCase)(curValue),
|
|
514
|
-
variant: "outlined",
|
|
515
|
-
onDelete: ()=>{
|
|
516
|
-
deleteOneItem(option);
|
|
517
|
-
}
|
|
518
|
-
}, option._id) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
519
|
-
status: curValue,
|
|
520
|
-
label: (0, _helpers.titleCase)(curValue),
|
|
521
|
-
variant: "outlined"
|
|
522
|
-
}, option._id);
|
|
523
|
-
};
|
|
524
362
|
const getSingleOptionFromListOrDisplayed = (option, modal)=>{
|
|
525
363
|
if (option) {
|
|
526
364
|
let rv = null;
|
|
527
365
|
const clicked = (0, _helpers.getOption)(option, title_path);
|
|
528
366
|
switch(modal_type){
|
|
529
367
|
case 'chip':
|
|
530
|
-
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
368
|
+
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ChipOption, {
|
|
531
369
|
option: option,
|
|
532
370
|
curValue: clicked,
|
|
533
371
|
modal: modal
|
|
534
372
|
});
|
|
535
373
|
break;
|
|
536
374
|
case 'logo':
|
|
537
|
-
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
375
|
+
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.LogoOption, {
|
|
538
376
|
option: option,
|
|
539
377
|
curValue: clicked,
|
|
540
|
-
modal: modal
|
|
541
|
-
modal_type: modal_type
|
|
378
|
+
modal: modal
|
|
542
379
|
});
|
|
543
380
|
break;
|
|
544
381
|
case 'text':
|
|
545
382
|
default:
|
|
546
|
-
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
383
|
+
rv = /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.TextOption, {
|
|
547
384
|
option: option,
|
|
548
385
|
curValue: clicked,
|
|
549
386
|
modal: modal
|
|
@@ -566,11 +403,12 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
566
403
|
sx: {
|
|
567
404
|
overflow: 'hidden',
|
|
568
405
|
flexWrap: 'wrap',
|
|
569
|
-
gap: 1
|
|
406
|
+
gap: 1,
|
|
407
|
+
width: '100%'
|
|
570
408
|
},
|
|
571
|
-
children: displayed.map((item)=>{
|
|
409
|
+
children: Array.isArray(displayed) && (displayed === null || displayed === void 0 ? void 0 : displayed.map((item)=>{
|
|
572
410
|
return getSingleOptionFromListOrDisplayed(item, 'displayed');
|
|
573
|
-
})
|
|
411
|
+
}))
|
|
574
412
|
}),
|
|
575
413
|
(displayed === null || displayed === void 0 ? void 0 : displayed.length) > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
576
414
|
sx: {
|
|
@@ -582,10 +420,12 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
582
420
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
|
|
583
421
|
onClick: ()=>{
|
|
584
422
|
setDisplayed([]);
|
|
585
|
-
|
|
423
|
+
if (onRemoveAll) {
|
|
424
|
+
onRemoveAll();
|
|
425
|
+
}
|
|
586
426
|
sessionStorage.removeItem(`dropdown-${query}-${name}-${_id}`);
|
|
587
427
|
},
|
|
588
|
-
icon:
|
|
428
|
+
icon: 'filters/remove_all_button.svg',
|
|
589
429
|
width: 16,
|
|
590
430
|
height: 16
|
|
591
431
|
})
|
|
@@ -609,7 +449,9 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
609
449
|
handleSearch(e);
|
|
610
450
|
},
|
|
611
451
|
onFocus: ()=>{
|
|
612
|
-
!isInitialOpen
|
|
452
|
+
if (!isInitialOpen) {
|
|
453
|
+
setIsOpen(true);
|
|
454
|
+
}
|
|
613
455
|
}
|
|
614
456
|
}),
|
|
615
457
|
loading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_dropdownstyles.Loading, {
|
|
@@ -627,7 +469,7 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
627
469
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
628
470
|
onClick: ()=>{
|
|
629
471
|
setReason('loaded more');
|
|
630
|
-
loadMore();
|
|
472
|
+
loadMore(page, prevPage);
|
|
631
473
|
},
|
|
632
474
|
children: "load more"
|
|
633
475
|
})
|
|
@@ -636,4 +478,4 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
|
|
|
636
478
|
}) : null
|
|
637
479
|
]
|
|
638
480
|
});
|
|
639
|
-
}
|
|
481
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "CheckboxIcon", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return CheckboxIcon;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
13
|
+
const _material = require("@mui/material");
|
|
14
|
+
const _iconsmaterial = require("@mui/icons-material");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const uncheckedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBoxOutlineBlank, {
|
|
21
|
+
fontSize: "small"
|
|
22
|
+
});
|
|
23
|
+
const checkedIcon = /*#__PURE__*/ (0, _jsxruntime.jsx)(_iconsmaterial.CheckBox, {
|
|
24
|
+
fontSize: "small"
|
|
25
|
+
});
|
|
26
|
+
const CheckboxIcon = ({ checked })=>{
|
|
27
|
+
const theme = (0, _material.useTheme)();
|
|
28
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
|
|
29
|
+
icon: uncheckedIcon,
|
|
30
|
+
checked: checked,
|
|
31
|
+
checkedIcon: checkedIcon,
|
|
32
|
+
sx: {
|
|
33
|
+
mr: 1,
|
|
34
|
+
minWidth: 24,
|
|
35
|
+
minHeight: 24,
|
|
36
|
+
p: 0,
|
|
37
|
+
['& svg']: {
|
|
38
|
+
fill: theme.palette.primary.light
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ChipOption", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ChipOption;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
13
|
+
const _FxChip = require("../../FxChip");
|
|
14
|
+
const _helpers = require("../helpers/helpers");
|
|
15
|
+
const _useDropdownStore = /*#__PURE__*/ _interop_require_default(require("./../useDropdownStore"));
|
|
16
|
+
function _interop_require_default(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const ChipOption = ({ option, curValue, modal })=>{
|
|
22
|
+
const { fetchedProps, displayed, setDisplayed } = (0, _useDropdownStore.default)();
|
|
23
|
+
return modal == 'displayed' ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
24
|
+
status: curValue,
|
|
25
|
+
label: (0, _helpers.titleCase)(curValue),
|
|
26
|
+
variant: "outlined",
|
|
27
|
+
onDelete: ()=>{
|
|
28
|
+
(0, _helpers.deleteOneItem)(option, fetchedProps, displayed, setDisplayed);
|
|
29
|
+
}
|
|
30
|
+
}, option._id) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxChip.FxChip, {
|
|
31
|
+
status: curValue,
|
|
32
|
+
label: (0, _helpers.titleCase)(curValue),
|
|
33
|
+
variant: "outlined"
|
|
34
|
+
}, option._id);
|
|
35
|
+
};
|