@symply.io/basic-components 1.6.2 → 1.6.4-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.
@@ -1,4 +1,4 @@
1
1
  import type { AutocompleteProps, AutocompleteValueType, AutocompleteOptionType } from "./types";
2
2
  declare function CustomAutocomplete<T, multiple extends boolean | undefined = false>(props: AutocompleteProps<T, multiple>): import("react/jsx-runtime").JSX.Element;
3
3
  export default CustomAutocomplete;
4
- export type { AutocompleteProps, AutocompleteValueType, AutocompleteOptionType };
4
+ export type { AutocompleteProps, AutocompleteValueType, AutocompleteOptionType, };
@@ -46,6 +46,7 @@ function CustomAutocomplete(props) {
46
46
  return opt.label === val.label;
47
47
  }, value: value, inputValue: inputValue, onInputChange: function (event, val) {
48
48
  onInputChange(val);
49
- }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, rest, { required: required, size: size, inputProps: __assign(__assign({}, params.inputProps), { required: required && (Array.isArray(value) ? value.length === 0 : !value) }) }))); } }) })));
49
+ }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, rest, { required: required, size: size, inputProps: __assign(__assign({}, params.inputProps), { required: required &&
50
+ (Array.isArray(value) ? value.length === 0 : !value) }) }))); } }) })));
50
51
  }
51
52
  export default CustomAutocomplete;
@@ -1,8 +1,7 @@
1
1
  import type { CSSProperties } from "react";
2
2
  import type { TextFieldProps } from "@mui/material/TextField";
3
- export declare type AutocompleteOptionType<T = {
4
- [name: string]: unknown;
5
- }> = T & {
3
+ import type { AutocompleteValue } from "@mui/base/AutocompleteUnstyled";
4
+ export declare type AutocompleteOptionType<T = Record<string, any>> = T & {
6
5
  label: string;
7
6
  value?: string | number;
8
7
  };
@@ -13,8 +12,8 @@ export interface AutocompleteProps<T, multiple extends boolean | undefined> exte
13
12
  disabled?: boolean;
14
13
  loading?: boolean;
15
14
  options: Array<AutocompleteOptionType<T>>;
16
- value: AutocompleteValueType<T, multiple>;
15
+ value: AutocompleteValue<AutocompleteOptionType<T>, multiple, undefined, undefined>;
17
16
  primaryColor?: CSSProperties["color"];
18
17
  secondaryColor?: CSSProperties["color"];
19
- onChange: (value: AutocompleteValueType<T, multiple>) => void;
18
+ onChange: (value: AutocompleteValue<AutocompleteOptionType<T>, multiple, undefined, undefined>) => void;
20
19
  }
@@ -1,4 +1,4 @@
1
1
  import type { AutocompleteWithFilterProps, AutocompleteWithFilterValueType, AutocompleteWithFilterOptionType } from "./types";
2
2
  declare function AutocompleteWithFilter<T, multiple extends boolean | undefined = false>(props: AutocompleteWithFilterProps<T, multiple>): import("react/jsx-runtime").JSX.Element;
3
3
  export default AutocompleteWithFilter;
4
- export type { AutocompleteWithFilterProps, AutocompleteWithFilterValueType, AutocompleteWithFilterOptionType };
4
+ export type { AutocompleteWithFilterProps, AutocompleteWithFilterValueType, AutocompleteWithFilterOptionType, };
@@ -36,7 +36,7 @@ function AutocompleteWithFilter(props) {
36
36
  ignoreCase: true,
37
37
  ignoreAccents: true,
38
38
  trim: true,
39
- stringify: function (option) { return option.label; }
39
+ stringify: function (option) { return option.label; },
40
40
  });
41
41
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
42
42
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Autocomplete, { size: size, fullWidth: true, loading: loading, limitTags: limitTags !== null && limitTags !== void 0 ? limitTags : -1, options: options, disabled: disabled, multiple: multiple, filterOptions: filter, onChange: function (event, val) {
@@ -54,6 +54,7 @@ function AutocompleteWithFilter(props) {
54
54
  var _b, _c;
55
55
  var selected = _a.selected;
56
56
  return (_jsxs("li", __assign({}, __assign(__assign({}, props), { key: (_c = (_b = option.value) !== null && _b !== void 0 ? _b : option.label) !== null && _c !== void 0 ? _c : option }), { children: [_jsx(Checkbox, { icon: icon, color: "primary", checkedIcon: checkedIcon, style: { marginRight: 8 }, checked: selected }), option.label || ""] })));
57
- }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, rest, { variant: "outlined", required: required, inputProps: __assign(__assign({}, params.inputProps), { required: required && (Array.isArray(value) ? value.length === 0 : !value) }) }))); } }) })));
57
+ }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, rest, { variant: "outlined", required: required, inputProps: __assign(__assign({}, params.inputProps), { required: required &&
58
+ (Array.isArray(value) ? value.length === 0 : !value) }) }))); } }) })));
58
59
  }
59
60
  export default AutocompleteWithFilter;
@@ -1,12 +1,13 @@
1
1
  import type { CSSProperties } from "react";
2
2
  import type { TextFieldProps } from "@mui/material/TextField";
3
+ import type { AutocompleteValue } from "@mui/base/AutocompleteUnstyled";
3
4
  export declare type AutocompleteWithFilterOptionType<T> = T & {
4
5
  label: string;
5
6
  value?: string | number;
6
7
  };
7
8
  export declare type AutocompleteWithFilterValueType<T, multiple extends boolean | undefined> = multiple extends false | undefined ? AutocompleteWithFilterOptionType<T> | null : Array<AutocompleteWithFilterOptionType<T>>;
8
9
  export interface AutocompleteWithFilterProps<T, multiple extends boolean | undefined> extends Omit<TextFieldProps, "onChange" | "value" | "disabled"> {
9
- value: AutocompleteWithFilterValueType<T, multiple>;
10
+ value: AutocompleteValue<AutocompleteWithFilterOptionType<T>, multiple, undefined, undefined>;
10
11
  options: Array<AutocompleteWithFilterOptionType<T>>;
11
12
  disableCloseOnSelect?: boolean;
12
13
  limitTags?: number;
@@ -15,5 +16,5 @@ export interface AutocompleteWithFilterProps<T, multiple extends boolean | undef
15
16
  loading?: boolean;
16
17
  primaryColor?: CSSProperties["color"];
17
18
  secondaryColor?: CSSProperties["color"];
18
- onChange: (value: AutocompleteWithFilterValueType<T, multiple>) => void;
19
+ onChange: (value: AutocompleteValue<AutocompleteWithFilterOptionType<T>, multiple, undefined, undefined>) => void;
19
20
  }
@@ -16,7 +16,7 @@ import TableCell from "@mui/material/TableCell";
16
16
  import useMediaQuery from "@mui/material/useMediaQuery";
17
17
  import useTheme from "@mui/material/styles/useTheme";
18
18
  function TableBodyRow(props) {
19
- var row = props.row, rows = props.rows, columns = props.columns, rowIndex = props.rowIndex, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible, onRowClick = props.onRowClick, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
19
+ var row = props.row, rows = props.rows, columns = props.columns, rowIndex = props.rowIndex, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
20
20
  var _a = useState(), rowEl = _a[0], setRowEl = _a[1];
21
21
  var theme = useTheme();
22
22
  var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
@@ -56,7 +56,12 @@ function TableBodyRow(props) {
56
56
  ? function () {
57
57
  onRowClick(row);
58
58
  }
59
- : undefined }, { children: [fixedLeftCols.map(function (col, index) {
59
+ : undefined, onContextMenu: function (event) {
60
+ event.preventDefault();
61
+ if (onContextMenu) {
62
+ onContextMenu(event, row);
63
+ }
64
+ } }, { children: [fixedLeftCols.map(function (col, index) {
60
65
  var accessor = col.accessor, Cell = col.Cell, width = col.width, _a = col.align, align = _a === void 0 ? "center" : _a;
61
66
  var left = fixedLeftCols
62
67
  .slice(0, index)
@@ -20,7 +20,7 @@ import TableBody from "./TableBody";
20
20
  import TableHeader from "./TableHeader";
21
21
  import TableFooter from "./TableFooter";
22
22
  function DataTable(props) {
23
- var _a = props.columns, columns = _a === void 0 ? [] : _a, _b = props.rows, rows = _b === void 0 ? [] : _b, _c = props.headers, headers = _c === void 0 ? [] : _c, _d = props.footers, footers = _d === void 0 ? [] : _d, _e = props.noDataText, noDataText = _e === void 0 ? "No Data!" : _e, dense = props.dense, stickyHeader = props.stickyHeader, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onRowClick = props.onRowClick, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
23
+ var _a = props.columns, columns = _a === void 0 ? [] : _a, _b = props.rows, rows = _b === void 0 ? [] : _b, _c = props.headers, headers = _c === void 0 ? [] : _c, _d = props.footers, footers = _d === void 0 ? [] : _d, _e = props.noDataText, noDataText = _e === void 0 ? "No Data!" : _e, dense = props.dense, stickyHeader = props.stickyHeader, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
24
24
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
25
25
  var tableRef = useRef(null);
26
26
  var _f = useState(false), leftShadowVisible = _f[0], setLeftShadowVisible = _f[1];
@@ -55,7 +55,7 @@ function DataTable(props) {
55
55
  borderRadius: "4px",
56
56
  borderCollapse: "unset !important",
57
57
  transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"
58
- } }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, stickyHeader: stickyHeader, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onCustomizeRowBgColor: onCustomizeRowBgColor, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), footers.length > 0 ? (_jsx(TableFooter, { footers: footers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })));
58
+ } }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, stickyHeader: stickyHeader, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onContextMenu: onContextMenu, onCustomizeRowBgColor: onCustomizeRowBgColor, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), footers.length > 0 ? (_jsx(TableFooter, { footers: footers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })));
59
59
  }
60
60
  export default DataTable;
61
61
  export * from "./types";
@@ -1,4 +1,4 @@
1
- import { ReactElement, CSSProperties } from "react";
1
+ import { ReactElement, CSSProperties, MouseEvent } from "react";
2
2
  declare type HexColor = `#${string}`;
3
3
  export declare type CustomRowBgColor = {
4
4
  normal?: HexColor;
@@ -63,6 +63,7 @@ export declare type TableBodyProps<RowProps extends KvProps, ExtendedProps exten
63
63
  rightShadowVisible?: boolean;
64
64
  noDataText?: string;
65
65
  onRowClick?: (row: RowProps) => unknown;
66
+ onContextMenu?: (event: MouseEvent<HTMLTableRowElement>, row: RowProps) => unknown;
66
67
  onCustomizeRowBgColor?: ({ row, columns }: {
67
68
  row: RowProps;
68
69
  columns: Array<TableBodyCellProps<RowProps, ExtendedProps>>;
@@ -31,13 +31,13 @@ import FormControlLabel from "@mui/material/FormControlLabel";
31
31
  import ThemeProvider from "@mui/material/styles/ThemeProvider";
32
32
  import useCustomTheme from "../useCustomTheme";
33
33
  function FormRadioGroup(props) {
34
- var formLabel = props.formLabel, value = props.value, options = props.options, disabled = props.disabled, tooltip = props.tooltip, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, radioLabelPlacement = props.radioLabelPlacement, onChange = props.onChange, rest = __rest(props, ["formLabel", "value", "options", "disabled", "tooltip", "primaryColor", "secondaryColor", "radioLabelPlacement", "onChange"]);
34
+ var formLabel = props.formLabel, value = props.value, name = props.name, options = props.options, disabled = props.disabled, tooltip = props.tooltip, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, radioLabelPlacement = props.radioLabelPlacement, onChange = props.onChange, rest = __rest(props, ["formLabel", "value", "name", "options", "disabled", "tooltip", "primaryColor", "secondaryColor", "radioLabelPlacement", "onChange"]);
35
35
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
36
36
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsxs(FormControl, __assign({ disabled: disabled }, rest, { children: [tooltip ? (_jsx(Tooltip, __assign({ arrow: true, placement: "top", title: tooltip, disableTouchListener: true }, { children: _jsx(FormLabel, { children: formLabel }) }))) : (_jsx(FormLabel, { children: formLabel })), _jsx(RadioGroup, __assign({ value: value, onChange: function (event) {
37
37
  onChange(event.target.value);
38
38
  } }, { children: options.map(function (opt) {
39
39
  var _a;
40
- return (_jsx(FormControlLabel, { value: opt.value, control: _jsx(Radio, {}), label: _jsx(Typography, { children: opt.label }), labelPlacement: radioLabelPlacement || "end", disabled: ((_a = opt.disabled) !== null && _a !== void 0 ? _a : false) || disabled }, String(opt.value)));
40
+ return (_jsx(FormControlLabel, { value: opt.value, name: name, control: _jsx(Radio, {}), label: _jsx(Typography, { children: opt.label }), labelPlacement: radioLabelPlacement || "end", disabled: ((_a = opt.disabled) !== null && _a !== void 0 ? _a : false) || disabled }, String(opt.value)));
41
41
  }) }))] })) })));
42
42
  }
43
43
  export default FormRadioGroup;
@@ -10,6 +10,7 @@ export interface FormRadioGroupProps extends Omit<FormControlProps, "onChange">
10
10
  formLabel: string;
11
11
  options: Array<RadioOption>;
12
12
  value: string | boolean | number;
13
+ name?: string;
13
14
  tooltip?: string;
14
15
  primaryColor?: CSSProperties["color"];
15
16
  secondaryColor?: CSSProperties["color"];
@@ -31,10 +31,10 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
31
31
  import useInteractions from "./useInteractions";
32
32
  import useCustomTheme from "../useCustomTheme";
33
33
  function MultipleSelector(props) {
34
- var label = props.label, _a = props.variant, variant = _a === void 0 ? "outlined" : _a, value = props.value, 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", "tooltip", "required", "disabled", "multiple", "showHelperText", "helperText", "options", "primaryColor", "secondaryColor", "onChange"]);
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"]);
35
35
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
36
36
  var _g = useInteractions(), tooltipOpen = _g.tooltipOpen, onOpenTooltip = _g.onOpenTooltip, onCloseTooltip = _g.onCloseTooltip;
37
- 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, onChange: function (event) {
37
+ 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
38
  var _a;
39
39
  event.preventDefault();
40
40
  onChange((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value);
@@ -31,10 +31,10 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
31
31
  import useInteractions from "./useInteractions";
32
32
  import useCustomTheme from "../useCustomTheme";
33
33
  function SimpleSelector(props) {
34
- var label = props.label, _a = props.variant, variant = _a === void 0 ? "outlined" : _a, value = props.value, tooltip = props.tooltip, _b = props.disabled, disabled = _b === void 0 ? false : _b, _c = props.required, required = _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, onChange = props.onChange, rest = __rest(props, ["label", "variant", "value", "tooltip", "disabled", "required", "showHelperText", "helperText", "options", "primaryColor", "secondaryColor", "onChange"]);
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.disabled, disabled = _b === void 0 ? false : _b, _c = props.required, required = _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, onChange = props.onChange, rest = __rest(props, ["label", "variant", "value", "name", "tooltip", "disabled", "required", "showHelperText", "helperText", "options", "primaryColor", "secondaryColor", "onChange"]);
35
35
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
36
36
  var _f = useInteractions(), tooltipOpen = _f.tooltipOpen, onOpenTooltip = _f.onOpenTooltip, onCloseTooltip = _f.onCloseTooltip;
37
- 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-simple-selector" }, { children: label }))), _jsx(Select, __assign({ value: value, required: required, disabled: disabled, onChange: function (event) {
37
+ 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-simple-selector" }, { children: label }))), _jsx(Select, __assign({ value: value, name: name, required: required, disabled: disabled, onChange: function (event) {
38
38
  var _a;
39
39
  event.preventDefault();
40
40
  onChange((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value);
@@ -3,6 +3,7 @@ import { SelectProps } from "@mui/material/Select";
3
3
  import { FormControlProps } from "@mui/material/FormControl";
4
4
  interface SelectorBaseProps extends Omit<FormControlProps, "onChange"> {
5
5
  label?: string;
6
+ name?: string;
6
7
  tooltip?: ReactNode;
7
8
  showHelperText?: boolean;
8
9
  helperText?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.6.2",
3
+ "version": "1.6.4-alpha.1",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",