@symply.io/basic-components 1.7.6-alpha.1 → 1.7.6-alpha.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.
@@ -57,7 +57,7 @@ var __rest = (this && this.__rest) || function (s, e) {
57
57
  return t;
58
58
  };
59
59
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
60
- import { useRef, forwardRef, useCallback, useImperativeHandle, } from "react";
60
+ import { useRef, forwardRef, useCallback, cloneElement, useImperativeHandle, } from "react";
61
61
  import Grid from "@mui/material/Grid";
62
62
  import Button from "@mui/material/Button";
63
63
  import Dialog from "@mui/material/Dialog";
@@ -121,7 +121,7 @@ function BasicModal(props, ref) {
121
121
  ? undefined
122
122
  : function (ev) {
123
123
  ev.preventDefault();
124
- } }, { children: [desc && _jsx(DialogContentText, { children: desc }), Boolean(children) ? children : _jsx(_Fragment, {})] })) })), !hideBottomButtons && (_jsx(DialogActions, __assign({ sx: { padding: theme.spacing(1.25) } }, { children: _jsx(Grid, __assign({ container: true, spacing: 2, justifyContent: "flex-end", alignItems: "center", sx: { margin: 0 } }, { children: buttons || (_jsxs(_Fragment, { children: [_jsx(Grid, __assign({ item: true, xs: 12, md: 3, xl: 2 }, { children: _jsx(Button, __assign({ onClick: onClose, variant: "outlined", color: color, disabled: loading, fullWidth: true }, { children: cancelText })) })), _jsx(Grid, __assign({ item: true, xs: 12, md: 3, xl: 2 }, { children: _jsx(Button, __assign({ type: noForm ? "button" : "submit", onClick: noForm ? onSubmit : onFormSubmit, variant: "contained", color: color, disabled: loading || disabled, fullWidth: true }, { children: submitText })) }))] })) })) })))] })) })));
124
+ } }, { children: [desc && _jsx(DialogContentText, { children: desc }), Boolean(children) && cloneElement(children)] })) })), !hideBottomButtons && (_jsx(DialogActions, __assign({ sx: { padding: theme.spacing(1.25) } }, { children: _jsx(Grid, __assign({ container: true, spacing: 2, justifyContent: "flex-end", alignItems: "center", sx: { margin: 0 } }, { children: buttons || (_jsxs(_Fragment, { children: [_jsx(Grid, __assign({ item: true, xs: 12, md: 3, xl: 2 }, { children: _jsx(Button, __assign({ onClick: onClose, variant: "outlined", color: color, disabled: loading, fullWidth: true }, { children: cancelText })) })), _jsx(Grid, __assign({ item: true, xs: 12, md: 3, xl: 2 }, { children: _jsx(Button, __assign({ type: noForm ? "button" : "submit", onClick: noForm ? onSubmit : onFormSubmit, variant: "contained", color: color, disabled: loading || disabled, fullWidth: true }, { children: submitText })) }))] })) })) })))] })) })));
125
125
  }
126
126
  var BasicModalWithRefForward = forwardRef(BasicModal);
127
127
  BasicModalWithRefForward.displayName = "BasicModal";
@@ -21,6 +21,8 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
24
+ import Box from "@mui/material/Box";
25
+ import Chip from "@mui/material/Chip";
24
26
  import Select from "@mui/material/Select";
25
27
  import Tooltip from "@mui/material/Tooltip";
26
28
  import Checkbox from "@mui/material/Checkbox";
@@ -33,28 +35,27 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
33
35
  import useInteractions from "./useInteractions";
34
36
  import useCustomTheme from "../useCustomTheme";
35
37
  function MultipleSelector(props) {
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"]);
38
+ 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.showHelperText, showHelperText = _d === void 0 ? false : _d, helperText = props.helperText, _e = props.options, options = _e === void 0 ? [] : _e, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, _f = props.showCheckmarks, showCheckmarks = _f === void 0 ? false : _f, onChange = props.onChange, rest = __rest(props, ["label", "variant", "value", "name", "tooltip", "required", "disabled", "showHelperText", "helperText", "options", "primaryColor", "secondaryColor", "showCheckmarks", "onChange"]);
37
39
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
38
- var _h = useInteractions(), tooltipOpen = _h.tooltipOpen, onOpenTooltip = _h.onOpenTooltip, onCloseTooltip = _h.onCloseTooltip;
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, PopperProps: { sx: { zIndex: theme.zIndex.modal + 1 } } }, { 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) {
40
+ var _g = useInteractions(), tooltipOpen = _g.tooltipOpen, onOpenTooltip = _g.onOpenTooltip, onCloseTooltip = _g.onCloseTooltip;
41
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tooltip, __assign({ arrow: true, placement: "top", title: tooltip !== null && tooltip !== void 0 ? tooltip : "", open: !!tooltip && tooltipOpen, PopperProps: { sx: { zIndex: theme.zIndex.modal + 1 } } }, { children: _jsxs(FormControl, __assign({ variant: variant, disabled: disabled, required: required }, rest, { children: [label ? (_jsx(InputLabel, __assign({ id: "symply-multiple-select" }, { children: label }))) : (_jsx(_Fragment, {})), _jsx(Select, __assign({ disabled: disabled, required: required, value: value, multiple: true, name: name, onChange: function (event) {
40
42
  var _a;
41
43
  event.preventDefault();
42
44
  onChange((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value);
43
45
  }, inputProps: {
44
46
  onFocus: onOpenTooltip,
45
- onBlur: onCloseTooltip
46
- }, label: label, renderValue: multiple
47
- ? function (selectedValues) {
48
- return options
49
- .filter(function (opt) {
50
- return selectedValues
47
+ onBlur: onCloseTooltip,
48
+ }, label: label, renderValue: function (selectedValues) { return (_jsx(Box, __assign({ sx: { display: "flex", flexWrap: "wrap", gap: 0.5 } }, { children: options
49
+ .filter(function (opt) {
50
+ return !["selectAll", "unselectAll"].includes(String(opt.value)) &&
51
+ selectedValues
51
52
  .map(function (v) { return String(v); })
52
53
  .includes(String(opt.value));
53
- })
54
- .map(function (opt) { return opt.label; })
55
- .join("; ");
56
- }
57
- : undefined }, { children: (options === null || options === void 0 ? void 0 : options.length) > 0 ? (options.map(function (option) {
54
+ })
55
+ .map(function (opt) {
56
+ var label = opt.label, value = opt.value;
57
+ return _jsx(Chip, { label: label || "" }, value);
58
+ }) }))); } }, { children: (options === null || options === void 0 ? void 0 : options.length) > 0 ? (options.map(function (option) {
58
59
  var label = option.label, v = option.value;
59
60
  return (_jsxs(MenuItem, __assign({ value: v }, { children: [showCheckmarks ? (_jsx(Checkbox, { checked: !!value.includes(v) })) : (_jsx(_Fragment, {})), _jsx(ListItemText, { primary: label })] }), v));
60
61
  })) : (_jsx(MenuItem, __assign({ value: "", disabled: true }, { children: "No Options" }))) })), !!helperText && showHelperText ? (_jsx(FormHelperText, { children: helperText })) : (_jsx(_Fragment, {}))] })) })) })));
@@ -1,5 +1,4 @@
1
1
  import { ReactNode, CSSProperties } from "react";
2
- import { SelectProps } from "@mui/material/Select";
3
2
  import { FormControlProps } from "@mui/material/FormControl";
4
3
  interface SelectorBaseProps<T extends string | number> extends Omit<FormControlProps, "onChange"> {
5
4
  label?: string;
@@ -7,7 +6,6 @@ interface SelectorBaseProps<T extends string | number> extends Omit<FormControlP
7
6
  tooltip?: ReactNode;
8
7
  helperText?: string;
9
8
  showHelperText?: boolean;
10
- multiple?: SelectProps["multiple"];
11
9
  primaryColor?: CSSProperties["color"];
12
10
  secondaryColor?: CSSProperties["color"];
13
11
  options: Array<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.7.6-alpha.1",
3
+ "version": "1.7.6-alpha.2",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",
@@ -47,7 +47,7 @@
47
47
  "@types/react": "^18.2.16",
48
48
  "@types/react-dom": "^18.2.7",
49
49
  "babel-loader": "^8.2.2",
50
- "typescript": "5.3.3"
50
+ "typescript": "~4.6.3"
51
51
  },
52
52
  "dependencies": {
53
53
  "@emotion/react": "^11.7.1",