@granto-umbrella/umbrella-components 1.3.2 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granto-umbrella/umbrella-components",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Umbrella Components for React",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -12,7 +12,7 @@
12
12
  "scripts": {
13
13
  "dev": "vite",
14
14
  "build": "tsc -b && vite build",
15
- "prepublish": "npm run bump:patch && npm run build && npm run build-storybook && git add * && git commit -m 'chore: release' && git push && git push --tags && npm publish",
15
+ "prepublish": "npm run build && npm run build-storybook && git add * && git commit -m 'chore: release' && git push && git push --tags && npm publish",
16
16
  "lint": "eslint .",
17
17
  "preview": "vite preview",
18
18
  "storybook": "storybook dev -p 6006",
@@ -40,6 +40,10 @@
40
40
  "@chromatic-com/storybook": "3.2.3",
41
41
  "@eslint/js": "^9.17.0",
42
42
  "@storybook/react-vite": "8.4.7",
43
+ "@storybook/addon-onboarding": "8.4.7",
44
+ "@storybook/addon-essentials": "8.4.7",
45
+ "@storybook/addon-interactions": "8.4.7",
46
+ "@storybook/addon-actions": "8.4.7",
43
47
  "@testing-library/jest-dom": "^6.6.3",
44
48
  "@testing-library/react": "^16.1.0",
45
49
  "@testing-library/user-event": "^14.5.2",
@@ -92,27 +92,27 @@ const buttonVariants = {
92
92
  };
93
93
 
94
94
  export const StyledButton = styled.button<{
95
- size: keyof typeof buttonSizes;
96
- variant: keyof typeof buttonVariants;
97
- radius: keyof typeof semanticRadiusBorders;
98
- width?: string;
99
- height?: string;
95
+ $size: keyof typeof buttonSizes;
96
+ $variant: keyof typeof buttonVariants;
97
+ $radius: keyof typeof semanticRadiusBorders;
98
+ $width?: string;
99
+ $height?: string;
100
100
  }>`
101
101
  display: flex;
102
102
  align-items: center;
103
103
  justify-content: center;
104
104
  font-weight: 500;
105
- border-radius: ${({ radius }) => semanticRadiusBorders[radius]};
105
+ border-radius: ${({ $radius }) => semanticRadiusBorders[$radius]};
106
106
  cursor: pointer;
107
107
  transition: all 0.2s ease-in-out;
108
108
 
109
109
  gap: ${semanticSizes.md};
110
110
 
111
- ${({ size }) => buttonSizes[size]}
112
- ${({ variant }) => buttonVariants[variant]}
111
+ ${({ $size }) => buttonSizes[$size]}
112
+ ${({ $variant }) => buttonVariants[$variant]}
113
113
 
114
- width: ${({ width }) => width || "auto"};
115
- height: ${({ height }) => height || "auto"};
114
+ width: ${({ $width }) => $width || "auto"};
115
+ height: ${({ $height }) => $height || "auto"};
116
116
 
117
117
  &:disabled {
118
118
  cursor: not-allowed;
@@ -22,11 +22,11 @@ const Button: React.FC<ButtonProps> = ({
22
22
 
23
23
  return (
24
24
  <StyledButton
25
- size={size}
26
- variant={variant}
27
- radius={radius}
28
- width={width}
29
- height={height}
25
+ $size={size}
26
+ $variant={variant}
27
+ $radius={radius}
28
+ $width={width}
29
+ $height={height}
30
30
  {...props}
31
31
  >
32
32
  {isLoading ? (
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { forwardRef } from "react";
2
2
  import { InputProps } from "./Input.types";
3
3
  import {
4
4
  Container,
@@ -9,46 +9,66 @@ import {
9
9
  SupportText,
10
10
  } from "./Input.styles";
11
11
 
12
- const Input: React.FC<InputProps> = ({
13
- type = "text",
14
- placeholder = "Placeholder",
15
- value,
16
- onChange,
17
- error = false,
18
- disabled = false,
19
- icon,
20
- label,
21
- supportText,
22
- size = "md",
23
- radius = "--border-1",
24
- shadow = "shadow",
25
- style,
26
- register,
27
- }) => {
28
- return (
29
- <Container>
30
- {label && <Label>{label}</Label>}
31
- <InputWrapper
32
- $error={error}
33
- $disabled={disabled}
34
- $size={size}
35
- $radius={radius}
36
- $shadow={shadow}
37
- >
38
- {icon && <Icon>{icon}</Icon>}
39
- <StyledInput
40
- {...register}
41
- style={style}
42
- type={type}
43
- placeholder={placeholder}
44
- value={value}
45
- onChange={onChange}
46
- disabled={disabled}
47
- />
48
- </InputWrapper>
49
- {supportText && <SupportText $error={error}>{supportText}</SupportText>}
50
- </Container>
51
- );
52
- };
12
+ function mergeRefs<T>(
13
+ ...refs: (React.Ref<T> | null | undefined)[]
14
+ ): React.RefCallback<T> {
15
+ return (value: T) => {
16
+ refs.forEach((ref) => {
17
+ if (typeof ref === "function") {
18
+ ref(value);
19
+ } else if (ref != null) {
20
+ (ref as React.MutableRefObject<T | null>).current = value;
21
+ }
22
+ });
23
+ };
24
+ }
25
+
26
+ const Input = forwardRef<HTMLInputElement, InputProps>(
27
+ (
28
+ {
29
+ type = "text",
30
+ placeholder = "Placeholder",
31
+ value,
32
+ onChange,
33
+ error = false,
34
+ disabled = false,
35
+ icon,
36
+ label,
37
+ supportText,
38
+ size = "md",
39
+ radius = "--border-1",
40
+ shadow = "shadow",
41
+ style,
42
+ register,
43
+ },
44
+ ref
45
+ ) => {
46
+ return (
47
+ <Container>
48
+ {label && <Label>{label}</Label>}
49
+ <InputWrapper
50
+ $error={error}
51
+ $disabled={disabled}
52
+ $size={size}
53
+ $radius={radius}
54
+ $shadow={shadow}
55
+ >
56
+ {icon && <Icon>{icon}</Icon>}
57
+ <StyledInput
58
+ {...(register || {})}
59
+ ref={mergeRefs(ref, register ? register.ref : null)}
60
+ style={style}
61
+ type={type}
62
+ placeholder={placeholder}
63
+ value={value}
64
+ onChange={onChange}
65
+ disabled={disabled}
66
+ />
67
+ </InputWrapper>
68
+ {supportText && <SupportText $error={error}>{supportText}</SupportText>}
69
+ </Container>
70
+ );
71
+ }
72
+ );
53
73
 
54
74
  export default Input;