From 4569854913704dce2a2592cfbe8b7d1c1018d284 Mon Sep 17 00:00:00 2001 From: Shayne Thiessen Date: Thu, 21 Mar 2024 09:46:30 -0500 Subject: [PATCH] feat: localTimeEditCell (#398) --- .../inputs/TableInput/LocalTimeEditCell.tsx | 35 +++++++++++++++++++ .../controls/src/inputs/TableInput/index.ts | 1 + 2 files changed, 36 insertions(+) create mode 100644 packages/controls/src/inputs/TableInput/LocalTimeEditCell.tsx diff --git a/packages/controls/src/inputs/TableInput/LocalTimeEditCell.tsx b/packages/controls/src/inputs/TableInput/LocalTimeEditCell.tsx new file mode 100644 index 00000000..07158e00 --- /dev/null +++ b/packages/controls/src/inputs/TableInput/LocalTimeEditCell.tsx @@ -0,0 +1,35 @@ +import type {LocalTime} from '@js-joda/core'; +import debug from 'debug'; +import {useState} from 'react'; +import type {TableCellProps} from './TableInput'; +import {LocalTimePicker} from '../../date/LocalTimePicker'; + +const d = debug('thx.controls.inputs.TableInput.LocalDateEditCell'); + +export function LocalTimeEditCell>() { + return function LocalTimeEditCellFn(props: TableCellProps) { + const { + value: initialValue, + row: {index: rowIndex}, + column: {id}, + updateData, + } = props; + + const [value, setValue] = useState(initialValue); + + return ( + { + setValue(val); + updateData(rowIndex, id, val); + }} + onBlur={() => { + updateData(rowIndex, id, value); + }} + /> + ); + }; +} diff --git a/packages/controls/src/inputs/TableInput/index.ts b/packages/controls/src/inputs/TableInput/index.ts index 2402efd3..840c4005 100644 --- a/packages/controls/src/inputs/TableInput/index.ts +++ b/packages/controls/src/inputs/TableInput/index.ts @@ -4,6 +4,7 @@ export {MoneyEditCell} from './MoneyEditCell'; export {LocalDateCell} from './LocalDateCell'; export {CheckboxEditCell} from './CheckboxEditCell'; export {LocalDateEditCell} from './LocalDateEditCell'; +export {LocalTimeEditCell} from './LocalTimeEditCell'; export {MoneySumFooter} from './MoneySumFooter'; export {StringEditCell} from './StringEditCell'; export {DropdownCell} from './DropdownCell';