Skip to content

Commit

Permalink
Update date field to latest api
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Jun 7, 2022
1 parent 8296243 commit 80a1c2a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/input/date/src/DateField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Field, Label, Value} from '@alinea/core'
import {Field, Label, Shape} from '@alinea/core'

/** Optional settings to configure a text field */
export type DateOptions = {
Expand All @@ -16,16 +16,16 @@ export type DateOptions = {
autoFocus?: boolean
}

/** Internal representation of a text field */
/** Internal representation of a date field */
export interface DateField extends Field.Scalar<string> {
label: Label
options: DateOptions
}

/** Create a text field configuration */
/** Create a date field configuration */
export function createDate(label: Label, options: DateOptions = {}): DateField {
return {
type: Value.Scalar(label),
shape: Shape.Scalar(label),
label,
options
}
Expand Down
9 changes: 3 additions & 6 deletions packages/input/date/src/DateInput.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {InputLabel, InputState, useInput} from '@alinea/editor'

import {DateField} from './DateField'
import {fromModule} from '@alinea/ui'
import {IcRoundDateRange} from '@alinea/ui/icons/IcRoundDateRange'
import {DateField} from './DateField'
import css from './DateInput.module.scss'
import {fromModule} from '@alinea/ui'
import {useState} from 'react'

const styles = fromModule(css)

Expand All @@ -16,15 +14,14 @@ export type DateInputProps = {
export function DateInput({state, field}: DateInputProps) {
const {width, inline, optional, help, autoFocus, initialValue} = field.options
const [value = initialValue, setValue] = useInput(state)
const [focus, setFocus] = useState(false)
return (
<InputLabel
asLabel
label={field.label}
help={help}
optional={optional}
inline={inline}
width={width}
focused={focus}
icon={IcRoundDateRange}
>
<input
Expand Down
2 changes: 1 addition & 1 deletion packages/input/select/src/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export function SelectInput<T extends string>({
})
return (
<InputLabel
width={width}
label={field.label}
help={help}
optional={optional}
inline={inline}
width={width}
icon={IcRoundArrowDropDownCircle}
>
<div className={styles.root()}>
Expand Down

0 comments on commit 80a1c2a

Please sign in to comment.