Skip to content

Commit cd037e3

Browse files
authored
fix(datepicker): pass required prop to Form.Field (#375)
1 parent 77f0ef8 commit cd037e3

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/components/input.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ const CustomInput = React.forwardRef<Input, InputProps>((props, ref) => {
1717
label,
1818
onClear,
1919
onClick,
20+
required,
2021
value,
2122
...rest
2223
} = props;
2324

2425
return (
25-
<Form.Field>
26+
<Form.Field required={required}>
2627
{label && <label htmlFor={rest.id as string | undefined}>{label}</label>}
2728
<Input
2829
data-testid="datepicker-input"
2930
{...rest}
3031
ref={ref}
32+
required={required}
3133
icon={
3234
<CustomIcon
3335
clearIcon={clearIcon}

src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export type SemanticDatepickerProps = PickedDayzedProps &
7575
data: SemanticDatepickerProps
7676
) => void;
7777
pointing: 'left' | 'right' | 'top left' | 'top right';
78+
required?: boolean;
7879
showToday: boolean;
7980
type: 'basic' | 'range';
8081
datePickerOnly: boolean;

stories/index.stories.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { boolean, date, number, select, text } from '@storybook/addon-knobs';
33
import { Form, SemanticICONS } from 'semantic-ui-react';
44
import 'semantic-ui-css/semantic.min.css';
55
import SemanticDatepicker from '../src';
6+
import { SemanticDatepickerProps } from '../src/types';
67
import {
78
Content,
89
iconMap,
@@ -31,7 +32,10 @@ export const basicUsage = () => {
3132
const clearIcon = select('Clear icon (with value)', iconMap, iconMap.close);
3233
const iconOnLeft = boolean('Icon on the left', false);
3334
const datePickerOnly = boolean('Datepicker only', false);
34-
const firstDayOfWeek = number('First day of week', 0, { max: 6, min: 0 });
35+
const firstDayOfWeek = number('First day of week', 0, {
36+
max: 6,
37+
min: 0,
38+
}) as SemanticDatepickerProps['firstDayOfWeek'];
3539
const format = text('Format', 'YYYY-MM-DD');
3640
const keepOpenOnClear = boolean('Keep open on clear', false);
3741
const keepOpenOnSelect = boolean('Keep open on select', false);

0 commit comments

Comments
 (0)