[READ-ONLY] Mirror of https://github.com/probablykasper/date-picker-svelte. Date and time picker for Svelte date-picker-svelte.kasper.space
calendar date date-picker date-time-picker datepicker package svelte time
0

Configure Feed

Select the types of activity you want to include in your feed.

Add date-fns 3 support

Kasper (May 23, 2024, 1:37 AM +0200) e3324d34 9b49671a

+18 -50
+1
CHANGELOG.md
··· 2 2 3 3 ## Next 4 4 - Add MMM format to allow short month names (@peterbell215) 5 + - Add date-fns 3 support 5 6 6 7 ## 2.12.0 - 2024 Apr 9 7 8 - Disable autocomplete for date input (@gianarb)
+6 -32
package-lock.json
··· 16 16 "@typescript-eslint/eslint-plugin": "^7.10.0", 17 17 "@typescript-eslint/parser": "^7.10.0", 18 18 "@vitest/coverage-v8": "^1.6.0", 19 - "date-fns": "^2.30.0", 19 + "date-fns": "^3.6.0", 20 20 "eslint": "^8.57.0", 21 21 "eslint-config-prettier": "^9.1.0", 22 22 "eslint-plugin-svelte": "^2.39.0", ··· 79 79 }, 80 80 "engines": { 81 81 "node": ">=6.0.0" 82 - } 83 - }, 84 - "node_modules/@babel/runtime": { 85 - "version": "7.24.5", 86 - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.5.tgz", 87 - "integrity": "sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==", 88 - "dev": true, 89 - "license": "MIT", 90 - "dependencies": { 91 - "regenerator-runtime": "^0.14.0" 92 - }, 93 - "engines": { 94 - "node": ">=6.9.0" 95 82 } 96 83 }, 97 84 "node_modules/@babel/types": { ··· 1854 1841 } 1855 1842 }, 1856 1843 "node_modules/date-fns": { 1857 - "version": "2.30.0", 1858 - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", 1859 - "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", 1844 + "version": "3.6.0", 1845 + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz", 1846 + "integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==", 1860 1847 "dev": true, 1861 1848 "license": "MIT", 1862 - "dependencies": { 1863 - "@babel/runtime": "^7.21.0" 1864 - }, 1865 - "engines": { 1866 - "node": ">=0.11" 1867 - }, 1868 1849 "funding": { 1869 - "type": "opencollective", 1870 - "url": "https://opencollective.com/date-fns" 1850 + "type": "github", 1851 + "url": "https://github.com/sponsors/kossnocorp" 1871 1852 } 1872 1853 }, 1873 1854 "node_modules/debug": { ··· 3740 3721 "engines": { 3741 3722 "node": ">=8.10.0" 3742 3723 } 3743 - }, 3744 - "node_modules/regenerator-runtime": { 3745 - "version": "0.14.1", 3746 - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", 3747 - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", 3748 - "dev": true, 3749 - "license": "MIT" 3750 3724 }, 3751 3725 "node_modules/resolve-from": { 3752 3726 "version": "4.0.0",
+1 -1
package.json
··· 23 23 "@typescript-eslint/eslint-plugin": "^7.10.0", 24 24 "@typescript-eslint/parser": "^7.10.0", 25 25 "@vitest/coverage-v8": "^1.6.0", 26 - "date-fns": "^2.30.0", 26 + "date-fns": "^3.6.0", 27 27 "eslint": "^8.57.0", 28 28 "eslint-config-prettier": "^9.1.0", 29 29 "eslint-plugin-svelte": "^2.39.0",
+8 -5
src/lib/locale.ts
··· 55 55 return innerLocale 56 56 } 57 57 58 + type Month = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 59 + type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6 60 + type LocaleWidth = 'short' | 'wide' | 'abbreviated' | 'narrow' | 'any' 58 61 type DateFnsLocale = { 59 62 options?: { 60 63 weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6 61 64 } 62 65 localize?: { 63 - month: (n: number, options?: { width?: string }) => string 64 - day: (i: number, options?: { width?: string }) => string 66 + month: (n: Month, options?: { width?: LocaleWidth }) => string 67 + day: (i: Day, options?: { width?: LocaleWidth }) => string 65 68 } 66 69 } 67 70 /** Create a Locale from a date-fns locale */ ··· 73 76 if (dateFnsLocale.localize) { 74 77 for (let i = 0; i < 7; i++) { 75 78 // widths: narrow, short, abbreviated, wide, any 76 - locale.weekdays[i] = dateFnsLocale.localize.day(i, { width: 'short' }) 79 + locale.weekdays[i] = dateFnsLocale.localize.day(i as Day, { width: 'short' }) 77 80 } 78 81 79 82 for (let i = 0; i < 12; i++) { 80 - locale.months[i] = dateFnsLocale.localize.month(i, { width: 'wide' }) 81 - locale.shortMonths[i] = dateFnsLocale.localize.month(i, { width: 'abbreviated' }) 83 + locale.months[i] = dateFnsLocale.localize.month(i as Month, { width: 'wide' }) 84 + locale.shortMonths[i] = dateFnsLocale.localize.month(i as Month, { width: 'abbreviated' }) 82 85 } 83 86 } 84 87 return locale
+1 -6
src/routes/DateInput.svelte
··· 3 3 import Prop from './prop.svelte' 4 4 import Split from './split.svelte' 5 5 import { localeFromDateFnsLocale } from '$lib' 6 - 7 - // had to import it this way to avoid errors 8 - // in `npm run build:site` or `npm run check`: 9 - import hy from 'date-fns/locale/hy/index' 10 - import de from 'date-fns/locale/de/index' 11 - import nb from 'date-fns/locale/nb/index' 6 + import { hy, de, nb } from 'date-fns/locale' 12 7 13 8 let id: string 14 9 let placeholder: string
+1 -6
src/routes/DatePicker.svelte
··· 3 3 import { localeFromDateFnsLocale } from '$lib/locale.js' 4 4 import Prop from './prop.svelte' 5 5 import Split from './split.svelte' 6 - 7 - // had to import it this way to avoid errors 8 - // in `npm run build:site` or `npm run check`: 9 - import hy from 'date-fns/locale/hy/index' 10 - import de from 'date-fns/locale/de/index' 11 - import nb from 'date-fns/locale/nb/index' 6 + import { hy, de, nb } from 'date-fns/locale' 12 7 13 8 let value: Date 14 9 let min: Date