@codedazur/react-date-picker
Advanced tools
| > @codedazur/react-date-picker@0.0.2 audit | ||
| > npm audit --omit dev | ||
| found 0 vulnerabilities |
+141
| import { Day, Locale } from 'date-fns'; | ||
| import { MouseEventHandler } from 'react'; | ||
| interface DayData { | ||
| date: Date; | ||
| label: string; | ||
| day: Day; | ||
| isDisabled: boolean; | ||
| isSelected: boolean; | ||
| isFirstDate: boolean; | ||
| isLastDate: boolean; | ||
| isInActiveMonth: boolean; | ||
| isInSelectedRange: boolean; | ||
| isInFocusedRange: boolean; | ||
| onClick: MouseEventHandler; | ||
| onMouseEnter: MouseEventHandler; | ||
| onMouseLeave: MouseEventHandler; | ||
| } | ||
| interface WeekdayData { | ||
| label: string; | ||
| } | ||
| interface MonthData { | ||
| year: number; | ||
| month: number; | ||
| label: string; | ||
| weekdays: Array<WeekdayData>; | ||
| days: Array<DayData | null>; | ||
| } | ||
| interface UseDatePickerProps extends UseDatePickerFlags { | ||
| count?: number; | ||
| initialDates?: Array<Date | null>; | ||
| initialCursor?: number; | ||
| initialMonth?: Date; | ||
| weekStartsOn?: Day; | ||
| minDate?: Date; | ||
| maxDate?: Date; | ||
| minDuration?: number; | ||
| maxDuration?: number; | ||
| isDateDisabled?: (date: Date, cursor: number, dates: Array<Date | null>) => boolean; | ||
| locale?: Locale | null; | ||
| dayLabelFormat?: string | ((date: Date) => string); | ||
| weekdayLabelFormat?: string | ((date: Date) => string); | ||
| monthLabelFormat?: string | ((date: Date) => string); | ||
| } | ||
| interface UseDatePickerFlags { | ||
| /** | ||
| * This flag causes `setDate` to ignore calls for dates that are currently | ||
| * disabled. | ||
| * | ||
| * @default false | ||
| */ | ||
| ignoreDisabledDates?: boolean; | ||
| /** | ||
| * This flag will include the days from the previous and next months in the | ||
| * current month. When not enabled, the month's `days` property will be | ||
| * padded with blank entries instead. | ||
| * | ||
| * @default false | ||
| */ | ||
| showExternalDays?: boolean; | ||
| /** | ||
| * This flag automatically switches the active month to the month of the | ||
| * clicked date when the clicked date changes the starting date. | ||
| * | ||
| * @default false | ||
| */ | ||
| autoProgressMonth?: boolean; | ||
| /** | ||
| * When clicking a date, this side-effect automatically increments the cursor | ||
| * position so that the next date can immediately be selected. If you want | ||
| * to control the cursor position manually, you can use the `setCursor` | ||
| * function to do so and optionally disable this flag as well. | ||
| * | ||
| * @default true | ||
| */ | ||
| autoProgressCursor?: boolean; | ||
| /** | ||
| * This side-effect makes sure that the selected dates are always in | ||
| * chronological order by moving previously selected dates along with a newly | ||
| * selected date. | ||
| * | ||
| * @default true | ||
| */ | ||
| enforceChronologicalOrder?: boolean; | ||
| /** | ||
| * When a date is selected, this side-effect determines what should happen to | ||
| * any selected dates that come after it. | ||
| * | ||
| * @enum {clear} Removes any subsequent selected dates. | ||
| * @enum {shift} Moves subsequent dates along with the selected date. | ||
| * @enum {keep} Leaves any subsequent dates where they are. Keep in mind that | ||
| * the `enforceChronologicalOrder` flag may still affect any subsequent dates. | ||
| * | ||
| * @default clear | ||
| */ | ||
| subsequentDates?: "clear" | "shift" | "keep"; | ||
| } | ||
| interface UseDatePickerResult { | ||
| dates: Array<Date | null>; | ||
| setDate: (index: number, date: Date | null) => void; | ||
| clear: () => void; | ||
| cursor: number; | ||
| setCursor: (index: number) => void; | ||
| isSelectedDate: (date: Date) => boolean; | ||
| isFirstDate: (date: Date) => boolean; | ||
| isLastDate: (date: Date) => boolean; | ||
| isDateDisabled: (date: Date) => boolean; | ||
| month: MonthData; | ||
| /** | ||
| * Returns a {@link MonthData} to be used for rendering more than one month. | ||
| * | ||
| * @param offset The number of months to offset the current `month` by. For | ||
| * example, to get the previous month, use `getMonth(-1)`. | ||
| */ | ||
| getMonth: (offset: number) => MonthData; | ||
| toDate: (date: Date) => void; | ||
| toMonth: (month: number) => void; | ||
| toYear: (year: number) => void; | ||
| moveMonth: (offset: number) => void; | ||
| moveYear: (offset: number) => void; | ||
| toPreviousMonth: () => void; | ||
| toNextMonth: () => void; | ||
| toPreviousYear: () => void; | ||
| toNextYear: () => void; | ||
| } | ||
| declare const useDatePicker: ({ count, initialDates, initialCursor, initialMonth, weekStartsOn, minDate, maxDate, minDuration, maxDuration, isDateDisabled: isDateDisabledByUser, dayLabelFormat, weekdayLabelFormat, monthLabelFormat, locale, ignoreDisabledDates, showExternalDays, autoProgressMonth, autoProgressCursor, enforceChronologicalOrder, subsequentDates, }?: UseDatePickerProps) => UseDatePickerResult; | ||
| interface UseSingleDatePickerProps extends Omit<UseDatePickerProps, "count" | "initialDates" | "minDuration" | "maxDuration" | "isDateDisabled" | "autoProgressCursor" | "enforceChronologicalOrder" | "subsequentDates"> { | ||
| initialDate?: Date; | ||
| isDateDisabled?: (date: Date, selectedDate: Date | null) => boolean; | ||
| } | ||
| interface UseSingleDatePickerResult extends Omit<UseDatePickerResult, "dates" | "setDate" | "cursor" | "setCursor" | "isFirstDate" | "isLastDate"> { | ||
| date: Date | null; | ||
| setDate: (date: Date | null) => void; | ||
| } | ||
| declare const useSingleDatePicker: ({ initialDate, isDateDisabled, ...props }?: UseSingleDatePickerProps) => UseSingleDatePickerResult; | ||
| export { type UseDatePickerProps, type UseDatePickerResult, type UseSingleDatePickerProps, type UseSingleDatePickerResult, useDatePicker, useSingleDatePicker }; |
| > @codedazur/react-date-picker@0.0.1 build | ||
| > @codedazur/react-date-picker@0.0.2 build | ||
| > tsup index.ts --format esm,cjs --dts | ||
@@ -7,12 +7,13 @@ | ||
| CLI Using tsconfig: tsconfig.json | ||
| CLI tsup v6.5.0 | ||
| CLI tsup v8.1.0 | ||
| CLI Target: es6 | ||
| ESM Build start | ||
| CJS Build start | ||
| CJS dist/index.js 16.00 KB | ||
| CJS ⚡️ Build success in 29ms | ||
| ESM dist/index.mjs 13.94 KB | ||
| ESM ⚡️ Build success in 30ms | ||
| ESM dist/index.mjs 13.98 KB | ||
| ESM ⚡️ Build success in 99ms | ||
| CJS dist/index.js 16.03 KB | ||
| CJS ⚡️ Build success in 105ms | ||
| DTS Build start | ||
| DTS ⚡️ Build success in 3002ms | ||
| DTS dist/index.d.ts 5.21 KB | ||
| DTS ⚡️ Build success in 7866ms | ||
| DTS dist/index.d.mts 5.23 KB | ||
| DTS dist/index.d.ts 5.23 KB |
+14
-13
| > @codedazur/react-date-picker@0.0.1 lint | ||
| > @codedazur/react-date-picker@0.0.2 lint | ||
| > TIMING=1 eslint "**/*.ts*" | ||
| Rule | Time (ms) | Relative | ||
| :------------------------------|----------:|--------: | ||
| react/display-name | 73.572 | 55.4% | ||
| turbo/no-undeclared-env-vars | 14.881 | 11.2% | ||
| react/no-direct-mutation-state | 10.608 | 8.0% | ||
| react/no-children-prop | 7.768 | 5.8% | ||
| react/require-render-return | 7.006 | 5.3% | ||
| react-hooks/exhaustive-deps | 6.748 | 5.1% | ||
| react-hooks/rules-of-hooks | 4.719 | 3.6% | ||
| react/jsx-no-comment-textnodes | 1.536 | 1.2% | ||
| @next/next/no-typos | 1.428 | 1.1% | ||
| react/no-deprecated | 1.118 | 0.8% | ||
| Pages directory cannot be found at . If using a custom path, please configure with the `no-html-link-for-pages` rule in your eslint config file. | ||
| Rule | Time (ms) | Relative | ||
| :---------------------------------|----------:|--------: | ||
| react/display-name | 124.360 | 22.6% | ||
| @typescript-eslint/no-unused-vars | 110.125 | 20.0% | ||
| react/no-direct-mutation-state | 52.978 | 9.6% | ||
| react-hooks/exhaustive-deps | 50.460 | 9.2% | ||
| @next/next/no-html-link-for-pages | 44.837 | 8.2% | ||
| no-fallthrough | 39.485 | 7.2% | ||
| react/no-unescaped-entities | 22.263 | 4.0% | ||
| prefer-const | 20.470 | 3.7% | ||
| react/require-render-return | 18.359 | 3.3% | ||
| no-empty-pattern | 15.166 | 2.8% |
| > @codedazur/react-date-picker@0.0.1 test | ||
| > echo "No tests configured." | ||
| > @codedazur/react-date-picker@0.0.2 test | ||
| > vitest run --passWithNoTests | ||
| No tests configured. | ||
| [7m[1m[36m RUN [39m[22m[27m [36mv1.6.0[39m [90m/home/runner/work/toolkit/toolkit/packages/react-date-picker[39m | ||
| [2minclude: [22m[33m**/*.{test,spec}.?(c|m)[jt]s?(x)[39m | ||
| [2mexclude: [22m[33m**/node_modules/**[2m, [22m**/dist/**[2m, [22m**/cypress/**[2m, [22m**/.{idea,git,cache,output,temp}/**[2m, [22m**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*[39m | ||
| [2mwatch exclude: [22m[33m**/node_modules/**[2m, [22m**/dist/**[39m | ||
| No test files found, exiting with code 0 | ||
+9
-0
| # @codedazur/react-date-picker | ||
| ## 0.0.2 | ||
| ### Patch Changes | ||
| - [`17034ee`](https://github.com/codedazur/toolkit/commit/17034ee5fcbc026fc779a12130572d515d2b8298) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Dependency versions were made explicit. | ||
| - Updated dependencies [[`17034ee`](https://github.com/codedazur/toolkit/commit/17034ee5fcbc026fc779a12130572d515d2b8298)]: | ||
| - @codedazur/essentials@1.9.1 | ||
| ## 0.0.1 | ||
@@ -4,0 +13,0 @@ |
+3
-3
@@ -1,2 +0,2 @@ | ||
| import { Day as Day$1 } from 'date-fns'; | ||
| import { Day, Locale } from 'date-fns'; | ||
| import { MouseEventHandler } from 'react'; | ||
@@ -7,3 +7,3 @@ | ||
| label: string; | ||
| day: Day$1; | ||
| day: Day; | ||
| isDisabled: boolean; | ||
@@ -142,2 +142,2 @@ isSelected: boolean; | ||
| export { UseDatePickerProps, UseDatePickerResult, UseSingleDatePickerProps, UseSingleDatePickerResult, useDatePicker, useSingleDatePicker }; | ||
| export { type UseDatePickerProps, type UseDatePickerResult, type UseSingleDatePickerProps, type UseSingleDatePickerResult, useDatePicker, useSingleDatePicker }; |
+2
-2
@@ -133,3 +133,3 @@ "use strict"; | ||
| }) { | ||
| const now = new Date(); | ||
| const now = /* @__PURE__ */ new Date(); | ||
| const weekdayLabelFormat = typeof weekdayLabelFormatInput === "string" ? getFormattingFn(weekdayLabelFormatInput, locale) : weekdayLabelFormatInput; | ||
@@ -226,3 +226,3 @@ return (0, import_date_fns4.eachDayOfInterval)({ | ||
| const [month, setMonth] = (0, import_react.useState)( | ||
| (0, import_date_fns6.startOfMonth)((_a = initialMonth != null ? initialMonth : initialDates == null ? void 0 : initialDates[0]) != null ? _a : new Date()) | ||
| (0, import_date_fns6.startOfMonth)((_a = initialMonth != null ? initialMonth : initialDates == null ? void 0 : initialDates[0]) != null ? _a : /* @__PURE__ */ new Date()) | ||
| ); | ||
@@ -229,0 +229,0 @@ const [focusedDate, setFocusedDate] = (0, import_react.useState)(null); |
+8
-3
@@ -124,3 +124,8 @@ var __defProp = Object.defineProperty; | ||
| // utilities/getWeekdaysData.ts | ||
| import { addDays as addDays2, eachDayOfInterval as eachDayOfInterval2, endOfWeek, startOfWeek } from "date-fns"; | ||
| import { | ||
| addDays as addDays2, | ||
| eachDayOfInterval as eachDayOfInterval2, | ||
| endOfWeek, | ||
| startOfWeek | ||
| } from "date-fns"; | ||
| function getWeekdaysData({ | ||
@@ -131,3 +136,3 @@ weekStartsOn, | ||
| }) { | ||
| const now = new Date(); | ||
| const now = /* @__PURE__ */ new Date(); | ||
| const weekdayLabelFormat = typeof weekdayLabelFormatInput === "string" ? getFormattingFn(weekdayLabelFormatInput, locale) : weekdayLabelFormatInput; | ||
@@ -224,3 +229,3 @@ return eachDayOfInterval2({ | ||
| const [month, setMonth] = useState( | ||
| startOfMonth3((_a = initialMonth != null ? initialMonth : initialDates == null ? void 0 : initialDates[0]) != null ? _a : new Date()) | ||
| startOfMonth3((_a = initialMonth != null ? initialMonth : initialDates == null ? void 0 : initialDates[0]) != null ? _a : /* @__PURE__ */ new Date()) | ||
| ); | ||
@@ -227,0 +232,0 @@ const [focusedDate, setFocusedDate] = useState(null); |
+24
-20
| import { clamp } from "@codedazur/essentials"; | ||
| import { | ||
| Day, | ||
| Locale, | ||
| addDays, | ||
@@ -17,3 +19,3 @@ addMonths, | ||
| import { useCallback, useEffect, useMemo, useState } from "react"; | ||
| import { getMonthData, MonthData } from "../utilities/getMonthData"; | ||
| import { MonthData, getMonthData } from "../utilities/getMonthData"; | ||
| import { isInRange } from "../utilities/isInRange"; | ||
@@ -34,3 +36,3 @@ | ||
| cursor: number, | ||
| dates: Array<Date | null> | ||
| dates: Array<Date | null>, | ||
| ) => boolean; | ||
@@ -179,7 +181,9 @@ locale?: Locale | null; | ||
| const [dates, setDates] = useState<Array<Date | null>>( | ||
| new Array(count).fill(null).map((_, index) => initialDates?.[index] ?? null) | ||
| new Array(count) | ||
| .fill(null) | ||
| .map((_, index) => initialDates?.[index] ?? null), | ||
| ); | ||
| const [cursor, setCursor] = useState<number>(initialCursor); | ||
| const [month, setMonth] = useState( | ||
| startOfMonth(initialMonth ?? initialDates?.[0] ?? new Date()) | ||
| startOfMonth(initialMonth ?? initialDates?.[0] ?? new Date()), | ||
| ); | ||
@@ -191,3 +195,3 @@ const [focusedDate, setFocusedDate] = useState<Date | null>(null); | ||
| setDates((dates) => | ||
| new Array(count).fill(null).map((_, index) => dates?.[index] ?? null) | ||
| new Array(count).fill(null).map((_, index) => dates?.[index] ?? null), | ||
| ); | ||
@@ -226,3 +230,3 @@ }, [count]); | ||
| cursor, | ||
| ] | ||
| ], | ||
| ); | ||
@@ -235,3 +239,3 @@ | ||
| }, | ||
| [dates] | ||
| [dates], | ||
| ); | ||
@@ -244,3 +248,3 @@ | ||
| }, | ||
| [dates] | ||
| [dates], | ||
| ); | ||
@@ -253,3 +257,3 @@ | ||
| .includes(true), | ||
| [dates] | ||
| [dates], | ||
| ); | ||
@@ -273,3 +277,3 @@ | ||
| }, | ||
| [dates] | ||
| [dates], | ||
| ); | ||
@@ -290,3 +294,3 @@ | ||
| }, | ||
| [dates, focusedDate] | ||
| [dates, focusedDate], | ||
| ); | ||
@@ -364,3 +368,3 @@ | ||
| isDateDisabled, | ||
| ] | ||
| ], | ||
| ); | ||
@@ -372,7 +376,7 @@ | ||
| setMonth((month) => startOfMonth(setMonthDateFns(month, index))), | ||
| [] | ||
| [], | ||
| ); | ||
| const toYear = useCallback( | ||
| (index: number) => setMonth((month) => startOfMonth(setYear(month, index))), | ||
| [] | ||
| [], | ||
| ); | ||
@@ -383,7 +387,7 @@ | ||
| setMonth((month) => startOfMonth(addMonths(month, offset))), | ||
| [] | ||
| [], | ||
| ); | ||
| const moveYear = useCallback( | ||
| (offset: number) => moveMonth(offset * 12), | ||
| [moveMonth] | ||
| [moveMonth], | ||
| ); | ||
@@ -398,3 +402,3 @@ | ||
| () => setDates((dates) => new Array(dates.length).fill(null) as null[]), | ||
| [] | ||
| [], | ||
| ); | ||
@@ -406,3 +410,3 @@ | ||
| }, | ||
| [setDate, cursor] | ||
| [setDate, cursor], | ||
| ); | ||
@@ -416,3 +420,3 @@ | ||
| }, | ||
| [dates, cursor] | ||
| [dates, cursor], | ||
| ); | ||
@@ -464,3 +468,3 @@ | ||
| locale, | ||
| ] | ||
| ], | ||
| ); | ||
@@ -467,0 +471,0 @@ |
+21
-16
| { | ||
| "name": "@codedazur/react-date-picker", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "main": ".dist/index.js", | ||
@@ -13,25 +13,30 @@ "module": "./dist/index.mjs", | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "license": "MIT", | ||
| "scripts": { | ||
| "develop": "tsup index.ts --format esm,cjs --dts --watch --external react", | ||
| "build": "tsup index.ts --format esm,cjs --dts", | ||
| "audit": "npm audit --omit dev", | ||
| "lint": "TIMING=1 eslint \"**/*.ts*\"", | ||
| "test": "echo \"No tests configured.\"", | ||
| "release": "echo \"No releases configured.\"", | ||
| "build": "tsup index.ts --format esm,cjs --dts" | ||
| "types": "tsc --noEmit", | ||
| "test": "vitest run --passWithNoTests" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": ">=16.8.0", | ||
| "react-dom": ">=16.8.0" | ||
| }, | ||
| "dependencies": { | ||
| "@codedazur/essentials": "*", | ||
| "date-fns": "^2.29.3" | ||
| "@codedazur/essentials": "^1.9.1", | ||
| "date-fns": "^2.30.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": ">=16.8.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^18.0.24", | ||
| "@types/react-dom": "^18.0.8", | ||
| "eslint": "^8.26.0", | ||
| "eslint-config-custom": "*", | ||
| "react": "^18.2.0", | ||
| "tsconfig": "*", | ||
| "typescript": "^4.8.4" | ||
| "@testing-library/dom": "10.2.0", | ||
| "@testing-library/react": "alpha", | ||
| "@types/react-dom": "^18.3.0", | ||
| "@types/react": "^18.3.3", | ||
| "react-dom": "^18.3.1", | ||
| "react": "^18.3.1" | ||
| } | ||
| } |
+1
-3
| { | ||
| "extends": "tsconfig/react-library.json", | ||
| "include": ["."], | ||
| "exclude": ["dist", "build", "node_modules"] | ||
| "extends": "@codedazur/tsconfig/react-library.json" | ||
| } |
| import { | ||
| Day, | ||
| Locale, | ||
| addDays, | ||
| addMonths, | ||
| Day, | ||
| eachDayOfInterval, | ||
@@ -70,3 +71,3 @@ endOfMonth, | ||
| startOfThisMonth, | ||
| -getDaysInPreviousMonth(startOfThisMonth, weekStartsOn) | ||
| -getDaysInPreviousMonth(startOfThisMonth, weekStartsOn), | ||
| ); | ||
@@ -76,3 +77,3 @@ | ||
| endOfThisMonth, | ||
| 7 - getDaysInPreviousMonth(startOfNextMonth, weekStartsOn) | ||
| 7 - getDaysInPreviousMonth(startOfNextMonth, weekStartsOn), | ||
| ); | ||
@@ -102,4 +103,4 @@ | ||
| } | ||
| : null | ||
| : null, | ||
| ); | ||
| } |
@@ -5,3 +5,3 @@ import { getDay, startOfMonth } from "date-fns"; | ||
| month: Date, | ||
| weekStartsOn: number | ||
| weekStartsOn: number, | ||
| ): number { | ||
@@ -8,0 +8,0 @@ const firstDayOfMonth = getDay(startOfMonth(month)); |
@@ -1,6 +0,6 @@ | ||
| import { format } from "date-fns"; | ||
| import { format, Locale } from "date-fns"; | ||
| export function getFormattingFn( | ||
| outputFormat: string, | ||
| locale?: Locale | null | ||
| locale?: Locale | null, | ||
| ): (date: Date) => string { | ||
@@ -7,0 +7,0 @@ return locale |
@@ -1,5 +0,5 @@ | ||
| import { Day } from "date-fns"; | ||
| import { Day, Locale } from "date-fns"; | ||
| import { DayData, getDaysData } from "./getDaysData"; | ||
| import { getFormattingFn } from "./getFormattingFn"; | ||
| import { getWeekdaysData, WeekdayData } from "./getWeekdaysData"; | ||
| import { WeekdayData, getWeekdaysData } from "./getWeekdaysData"; | ||
@@ -6,0 +6,0 @@ interface GetMonthDataProps { |
@@ -1,2 +0,9 @@ | ||
| import { addDays, eachDayOfInterval, endOfWeek, startOfWeek } from "date-fns"; | ||
| import { | ||
| Day, | ||
| Locale, | ||
| addDays, | ||
| eachDayOfInterval, | ||
| endOfWeek, | ||
| startOfWeek, | ||
| } from "date-fns"; | ||
| import { getFormattingFn } from "./getFormattingFn"; | ||
@@ -3,0 +10,0 @@ |
@@ -6,3 +6,3 @@ import { isAfter, isBefore } from "date-fns"; | ||
| start?: Date | null, | ||
| end?: Date | null | ||
| end?: Date | null, | ||
| ): boolean { | ||
@@ -9,0 +9,0 @@ const isBeforeMinDate = start && isBefore(date, start); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
66389
11.59%6
-14.29%22
10%1830
0.83%2
-33.33%1
-50%4
33.33%1
Infinity%+ Added
+ Added
Updated
Updated