Skip to content

Commit

Permalink
refactor(select): improve keyboard and events, split native to Select…
Browse files Browse the repository at this point in the history
…Native

BREAKING CHANGE: Select props changed significantly, native is now the SelectNative component
  • Loading branch information
WesSouza authored and arturbien committed Sep 10, 2022
1 parent 2a0d9ba commit 107fe15
Show file tree
Hide file tree
Showing 17 changed files with 1,845 additions and 797 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"access": "public"
},
"scripts": {
"start": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9009",
"start": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9009 --no-open",
"build:storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true build-storybook -o ./storybook",
"build": "rm -rf dist && yarn run build:prod",
"build:dev": "cross-env NODE_ENV=development rollup -c",
Expand Down Expand Up @@ -82,6 +82,7 @@
"@storybook/react": "6.5.10",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^12.1.5",
"@testing-library/react-hooks": "^8.0.1",
"@types/jest": "^28.1.6",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
Expand Down
10 changes: 6 additions & 4 deletions src/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Button } from '../Button/Button';
import { NumberInput } from '../NumberInput/NumberInput';
import { ScrollView } from '../ScrollView/ScrollView';
import { Select } from '../Select/Select';
import { SelectChangeEvent } from '../Select/Select.types';
import { Toolbar } from '../Toolbar/Toolbar';
import { Window, WindowContent, WindowHeader } from '../Window/Window';

Expand Down Expand Up @@ -101,9 +100,12 @@ const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
const [date, setDate] = useState(() => convertDateToState(initialDate));
const { year, month, day } = date;

const handleMonthSelect = useCallback((e: SelectChangeEvent<number>) => {
setDate(currentDate => ({ ...currentDate, month: e.target.value }));
}, []);
const handleMonthSelect = useCallback(
({ value: monthSelected }: { value: number }) => {
setDate(currentDate => ({ ...currentDate, month: monthSelected }));
},
[]
);

const handleYearSelect = useCallback((yearSelected: number) => {
setDate(currentDate => ({ ...currentDate, year: yearSelected }));
Expand Down
Loading

0 comments on commit 107fe15

Please sign in to comment.