@bluemarble/bm-components 0.0.82 → 0.0.84

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/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { memo, useState, useRef, useMemo, useEffect, useCallback } from 'react';
3
- import { TableHead, TableRow, TableCell, TableSortLabel, Chip, Tooltip, IconButton, Paper, LinearProgress, TableContainer, Table, TableBody, TablePagination, Popover, Box as Box$2, Typography, Autocomplete as Autocomplete$1, TextField, Button, FormControl, Select as Select$1, InputLabel, FormControlLabel, Checkbox as Checkbox$1, Switch as Switch$1, FormLabel, RadioGroup, Radio as Radio$1, CircularProgress, Stack, MenuItem, Modal as Modal$1, Dialog as Dialog$1, DialogTitle, DialogContentText, DialogActions } from '@mui/material';
3
+ import { TableHead, TableRow, TableCell, TableSortLabel, Chip, Tooltip, IconButton, Paper, LinearProgress, TableContainer, Table, TableBody, TablePagination, Popover, Box as Box$2, Typography, Autocomplete as Autocomplete$1, TextField, Button, FormControl, Select as Select$1, FormHelperText, InputLabel, FormControlLabel, Checkbox as Checkbox$1, Switch as Switch$1, FormLabel, RadioGroup, Radio as Radio$1, CircularProgress, Stack, MenuItem, Modal as Modal$1, Dialog as Dialog$1, DialogTitle, DialogContentText, DialogActions } from '@mui/material';
4
4
  import emStyled from '@emotion/styled';
5
5
  import '@emotion/react';
6
6
  import { Field, useField } from 'formik';
@@ -14804,8 +14804,8 @@ const BaseInput$1 = (props) => {
14804
14804
  const FormikInput = (_a) => {
14805
14805
  var { name, shrink } = _a, rest = __rest(_a, ["name", "shrink"]);
14806
14806
  return (React__default.createElement(Field, { name: name }, (_a) => {
14807
- var _b = _a.field, { value } = _b, field = __rest(_b, ["value"]);
14808
- return (React__default.createElement(BaseInput$1, Object.assign({ defaultValue: value }, field, rest, { InputLabelProps: Object.assign({ shrink }, rest.InputLabelProps) })));
14807
+ var _b = _a.field, { value } = _b, field = __rest(_b, ["value"]), { meta: { error } } = _a;
14808
+ return (React__default.createElement(BaseInput$1, Object.assign({ defaultValue: value, error: Boolean(error), helperText: error }, field, rest, { InputLabelProps: Object.assign({ shrink }, rest.InputLabelProps) })));
14809
14809
  }));
14810
14810
  };
14811
14811
 
@@ -14846,10 +14846,10 @@ function FormikInputMask(_a) {
14846
14846
  formikSaveFunction.current(name, unmaskedValue);
14847
14847
  }, [value]);
14848
14848
  return (React__default.createElement(Field, { name: name }, (_a) => {
14849
- var _b = _a.field, { value } = _b, field = __rest(_b, ["value"]), { form: { setFieldValue } } = _a;
14849
+ var _b = _a.field, { value } = _b, field = __rest(_b, ["value"]), { meta: { error }, form: { setFieldValue } } = _a;
14850
14850
  initialValue.current = value;
14851
14851
  formikSaveFunction.current = setFieldValue;
14852
- return React__default.createElement(BaseInput$1, Object.assign({}, rest, field, { inputRef: ref }));
14852
+ return (React__default.createElement(BaseInput$1, Object.assign({}, rest, field, { inputRef: ref, error: Boolean(error), helperText: error })));
14853
14853
  }));
14854
14854
  }
14855
14855
 
@@ -14870,16 +14870,17 @@ const BaseSelect = (_a) => {
14870
14870
  }, label: label }, rest), children)));
14871
14871
  };
14872
14872
  const FormikSelect = (_a) => {
14873
- var { name, label, children, FormControlProps, InputLabelProps } = _a, rest = __rest(_a, ["name", "label", "children", "FormControlProps", "InputLabelProps"]);
14873
+ var { name, label, children, FormControlProps, InputLabelProps, helperText } = _a, rest = __rest(_a, ["name", "label", "children", "FormControlProps", "InputLabelProps", "helperText"]);
14874
14874
  const [_b, meta, { setValue }] = useField({ name }), { value } = _b, field = __rest(_b, ["value"]);
14875
14875
  const onChange = (_, { props: { value } }) => {
14876
14876
  setValue(value);
14877
14877
  };
14878
- return (React__default.createElement(FormControl, Object.assign({ fullWidth: true }, FormControlProps),
14878
+ return (React__default.createElement(FormControl, Object.assign({ fullWidth: true }, FormControlProps, { error: Boolean(meta === null || meta === void 0 ? void 0 : meta.error) }),
14879
14879
  React__default.createElement(CustomInputLabel, Object.assign({}, InputLabelProps), label),
14880
14880
  React__default.createElement(Select$1, Object.assign({ inputProps: {
14881
14881
  name
14882
- }, label: label }, rest, field, { defaultValue: value, onChange: onChange }), children)));
14882
+ }, label: label }, rest, field, { defaultValue: value, onChange: onChange }), children),
14883
+ React__default.createElement(FormHelperText, null, helperText || (meta === null || meta === void 0 ? void 0 : meta.error))));
14883
14884
  };
14884
14885
 
14885
14886
  function Autocomplete(_a) {
@@ -14895,7 +14896,7 @@ function BaseInput(props) {
14895
14896
  }
14896
14897
  function FormikAutocomplete(_a) {
14897
14898
  var { getOptionValue, option } = _a, props = __rest(_a, ["getOptionValue", "option"]);
14898
- const [_b, , { setValue }] = useField({
14899
+ const [_b, meta, { setValue }] = useField({
14899
14900
  name: props.name
14900
14901
  }), { value: defaultValue } = _b, field = __rest(_b, ["value"]);
14901
14902
  const defaultOption = useMemo(() => {
@@ -14931,7 +14932,7 @@ function FormikAutocomplete(_a) {
14931
14932
  return a[key] === b[key];
14932
14933
  return Object.values(a)[0] === Object.values(b)[0];
14933
14934
  };
14934
- return (React__default.createElement(Autocomplete$1, Object.assign({ getOptionLabel: getOptionLabel, renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, field, { label: props.label }))), defaultValue: defaultOption, onChange: onChange, isOptionEqualToValue: isOptionEqualToValue }, props)));
14935
+ return (React__default.createElement(Autocomplete$1, Object.assign({ getOptionLabel: getOptionLabel, renderInput: (params) => (React__default.createElement(TextField, Object.assign({ error: Boolean(meta === null || meta === void 0 ? void 0 : meta.error), helperText: meta === null || meta === void 0 ? void 0 : meta.error }, params, field, { label: props.label }))), defaultValue: defaultOption, onChange: onChange, isOptionEqualToValue: isOptionEqualToValue }, props)));
14935
14936
  }
14936
14937
 
14937
14938
  const Checkbox = (_a) => {
@@ -14953,7 +14954,7 @@ const FormikCheckbox = (_a) => {
14953
14954
  const onChange = (_, value) => {
14954
14955
  setValue(value);
14955
14956
  };
14956
- return (React__default.createElement(FormControlLabel, Object.assign({ label: label, onChange: onChange, control: React__default.createElement(Checkbox$1, Object.assign({}, props, { defaultChecked: value })) }, field, FormControlLabelProps)));
14957
+ return (React__default.createElement(FormControlLabel, Object.assign({ label: label, onChange: onChange, control: React__default.createElement(Checkbox$1, Object.assign({}, props, { defaultChecked: Boolean(value) })) }, field, FormControlLabelProps)));
14957
14958
  };
14958
14959
 
14959
14960
  const Switch = (_a) => {
@@ -15032,18 +15033,43 @@ const GridPagination = ({ currentPage, totalNumberOfPages, onPageChange, rowsPer
15032
15033
  React__default.createElement(MdArrowForwardIos, { size: 8 * 2 })))));
15033
15034
  };
15034
15035
 
15035
- function BaseGrid({ columns, children, fixedColumns, paperProps, tableBodyProps, tableHeadProps, tableProps, sortedDirection, sortedBy, onSortBy, dense = true, striped, bordered, currentPage, totalNumberOfPages, onPageChange, rowsPerPage, setRowsPerPage, rowsPerPageOptions, hideFooter, isLoading }) {
15036
- return (React__default.createElement(Paper, Object.assign({}, paperProps, { sx: Object.assign({ 'tr td': {
15037
- py: dense ? 0.23 : 0.7
15038
- }, 'tr td:not(:last-child), tr th:not(:last-child)': {
15039
- borderRight: bordered ? '1px solid' : '',
15036
+ const styles = {
15037
+ rowGap: function (dense) {
15038
+ return {
15039
+ py: dense ? 0.23 : 0.7
15040
+ };
15041
+ },
15042
+ bordered: function (active) {
15043
+ if (!active)
15044
+ return {};
15045
+ return {
15046
+ 'tr td:not(:last-child), tr th:not(:last-child)': {
15047
+ borderRight: '1px solid',
15040
15048
  borderColor: 'divider'
15041
- }, 'tr:nth-of-type(even)': {
15049
+ }
15050
+ };
15051
+ },
15052
+ striped: function (active) {
15053
+ if (!active)
15054
+ return {};
15055
+ return {
15056
+ 'tr:nth-of-type(even)': {
15042
15057
  transition: 'background-color ease 200ms',
15043
- bgcolor: striped ? 'divider' : 'initial'
15044
- }, 'tbody tr:last-child td': {
15045
- borderBottomWidth: hideFooter ? 0 : 1
15046
- } }, paperProps === null || paperProps === void 0 ? void 0 : paperProps.sx) }),
15058
+ bgcolor: 'divider'
15059
+ }
15060
+ };
15061
+ },
15062
+ lastRowBorder: function (active) {
15063
+ return {
15064
+ 'tbody tr:last-child td': {
15065
+ borderBottomWidth: active ? 0 : 1
15066
+ }
15067
+ };
15068
+ }
15069
+ };
15070
+
15071
+ function BaseGrid({ columns, children, fixedColumns, paperProps, tableBodyProps, tableHeadProps, tableProps, sortedDirection, sortedBy, onSortBy, dense = true, striped, bordered, currentPage, totalNumberOfPages, onPageChange, rowsPerPage, setRowsPerPage, rowsPerPageOptions, hideFooter, isLoading }) {
15072
+ return (React__default.createElement(Paper, Object.assign({}, paperProps, { sx: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, styles.rowGap(dense)), styles.bordered(bordered)), styles.striped(striped)), styles.lastRowBorder(hideFooter)), paperProps === null || paperProps === void 0 ? void 0 : paperProps.sx) }),
15047
15073
  React__default.createElement(Table, Object.assign({ size: "small", stickyHeader: true }, tableProps, { sx: Object.assign({}, tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx) }),
15048
15074
  React__default.createElement(TableHead, Object.assign({}, tableHeadProps),
15049
15075
  React__default.createElement(TableRow, null, columns.map((column) => (React__default.createElement(TableCell, { key: column.name, padding: dense ? 'none' : 'normal', sx: Object.assign({ pl: 2 }, column === null || column === void 0 ? void 0 : column.sx) }, column.children ? (column.children) : (React__default.createElement(TableSortLabel, { active: sortedBy === column.name, direction: sortedDirection, onClick: () => onSortBy(column.name), disabled: column.canSort === false }, column.label)))))),