@fixefy/fixefy-ui-components 0.3.0 → 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':
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- export declare const FxMenuItemWithIcon: ({ title, icon, onClick }: {
2
+ export declare const FxMenuItemWithIcon: ({ title, icon, onClick, sx, }: {
3
3
  title: string;
4
4
  icon: any;
5
5
  onClick?: any;
6
+ sx?: any;
6
7
  }) => React.JSX.Element;
@@ -13,12 +13,40 @@ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
13
13
  const _material = require("@mui/material");
14
14
  const _fixefyuiutils = require("@fixefy/fixefy-ui-utils");
15
15
  const _FxIcon = require("../FxIcon");
16
+ function _define_property(obj, key, value) {
17
+ if (key in obj) {
18
+ Object.defineProperty(obj, key, {
19
+ value: value,
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true
23
+ });
24
+ } else {
25
+ obj[key] = value;
26
+ }
27
+ return obj;
28
+ }
16
29
  function _interop_require_default(obj) {
17
30
  return obj && obj.__esModule ? obj : {
18
31
  default: obj
19
32
  };
20
33
  }
21
- const FxMenuItemWithIcon = ({ title, icon, onClick })=>{
34
+ function _object_spread(target) {
35
+ for(var i = 1; i < arguments.length; i++){
36
+ var source = arguments[i] != null ? arguments[i] : {};
37
+ var ownKeys = Object.keys(source);
38
+ if (typeof Object.getOwnPropertySymbols === "function") {
39
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
40
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
41
+ }));
42
+ }
43
+ ownKeys.forEach(function(key) {
44
+ _define_property(target, key, source[key]);
45
+ });
46
+ }
47
+ return target;
48
+ }
49
+ const FxMenuItemWithIcon = ({ title, icon, onClick, sx = {} })=>{
22
50
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
23
51
  sx: {
24
52
  width: '197px',
@@ -43,10 +71,10 @@ const FxMenuItemWithIcon = ({ title, icon, onClick })=>{
43
71
  }),
44
72
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ListItemText, {
45
73
  secondary: (0, _fixefyuiutils.titleCase)(title),
46
- secondaryTypographyProps: {
74
+ secondaryTypographyProps: _object_spread({
47
75
  fontSize: '14px',
48
76
  marginLeft: '-10px'
49
- }
77
+ }, sx)
50
78
  })
51
79
  ]
52
80
  });
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
- export declare const FxModalWithMenu: ({ btnType, btnValue, modalData, onClick, disabled, icon, shouldShowModal, sx, iconSize, }: {
2
+ export declare const FxModalWithMenu: ({ btnType, btnValue, modalData, onClick, disabled, startIcon, endIcon, shouldShowModal, buttonSx, menuItemSx, iconSize, }: {
3
3
  btnType?: 'text' | 'icon';
4
4
  btnValue?: string;
5
5
  modalData: any;
6
6
  onClick?: any;
7
7
  disabled?: boolean;
8
- icon?: string;
8
+ startIcon?: string;
9
+ endIcon?: string;
9
10
  shouldShowModal?: boolean;
10
- sx?: any;
11
+ buttonSx?: any;
12
+ menuItemSx?: any;
11
13
  iconSize?: number;
12
14
  }) => React.JSX.Element;
@@ -54,7 +54,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
54
54
  }
55
55
  return newObj;
56
56
  }
57
- const FxModalWithMenu = ({ btnType = 'text', btnValue, modalData, onClick, disabled, icon, shouldShowModal = true, sx, iconSize })=>{
57
+ const FxModalWithMenu = ({ btnType = 'text', btnValue, modalData, onClick, disabled, startIcon, endIcon, shouldShowModal = true, buttonSx, menuItemSx, iconSize })=>{
58
58
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
59
59
  const [AnchorEl, setAnchorEl] = (0, _react.useState)(null);
60
60
  const handleClick = (e)=>{
@@ -79,11 +79,12 @@ const FxModalWithMenu = ({ btnType = 'text', btnValue, modalData, onClick, disab
79
79
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
80
80
  children: [
81
81
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_FxStyledButton.FxStyledButton, {
82
- sx: sx,
82
+ sx: buttonSx,
83
83
  btnType: btnType,
84
84
  btnValue: btnValue,
85
85
  onClick: handleClick,
86
- startIcon: icon,
86
+ startIcon: startIcon,
87
+ endIcon: endIcon,
87
88
  iconSize: iconSize || 20,
88
89
  disabled: disabled
89
90
  }),
@@ -103,7 +104,8 @@ const FxModalWithMenu = ({ btnType = 'text', btnValue, modalData, onClick, disab
103
104
  onClick: ()=>{
104
105
  handleClose();
105
106
  item.onClick();
106
- }
107
+ },
108
+ sx: menuItemSx
107
109
  }, i);
108
110
  }))
109
111
  })
package/package.json CHANGED
@@ -65,5 +65,5 @@
65
65
  "require": "./dist/index.js"
66
66
  }
67
67
  },
68
- "version": "0.3.0"
68
+ "version": "0.3.2"
69
69
  }