Skip to content

Commit

Permalink
chore: bump react to the v19 (#75)
Browse files Browse the repository at this point in the history
* chore: bump react to the v19

* fix: make e2e more robust
  • Loading branch information
Feshchenko authored Dec 6, 2024
1 parent 76986c2 commit a23eebc
Show file tree
Hide file tree
Showing 4 changed files with 1,184 additions and 1,133 deletions.
26 changes: 13 additions & 13 deletions packages/datepicker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rehookify/datepicker",
"version": "6.6.7",
"version": "6.6.8",
"description": "The ultimate tool to create a date, range and time picker in your React applications.",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.mjs",
Expand Down Expand Up @@ -60,24 +60,24 @@
},
"homepage": "https://github.com/rehookify/datepicker#readme",
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@babel/preset-typescript": "^7.24.7",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@testing-library/react": "^16.0.1",
"@types/react": "^18.3.5",
"jsdom": "^25.0.0",
"react": "^18.3.1",
"@testing-library/react": "^16.1.0",
"@types/react": "^19.0.0",
"jsdom": "^25.0.1",
"react": "^19.0.0",
"rimraf": "^6.0.1",
"rollup": "^4.21.2",
"rollup": "^4.28.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-typescript2": "^0.36.0",
"vitest": "^2.0.5"
"vitest": "^2.1.8"
},
"peerDependencies": {
"react": "^16.8.0 || ^17 || ^18"
"react": "^16.8.0 || ^17 || ^18 || ^19"
},
"publishConfig": {
"access": "public"
Expand Down
16 changes: 6 additions & 10 deletions packages/datepicker/src/use-date-picker-state.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import { Reducer, useReducer } from 'react';
import { useReducer } from 'react';

import { stateReducer } from './state-reducer';
import type {
DPReducerAction,
DPReducerState,
DPState,
DPUserConfig,
} from './types';
import type { DPState, DPUserConfig } from './types';
import { createConfig } from './utils/config';
import { createInitialState } from './utils/create-initial-state';

export const useDatePickerState = (config: DPUserConfig): DPState => {
const dpConfig = createConfig(config);

const [state, dispatch] = useReducer<
Reducer<DPReducerState, DPReducerAction>
>(stateReducer, createInitialState(dpConfig));
const [state, dispatch] = useReducer(
stateReducer,
createInitialState(dpConfig),
);

return {
dispatch,
Expand Down
23 changes: 11 additions & 12 deletions packages/examples-e2e/test/min-max-date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ test('month and years availability with min and max date', async ({ page }) => {

const NOW = new Date();
const Y = NOW.getFullYear();
const M = NOW.getMonth();
const currentMonthName = NOW.toLocaleDateString('en-us', { month: 'long' });

const nextMonth = new Date(Y, M + 1, 1);
const nextMonthName = nextMonth.toLocaleDateString('en-us', {
month: 'long',
});

// Previous year should be enabled since we are defining minDate as new Date(Y - 1, 0, 1)
await expect(page.getByRole('button', { name: `${Y - 1}` })).toBeEnabled();

Expand All @@ -24,11 +18,16 @@ test('month and years availability with min and max date', async ({ page }) => {
page.getByRole('button', { name: currentMonthName }),
).toBeEnabled();

// Next month should be disabled since we are defining maxDate as new Date()
await expect(
page.getByRole('button', { name: nextMonthName }),
).toBeDisabled();
const nextMonthButton = page.getByRole('button', {
name: /next month button/i,
});
const previousMonthButton = page.getByRole('button', {
name: /previous month button/i,
});

await expect(nextMonthButton).toBeDisabled();
await expect(previousMonthButton).toBeEnabled();

await page.getByRole('button', { name: `${Y - 1}` }).click();
await expect(page.getByRole('button', { name: /january/i })).toBeEnabled();
await previousMonthButton.click();
await expect(nextMonthButton).toBeEnabled();
});
Loading

0 comments on commit a23eebc

Please sign in to comment.