@symply.io/basic-components 1.4.4-beta.2 → 1.4.4-beta.3

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/README.md CHANGED
@@ -812,6 +812,8 @@ import SocialInput from '@symply.io/basic-components/SocialInput';
812
812
 
813
813
  Tabs group.
814
814
 
815
+ It is extended from `@mui/material/Tabs`, so it includes all properties of `@mui/material/Tabs`.
816
+
815
817
  <h5>Import</h5>
816
818
 
817
819
  ```typescript
@@ -822,13 +824,12 @@ import TabGroup from '@symply.io/basic-components/TabGroup';
822
824
 
823
825
  <h5>Props</h5>
824
826
 
825
- | Name | Type | Default | Required | Description |
826
- | --------------- | --------------------------------------------- | ------------ | -------- | ------------------------------------------------------------ |
827
- | currentTabIndex | number | 0 | false | the tab index from the higher component |
828
- | onTabChange | func | | true | Callback fired when the `Tab` is changed.<br />**Signature:**<br/>`function(index: number) => void`<br/>*index:* The selected index of the `Tab` element. |
829
- | tabs | Array\<{ text: string; disabled?: boolean }\> | | true | All tab items. |
830
- | textColor | 'primary' \| 'secondary' | 'primary' | false | The color of the tab text. |
831
- | variant | 'standard' \| 'scrollable' \| 'fullWidth' | 'scrollable' | false | Determines additional display behavior of the tabs |
827
+ | Name | Type | Default | Required | Description |
828
+ | --------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
829
+ | currentTabIndex | number | 0 | true | the tab index from the higher component |
830
+ | onChange | func | If `onChange` is undefined and the `url` of tab is defined, we will navigate to that url when the tab changed | false | Callback fired when the `Tab` is changed.<br />**Signature:**<br/>`function(args: {tabIndex: number; url?: string}) => void`<br/>*tabIndex:* The selected index of the `Tab` element.<br/>*url*: The url for navigating. |
831
+ | tabs | Array\<{ key: string; text: string; url?: string; disabled?: boolean }\> | | true | All tab items. |
832
+ | variant | 'standard' \| 'scrollable' \| 'fullWidth' | 'scrollable' | false | Determines additional display behavior of the tabs |
832
833
 
833
834
 
834
835
 
package/TabGroup/index.js CHANGED
@@ -35,16 +35,17 @@ function TabGroup(props) {
35
35
  var onTabClick = useCallback(function (_, val) {
36
36
  var tab = tabs[val];
37
37
  if (tab) {
38
+ var url = tab.url;
38
39
  if (onChange) {
39
- onChange({ tabIndex: val, url: tab.url });
40
+ onChange({ tabIndex: val, url: url });
40
41
  }
41
- else {
42
- navigate(tab.url);
42
+ else if (url) {
43
+ navigate(url);
43
44
  }
44
45
  }
45
46
  }, [tabs]);
46
47
  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) {
47
- var text = tab.text, _a = tab.disabled, disabled = _a === void 0 ? false : _a;
48
+ var key = tab.key, text = tab.text, _a = tab.disabled, disabled = _a === void 0 ? false : _a;
48
49
  var active = currentTabIndex === index;
49
50
  return (_jsx(Tab, { disableFocusRipple: true, disableRipple: true, label: text, disabled: disabled, sx: {
50
51
  cursor: disabled ? "not-allowed" : "pointer",
@@ -52,7 +53,7 @@ function TabGroup(props) {
52
53
  background: active ? "#fff" : undefined,
53
54
  borderRadius: active ? theme.spacing(0.5) : undefined,
54
55
  boxShadow: active ? "0px 4px 6px #acc1c2" : undefined
55
- } }, index));
56
+ } }, key || index));
56
57
  }) })) })));
57
58
  }
58
59
  export default TabGroup;
@@ -2,18 +2,16 @@ import { CSSProperties } from "react";
2
2
  import { TabsProps } from "@mui/material/Tabs";
3
3
  export interface TabGroupProps extends Omit<TabsProps, "onChange"> {
4
4
  tabs: Array<{
5
+ key: string;
5
6
  text: string;
6
7
  disabled?: boolean;
7
- url: string;
8
+ url?: string;
8
9
  }>;
9
- currentTabIndex?: number;
10
+ currentTabIndex: number;
10
11
  primaryColor?: CSSProperties["color"];
11
12
  secondaryColor?: CSSProperties["color"];
12
13
  onChange?: (args: {
13
14
  tabIndex: number;
14
- url: string;
15
+ url?: string;
15
16
  }) => unknown;
16
17
  }
17
- export interface TabGroupStates {
18
- onChange: TabsProps["onChange"];
19
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.4.4-beta.2",
3
+ "version": "1.4.4-beta.3",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",