Skip to content

Commit

Permalink
Merge pull request #752 from lyytioy/next
Browse files Browse the repository at this point in the history
v3.7.4
  • Loading branch information
mikael-jarvinen authored Jan 16, 2024
2 parents 456410e + 19860fd commit 795afd4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@lyyti/design-system",
"description": "Lyyti Design System",
"homepage": "https://lyytioy.github.io/lyyti-design-system",
"version": "3.7.3",
"version": "3.7.4",
"engines": {
"node": "^18",
"npm": "^9"
Expand Down
26 changes: 19 additions & 7 deletions src/components/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ export type SizeTypes = 'small' | 'medium';

export type ColorTypes = 'primary' | 'white';

export type NumberInputProps = {
export interface NumberInputProps extends Omit<
OutlinedTextFieldProps,
'variant' | 'color' | 'fullWidth' | 'error' | 'helperText' | 'hiddenLabel' | 'onChange' | 'onBlur' | 'onClick' | 'onFocus'
>, Omit<UseNumberInputParameters, 'value' | 'inputRef'> {
fullWidth?: boolean;
size?: SizeTypes;
startAdornment?: string | JSX.Element;
color?: ColorTypes;
error?: boolean;
helperText?: string;
'data-testid'?: string;
} & Omit<
OutlinedTextFieldProps,
'variant' | 'color' | 'fullWidth' | 'error' | 'helperText' | 'hiddenLabel'
> & UseNumberInputParameters;
value?: number | string; // Allow strings to enable controlled behaviour, empty value "" instead of undefined
}

const NumberInput = (
{
Expand All @@ -43,11 +44,22 @@ const NumberInput = (
helperText = '',
sx = {},
InputLabelProps = {},
...props
...rest
}: NumberInputProps,
ref: Ref<HTMLDivElement>
): JSX.Element => {
const { getRootProps, getInputProps, getIncrementButtonProps, getDecrementButtonProps } = useNumberInput(props);
const { onChange, onBlur, ...props } = rest;

const {
getRootProps,
getInputProps,
getIncrementButtonProps,
getDecrementButtonProps
} = useNumberInput({
...props as UseNumberInputParameters, // Casting due to different value type
onChange,
onBlur
});
const muiTextField = useRef<HTMLDivElement>(null);
const overrideColor = color === 'white' ? 'common.white' : undefined;

Expand Down

0 comments on commit 795afd4

Please sign in to comment.