@symply.io/basic-components 1.4.3 → 1.4.4-beta.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.
@@ -27,6 +27,6 @@ import TableCell from "@mui/material/TableCell";
27
27
  import TableBodyRow from "./TableBodyRow";
28
28
  function TBody(props) {
29
29
  var rows = props.rows, columns = props.columns, _a = props.noDataText, noDataText = _a === void 0 ? "No Data!" : _a, rest = __rest(props, ["rows", "columns", "noDataText"]);
30
- return (_jsx(TableBody, { children: rows.length > 0 ? (rows.map(function (row, index) { return (_jsx(TableBodyRow, __assign({ row: row, rows: rows, columns: columns }, rest), "DataTable_".concat(index))); })) : (_jsx(TableRow, { children: _jsx(TableCell, __assign({ colSpan: columns.length, align: "center" }, { children: noDataText })) })) }));
30
+ return (_jsx(TableBody, { children: rows.length > 0 ? (rows.map(function (row, index) { return (_jsx(TableBodyRow, __assign({ rowIndex: index, row: row, rows: rows, columns: columns }, rest), "DataTable_".concat(index))); })) : (_jsx(TableRow, { children: _jsx(TableCell, __assign({ colSpan: columns.length, align: "center" }, { children: noDataText })) })) }));
31
31
  }
32
32
  export default TBody;
@@ -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, 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, 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"));
@@ -80,14 +80,14 @@ function TableBodyRow(props) {
80
80
  boxShadow: "inset 10px 0 10px -8px rgba(0, 0, 0, 0.1)"
81
81
  }
82
82
  : undefined
83
- } }, { children: cloneElement(Cell, { column: col, rows: rows, row: row }) }), accessor));
83
+ } }, { children: cloneElement(Cell, { column: col, rows: rows, row: row, rowIndex: rowIndex }) }), accessor));
84
84
  }), dynamicCols.map(function (col) {
85
85
  var accessor = col.accessor, Cell = col.Cell, width = col.width, _a = col.align, align = _a === void 0 ? "center" : _a;
86
86
  return (_jsx(TableCell, __assign({ align: align, sx: {
87
87
  width: width,
88
88
  zIndex: 9,
89
89
  backgroundColor: onRowClick && rowEl ? hover : normal
90
- } }, { children: cloneElement(Cell, { column: col, rows: rows, row: row }) }), accessor));
90
+ } }, { children: cloneElement(Cell, { column: col, rows: rows, row: row, rowIndex: rowIndex }) }), accessor));
91
91
  }), fixedRightCols.map(function (col, index) {
92
92
  var accessor = col.accessor, Cell = col.Cell, width = col.width, _a = col.align, align = _a === void 0 ? "center" : _a;
93
93
  var right = fixedRightCols
@@ -112,7 +112,7 @@ function TableBodyRow(props) {
112
112
  boxShadow: "inset -10px 0 10px -8px rgba(0, 0, 0, 0.1)"
113
113
  }
114
114
  : undefined
115
- } }, { children: cloneElement(Cell, { column: col, rows: rows, row: row }) }), accessor));
115
+ } }, { children: cloneElement(Cell, { column: col, rows: rows, row: row, rowIndex: rowIndex }) }), accessor));
116
116
  })] })));
117
117
  }
118
118
  export default TableBodyRow;
@@ -69,6 +69,7 @@ export declare type TableBodyProps<RowProps extends KvProps, ExtendedProps exten
69
69
  };
70
70
  export declare type TableBodyRowProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableBodyProps<RowProps, ExtendedProps>, "noDataText"> & {
71
71
  row: RowProps;
72
+ rowIndex: number;
72
73
  };
73
74
  export declare type TableFooterProps<RowProps extends KvProps, ExtendedProps extends KvProps> = {
74
75
  footers: Array<TableFooterCellProps<RowProps, ExtendedProps>>;
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  import type { TabGroupProps } from "./types";
3
- declare const TabGroup: import("react").ForwardRefExoticComponent<TabGroupProps & import("react").RefAttributes<unknown>>;
2
+ declare function TabGroup(props: TabGroupProps): JSX.Element;
4
3
  export default TabGroup;
5
4
  export type { TabGroupProps };
package/TabGroup/index.js CHANGED
@@ -9,33 +9,41 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
12
23
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { useState, useEffect, forwardRef, useImperativeHandle } from "react";
24
+ import { useCallback } from "react";
25
+ import { navigate } from "@reach/router";
14
26
  import Tab from "@mui/material/Tab";
15
27
  import Tabs from "@mui/material/Tabs";
16
28
  import useMediaQuery from "@mui/material/useMediaQuery";
17
29
  import ThemeProvider from "@mui/material/styles/ThemeProvider";
18
30
  import useCustomTheme from "../useCustomTheme";
19
- var TabGroup = forwardRef(function (props, ref) {
20
- var tabs = props.tabs, _a = props.textColor, textColor = _a === void 0 ? "primary" : _a, _b = props.variant, variant = _b === void 0 ? "scrollable" : _b, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onTabChange = props.onTabChange, outerTabIndex = props.currentTabIndex;
31
+ function TabGroup(props) {
32
+ var tabs = props.tabs, _a = props.textColor, textColor = _a === void 0 ? "primary" : _a, _b = props.variant, variant = _b === void 0 ? "scrollable" : _b, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, currentTabIndex = props.currentTabIndex, onChange = props.onChange, rest = __rest(props, ["tabs", "textColor", "variant", "primaryColor", "secondaryColor", "currentTabIndex", "onChange"]);
21
33
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
22
34
  var mobileViewport = useMediaQuery(theme.breakpoints.down("md"));
23
- var _c = useState(outerTabIndex || 0), currentTabIndex = _c[0], setCurrentTabIndex = _c[1];
24
- var onClick = function (index) {
25
- setCurrentTabIndex(index);
26
- };
27
- useImperativeHandle(ref, function () { return ({
28
- tabIndex: currentTabIndex
29
- }); });
30
- useEffect(function () {
31
- if (outerTabIndex !== undefined && outerTabIndex !== currentTabIndex) {
32
- setCurrentTabIndex(outerTabIndex);
35
+ var onTabClick = useCallback(function (_, val) {
36
+ var tab = tabs[val];
37
+ if (tab) {
38
+ if (onChange) {
39
+ onChange({ tabIndex: val, url: tab.url });
40
+ }
41
+ else {
42
+ navigate(tab.url);
43
+ }
33
44
  }
34
- }, [outerTabIndex, currentTabIndex]);
35
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tabs, __assign({ value: currentTabIndex, TabIndicatorProps: { hidden: true }, variant: mobileViewport ? "scrollable" : variant, textColor: textColor, onChange: function (_, val) {
36
- onClick(val);
37
- onTabChange(val);
38
- } }, { children: tabs.map(function (tab, index) {
45
+ }, [tabs]);
46
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Tabs, __assign({ value: currentTabIndex, TabIndicatorProps: { hidden: true }, variant: mobileViewport ? "scrollable" : variant, textColor: textColor, onChange: onTabClick }, rest, { children: tabs.map(function (tab, index) {
39
47
  var text = tab.text, _a = tab.disabled, disabled = _a === void 0 ? false : _a;
40
48
  var active = currentTabIndex === index;
41
49
  return (_jsx(Tab, { disableFocusRipple: true, disableRipple: true, label: text, disabled: disabled, sx: {
@@ -46,5 +54,5 @@ var TabGroup = forwardRef(function (props, ref) {
46
54
  boxShadow: active ? "0px 4px 6px #acc1c2" : undefined
47
55
  } }, index));
48
56
  }) })) })));
49
- });
57
+ }
50
58
  export default TabGroup;
@@ -1,14 +1,19 @@
1
1
  import { CSSProperties } from "react";
2
2
  import { TabsProps } from "@mui/material/Tabs";
3
- export interface TabGroupProps {
4
- textColor?: TabsProps["textColor"];
3
+ export interface TabGroupProps extends Omit<TabsProps, "onChange"> {
5
4
  tabs: Array<{
6
5
  text: string;
7
6
  disabled?: boolean;
7
+ url: string;
8
8
  }>;
9
- variant?: TabsProps["variant"];
10
9
  currentTabIndex?: number;
11
10
  primaryColor?: CSSProperties["color"];
12
11
  secondaryColor?: CSSProperties["color"];
13
- onTabChange: (index: number) => void;
12
+ onChange?: (args: {
13
+ tabIndex: number;
14
+ url: string;
15
+ }) => unknown;
16
+ }
17
+ export interface TabGroupStates {
18
+ onChange: TabsProps["onChange"];
14
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.4.3",
3
+ "version": "1.4.4-beta.2",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",