@cyber-harbour/ui 1.0.31 → 1.0.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyber-harbour/ui",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -1,11 +1,17 @@
1
1
  import { createComponent, FabricComponent } from '../../Theme';
2
2
  import { styled } from 'styled-components';
3
3
 
4
- type BoxProps = FabricComponent<{
5
- children: any;
6
- }>;
4
+ type BoxProps = FabricComponent<
5
+ {
6
+ children: any;
7
+ } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
8
+ >;
7
9
 
8
- export const Box = styled(createComponent<BoxProps>('div'))(
10
+ export const Box = ({ children, ...props }: BoxProps) => {
11
+ return <StyledBox {...props}>{children}</StyledBox>;
12
+ };
13
+
14
+ const StyledBox = styled(createComponent('div'))(
9
15
  ({ theme }) => `
10
16
  padding: ${theme.box.padding};
11
17
  border-radius: ${theme.box.borderRadius};
@@ -1,28 +1,27 @@
1
- import { InputSize, InputSizeStyle } from '../../Theme';
2
- import { InputHTMLAttributes } from 'react';
1
+ import { InputSize, InputSizeStyle, InputVariant, getInputStyles } from '../../Theme';
2
+ import { forwardRef, InputHTMLAttributes, Ref } from 'react';
3
3
  import { styled } from 'styled-components';
4
4
  import { InfoCircleFilledIcon } from '../IconComponents';
5
5
 
6
- type StyledProps = {
7
- $error?: boolean;
8
- $sizes: InputSizeStyle;
9
- };
10
-
11
- type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & {
6
+ export type InputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & {
12
7
  error?: boolean;
13
8
  append?: any;
14
9
  prepend?: any;
15
10
  size?: InputSize;
11
+ variant?: InputVariant;
16
12
  };
17
13
 
18
- export const Input = ({ error, append, prepend, size = 'small', disabled, className, ...props }: InputProps) => {
14
+ export const Input: any = forwardRef<HTMLInputElement, InputProps>(function Input(
15
+ { error, append, prepend, size = 'small', variant = 'outlined', disabled, className, ...props },
16
+ ref
17
+ ) {
19
18
  return (
20
- <Group className={className} $error={error} $size={size} $disabled={!!disabled}>
19
+ <Group className={className} $error={error} $size={size} $variant={variant} $disabled={!!disabled}>
21
20
  {!!prepend && prepend}
22
- <InputGroup $size={size}>
23
- <input {...props} disabled={disabled} />
21
+ <InputGroup $size={size} $variant={variant}>
22
+ <input ref={ref} disabled={disabled} {...props} />
24
23
  {!!error && (
25
- <IconWrapper>
24
+ <IconWrapper $variant={variant}>
26
25
  <InfoCircleFilledIcon />
27
26
  </IconWrapper>
28
27
  )}
@@ -30,10 +29,10 @@ export const Input = ({ error, append, prepend, size = 'small', disabled, classN
30
29
  {!!append && append}
31
30
  </Group>
32
31
  );
33
- };
32
+ });
34
33
 
35
- const InputGroup = styled.div<{ $size: InputSize }>(
36
- ({ theme, $size }) => `
34
+ const InputGroup = styled.div<{ $size: InputSize; $variant?: InputVariant }>(
35
+ ({ theme, $size, $variant = 'outlined' }) => `
37
36
  display: inline-flex;
38
37
  align-items: center;
39
38
  width: 100%;
@@ -56,7 +55,7 @@ const InputGroup = styled.div<{ $size: InputSize }>(
56
55
  border: none;
57
56
 
58
57
  &::placeholder {
59
- color: ${theme.input.outlined.default.placeholder};
58
+ color: ${theme.input[$variant].default.placeholder};
60
59
  font-size: ${theme.input.sizes[$size].fontSize};
61
60
  }
62
61
 
@@ -68,19 +67,19 @@ const InputGroup = styled.div<{ $size: InputSize }>(
68
67
  `
69
68
  );
70
69
 
71
- const IconWrapper = styled.span(
72
- ({ theme }) => `
70
+ const IconWrapper = styled.span<{ $variant: InputVariant }>(
71
+ ({ theme, $variant }) => `
73
72
  display: inline-flex;
74
73
  flex: 0 0 auto;
75
74
  align-items: center;
76
- color: ${theme.input.outlined.error.icon};
75
+ color: ${theme.input[$variant].error.icon};
77
76
  margin-right: 10px;
78
77
 
79
78
  `
80
79
  );
81
80
 
82
- const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSize }>(
83
- ({ theme, $disabled, $error, $size }) => `
81
+ const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSize; $variant: InputVariant }>(
82
+ ({ theme, $disabled, $error, $size, $variant }) => `
84
83
  display: inline-flex;
85
84
  align-items: center;
86
85
  width: 100%;
@@ -93,14 +92,14 @@ const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSiz
93
92
  ${
94
93
  $error
95
94
  ? `
96
- border-color: ${theme.input.outlined.error.border};
97
- color: ${theme.input.outlined.error.text};
98
- background: ${theme.input.outlined.error.background};
95
+ border-color: ${theme.input[$variant].error.border};
96
+ color: ${theme.input[$variant].error.text};
97
+ background: ${theme.input[$variant].error.background};
99
98
  `
100
99
  : `
101
- border-color: ${theme.input.outlined.default.border};
102
- color: ${theme.input.outlined.default.text};
103
- background: ${theme.input.outlined.default.background};
100
+ border-color: ${theme.input[$variant].default.border};
101
+ color: ${theme.input[$variant].default.text};
102
+ background: ${theme.input[$variant].default.background};
104
103
  `
105
104
  }
106
105
 
@@ -109,13 +108,13 @@ const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSiz
109
108
  !$error &&
110
109
  `
111
110
  &:hover {
112
- border-color: ${theme.input.outlined.focus.border};
111
+ border-color: ${theme.input[$variant].focus.border};
113
112
  }
114
113
 
115
114
  &:focus-within {
116
- border-color: ${theme.input.outlined.focus.border};
117
- color: ${theme.input.outlined.focus.text};
118
- background: ${theme.input.outlined.focus.background};
115
+ border-color: ${theme.input[$variant].focus.border};
116
+ color: ${theme.input[$variant].focus.text};
117
+ background: ${theme.input[$variant].focus.background};
119
118
  }
120
119
  `
121
120
  }
@@ -123,9 +122,9 @@ const Group = styled.div<{ $disabled: boolean; $error?: boolean; $size: InputSiz
123
122
  ${
124
123
  $disabled &&
125
124
  `
126
- border-color: ${theme.input.outlined.disabled.border};
127
- color: ${theme.input.outlined.disabled.text};
128
- background: ${theme.input.outlined.disabled.background};
125
+ border-color: ${theme.input[$variant].disabled.border};
126
+ color: ${theme.input[$variant].disabled.text};
127
+ background: ${theme.input[$variant].disabled.background};
129
128
  cursor: not-allowed;
130
129
  `
131
130
  }
@@ -1,4 +1,4 @@
1
- import { createComponent, FabricComponent, pxToRem } from '../../Theme';
1
+ import { createComponent, FabricComponent } from '../../Theme';
2
2
  import { styled } from 'styled-components';
3
3
 
4
4
  type LineProps = FabricComponent<
@@ -12,6 +12,7 @@ type TypographyProps = FabricComponent<{
12
12
  fontStyle?: CSSProperties['fontStyle'];
13
13
  color?: ColorVariant | string;
14
14
  className?: string;
15
+ ellipsis?: boolean;
15
16
  }>;
16
17
 
17
18
  // Create a styled component that can be dynamically rendered as different HTML elements
@@ -20,7 +21,8 @@ const StyledTypography = styled(createComponent('div'))<{
20
21
  $weight?: CSSProperties['fontWeight'];
21
22
  $style?: CSSProperties['fontStyle'];
22
23
  $color?: ColorVariant | string;
23
- }>(({ theme, $variant, $color, $weight = '400', $style = 'initial' }) => {
24
+ $ellipsis?: boolean;
25
+ }>(({ theme, $variant, $color, $weight = '400', $style = 'initial', $ellipsis }) => {
24
26
  // Resolve color from theme if it's a theme color path, or use the direct color value
25
27
 
26
28
  return `
@@ -28,6 +30,7 @@ const StyledTypography = styled(createComponent('div'))<{
28
30
  font-weight: ${$weight};
29
31
  font-style: ${$style};
30
32
  color: ${resolveThemeColor(theme, $color) || theme.colors.text.main};
33
+ ${$ellipsis ? 'overflow: hidden; text-overflow: ellipsis; white-space: nowrap;' : ''}
31
34
  `;
32
35
  });
33
36
 
@@ -40,6 +43,7 @@ export const Typography = ({
40
43
  color,
41
44
  className,
42
45
  style,
46
+ ellipsis = false,
43
47
  ...props
44
48
  }: TypographyProps) => {
45
49
  // Determine which HTML element to render based on the variant if not explicitly specified
@@ -52,6 +56,7 @@ export const Typography = ({
52
56
  $weight={weight}
53
57
  $style={fontStyle}
54
58
  $color={color}
59
+ $ellipsis={ellipsis}
55
60
  className={className}
56
61
  style={style}
57
62
  {...props}