Skip to content

Commit

Permalink
fix(nhsuk-frontend-react): update DateInputPart type
Browse files Browse the repository at this point in the history
  • Loading branch information
rowellx68 committed Sep 30, 2024
1 parent 4b5f018 commit f4ab50a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-birds-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nhsuk-frontend-react": patch
---

fix(nhsuk-frontend-react): update DateInputPart type
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,11 @@ const datePartLabels: Record<DatePart, string> = {
export type DateInputPartProps = {
label?: string;
labelProps?: LabelProps;
itemProps?: ElementProps<'div'>;
error?: boolean;
part: DatePart;
name?: string;
width?: InputWidth;
value?: string;
disabled?: boolean;
} & ElementProps<'div', 'value' | 'defaultValue' | 'type' | 'ref'>;
} & ElementProps<'input', 'defaultValue' | 'type'>;

type DateInputPartFactory = Factory<{
props: DateInputPartProps;
Expand All @@ -166,6 +164,7 @@ const BaseDatePart = factory<DateInputPartFactory>(
value,
disabled,
onChange,
itemProps = {},
...props
},
ref,
Expand All @@ -189,6 +188,8 @@ const BaseDatePart = factory<DateInputPartFactory>(
}, []);

const { className: labelClassName, ...restLabelProps } = labelProps;
const { className: wrapperClassName, ...restWrapperProps } = itemProps;

const _label = label || datePartLabels[part];

const inputId = id || `${ctxId}-${part}`;
Expand All @@ -206,7 +207,10 @@ const BaseDatePart = factory<DateInputPartFactory>(
error || (errorMap && errorMap[part]) || (ctxError && !errorMap);

return (
<div className={clsx('nhsuk-date-input__item')} {...props}>
<div
className={clsx('nhsuk-date-input__item', wrapperClassName)}
{...restWrapperProps}
>
<Input
labelProps={{
className: clsx('nhsuk-date-input__label', labelClassName),
Expand All @@ -228,6 +232,7 @@ const BaseDatePart = factory<DateInputPartFactory>(
type="text"
inputMode="numeric"
pattern="[0-9]*"
{...props}
onChange={handleChange}
disabled={disabled || ctxDisabled}
ref={ref}
Expand Down

0 comments on commit f4ab50a

Please sign in to comment.