@symply.io/basic-components 1.6.5-alpha.1 → 1.6.6-alpha.1

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.
@@ -20,27 +20,29 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  }
21
21
  return t;
22
22
  };
23
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  import Select from "@mui/material/Select";
25
25
  import Tooltip from "@mui/material/Tooltip";
26
+ import Checkbox from "@mui/material/Checkbox";
26
27
  import MenuItem from "@mui/material/MenuItem";
27
28
  import InputLabel from "@mui/material/InputLabel";
28
29
  import FormControl from "@mui/material/FormControl";
30
+ import ListItemText from "@mui/material/ListItemText";
29
31
  import FormHelperText from "@mui/material/FormHelperText";
30
32
  import ThemeProvider from "@mui/material/styles/ThemeProvider";
31
33
  import useInteractions from "./useInteractions";
32
34
  import useCustomTheme from "../useCustomTheme";
33
35
  function MultipleSelector(props) {
34
- var label = props.label, _a = props.variant, variant = _a === void 0 ? "outlined" : _a, value = props.value, name = props.name, tooltip = props.tooltip, _b = props.required, required = _b === void 0 ? false : _b, _c = props.disabled, disabled = _c === void 0 ? false : _c, _d = props.multiple, multiple = _d === void 0 ? false : _d, _e = props.showHelperText, showHelperText = _e === void 0 ? false : _e, helperText = props.helperText, _f = props.options, options = _f === void 0 ? [] : _f, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onChange = props.onChange, rest = __rest(props, ["label", "variant", "value", "name", "tooltip", "required", "disabled", "multiple", "showHelperText", "helperText", "options", "primaryColor", "secondaryColor", "onChange"]);
36
+ var label = props.label, _a = props.variant, variant = _a === void 0 ? "outlined" : _a, value = props.value, name = props.name, tooltip = props.tooltip, _b = props.required, required = _b === void 0 ? false : _b, _c = props.disabled, disabled = _c === void 0 ? false : _c, _d = props.multiple, multiple = _d === void 0 ? false : _d, _e = props.showHelperText, showHelperText = _e === void 0 ? false : _e, helperText = props.helperText, _f = props.options, options = _f === void 0 ? [] : _f, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, _g = props.showCheckmarks, showCheckmarks = _g === void 0 ? false : _g, onChange = props.onChange, rest = __rest(props, ["label", "variant", "value", "name", "tooltip", "required", "disabled", "multiple", "showHelperText", "helperText", "options", "primaryColor", "secondaryColor", "showCheckmarks", "onChange"]);
35
37
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
36
- var _g = useInteractions(), tooltipOpen = _g.tooltipOpen, onOpenTooltip = _g.onOpenTooltip, onCloseTooltip = _g.onCloseTooltip;
38
+ var _h = useInteractions(), tooltipOpen = _h.tooltipOpen, onOpenTooltip = _h.onOpenTooltip, onCloseTooltip = _h.onCloseTooltip;
37
39
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ arrow: true, placement: "top", title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen }, { children: _jsxs(FormControl, __assign({ variant: variant, disabled: disabled, required: required }, rest, { children: [label && (_jsx(InputLabel, __assign({ id: "symply-multiple-select" }, { children: label }))), _jsx(Select, __assign({ disabled: disabled, required: required, value: value, multiple: true, name: name, onChange: function (event) {
38
40
  var _a;
39
41
  event.preventDefault();
40
42
  onChange((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value);
41
43
  }, inputProps: {
42
44
  onFocus: onOpenTooltip,
43
- onBlur: onCloseTooltip
45
+ onBlur: onCloseTooltip,
44
46
  }, label: label, renderValue: multiple
45
47
  ? function (selectedValues) {
46
48
  return options
@@ -53,8 +55,8 @@ function MultipleSelector(props) {
53
55
  .join("; ");
54
56
  }
55
57
  : undefined }, { children: (options === null || options === void 0 ? void 0 : options.length) > 0 ? (options.map(function (option) {
56
- var _a = option, label = _a.label, value = _a.value;
57
- return (_jsx(MenuItem, __assign({ value: value }, { children: label }), value));
58
+ var _a = option, label = _a.label, v = _a.value;
59
+ return (_jsxs(MenuItem, __assign({ value: v }, { children: [showCheckmarks ? (_jsx(Checkbox, { checked: !!options.find(function (opt) { return opt.value === v; }) })) : (_jsx(_Fragment, {})), _jsx(ListItemText, { primary: label })] }), v));
58
60
  })) : (_jsx(MenuItem, __assign({ value: "", disabled: true }, { children: "No Options" }))) })), !!helperText && showHelperText && (_jsx(FormHelperText, { children: showHelperText }))] })) })) })));
59
61
  }
60
62
  export default MultipleSelector;
@@ -40,10 +40,10 @@ function SimpleSelector(props) {
40
40
  onChange((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value);
41
41
  }, inputProps: {
42
42
  onFocus: onOpenTooltip,
43
- onBlur: onCloseTooltip
43
+ onBlur: onCloseTooltip,
44
44
  }, label: label }, { children: (options === null || options === void 0 ? void 0 : options.length) > 0 ? (options.map(function (option) {
45
- var label = option.label, value = option.value, disabled = option.disabled;
46
- return (_jsx(MenuItem, __assign({ value: value, disabled: disabled }, { children: label }), value));
45
+ var label = option.label, v = option.value, disabled = option.disabled;
46
+ return (_jsx(MenuItem, __assign({ value: v, disabled: disabled }, { children: label }), v));
47
47
  })) : (_jsx(MenuItem, __assign({ value: "", disabled: true }, { children: "No Options" }))) })), !!helperText && showHelperText && (_jsx(FormHelperText, { children: showHelperText }))] })) })) })));
48
48
  }
49
49
  export default SimpleSelector;
@@ -22,6 +22,7 @@ export interface SimpleSelectorProps extends SelectorBaseProps {
22
22
  }
23
23
  export interface MultipleSelectorProps extends SelectorBaseProps {
24
24
  value: Array<number> | Array<string>;
25
+ showCheckmarks?: boolean;
25
26
  onChange: (value?: string | Array<number> | Array<string>) => void;
26
27
  }
27
28
  export {};
package/README.md CHANGED
@@ -589,7 +589,7 @@ It is extended from `@mui/material/FormControl`, so it includes all properties o
589
589
  | label | string | | false | The label of `Select` element. |
590
590
  | multiple | bool | false | false | If `true`, you can select more than 1 option. |
591
591
  | options | Array\<IRadioOption\> | | true | The radio options. See the **Selector Option Props** above. |
592
- | showHelperText | bool | false | False | If `true`, show the helper text. |
592
+ | showHelperText | bool | false | false | If `true`, show the helper text. |
593
593
  | tooltip | string | | false | A tooltip for the `Select` element. |
594
594
 
595
595
  <h5>Simple Selector Props</h5> Extended from the Base Props
@@ -597,14 +597,15 @@ It is extended from `@mui/material/FormControl`, so it includes all properties o
597
597
  | Name | Type | Default | Required | Description |
598
598
  | -------- | ---------------- | ------- | -------- | ------------------------------------------------------------ |
599
599
  | onChange | func | | true | Callback fired when the `Select` value is changed.<br />**Signature:**<br/>`function(value: string | number) => void`<br/>*value:* The value of the `Select` element. |
600
- | value | number \| string | | True | The value of the `Select` element. |
600
+ | value | number \| string | | true | The value of the `Select` element. |
601
601
 
602
602
  <h5>Multiple Selector Props</h5> Extended from the Base Props
603
603
 
604
- | Name | Type | Default | Required | Description |
605
- | -------- | ---------------------------------- | ------- | -------- | ------------------------------------------------------------ |
606
- | onChange | func | | true | Callback fired when the `Select` value is changed.<br />**Signature:**<br/>`function(value: Array<number> | Array<string>) => void`<br/>*value:* The value of the `Select` element. |
607
- | value | Array\<number\> \| Array\<string\> | | | The value of the `Select` element. |
604
+ | Name | Type | Default | Required | Description |
605
+ | -------------- | ---------------------------------- | ------- | -------- | ------------------------------------------------------------ |
606
+ | onChange | func | | true | Callback fired when the `Select` value is changed.<br />**Signature:**<br/>`function(value: Array<number> | Array<string>) => void`<br/>*value:* The value of the `Select` element. |
607
+ | showCheckmarks | bool | false | false | If `true` the option will be shown with a checkbox. |
608
+ | value | Array\<number\> \| Array\<string\> | | false | The value of the `Select` element. |
608
609
 
609
610
 
610
611
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.6.5-alpha.1",
3
+ "version": "1.6.6-alpha.1",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",