Skip to content

Commit

Permalink
fix(datepicker): pass required prop to Form.Field (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurdenner committed Aug 24, 2020
1 parent 77f0ef8 commit cd037e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ const CustomInput = React.forwardRef<Input, InputProps>((props, ref) => {
label,
onClear,
onClick,
required,
value,
...rest
} = props;

return (
<Form.Field>
<Form.Field required={required}>
{label && <label htmlFor={rest.id as string | undefined}>{label}</label>}
<Input
data-testid="datepicker-input"
{...rest}
ref={ref}
required={required}
icon={
<CustomIcon
clearIcon={clearIcon}
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export type SemanticDatepickerProps = PickedDayzedProps &
data: SemanticDatepickerProps
) => void;
pointing: 'left' | 'right' | 'top left' | 'top right';
required?: boolean;
showToday: boolean;
type: 'basic' | 'range';
datePickerOnly: boolean;
Expand Down
6 changes: 5 additions & 1 deletion stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { boolean, date, number, select, text } from '@storybook/addon-knobs';
import { Form, SemanticICONS } from 'semantic-ui-react';
import 'semantic-ui-css/semantic.min.css';
import SemanticDatepicker from '../src';
import { SemanticDatepickerProps } from '../src/types';
import {
Content,
iconMap,
Expand Down Expand Up @@ -31,7 +32,10 @@ export const basicUsage = () => {
const clearIcon = select('Clear icon (with value)', iconMap, iconMap.close);
const iconOnLeft = boolean('Icon on the left', false);
const datePickerOnly = boolean('Datepicker only', false);
const firstDayOfWeek = number('First day of week', 0, { max: 6, min: 0 });
const firstDayOfWeek = number('First day of week', 0, {
max: 6,
min: 0,
}) as SemanticDatepickerProps['firstDayOfWeek'];
const format = text('Format', 'YYYY-MM-DD');
const keepOpenOnClear = boolean('Keep open on clear', false);
const keepOpenOnSelect = boolean('Keep open on select', false);
Expand Down

1 comment on commit cd037e3

@vercel
Copy link

@vercel vercel bot commented on cd037e3 Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.