Skip to content

Commit

Permalink
add js changes to ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
joakbjerk committed Jan 5, 2024
1 parent f76f3db commit 66c8707
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type DatePickerAlignPicker = 'auto' | 'left' | 'right'

export type DatePickerProps = Omit<
React.HTMLProps<HTMLElement>,
'ref' | 'children'
'ref' | 'children' | 'label' | 'size' | 'onBlur'
> &
SpacingProps & {
id?: string
Expand Down Expand Up @@ -278,6 +278,10 @@ export type DatePickerProps = Omit<
* Will be called once a user presses the reset button.
*/
on_reset?: (...args: any[]) => any
/**
* Will be called once the input loses focus.
*/
onBlur?: (event: React.FocusEventHandler<HTMLInputElement>) => void
}

const defaultProps: DatePickerProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,13 @@ function DatePickerInput(externalProps: DatePickerInputProps) {
setFocusState('focus')
}

function onBlurHandler() {
function onBlurHandler(event: React.FocusEvent<HTMLInputElement>) {
focusMode.current = null
setFocusState('blur')

if (props.onBlur) {
props.onBlur(event)
}
}

async function onKeyDownHandler(event) {
Expand Down Expand Up @@ -748,6 +752,7 @@ function DatePickerInput(externalProps: DatePickerInputProps) {
onChange, // eslint-disable-line
onFocus, // eslint-disable-line
onSubmit, // eslint-disable-line
onBlur, // eslint-disable-line
selectedDateTitle, // eslint-disable-line
showInput, // eslint-disable-line
input_element,
Expand Down Expand Up @@ -836,7 +841,7 @@ const selectAll = (target) => {
target.select()
}

function InputElement(props: TextMaskProps) {
function InputElement({ className, value, ...props }: TextMaskProps) {
return (
<TextMask
guide={true}
Expand All @@ -846,6 +851,11 @@ function InputElement(props: TextMaskProps) {
autoCapitalize="none"
spellCheck={false}
autoCorrect="off"
className={classnames(
className,
/\d+/.test(String(value)) && 'dnb-date-picker__input--highlight'
)}
value={value}
{...props}
/>
)
Expand Down

0 comments on commit 66c8707

Please sign in to comment.