@sphereon/ui-components.ssi-react 0.4.1-next.179 → 0.4.1-next.182

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,11 +1,14 @@
1
1
  import { CSSProperties, FC } from 'react';
2
2
  type Props = {
3
+ label?: string;
4
+ placeholder?: string;
5
+ type?: 'text' | 'password' | 'email';
3
6
  initialValue?: string;
4
7
  value?: string;
5
8
  onChangeValue?: (value: string) => Promise<void>;
6
- placeholder?: string;
9
+ onChange?: (value: string) => void;
7
10
  maxLength?: number;
8
- label?: string;
11
+ disabled?: boolean;
9
12
  style?: CSSProperties;
10
13
  };
11
14
  declare const TextInputField: FC<Props>;
@@ -1,20 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useState } from 'react';
3
- import { TextFieldInputContainerStyled as Container, TextFieldInputInputStyled as Input, SSITextH2Styled as Label } from '../../../styles';
2
+ import { useState } from 'react';
3
+ import { TextFieldInputContainerStyled as Container, TextFieldInputWrapperStyled as Wrapper, TextFieldInputInputStyled as Input, TextFieldInputLabelStyled as Label, } from '../../../styles';
4
4
  const TextInputField = (props) => {
5
- const { initialValue, label, placeholder, maxLength, onChangeValue, style } = props;
6
- const [value, setValue] = React.useState(initialValue);
7
- const [isFocused, setIsFocused] = useState(false);
8
- const onChange = async (event) => {
9
- setValue(event.target.value);
10
- await onChangeValue?.(event.target.value);
5
+ const { label, placeholder, type = 'text', initialValue, maxLength, onChangeValue, onChange, disabled = false, style } = props;
6
+ const isControlled = props.value !== undefined;
7
+ const [internalValue, setInternalValue] = useState(initialValue ?? '');
8
+ const currentValue = isControlled ? props.value : internalValue;
9
+ const handleChange = async (event) => {
10
+ const newValue = event.target.value;
11
+ if (!isControlled) {
12
+ setInternalValue(newValue);
13
+ }
14
+ onChange?.(newValue);
15
+ await onChangeValue?.(newValue);
11
16
  };
12
- const onFocus = () => {
13
- setIsFocused(true);
14
- };
15
- const onBlur = () => {
16
- setIsFocused(false);
17
- };
18
- return (_jsxs(Container, { style: { ...style }, children: [label && _jsx(Label, { children: label }), _jsx(Input, { onChange: onChange, value: value, placeholder: isFocused ? '' : placeholder, type: 'text', onFocus: onFocus, onBlur: onBlur, maxLength: maxLength })] }));
17
+ return (_jsx(Container, { style: { ...style }, children: _jsxs(Wrapper, { children: [_jsx(Input, { type: type, value: currentValue, onChange: handleChange, placeholder: placeholder, maxLength: maxLength, disabled: disabled }), label && _jsx(Label, { children: label })] }) }));
19
18
  };
20
19
  export default TextInputField;
@@ -1,3 +1,5 @@
1
1
  import type { IStyledComponent } from 'styled-components';
2
2
  export declare const TextFieldInputContainerStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
3
+ export declare const TextFieldInputWrapperStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
3
4
  export declare const TextFieldInputInputStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>>;
5
+ export declare const TextFieldInputLabelStyled: IStyledComponent<'web', React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
@@ -1,27 +1,49 @@
1
- import { borderColors, fontColors } from '@sphereon/ui-components.core';
1
+ import { backgroundColors, borderColors, elementColors, fontColors } from '@sphereon/ui-components.core';
2
2
  import styled from 'styled-components';
3
- import { SSITextH2Css } from '../../../css';
3
+ import { SSITextH3Css, SSITextH7RegularCss } from '../../../css';
4
4
  export const TextFieldInputContainerStyled = styled.div `
5
- display: flex;
6
- flex-direction: column;
5
+ position: relative;
6
+ width: 100%;
7
+ height: 56px;
7
8
  `;
8
- export const TextFieldInputInputStyled = styled.input `Retry
9
- ${SSITextH2Css};
9
+ export const TextFieldInputWrapperStyled = styled.div `
10
+ position: absolute;
11
+ inset: 0;
12
+ border: 1px solid ${elementColors.lightGrey};
13
+ border-radius: 4px;
14
+ background-color: ${backgroundColors.primaryLight};
15
+
16
+ &:focus-within {
17
+ border-color: ${borderColors.purple};
18
+ }
19
+ `;
20
+ export const TextFieldInputInputStyled = styled.input `
21
+ ${SSITextH3Css};
10
22
  color: ${fontColors.dark};
11
- display: flex;
12
- padding: 12px 16px;
13
- align-items: center;
23
+ width: 100%;
24
+ height: 100%;
25
+ padding: 0 16px;
26
+ border: none;
14
27
  border-radius: 4px;
15
- border: 1px solid ${borderColors.lightGrey};
16
28
  outline: none;
17
- background-color: unset;
18
- font-family: Poppins, serif;
29
+ background-color: transparent;
30
+ font-family: Poppins, sans-serif;
19
31
 
20
- &:focus {
21
- border-color: ${borderColors.purple};
32
+ &::placeholder {
33
+ color: #727272;
22
34
  }
23
35
 
24
- &:hover {
25
- border-color: ${borderColors.purple};
36
+ &:disabled {
37
+ opacity: 0.5;
38
+ cursor: not-allowed;
26
39
  }
27
40
  `;
41
+ export const TextFieldInputLabelStyled = styled.div `
42
+ ${SSITextH7RegularCss};
43
+ position: absolute;
44
+ top: -10px;
45
+ left: 12px;
46
+ padding: 0 4px;
47
+ background-color: ${backgroundColors.primaryLight};
48
+ color: ${fontColors.dark};
49
+ `;
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.179+216c7c7",
4
+ "version": "0.4.1-next.182+f365faa",
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>",
@@ -48,9 +48,9 @@
48
48
  "@mui/styled-engine-sc": "^7.3.5",
49
49
  "@mui/system": "^7.3.5",
50
50
  "@mui/x-date-pickers": "^8.18.0",
51
- "@sphereon/ssi-sdk.data-store-types": "0.36.1-next.159",
52
- "@sphereon/ssi-types": "0.36.1-next.159",
53
- "@sphereon/ui-components.core": "0.4.1-next.179+216c7c7",
51
+ "@sphereon/ssi-sdk.data-store-types": "0.37.0",
52
+ "@sphereon/ssi-types": "0.37.0",
53
+ "@sphereon/ui-components.core": "0.4.1-next.182+f365faa",
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": "216c7c7dd49b3f1ed6048ed17f746d5b477682da"
75
+ "gitHead": "f365faa68bacc4671c039cd473bbd306b1d09aa8"
76
76
  }