sbwb-ds 2.2.0 → 2.2.2

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": "sbwb-ds",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "type": "module",
5
5
  "description": "Sistema de design para padronização dos processos visuais do portal SUBWEB",
6
6
  "main": "dist/sbwb-ds.js",
@@ -84,6 +84,28 @@ const Input: React.FC<InputProps> = forwardRef<
84
84
  setHasValue(e.target.value !== '');
85
85
  };
86
86
 
87
+ const handleKeyPress = (e: KeyboardEvent<HTMLInputElement>) => {
88
+ if (type === 'number') {
89
+ preventNonNumericalInput(e);
90
+ }
91
+ };
92
+
93
+ function preventNonNumericalInput(e: KeyboardEvent<HTMLInputElement>) {
94
+ const char = e.key;
95
+ const currentValue = e.currentTarget.value;
96
+
97
+ if (!/[0-9]/.test(char) && char !== '.' && char !== ',') {
98
+ e.preventDefault();
99
+ }
100
+
101
+ if (
102
+ (char === '.' || char === ',') &&
103
+ (currentValue.includes('.') || currentValue.includes(','))
104
+ ) {
105
+ e.preventDefault();
106
+ }
107
+ }
108
+
87
109
  const VisibilityIcon =
88
110
  Icons[`Visibility${size === 'Small' ? 'Ant' : 'Sm'}`];
89
111
  const VisibilityIconOff =
@@ -155,7 +177,7 @@ const Input: React.FC<InputProps> = forwardRef<
155
177
  data-testid="input"
156
178
  id={`input-${id}`}
157
179
  disabled={disabled}
158
- type={inputType}
180
+ type={'float'}
159
181
  placeholder={placeholder}
160
182
  error={errorMessage}
161
183
  value={value}
@@ -163,6 +185,7 @@ const Input: React.FC<InputProps> = forwardRef<
163
185
  size={size}
164
186
  variant={variant}
165
187
  onKeyDown={handleKeyDown}
188
+ onKeyPress={handleKeyPress}
166
189
  onFocus={(e) => {
167
190
  setIsFocused(true);
168
191
  focus();
@@ -226,10 +226,15 @@ interface InputProps {
226
226
  export const Input = styled.input<InputProps>`
227
227
  ${resetStyles}
228
228
  font-family: ${sg.fonts.fontFamily.fontFamilyPrimary};
229
- font-size: ${({ size }) =>
230
- size === 'Small'
231
- ? sg.fonts.fontSize.fontSizeBodyMd
232
- : sg.fonts.fontSize.fontSizeBodyLg};
229
+ font-size: ${({ size, variant }) => {
230
+ if (variant === 'table') {
231
+ return size === 'large' ? '12px' : '10px';
232
+ } else {
233
+ return size === 'Small'
234
+ ? sg.fonts.fontSize.fontSizeBodyMd
235
+ : sg.fonts.fontSize.fontSizeBodyLg;
236
+ }
237
+ }};
233
238
  background-color: ${({ disabled }) =>
234
239
  disabled ? sg.colors.brandColors.colorBrandSeSoft : 'transparent'};
235
240
  outline: none;
@@ -239,10 +244,15 @@ export const Input = styled.input<InputProps>`
239
244
 
240
245
  &::placeholder {
241
246
  font-family: ${sg.fonts.fontFamily.fontFamilyPrimary};
242
- font-size: ${({ size }) =>
243
- size === 'Small'
244
- ? sg.fonts.fontSize.fontSizeBodyMd
245
- : sg.fonts.fontSize.fontSizeBodyLg};
247
+ font-size: ${({ size, variant }) => {
248
+ if (variant === 'table') {
249
+ return size === 'large' ? '12px' : '10px';
250
+ } else {
251
+ return size === 'Small'
252
+ ? sg.fonts.fontSize.fontSizeBodyMd
253
+ : sg.fonts.fontSize.fontSizeBodyLg;
254
+ }
255
+ }};
246
256
  color: ${({ error, variant }) => {
247
257
  if (error && variant === 'table') {
248
258
  return sg.colors.feedbackColors.colorFeedbackError;