@sphereon/ui-components.ssi-react 0.4.1-unstable.94 → 0.4.1-unstable.95

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,8 +1,8 @@
1
- import React from 'react';
1
+ import { FC } from 'react';
2
2
  import { TabNavigationState } from '@sphereon/ui-components.core';
3
3
  type Props = {
4
4
  navigationState: TabNavigationState;
5
- onIndexChange: (index: number) => void;
5
+ onRouteChange: (key: string) => void;
6
6
  };
7
- declare const SSITabViewHeader: React.FC<Props>;
7
+ declare const SSITabViewHeader: FC<Props>;
8
8
  export default SSITabViewHeader;
@@ -1,13 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { SSITabViewHeaderContainerStyled as Container, SSITabViewHeaderTitleContainerStyled as TitleContainer, SSITabViewHeaderTitleCaptionStyled as TitleCaption, } from '../../../../styles';
3
3
  const SSITabViewHeader = (props) => {
4
- const { navigationState, onIndexChange } = props;
5
- return (_jsx(Container, { children: navigationState.routes.map((value, index) => {
6
- const tabIndex = index + 1;
7
- const isActiveTab = tabIndex === navigationState.index;
8
- return (_jsx(TitleContainer, { onClick: () => onIndexChange(tabIndex), style: {
9
- ...(isActiveTab && { borderBottom: `2px solid #7276F7`, alignSelf: 'stretch' }),
10
- }, children: _jsx(TitleCaption, { style: { fontWeight: !isActiveTab ? '400' : '600' }, children: value.title }) }, tabIndex));
4
+ const { navigationState, onRouteChange } = props;
5
+ return (_jsx(Container, { children: navigationState.routes.map((value) => {
6
+ const isActiveRoute = value.key === navigationState.activeRoute;
7
+ return (_jsx(TitleContainer, { onClick: () => onRouteChange(value.key), style: {
8
+ ...(isActiveRoute && { borderBottom: `2px solid #7276F7`, alignSelf: 'stretch' }),
9
+ }, children: _jsx(TitleCaption, { style: { fontWeight: !isActiveRoute ? '400' : '600' }, children: value.title }) }, value.key));
11
10
  }) }));
12
11
  };
13
12
  export default SSITabViewHeader;
@@ -1,7 +1,8 @@
1
- import React from 'react';
1
+ import { FC } from 'react';
2
2
  import { TabViewRoute } from '@sphereon/ui-components.core';
3
3
  type Props = {
4
4
  routes: Array<TabViewRoute>;
5
+ onRouteChange?: (key: string) => Promise<void>;
5
6
  };
6
- declare const SSITabView: React.FC<Props>;
7
+ declare const SSITabView: FC<Props>;
7
8
  export default SSITabView;
@@ -1,27 +1,27 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from 'react';
2
+ import { Fragment, useEffect, useState } from 'react';
3
3
  import SSITabViewHeader from './SSITabViewHeader';
4
4
  import { SSITabViewContainerStyled as Container } from '../../../styles';
5
5
  const Tab = (props) => {
6
- return _jsx(React.Fragment, { children: props.children });
6
+ return _jsx(Fragment, { children: props.children });
7
7
  };
8
8
  const SSITabView = (props) => {
9
9
  const { routes = [] } = props;
10
- const [activeTabIndex, setActiveTabIndex] = React.useState(1);
11
- const [content, setContent] = React.useState();
12
- React.useEffect(() => {
13
- routes.forEach((route, index) => {
14
- if (index + 1 === activeTabIndex) {
10
+ const [activeRoute, setActiveRoute] = useState(routes.length > 0 ? routes[0].key : "");
11
+ const [content, setContent] = useState();
12
+ useEffect(() => {
13
+ routes.forEach((route) => {
14
+ if (route.key === activeRoute) {
15
15
  setContent(route.content);
16
16
  }
17
17
  });
18
- }, [routes, activeTabIndex]);
19
- const onTabChange = async (tabIndex) => {
20
- setActiveTabIndex(tabIndex);
18
+ }, [routes, activeRoute]);
19
+ const onTabChange = async (key) => {
20
+ setActiveRoute(key);
21
21
  };
22
22
  return (_jsxs(Container, { children: [_jsx(SSITabViewHeader, { navigationState: {
23
- routes: routes,
24
- index: activeTabIndex,
25
- }, onIndexChange: onTabChange }), _jsx(Tab, { children: content })] }));
23
+ routes,
24
+ activeRoute,
25
+ }, onRouteChange: onTabChange }), _jsx(Tab, { children: content })] }));
26
26
  };
27
27
  export default SSITabView;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sphereon/ui-components.ssi-react",
3
3
  "private": false,
4
- "version": "0.4.1-unstable.94+8367a6f",
4
+ "version": "0.4.1-unstable.95+a3cc3d0",
5
5
  "description": "SSI UI components for React",
6
6
  "repository": "git@github.com:Sphereon-Opensource/UI-Components.git",
7
7
  "author": "Sphereon <dev@sphereon.com>",
@@ -50,7 +50,7 @@
50
50
  "@mui/x-date-pickers": "^8.18.0",
51
51
  "@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.45.94",
52
52
  "@sphereon/ssi-types": "0.34.1-feature.SSISDK.45.94",
53
- "@sphereon/ui-components.core": "0.4.1-unstable.94+8367a6f",
53
+ "@sphereon/ui-components.core": "0.4.1-unstable.95+a3cc3d0",
54
54
  "@tanstack/react-table": "^8.9.3",
55
55
  "ajv": "^8.17.1",
56
56
  "ajv-formats": "^3.0.1",
@@ -72,5 +72,5 @@
72
72
  "peerDependencies": {
73
73
  "react": ">= 18"
74
74
  },
75
- "gitHead": "8367a6f85c906e96dd0544147f3375602a111940"
75
+ "gitHead": "a3cc3d0e2bc5981461074a5fee29c32c86ee6e73"
76
76
  }