@sphereon/ui-components.ssi-react 0.4.1-next.183 → 0.4.1-next.186

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,13 +1,17 @@
1
1
  import { CSSProperties, FC, ReactNode } from 'react';
2
+ import { GradientProperties } from '@sphereon/ui-components.core';
3
+ import { Position } from '../../../types';
2
4
  export interface IProps {
3
5
  onValueChange?: (isChecked: boolean) => Promise<void>;
4
6
  initialValue?: boolean;
5
7
  isChecked?: boolean;
6
8
  label?: string | ReactNode;
9
+ labelPosition?: Position;
7
10
  disabled?: boolean;
8
11
  backgroundColor?: string;
9
12
  borderColor?: string;
10
13
  selectedColor?: string;
14
+ gradient?: GradientProperties;
11
15
  labelColor?: string;
12
16
  checkmarkColor?: string;
13
17
  style?: CSSProperties;
@@ -1,9 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { OpacityStyleEnum, fontColors, selectionElementColors } from '@sphereon/ui-components.core';
3
+ import { OpacityStyleEnum, elementColors, fontColors, gradientsColors } from '@sphereon/ui-components.core';
4
4
  import { SSICheckboxContainerStyled as Container, SSICheckboxLabelContainerStyled as LabelCaption, SSICheckboxSelectedContainerStyled as SelectedContainer, SSICheckboxUnselectedContainerStyled as UnselectedContainer, } from '../../../styles/components';
5
+ const flexDirectionMap = {
6
+ right: 'row',
7
+ left: 'row-reverse',
8
+ top: 'column-reverse',
9
+ bottom: 'column',
10
+ };
5
11
  const SSICheckbox = (props) => {
6
- const { backgroundColor, borderColor = selectionElementColors.primaryBorderDark, disabled = false, initialValue = false, label, selectedColor = selectionElementColors.primaryDark, labelColor = fontColors.light, checkmarkColor = fontColors.dark, style, } = props;
12
+ const { backgroundColor, borderColor = elementColors.lightGrey, disabled = false, initialValue = false, label, labelPosition = 'right', selectedColor, gradient = gradientsColors[100], labelColor = fontColors.dark, checkmarkColor = '#FFFFFF', style, } = props;
7
13
  const [isChecked, setChecked] = React.useState(initialValue);
8
14
  const value = props.isChecked !== undefined ? props.isChecked : isChecked;
9
15
  const onValueChange = async () => {
@@ -16,6 +22,18 @@ const SSICheckbox = (props) => {
16
22
  }
17
23
  setChecked(!isChecked);
18
24
  };
19
- return (_jsxs(Container, { onClick: onValueChange, style: { ...style, ...(disabled && { opacity: OpacityStyleEnum.DISABLED }) }, children: [value ? (_jsx(SelectedContainer, { style: { backgroundColor: selectedColor, border: `1px solid ${borderColor}` } })) : (_jsx(UnselectedContainer, { style: { backgroundColor, border: `1px solid ${borderColor}` } })), label && (typeof label === 'string' ? _jsx(LabelCaption, { style: { color: labelColor }, children: label }) : label)] }));
25
+ const selectedBackground = gradient
26
+ ? `linear-gradient(172deg, ${gradient.primaryColor} 0%, ${gradient.secondaryColor} 100%)`
27
+ : selectedColor;
28
+ return (_jsxs(Container, { onClick: onValueChange, style: {
29
+ ...style,
30
+ flexDirection: flexDirectionMap[labelPosition],
31
+ ...(disabled && { opacity: OpacityStyleEnum.DISABLED, cursor: 'not-allowed' }),
32
+ }, role: "checkbox", "aria-checked": value, tabIndex: 0, onKeyDown: (e) => {
33
+ if (e.key === 'Enter' || e.key === ' ') {
34
+ e.preventDefault();
35
+ onValueChange();
36
+ }
37
+ }, children: [value ? (_jsx(SelectedContainer, { style: { background: selectedBackground, border: 'none' }, children: _jsx("svg", { width: "12", height: "10", viewBox: "0 0 12 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M1 5L4.5 8.5L11 1.5", stroke: checkmarkColor, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) })) : (_jsx(UnselectedContainer, { style: { backgroundColor, border: `2px solid ${borderColor}` } })), label && (typeof label === 'string' ? _jsx(LabelCaption, { style: { color: labelColor }, children: label }) : label)] }));
20
38
  };
21
39
  export default SSICheckbox;
@@ -1,12 +1,10 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { SSITabViewHeaderContainerStyled as Container, SSITabViewHeaderTitleContainerStyled as TitleContainer, SSITabViewHeaderTitleCaptionStyled as TitleCaption, } from '../../../../styles';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SSITabViewHeaderContainerStyled as Container, SSITabViewHeaderTabBarStyled as TabBar, SSITabViewHeaderTitleContainerStyled as TitleContainer, SSITabViewHeaderTitleCaptionStyled as TitleCaption, SSITabViewHeaderActiveIndicatorStyled as ActiveIndicator, SSITabViewHeaderDividerStyled as Divider, } from '../../../../styles';
3
3
  const SSITabViewHeader = (props) => {
4
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));
10
- }) }));
5
+ return (_jsxs(Container, { role: "tablist", children: [_jsx(TabBar, { children: navigationState.routes.map((value) => {
6
+ const isActiveRoute = value.key === navigationState.activeRoute;
7
+ return (_jsxs(TitleContainer, { onClick: () => onRouteChange(value.key), role: "tab", "aria-selected": isActiveRoute, children: [_jsx(TitleCaption, { style: { fontWeight: isActiveRoute ? 600 : 400 }, children: value.title }), isActiveRoute && _jsx(ActiveIndicator, {})] }, value.key));
8
+ }) }), _jsx(Divider, {})] }));
11
9
  };
12
10
  export default SSITabViewHeader;
@@ -1,7 +1,11 @@
1
- import { FC } from 'react';
2
- import { TabViewRoute } from '@sphereon/ui-components.core';
1
+ import { FC, ReactNode } from 'react';
2
+ type SSITabViewRoute = {
3
+ key: string;
4
+ title: string;
5
+ content: ReactNode;
6
+ };
3
7
  type Props = {
4
- routes: Array<TabViewRoute>;
8
+ routes: Array<SSITabViewRoute>;
5
9
  activeRoute?: string;
6
10
  onRouteChange?: (key: string) => Promise<void>;
7
11
  };
@@ -1,28 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment, useEffect, useState } from 'react';
2
+ import { useState } from 'react';
3
3
  import SSITabViewHeader from './SSITabViewHeader';
4
4
  import { SSITabViewContainerStyled as Container } from '../../../styles';
5
- const Tab = (props) => {
6
- return _jsx(Fragment, { children: props.children });
7
- };
8
5
  const SSITabView = (props) => {
9
6
  const { routes = [] } = props;
10
- const [activeRoute, setActiveRoute] = useState(props.activeRoute ?? (routes.length > 0 ? routes[0].key : ""));
11
- const [content, setContent] = useState();
12
- useEffect(() => {
13
- routes.forEach((route) => {
14
- if (route.key === activeRoute) {
15
- setContent(route.content);
16
- }
17
- });
18
- }, [routes, activeRoute]);
7
+ const [activeRoute, setActiveRoute] = useState(props.activeRoute ?? (routes.length > 0 ? routes[0].key : ''));
8
+ const activeContent = routes.find((route) => route.key === activeRoute)?.content;
19
9
  const onRouteChange = async (key) => {
20
10
  setActiveRoute(key);
21
11
  props.onRouteChange?.(key);
22
12
  };
23
- return (_jsxs(Container, { children: [_jsx(SSITabViewHeader, { navigationState: {
24
- routes,
25
- activeRoute,
26
- }, onRouteChange: onRouteChange }), _jsx(Tab, { children: content })] }));
13
+ return (_jsxs(Container, { children: [_jsx(SSITabViewHeader, { navigationState: { routes, activeRoute }, onRouteChange: onRouteChange }), _jsx("div", { role: "tabpanel", children: activeContent })] }));
27
14
  };
28
15
  export default SSITabView;
@@ -3,23 +3,26 @@ import { SSITextH2Styled } from '../../../fonts';
3
3
  import { SSIFlexDirectionRowViewStyled } from '../../containers';
4
4
  export const SSICheckboxContainerStyled = styled(SSIFlexDirectionRowViewStyled) `
5
5
  align-items: center;
6
- gap: 10px;
6
+ gap: 8px;
7
7
  cursor: pointer;
8
8
  `;
9
9
  export const SSICheckboxUnselectedContainerStyled = styled.div `
10
10
  width: 18px;
11
- aspect-ratio: 1;
12
- border-radius: 4px;
13
- border-width: 1px;
11
+ height: 18px;
12
+ min-width: 18px;
13
+ border-radius: 2px;
14
14
  `;
15
15
  export const SSICheckboxSelectedContainerStyled = styled.div `
16
16
  width: 18px;
17
- aspect-ratio: 1;
18
- border-radius: 4px;
17
+ height: 18px;
18
+ min-width: 18px;
19
+ border-radius: 2px;
20
+ display: flex;
19
21
  align-items: center;
20
22
  justify-content: center;
21
23
  `;
22
24
  export const SSICheckboxLabelContainerStyled = styled(SSITextH2Styled) `
23
25
  display: flex;
24
26
  flex-wrap: wrap;
27
+ font-size: 14px;
25
28
  `;
@@ -3,4 +3,5 @@ export const SSITabViewContainerStyled = styled.div `
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  flex-grow: 1;
6
+ width: 100%;
6
7
  `;
@@ -1,5 +1,7 @@
1
1
  import type { IStyledComponent } from 'styled-components';
2
- import { SSITextH3Styled } from '../../../fonts';
3
2
  export declare const SSITabViewHeaderContainerStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
3
+ export declare const SSITabViewHeaderTabBarStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
4
4
  export declare const SSITabViewHeaderTitleContainerStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
5
- export declare const SSITabViewHeaderTitleCaptionStyled: typeof SSITextH3Styled;
5
+ export declare const SSITabViewHeaderTitleCaptionStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
6
+ export declare const SSITabViewHeaderActiveIndicatorStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
7
+ export declare const SSITabViewHeaderDividerStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
@@ -1,15 +1,40 @@
1
1
  import styled from 'styled-components';
2
- import { SSITextH3Styled } from '../../../fonts';
2
+ import { elementColors, fontColors } from '@sphereon/ui-components.core';
3
+ import { SSITextH3Css } from '../../../css';
3
4
  export const SSITabViewHeaderContainerStyled = styled.div `
4
5
  display: flex;
5
- flex-direction: row;
6
- gap: 84px;
7
- margin-left: 66px;
6
+ flex-direction: column;
7
+ width: 100%;
8
+ `;
9
+ export const SSITabViewHeaderTabBarStyled = styled.div `
10
+ display: flex;
11
+ height: 48px;
8
12
  `;
9
13
  export const SSITabViewHeaderTitleContainerStyled = styled.div `
14
+ flex: 1;
15
+ display: flex;
16
+ flex-direction: column;
17
+ align-items: center;
18
+ justify-content: flex-end;
19
+ height: 48px;
10
20
  cursor: pointer;
21
+ `;
22
+ export const SSITabViewHeaderTitleCaptionStyled = styled.div `
23
+ ${SSITextH3Css};
11
24
  display: flex;
25
+ align-items: center;
26
+ justify-content: center;
27
+ padding: 0 16px;
28
+ height: 100%;
29
+ color: ${fontColors.dark};
30
+ `;
31
+ export const SSITabViewHeaderActiveIndicatorStyled = styled.div `
32
+ width: 100%;
33
+ height: 2px;
34
+ background: linear-gradient(172deg, #7276f7 0%, #7c40e8 100%);
12
35
  `;
13
- export const SSITabViewHeaderTitleCaptionStyled = styled(SSITextH3Styled) `
14
- margin-top: auto;
36
+ export const SSITabViewHeaderDividerStyled = styled.div `
37
+ width: 100%;
38
+ height: 1px;
39
+ background-color: ${elementColors.lightGrey};
15
40
  `;
@@ -6,3 +6,4 @@ export * from './field';
6
6
  export * from './view';
7
7
  export * from './icon';
8
8
  export * from './jsonForms';
9
+ export * from './position';
@@ -6,3 +6,4 @@ export * from './field';
6
6
  export * from './view';
7
7
  export * from './icon';
8
8
  export * from './jsonForms';
9
+ export * from './position';
@@ -1 +1,2 @@
1
1
  export type Direction = 'down' | 'up';
2
+ export type Position = 'left' | 'right' | 'top' | 'bottom';
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-next.183+a3ea620",
4
+ "version": "0.4.1-next.186+8f34f58",
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-types": "0.37.0",
52
52
  "@sphereon/ssi-types": "0.37.0",
53
- "@sphereon/ui-components.core": "0.4.1-next.183+a3ea620",
53
+ "@sphereon/ui-components.core": "0.4.1-next.186+8f34f58",
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": "a3ea620f95d823f6a2447e49d0eab3fca7ec32a0"
75
+ "gitHead": "8f34f589c1358a54d7e34624611aa6352982d84c"
76
76
  }