diff options
author | Sebastian <sebasjm@gmail.com> | 2022-10-26 14:50:50 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-10-26 14:52:52 -0300 |
commit | b4bad2deaf93eff5858d903cd68b8fdd5a5eecd3 (patch) | |
tree | e6ead0edbd2b56cf9bcd8bc312fb07ed9280c5cc /packages/demobank-ui/src/components/fields/DateInput.tsx | |
parent | c34e71cf3de3da90d0d1662141aa1754a42ea37a (diff) |
pretty
Diffstat (limited to 'packages/demobank-ui/src/components/fields/DateInput.tsx')
-rw-r--r-- | packages/demobank-ui/src/components/fields/DateInput.tsx | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/packages/demobank-ui/src/components/fields/DateInput.tsx b/packages/demobank-ui/src/components/fields/DateInput.tsx index 06ec4b6a7..22a83c93c 100644 --- a/packages/demobank-ui/src/components/fields/DateInput.tsx +++ b/packages/demobank-ui/src/components/fields/DateInput.tsx @@ -1,7 +1,7 @@ -import { format, subYears } from 'date-fns'; -import { h, VNode } from 'preact'; -import { useLayoutEffect, useRef, useState } from 'preact/hooks'; -import { DatePicker } from '../picker/DatePicker'; +import { format, subYears } from "date-fns"; +import { h, VNode } from "preact"; +import { useLayoutEffect, useRef, useState } from "preact/hooks"; +import { DatePicker } from "../picker/DatePicker"; export interface DateInputProps { label: string; @@ -16,13 +16,11 @@ export interface DateInputProps { export function DateInput(props: DateInputProps): VNode { const inputRef = useRef<HTMLInputElement>(null); useLayoutEffect(() => { - if (props.grabFocus) - inputRef.current?.focus(); - + if (props.grabFocus) inputRef.current?.focus(); }, [props.grabFocus]); const [opened, setOpened] = useState(false); - const value = props.bind[0] || ''; + const value = props.bind[0] || ""; const [dirty, setDirty] = useState(false); const showError = dirty && props.error; @@ -43,12 +41,10 @@ export function DateInput(props: DateInputProps): VNode { <p class="control"> <input type="text" - class={showError ? 'input is-danger' : 'input'} + class={showError ? "input is-danger" : "input"} value={value} onKeyPress={(e) => { - if (e.key === 'Enter' && props.onConfirm) - props.onConfirm() - + if (e.key === "Enter" && props.onConfirm) props.onConfirm(); }} onInput={(e) => { const text = e.currentTarget.value; @@ -81,7 +77,7 @@ export function DateInput(props: DateInputProps): VNode { closeFunction={() => setOpened(false)} dateReceiver={(d) => { setDirty(true); - const v = format(d, 'yyyy-MM-dd'); + const v = format(d, "yyyy-MM-dd"); props.bind[1](v); }} /> |