@symply.io/basic-components 1.6.7-alpha.3 → 1.6.7
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.
- package/DataTable/TableFooter.js +2 -0
- package/DataTable/TableHeader.js +2 -0
- package/FormSelector/MultipleSelector.d.ts +1 -1
- package/FormSelector/MultipleSelector.js +8 -6
- package/FormSelector/SimpleSelector.d.ts +1 -1
- package/FormSelector/SimpleSelector.js +3 -3
- package/FormSelector/types.d.ts +9 -8
- package/README.md +19 -14
- package/package.json +1 -1
package/DataTable/TableFooter.js
CHANGED
@@ -67,6 +67,8 @@ function TableFooter(props) {
|
|
67
67
|
zIndex: 9,
|
68
68
|
width: width,
|
69
69
|
userSelect: "none",
|
70
|
+
backgroundColor: "".concat(footerBgColor || "#eaf0f6", " !important"),
|
71
|
+
color: "".concat(footerTextColor || "inherit", " !important"),
|
70
72
|
} }, { children: cloneElement(Cell) }), accessor));
|
71
73
|
}), fixedRightFooters.map(function (footer, index) {
|
72
74
|
var accessor = footer.accessor, Cell = footer.Cell, _a = footer.align, align = _a === void 0 ? "center" : _a, width = footer.width;
|
package/DataTable/TableHeader.js
CHANGED
@@ -71,6 +71,8 @@ function TableHeader(props) {
|
|
71
71
|
zIndex: 9,
|
72
72
|
userSelect: "none",
|
73
73
|
cursor: sortable ? "pointer" : "default",
|
74
|
+
backgroundColor: "".concat(headerBgColor || "#eaf0f6", " !important"),
|
75
|
+
color: "".concat(headerTextColor || "inherit", " !important"),
|
74
76
|
}, onClick: function () {
|
75
77
|
onSort({ accessor: accessor });
|
76
78
|
} }, { children: cloneElement(Cell) }), accessor));
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { MultipleSelectorProps } from "./types";
|
2
|
-
declare function MultipleSelector(props: MultipleSelectorProps): import("react/jsx-runtime").JSX.Element;
|
2
|
+
declare function MultipleSelector<T extends string | number>(props: MultipleSelectorProps<T>): import("react/jsx-runtime").JSX.Element;
|
3
3
|
export default MultipleSelector;
|
@@ -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
|
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
|
57
|
-
return (
|
58
|
+
var label = option.label, v = option.value;
|
59
|
+
return (_jsxs(MenuItem, __assign({ value: v }, { children: [showCheckmarks ? (_jsx(Checkbox, { checked: !!value.includes(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;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { SimpleSelectorProps } from "./types";
|
2
|
-
declare function SimpleSelector(props: SimpleSelectorProps): import("react/jsx-runtime").JSX.Element;
|
2
|
+
declare function SimpleSelector<T extends string | number>(props: SimpleSelectorProps<T>): import("react/jsx-runtime").JSX.Element;
|
3
3
|
export default SimpleSelector;
|
@@ -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,
|
46
|
-
return (_jsx(MenuItem, __assign({ 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;
|
package/FormSelector/types.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ReactNode, CSSProperties } from "react";
|
2
2
|
import { SelectProps } from "@mui/material/Select";
|
3
3
|
import { FormControlProps } from "@mui/material/FormControl";
|
4
|
-
interface SelectorBaseProps extends Omit<FormControlProps, "onChange"> {
|
4
|
+
interface SelectorBaseProps<T extends string | number> extends Omit<FormControlProps, "onChange"> {
|
5
5
|
label?: string;
|
6
6
|
name?: string;
|
7
7
|
tooltip?: ReactNode;
|
@@ -12,16 +12,17 @@ interface SelectorBaseProps extends Omit<FormControlProps, "onChange"> {
|
|
12
12
|
secondaryColor?: CSSProperties["color"];
|
13
13
|
options: Array<{
|
14
14
|
label: string;
|
15
|
-
value:
|
15
|
+
value: T;
|
16
16
|
disabled?: boolean;
|
17
17
|
}>;
|
18
18
|
}
|
19
|
-
export interface SimpleSelectorProps extends SelectorBaseProps {
|
20
|
-
value:
|
21
|
-
onChange: (value?: string |
|
19
|
+
export interface SimpleSelectorProps<T extends string | number> extends SelectorBaseProps<T> {
|
20
|
+
value: T | "";
|
21
|
+
onChange: (value?: string | T) => void;
|
22
22
|
}
|
23
|
-
export interface MultipleSelectorProps extends SelectorBaseProps {
|
24
|
-
value: Array<
|
25
|
-
|
23
|
+
export interface MultipleSelectorProps<T extends string | number> extends SelectorBaseProps<T> {
|
24
|
+
value: Array<T>;
|
25
|
+
showCheckmarks?: boolean;
|
26
|
+
onChange: (value?: string | Array<T>) => void;
|
26
27
|
}
|
27
28
|
export {};
|
package/README.md
CHANGED
@@ -374,7 +374,11 @@ import DataTable, { useDataTable } from '@symply.io/basic-components/DataTable';
|
|
374
374
|
| columns | Array\<TableBodyCellProps\> | | true | The cells for the body. (from the hook) |
|
375
375
|
| dense | bool | | false | If `true` the table size/density would be tight. |
|
376
376
|
| footers | Array\<TableFooterCellProps> | [] | false | The cells for the footer. (from the hook) |
|
377
|
+
| footerBgColor | CSSProperties["color"] | | false | Customized footer background color. |
|
378
|
+
| footerTextColor | CSSProperties["color"] | | false | Customized footer text color. |
|
377
379
|
| headers | Array\<TableHeaderCellProps\> | | true | The cells for the header. (from the hook) |
|
380
|
+
| headerBgColor | CSSProperties["color"] | | false | Customized header background color. |
|
381
|
+
| headerTextColor | CSSProperties["color"] | | false | Customized header text color. |
|
378
382
|
| noDataText | string | 'No Data!' | false | The text when no data rendered. |
|
379
383
|
| onContextMenu | func | | false | The function for row right-clicking.<br />**Signature:**<br/>`function(event: MouseEvent, row: RowProps) => unknown` |
|
380
384
|
| onCustomizeRowBgColor | func | | false | The function for customizing the row background color.<br />**Signature:**<br/>`function(props: {row: RowProps, columns: Array\<ColumnProps\>}) => {normal?: HexColor;<br/> hover?: HexColor;<br/>}` |
|
@@ -573,11 +577,11 @@ import { MultipleSelector } from '@symply.io/basic-components/FormRadioGroup';
|
|
573
577
|
|
574
578
|
<h5>Selector Option Props</h5>
|
575
579
|
|
576
|
-
| Name | Type
|
577
|
-
| -------- |
|
578
|
-
| disabled | bool
|
579
|
-
| label | string
|
580
|
-
| value |
|
580
|
+
| Name | Type | Default | Required | Description |
|
581
|
+
| -------- | -------------------------- | ------- | -------- | ---------------------------------------- |
|
582
|
+
| disabled | bool | false | false | If `true`, the opiton would be disabled. |
|
583
|
+
| label | string | | true | The label of the option. |
|
584
|
+
| value | T extends number \| string | | | The value of the option. |
|
581
585
|
|
582
586
|
<h5>Base Props</h5>
|
583
587
|
|
@@ -589,22 +593,23 @@ It is extended from `@mui/material/FormControl`, so it includes all properties o
|
|
589
593
|
| label | string | | false | The label of `Select` element. |
|
590
594
|
| multiple | bool | false | false | If `true`, you can select more than 1 option. |
|
591
595
|
| options | Array\<IRadioOption\> | | true | The radio options. See the **Selector Option Props** above. |
|
592
|
-
| showHelperText | bool | false |
|
596
|
+
| showHelperText | bool | false | false | If `true`, show the helper text. |
|
593
597
|
| tooltip | string | | false | A tooltip for the `Select` element. |
|
594
598
|
|
595
599
|
<h5>Simple Selector Props</h5> Extended from the Base Props
|
596
600
|
|
597
|
-
| Name | Type
|
598
|
-
| -------- |
|
599
|
-
| onChange | func
|
600
|
-
| value | number \| string | |
|
601
|
+
| Name | Type | Default | Required | Description |
|
602
|
+
| -------- | -------------------------- | ------- | -------- | ------------------------------------------------------------ |
|
603
|
+
| 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. |
|
604
|
+
| value | T extends number \| string | | true | The value of the `Select` element. |
|
601
605
|
|
602
606
|
<h5>Multiple Selector Props</h5> Extended from the Base Props
|
603
607
|
|
604
|
-
| Name
|
605
|
-
|
|
606
|
-
| onChange
|
607
|
-
|
|
608
|
+
| Name | Type | Default | Required | Description |
|
609
|
+
| -------------- | ----------------------------------- | ------- | -------- | ------------------------------------------------------------ |
|
610
|
+
| 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. |
|
611
|
+
| showCheckmarks | bool | false | false | If `true` the option will be shown with a checkbox. |
|
612
|
+
| value | Array\<T extends number \| string\> | | | The value of the `Select` element. |
|
608
613
|
|
609
614
|
|
610
615
|
|