Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"module": "dist/react-semantic-ui-datepickers.esm.js",
"typings": "dist/index.d.ts",
"scripts": {
"lint": "tsdx lint src",
"lint": "tsdx lint src stories",
"lint:fix": "yarn lint --fix",
"start": "tsdx watch",
"build": "tsdx build",
"prebuild": "rimraf dist",
Expand Down
20 changes: 20 additions & 0 deletions src/__tests__/datepicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,26 @@ describe('Basic datepicker', () => {
expect(onBlur).not.toHaveBeenCalled();
});
});

describe('placeholder', () => {
it('should use the format prop as default', () => {
const { datePickerInput } = setup();

expect(datePickerInput.placeholder).toBe('YYYY-MM-DD');
});

it('should allow empty strings', () => {
const { datePickerInput } = setup({ placeholder: '' });

expect(datePickerInput.placeholder).toBe('');
});

it('should allow null', () => {
const { datePickerInput } = setup({ placeholder: null });

expect(datePickerInput.placeholder).toBe('');
});
});
});

describe('Range datepicker', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SemanticDatepicker extends React.Component<
name: undefined,
onBlur: () => {},
onChange: () => {},
placeholder: null,
placeholder: undefined,
pointing: 'left',
readOnly: false,
datePickerOnly: false,
Expand Down Expand Up @@ -131,7 +131,8 @@ class SemanticDatepicker extends React.Component<

get inputProps() {
const props = pick(semanticInputProps, this.props);
const placeholder = props.placeholder || this.props.format;
const placeholder =
props.placeholder !== undefined ? props.placeholder : this.props.format;

return {
...props,
Expand Down
2 changes: 1 addition & 1 deletion stories/basic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SemanticDatepicker from '../src';
import { Content } from './common';
import { parseISO } from 'date-fns';

const isWeekday = date => {
const isWeekday = (date: Date) => {
const day = date.getDay();

return day !== 0 && day !== 6;
Expand Down