Skip to content

Commit 9efce42

Browse files
committed
fix: restrict date input to 4-digit years
1 parent 982eb8e commit 9efce42

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

app/components/Package/TrendsChart.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useCssVariables } from '~/composables/useColors'
66
import { OKLCH_NEUTRAL_FALLBACK, transparentizeOklch } from '~/utils/colors'
77
import { getFrameworkColor, isListedFramework } from '~/utils/frameworks'
88
import { drawNpmxLogoAndTaglineWatermark } from '~/composables/useChartWatermark'
9+
import { DATE_INPUT_MAX } from '~/utils/input'
910
1011
const props = defineProps<{
1112
// For single package downloads history
@@ -1468,6 +1469,7 @@ watch(selectedMetric, value => {
14681469
id="startDate"
14691470
v-model="startDate"
14701471
type="date"
1472+
:max="DATE_INPUT_MAX"
14711473
class="w-full min-w-0 bg-transparent ps-7"
14721474
size="medium"
14731475
/>
@@ -1487,6 +1489,7 @@ watch(selectedMetric, value => {
14871489
id="endDate"
14881490
v-model="endDate"
14891491
type="date"
1492+
:max="DATE_INPUT_MAX"
14901493
class="w-full min-w-0 bg-transparent ps-7"
14911494
size="medium"
14921495
/>

app/utils/input.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ export function isKeyWithoutModifiers(event: KeyboardEvent, key: string): boolea
2626
!event.shiftKey
2727
)
2828
}
29+
30+
export const DATE_INPUT_MAX = '9999-12-31'

0 commit comments

Comments
 (0)