@fixefy/fixefy-ui-components 0.3.1 → 0.3.2

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.
@@ -317,33 +317,85 @@ const FxAsyncDropdown = /*#__PURE__*/ _react.default.forwardRef((props)=>{
317
317
  }
318
318
  }
319
319
  };
320
+ const selectAll = ()=>{
321
+ setDisplayed((prev)=>{
322
+ const unselectedOptions = options.filter((option)=>{
323
+ return !prev.map((item)=>item[title_path]).includes((0, _helpers.getOption)(option, title_path));
324
+ });
325
+ const opts = [
326
+ ...prev,
327
+ ...unselectedOptions
328
+ ];
329
+ onAdd && onAdd(opts);
330
+ sessionStorage.setItem(`dropdown-${query}-${name}-${_id}`, JSON.stringify({
331
+ [name]: opts
332
+ }));
333
+ return opts;
334
+ });
335
+ };
336
+ const removeAllSelected = ()=>{
337
+ setDisplayed([]);
338
+ onRemoveAll && onRemoveAll();
339
+ sessionStorage.removeItem(`dropdown-${query}-${name}-${_id}`);
340
+ };
320
341
  const displayListOptions = ()=>{
321
342
  switch(type){
322
343
  case 'checkbox':
323
344
  {
324
- return options.map((option)=>{
325
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
326
- onClick: ()=>{
327
- handleOptionClick(option);
328
- },
329
- children: [
330
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
331
- icon: uncheckedIcon,
332
- checked: isChecked(option),
333
- checkedIcon: checkedIcon,
334
- sx: {
335
- mr: 1,
336
- minWidth: 24,
337
- minHeight: 24,
338
- p: 0,
339
- ['& svg']: {
340
- fill: theme.palette.primary.light
341
- }
345
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
346
+ children: [
347
+ multiple && /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
348
+ onClick: ()=>{
349
+ if (displayed.length === options.length) {
350
+ removeAllSelected();
351
+ } else {
352
+ selectAll();
342
353
  }
343
- }),
344
- getSingleOptionFromListOrDisplayed(option, 'list')
345
- ]
346
- }, option._id);
354
+ },
355
+ children: [
356
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
357
+ icon: uncheckedIcon,
358
+ checked: displayed.length === options.length,
359
+ checkedIcon: checkedIcon,
360
+ sx: {
361
+ mr: 1,
362
+ minWidth: 24,
363
+ minHeight: 24,
364
+ p: 0,
365
+ ['& svg']: {
366
+ fill: theme.palette.primary.light
367
+ }
368
+ }
369
+ }),
370
+ (0, _helpers.titleCase)('select all')
371
+ ]
372
+ }),
373
+ options.map((option)=>{
374
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)("li", {
375
+ onClick: ()=>{
376
+ handleOptionClick(option);
377
+ },
378
+ children: [
379
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Checkbox, {
380
+ icon: uncheckedIcon,
381
+ checked: isChecked(option),
382
+ checkedIcon: checkedIcon,
383
+ sx: {
384
+ mr: 1,
385
+ minWidth: 24,
386
+ minHeight: 24,
387
+ p: 0,
388
+ ['& svg']: {
389
+ fill: theme.palette.primary.light
390
+ }
391
+ }
392
+ }),
393
+ getSingleOptionFromListOrDisplayed(option, 'list')
394
+ ]
395
+ }, option._id);
396
+ }),
397
+ ' '
398
+ ]
347
399
  });
348
400
  }
349
401
  case 'text':
package/package.json CHANGED
@@ -65,5 +65,5 @@
65
65
  "require": "./dist/index.js"
66
66
  }
67
67
  },
68
- "version": "0.3.1"
68
+ "version": "0.3.2"
69
69
  }