@fixefy/fixefy-ui-components 0.3.51 → 0.3.53

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.
@@ -1,35 +1,3 @@
1
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
- 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 uncheckedIcon = /*#__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)=>{
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 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 [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)(isLocal ? fetcher.query.loc.source.body : fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
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)(isLocal ? fetcher.query.loc.source.body : fetcher.query), _object_spread_props(_object_spread({}, fetcher.queryOptions), {
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 ? setDisplayed([
192
- ...items
193
- ]) : setDisplayed(items[0]);
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' ? setOptions(newOptions) : setOptions((prevOptions)=>[
207
- ...prevOptions,
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
- onAdd && onAdd(defaultValueData === null || defaultValueData === void 0 ? void 0 : defaultValueData[method_name][0]);
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
- let clicked = (0, _helpers.getOption)(option, title_path);
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
- onAdd && onAdd(option);
284
- !multiple && setIsOpen(false);
285
- setDisplayed((prev)=>[
286
- ...prev,
287
- option
288
- ]);
289
- addToStoredDisplayed(option);
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
- onAdd && onAdd(option);
295
- addToStoredDisplayed(option);
296
- !multiple && !defaultValue && setIsOpen(false);
297
- }
298
- };
299
- const deleteOneItem = (item)=>{
300
- if (multiple) {
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
- setDisplayed((prev)=>{
324
- const unselectedOptions = options.filter((option)=>{
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)(_material.Checkbox, {
361
- icon: uncheckedIcon,
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)(_material.Checkbox, {
384
- icon: uncheckedIcon,
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
- setPage((prevPage)=>prevPage + 1);
421
- setPrevPage((prevPage)=>prevPage + 1);
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)(Chip, {
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)(OneOption, {
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)(OneOption, {
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
- onRemoveAll && onRemoveAll();
423
+ if (onRemoveAll) {
424
+ onRemoveAll();
425
+ }
586
426
  sessionStorage.removeItem(`dropdown-${query}-${name}-${_id}`);
587
427
  },
588
- icon: `filters/remove_all_button.svg`,
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 && setIsOpen(true);
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,4 @@
1
+ import React from 'react';
2
+ export declare const CheckboxIcon: ({ checked }: {
3
+ checked: any;
4
+ }) => React.JSX.Element;
@@ -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,6 @@
1
+ import React from 'react';
2
+ export declare const ChipOption: ({ option, curValue, modal }: {
3
+ option: any;
4
+ curValue: any;
5
+ modal: 'displayed' | 'list';
6
+ }) => React.JSX.Element;
@@ -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
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const ChosenIcon: ({ option, isDisplay }: {
3
+ option: any;
4
+ isDisplay: boolean;
5
+ }) => React.JSX.Element | null;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ChosenIcon", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ChosenIcon;
9
+ }
10
+ });
11
+ const _jsxruntime = require("react/jsx-runtime");
12
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
13
+ const _FxIcon = require("../../FxIcon");
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 ChosenIcon = ({ option, isDisplay })=>{
22
+ const { fetchedProps, displayed } = (0, _useDropdownStore.default)();
23
+ const { title_path, multiple, search_path } = fetchedProps;
24
+ const isChecked = (option)=>{
25
+ const clicked = (0, _helpers.getOption)(option, title_path);
26
+ if (typeof displayed === 'string') {
27
+ return false;
28
+ } else {
29
+ if (multiple) {
30
+ return Array.isArray(displayed) && displayed.map((item)=>{
31
+ return item[title_path];
32
+ }).includes(clicked);
33
+ } else {
34
+ return displayed[search_path] === clicked;
35
+ }
36
+ }
37
+ };
38
+ if (isDisplay && isChecked(option)) {
39
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
40
+ width: 16,
41
+ height: 16,
42
+ icon: 'filters/chosen_icon.svg'
43
+ });
44
+ }
45
+ return null;
46
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const DeleteButton: ({ option, isDisplay }: {
3
+ option: any;
4
+ isDisplay: boolean;
5
+ }) => React.JSX.Element | null;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "DeleteButton", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return DeleteButton;
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 _useDropdownStore = /*#__PURE__*/ _interop_require_default(require("./../useDropdownStore"));
15
+ const _helpers = require("../helpers/helpers");
16
+ function _interop_require_default(obj) {
17
+ return obj && obj.__esModule ? obj : {
18
+ default: obj
19
+ };
20
+ }
21
+ const DeleteButton = ({ option, isDisplay })=>{
22
+ const { fetchedProps, displayed, setDisplayed } = (0, _useDropdownStore.default)();
23
+ const { multiple, search_path, getOption, title_path } = fetchedProps !== null && fetchedProps !== void 0 ? fetchedProps : {};
24
+ const isDisplayButton = isDisplay && (multiple && (displayed === null || displayed === void 0 ? void 0 : displayed.length) > 0 || !multiple && displayed[search_path] === getOption(option, title_path));
25
+ switch(isDisplayButton){
26
+ case true:
27
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
28
+ sx: {
29
+ margin: '0 5px'
30
+ },
31
+ onClick: ()=>{
32
+ (0, _helpers.deleteOneItem)(option, fetchedProps, displayed, setDisplayed);
33
+ },
34
+ children: "x"
35
+ });
36
+ default:
37
+ return null;
38
+ }
39
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export declare const LogoOption: ({ option, curValue, modal }: {
3
+ option: any;
4
+ curValue: any;
5
+ modal: 'displayed' | 'list';
6
+ }) => React.JSX.Element;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "LogoOption", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return LogoOption;
9
+ }
10
+ });
11
+ const _jsxruntime = require("react/jsx-runtime");
12
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
13
+ const _FxIcon = require("../../FxIcon");
14
+ const _material = require("@mui/material");
15
+ const _styles = require("@mui/styles");
16
+ const _helpers = require("../helpers/helpers");
17
+ const _fixefyhooks = require("@fixefy/fixefy-hooks");
18
+ const _DeleteButton = require("./DeleteButton");
19
+ const _ChosenIcon = require("./ChosenIcon");
20
+ const _useDropdownStore = /*#__PURE__*/ _interop_require_default(require("./../useDropdownStore"));
21
+ function _interop_require_default(obj) {
22
+ return obj && obj.__esModule ? obj : {
23
+ default: obj
24
+ };
25
+ }
26
+ const LogoOption = ({ option, curValue, modal })=>{
27
+ const theme = (0, _styles.useTheme)();
28
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
29
+ sx: {
30
+ display: 'flex',
31
+ justifyContent: 'space-between',
32
+ width: '100%',
33
+ gap: 1,
34
+ color: 'grey',
35
+ cursor: 'pointer'
36
+ },
37
+ children: [
38
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
39
+ sx: {
40
+ width: '100%',
41
+ display: 'flex',
42
+ justifyContent: 'flex-start',
43
+ gap: 1,
44
+ alignItems: 'center'
45
+ },
46
+ children: [
47
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(Logo, {
48
+ option: option
49
+ }),
50
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
51
+ sx: {
52
+ display: 'flex',
53
+ justifyContent: 'space-between',
54
+ width: '100%'
55
+ },
56
+ children: [
57
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
58
+ variant: "subtitle2",
59
+ color: theme.palette.typography.title,
60
+ children: (0, _helpers.titleCase)(curValue)
61
+ }),
62
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteButton.DeleteButton, {
63
+ option: option,
64
+ isDisplay: modal == 'displayed'
65
+ })
66
+ ]
67
+ })
68
+ ]
69
+ }),
70
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChosenIcon.ChosenIcon, {
71
+ option: option,
72
+ isDisplay: modal == 'list'
73
+ })
74
+ ]
75
+ }, option._id);
76
+ };
77
+ const Logo = ({ option })=>{
78
+ const getRandomColor = (0, _fixefyhooks.useRandomColor)();
79
+ const { fetchedProps } = (0, _useDropdownStore.default)();
80
+ const { logo_folder_name, logo_placeholder, name } = fetchedProps !== null && fetchedProps !== void 0 ? fetchedProps : {};
81
+ var _option_name;
82
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
83
+ style: {
84
+ width: '70px'
85
+ },
86
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxIcon.FxIcon, {
87
+ 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'}`,
88
+ width: 70,
89
+ height: 16,
90
+ variant: "rounded",
91
+ fontSize: 17,
92
+ background: getRandomColor()
93
+ })
94
+ });
95
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export declare const TextOption: ({ option, curValue, modal }: {
3
+ option: any;
4
+ curValue: any;
5
+ modal: 'displayed' | 'list';
6
+ }) => React.JSX.Element;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "TextOption", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return TextOption;
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 _styles = require("@mui/styles");
15
+ const _helpers = require("../helpers/helpers");
16
+ const _DeleteButton = require("./DeleteButton");
17
+ const _ChosenIcon = require("./ChosenIcon");
18
+ function _interop_require_default(obj) {
19
+ return obj && obj.__esModule ? obj : {
20
+ default: obj
21
+ };
22
+ }
23
+ const TextOption = ({ option, curValue, modal })=>{
24
+ const theme = (0, _styles.useTheme)();
25
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
26
+ sx: {
27
+ display: 'flex',
28
+ justifyContent: 'space-between',
29
+ width: '100%',
30
+ gap: 1,
31
+ color: 'grey',
32
+ cursor: 'pointer'
33
+ },
34
+ children: [
35
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
36
+ sx: {
37
+ width: '100%',
38
+ display: 'flex',
39
+ justifyContent: 'flex-start',
40
+ gap: 1,
41
+ alignItems: 'center'
42
+ },
43
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
44
+ sx: {
45
+ display: 'flex',
46
+ justifyContent: 'space-between',
47
+ width: '100%'
48
+ },
49
+ children: [
50
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
51
+ variant: "subtitle2",
52
+ color: theme.palette.typography.title,
53
+ children: (0, _helpers.titleCase)(curValue)
54
+ }),
55
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteButton.DeleteButton, {
56
+ option: option,
57
+ isDisplay: modal == 'displayed'
58
+ })
59
+ ]
60
+ })
61
+ }),
62
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChosenIcon.ChosenIcon, {
63
+ option: option,
64
+ isDisplay: modal == 'list'
65
+ })
66
+ ]
67
+ }, option._id);
68
+ };
@@ -0,0 +1,6 @@
1
+ export { CheckboxIcon } from './CheckboxIcon';
2
+ export { ChipOption } from './ChipOption';
3
+ export { ChosenIcon } from './ChosenIcon';
4
+ export { DeleteButton } from './DeleteButton';
5
+ export { LogoOption } from './LogoOption';
6
+ export { TextOption } from './TextOption';
@@ -0,0 +1,36 @@
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
+ CheckboxIcon: function() {
13
+ return _CheckboxIcon.CheckboxIcon;
14
+ },
15
+ ChipOption: function() {
16
+ return _ChipOption.ChipOption;
17
+ },
18
+ ChosenIcon: function() {
19
+ return _ChosenIcon.ChosenIcon;
20
+ },
21
+ DeleteButton: function() {
22
+ return _DeleteButton.DeleteButton;
23
+ },
24
+ LogoOption: function() {
25
+ return _LogoOption.LogoOption;
26
+ },
27
+ TextOption: function() {
28
+ return _TextOption.TextOption;
29
+ }
30
+ });
31
+ const _CheckboxIcon = require("./CheckboxIcon");
32
+ const _ChipOption = require("./ChipOption");
33
+ const _ChosenIcon = require("./ChosenIcon");
34
+ const _DeleteButton = require("./DeleteButton");
35
+ const _LogoOption = require("./LogoOption");
36
+ const _TextOption = require("./TextOption");
@@ -6,3 +6,7 @@ export declare const titleCase: (str?: string) => string;
6
6
  export declare const toPascalCase: (string: string, title?: boolean) => string;
7
7
  export declare const useRandomColor: (theme: any) => () => unknown;
8
8
  export declare const getOption: (option: any, title_path: string) => any;
9
+ export declare const removeOneFromStoredDisplayed: (option: any, fetchedProps: any) => void;
10
+ export declare const deleteOneItem: (item: any, fetchedProps: any, displayed: any, setDisplayed: any) => void;
11
+ export declare const addToStoredDisplayed: (option: any, fetchedProps: any) => void;
12
+ export declare const isChecked: (option: any, displayed: any, fetchedProps: any) => any;
@@ -9,6 +9,12 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ addToStoredDisplayed: function() {
13
+ return addToStoredDisplayed;
14
+ },
15
+ deleteOneItem: function() {
16
+ return deleteOneItem;
17
+ },
12
18
  getJPart: function() {
13
19
  return getJPart;
14
20
  },
@@ -18,12 +24,18 @@ _export(exports, {
18
24
  isArrayValid: function() {
19
25
  return isArrayValid;
20
26
  },
27
+ isChecked: function() {
28
+ return isChecked;
29
+ },
21
30
  isObjectValid: function() {
22
31
  return isObjectValid;
23
32
  },
24
33
  isStringValid: function() {
25
34
  return isStringValid;
26
35
  },
36
+ removeOneFromStoredDisplayed: function() {
37
+ return removeOneFromStoredDisplayed;
38
+ },
27
39
  titleCase: function() {
28
40
  return titleCase;
29
41
  },
@@ -155,3 +167,67 @@ const getOption = (option, title_path)=>{
155
167
  }
156
168
  return null;
157
169
  };
170
+ const removeOneFromStoredDisplayed = (option, fetchedProps)=>{
171
+ const { multiple, title_path, name, _id, query } = fetchedProps !== null && fetchedProps !== void 0 ? fetchedProps : {};
172
+ let storedDisplayed = sessionStorage.getItem(`dropdown-${query}-${name}-${_id}`);
173
+ if (storedDisplayed) {
174
+ storedDisplayed = JSON.parse(storedDisplayed);
175
+ if (multiple) {
176
+ const newDisplayed = storedDisplayed[name].filter((opt)=>opt[title_path] !== option[title_path]);
177
+ storedDisplayed[name] = newDisplayed;
178
+ } else {
179
+ delete storedDisplayed[name];
180
+ }
181
+ sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify(storedDisplayed));
182
+ }
183
+ };
184
+ const deleteOneItem = (item, fetchedProps, displayed, setDisplayed)=>{
185
+ const { multiple, title_path, onRemoveOne } = fetchedProps !== null && fetchedProps !== void 0 ? fetchedProps : {};
186
+ if (multiple) {
187
+ const newDisplayed = displayed.filter((opt)=>opt[title_path] !== item[title_path]);
188
+ setDisplayed(newDisplayed);
189
+ } else {
190
+ setDisplayed('');
191
+ }
192
+ if (onRemoveOne) {
193
+ onRemoveOne(item);
194
+ }
195
+ removeOneFromStoredDisplayed(item, fetchedProps);
196
+ };
197
+ const addToStoredDisplayed = (option, fetchedProps)=>{
198
+ const { name, multiple, query, _id } = fetchedProps !== null && fetchedProps !== void 0 ? fetchedProps : {};
199
+ const prevStored = sessionStorage.getItem(`dropdown-${query}-${name}-${_id}`);
200
+ const data = prevStored ? JSON.parse(prevStored) : {};
201
+ if (data[name]) {
202
+ if (multiple) {
203
+ data[name] = [
204
+ ...data[name],
205
+ option
206
+ ];
207
+ } else {
208
+ data[name] = [
209
+ option
210
+ ];
211
+ }
212
+ } else {
213
+ data[name] = [
214
+ option
215
+ ];
216
+ }
217
+ sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify(data));
218
+ };
219
+ const isChecked = (option, displayed, fetchedProps)=>{
220
+ const { multiple, title_path, search_path } = fetchedProps !== null && fetchedProps !== void 0 ? fetchedProps : {};
221
+ const clicked = getOption(option, title_path);
222
+ if (typeof displayed === 'string') {
223
+ return false;
224
+ } else {
225
+ if (multiple) {
226
+ return displayed.map((item)=>{
227
+ return item[title_path];
228
+ }).includes(clicked);
229
+ } else {
230
+ return displayed[search_path] === clicked;
231
+ }
232
+ }
233
+ };
@@ -1 +1 @@
1
- export { FxAsyncDropdown, Option, StylesOptions, AsyncDropdownPropsType } from './FxAsyncDropdown';
1
+ export { FxAsyncDropdown } from './FxAsyncDropdown';
@@ -2,24 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
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 _FxAsyncDropdown.AsyncDropdownPropsType;
14
- },
15
- FxAsyncDropdown: function() {
5
+ Object.defineProperty(exports, "FxAsyncDropdown", {
6
+ enumerable: true,
7
+ get: function() {
16
8
  return _FxAsyncDropdown.FxAsyncDropdown;
17
- },
18
- Option: function() {
19
- return _FxAsyncDropdown.Option;
20
- },
21
- StylesOptions: function() {
22
- return _FxAsyncDropdown.StylesOptions;
23
9
  }
24
10
  });
25
11
  const _FxAsyncDropdown = require("./FxAsyncDropdown");
@@ -0,0 +1,39 @@
1
+ export interface Option {
2
+ title: string;
3
+ value: string | number | boolean;
4
+ [key: string]: any;
5
+ }
6
+ export interface StylesOptions {
7
+ width?: string | number;
8
+ maxWidth?: string | number;
9
+ inputSx?: object;
10
+ menuSx?: object;
11
+ }
12
+ export type AsyncDropdownPropsType = {
13
+ initialValue?: Option | any;
14
+ styles?: StylesOptions;
15
+ multiple?: boolean;
16
+ name: any;
17
+ variables: 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
+ options_path?: string;
31
+ defaultValue?: any;
32
+ fetcher?: any;
33
+ disabled?: boolean;
34
+ search_path?: any;
35
+ title_path: string;
36
+ _id: any;
37
+ logo_folder_name?: string;
38
+ logo_placeholder?: string;
39
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -0,0 +1,2 @@
1
+ declare const useDropdownStore: import("zustand").UseBoundStore<import("zustand").StoreApi<unknown>>;
2
+ export default useDropdownStore;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _default;
9
+ }
10
+ });
11
+ const _zustand = require("zustand");
12
+ const useDropdownStore = (0, _zustand.create)((set)=>({
13
+ fetchedProps: {},
14
+ setFetchedProps: (val)=>set({
15
+ fetchedProps: val
16
+ }),
17
+ displayed: null,
18
+ setDisplayed: (val)=>set({
19
+ displayed: val
20
+ }),
21
+ options: [],
22
+ setOptions: (val)=>set({
23
+ options: val
24
+ }),
25
+ reason: 'init',
26
+ setReason: (val)=>set({
27
+ reason: val
28
+ }),
29
+ isLastPage: false,
30
+ setIsLastPage: (val)=>set({
31
+ isLastPage: val
32
+ }),
33
+ isOpen: false,
34
+ setIsOpen: (val)=>set({
35
+ isOpen: val
36
+ }),
37
+ searchValue: null,
38
+ setSearchValue: (val)=>set({
39
+ searchValue: val
40
+ }),
41
+ page: 1,
42
+ setPage: (val)=>set({
43
+ page: val
44
+ }),
45
+ prevPage: 0,
46
+ setPrevPage: (val)=>set({
47
+ prevPage: val
48
+ }),
49
+ pageSize: 20,
50
+ loadMore: (page, prevPage)=>{
51
+ set({
52
+ page: page + 1,
53
+ prevPage: prevPage + 1
54
+ });
55
+ }
56
+ }));
57
+ const _default = useDropdownStore;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { FxActionsTray } from './FxActionsTray';
2
2
  export { FxAggregationsBar, AggregationsDataPropsType, AggreationsBarPropsType } from './FxAggregationsBar';
3
- export { FxAsyncDropdown, Option, StylesOptions, AsyncDropdownPropsType } from './FxAsyncDropdown';
3
+ export { FxAsyncDropdown } from './FxAsyncDropdown';
4
4
  export { FxAvatar, AvatarPropsType, BackgroundColorsType } from './FxAvatar';
5
5
  export { FxButton, ButtonPropsType } from './FxButton';
6
6
  export { FxChip, ChipPropsType } from './FxChip';
package/dist/index.js CHANGED
@@ -18,9 +18,6 @@ _export(exports, {
18
18
  Arrow: function() {
19
19
  return _FxPopper.Arrow;
20
20
  },
21
- AsyncDropdownPropsType: function() {
22
- return _FxAsyncDropdown.AsyncDropdownPropsType;
23
- },
24
21
  AvatarPropsType: function() {
25
22
  return _FxAvatar.AvatarPropsType;
26
23
  },
@@ -159,9 +156,6 @@ _export(exports, {
159
156
  NumberfieldPropsType: function() {
160
157
  return _FxNumberField.NumberfieldPropsType;
161
158
  },
162
- Option: function() {
163
- return _FxAsyncDropdown.Option;
164
- },
165
159
  Options: function() {
166
160
  return _FxStatusBar.Options;
167
161
  },
@@ -213,9 +207,6 @@ _export(exports, {
213
207
  StepsLauncher: function() {
214
208
  return _FxWizard.StepsLauncher;
215
209
  },
216
- StylesOptions: function() {
217
- return _FxAsyncDropdown.StylesOptions;
218
- },
219
210
  TagPropsType: function() {
220
211
  return _FxTag.TagPropsType;
221
212
  },
package/package.json CHANGED
@@ -19,7 +19,8 @@
19
19
  "react": "18.3.1",
20
20
  "react-dom": "18.3.1",
21
21
  "react-use-wizard": "2.3.0",
22
- "tss-react": "^4.9.14"
22
+ "tss-react": "^4.9.14",
23
+ "zustand": "^5.0.3"
23
24
  },
24
25
  "devDependencies": {
25
26
  "@svgr/webpack": "8.1.0",
@@ -69,5 +70,5 @@
69
70
  "require": "./dist/index.js"
70
71
  }
71
72
  },
72
- "version": "0.3.51"
73
+ "version": "0.3.53"
73
74
  }