@react-fabric/lexical 1.0.0-beta.60 → 1.0.0-beta.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/_lexical.css +61 -0
- package/dist/cjs/node_modules/date-fns/_lib/addLeadingZeros.js +9 -0
- package/dist/cjs/node_modules/date-fns/_lib/defaultOptions.js +9 -0
- package/dist/cjs/node_modules/date-fns/_lib/format/formatters.js +779 -0
- package/dist/cjs/node_modules/date-fns/_lib/format/lightFormatters.js +96 -0
- package/dist/cjs/node_modules/date-fns/_lib/format/longFormatters.js +68 -0
- package/dist/cjs/node_modules/date-fns/_lib/getRoundingMethod.js +12 -0
- package/dist/cjs/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +33 -0
- package/dist/cjs/node_modules/date-fns/_lib/normalizeDates.js +13 -0
- package/dist/cjs/node_modules/date-fns/_lib/normalizeInterval.js +10 -0
- package/dist/cjs/node_modules/date-fns/_lib/protectedTokens.js +29 -0
- package/dist/cjs/node_modules/date-fns/add.js +73 -0
- package/dist/cjs/node_modules/date-fns/addDays.js +46 -0
- package/dist/cjs/node_modules/date-fns/addHours.js +39 -0
- package/dist/cjs/node_modules/date-fns/addMilliseconds.js +39 -0
- package/dist/cjs/node_modules/date-fns/addMinutes.js +41 -0
- package/dist/cjs/node_modules/date-fns/addMonths.js +80 -0
- package/dist/cjs/node_modules/date-fns/addQuarters.js +38 -0
- package/dist/cjs/node_modules/date-fns/addWeeks.js +38 -0
- package/dist/cjs/node_modules/date-fns/addYears.js +38 -0
- package/dist/cjs/node_modules/date-fns/compareAsc.js +50 -0
- package/dist/cjs/node_modules/date-fns/constants.js +66 -0
- package/dist/cjs/node_modules/date-fns/constructFrom.js +54 -0
- package/dist/cjs/node_modules/date-fns/differenceInCalendarDays.js +67 -0
- package/dist/cjs/node_modules/date-fns/differenceInCalendarMonths.js +47 -0
- package/dist/cjs/node_modules/date-fns/differenceInCalendarYears.js +43 -0
- package/dist/cjs/node_modules/date-fns/differenceInDays.js +112 -0
- package/dist/cjs/node_modules/date-fns/differenceInHours.js +46 -0
- package/dist/cjs/node_modules/date-fns/differenceInMilliseconds.js +34 -0
- package/dist/cjs/node_modules/date-fns/differenceInMinutes.js +50 -0
- package/dist/cjs/node_modules/date-fns/differenceInMonths.js +65 -0
- package/dist/cjs/node_modules/date-fns/differenceInSeconds.js +41 -0
- package/dist/cjs/node_modules/date-fns/differenceInYears.js +67 -0
- package/dist/cjs/node_modules/date-fns/endOfDay.js +40 -0
- package/dist/cjs/node_modules/date-fns/endOfDecade.js +45 -0
- package/dist/cjs/node_modules/date-fns/endOfHour.js +40 -0
- package/dist/cjs/node_modules/date-fns/endOfMinute.js +40 -0
- package/dist/cjs/node_modules/date-fns/endOfMonth.js +42 -0
- package/dist/cjs/node_modules/date-fns/endOfQuarter.js +43 -0
- package/dist/cjs/node_modules/date-fns/endOfWeek.js +58 -0
- package/dist/cjs/node_modules/date-fns/endOfYear.js +42 -0
- package/dist/cjs/node_modules/date-fns/format.js +431 -0
- package/dist/cjs/node_modules/date-fns/getDayOfYear.js +39 -0
- package/dist/cjs/node_modules/date-fns/getISOWeek.js +45 -0
- package/dist/cjs/node_modules/date-fns/getISOWeekYear.js +57 -0
- package/dist/cjs/node_modules/date-fns/getWeek.js +59 -0
- package/dist/cjs/node_modules/date-fns/getWeekYear.js +80 -0
- package/dist/cjs/node_modules/date-fns/intervalToDuration.js +70 -0
- package/dist/cjs/node_modules/date-fns/isAfter.js +30 -0
- package/dist/cjs/node_modules/date-fns/isBefore.js +30 -0
- package/dist/cjs/node_modules/date-fns/isDate.js +46 -0
- package/dist/cjs/node_modules/date-fns/isLastDayOfMonth.js +33 -0
- package/dist/cjs/node_modules/date-fns/isSameMonth.js +48 -0
- package/dist/cjs/node_modules/date-fns/isSameWeek.js +56 -0
- package/dist/cjs/node_modules/date-fns/isSameYear.js +40 -0
- package/dist/cjs/node_modules/date-fns/isValid.js +44 -0
- package/dist/cjs/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +12 -0
- package/dist/cjs/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +66 -0
- package/dist/cjs/node_modules/date-fns/locale/_lib/buildMatchFn.js +61 -0
- package/dist/cjs/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +24 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/formatDistance.js +139 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/localize.js +166 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA/_lib/match.js +146 -0
- package/dist/cjs/node_modules/date-fns/locale/ar-SA.js +32 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/formatDistance.js +200 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/formatLong.js +44 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/localize.js +195 -0
- package/dist/cjs/node_modules/date-fns/locale/de/_lib/match.js +138 -0
- package/dist/cjs/node_modules/date-fns/locale/de.js +36 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/localize.js +191 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US/_lib/match.js +136 -0
- package/dist/cjs/node_modules/date-fns/locale/en-US.js +33 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/formatRelative.js +29 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/localize.js +168 -0
- package/dist/cjs/node_modules/date-fns/locale/es/_lib/match.js +142 -0
- package/dist/cjs/node_modules/date-fns/locale/es.js +36 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/formatDistance.js +104 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/localize.js +169 -0
- package/dist/cjs/node_modules/date-fns/locale/fr/_lib/match.js +137 -0
- package/dist/cjs/node_modules/date-fns/locale/fr.js +33 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/formatDistance.js +109 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/localize.js +233 -0
- package/dist/cjs/node_modules/date-fns/locale/hi/_lib/match.js +141 -0
- package/dist/cjs/node_modules/date-fns/locale/hi.js +32 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/formatRelative.js +70 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/localize.js +168 -0
- package/dist/cjs/node_modules/date-fns/locale/it/_lib/match.js +137 -0
- package/dist/cjs/node_modules/date-fns/locale/it.js +34 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/formatDistance.js +119 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/formatRelative.js +16 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/localize.js +181 -0
- package/dist/cjs/node_modules/date-fns/locale/ja/_lib/match.js +122 -0
- package/dist/cjs/node_modules/date-fns/locale/ja.js +36 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/formatRelative.js +15 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/localize.js +171 -0
- package/dist/cjs/node_modules/date-fns/locale/ko/_lib/match.js +119 -0
- package/dist/cjs/node_modules/date-fns/locale/ko.js +34 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/formatRelative.js +26 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/localize.js +168 -0
- package/dist/cjs/node_modules/date-fns/locale/pt/_lib/match.js +141 -0
- package/dist/cjs/node_modules/date-fns/locale/pt.js +33 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/formatDistance.js +250 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/formatLong.js +40 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/formatRelative.js +92 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/localize.js +214 -0
- package/dist/cjs/node_modules/date-fns/locale/ru/_lib/match.js +142 -0
- package/dist/cjs/node_modules/date-fns/locale/ru.js +33 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/formatDistance.js +105 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/formatLong.js +43 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/formatRelative.js +35 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/localize.js +187 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN/_lib/match.js +134 -0
- package/dist/cjs/node_modules/date-fns/locale/zh-CN.js +36 -0
- package/dist/cjs/node_modules/date-fns/startOfDay.js +40 -0
- package/dist/cjs/node_modules/date-fns/startOfDecade.js +45 -0
- package/dist/cjs/node_modules/date-fns/startOfHour.js +40 -0
- package/dist/cjs/node_modules/date-fns/startOfISOWeek.js +40 -0
- package/dist/cjs/node_modules/date-fns/startOfISOWeekYear.js +47 -0
- package/dist/cjs/node_modules/date-fns/startOfMinute.js +40 -0
- package/dist/cjs/node_modules/date-fns/startOfMonth.js +42 -0
- package/dist/cjs/node_modules/date-fns/startOfQuarter.js +43 -0
- package/dist/cjs/node_modules/date-fns/startOfWeek.js +58 -0
- package/dist/cjs/node_modules/date-fns/startOfWeekYear.js +69 -0
- package/dist/cjs/node_modules/date-fns/startOfYear.js +41 -0
- package/dist/cjs/node_modules/date-fns/toDate.js +51 -0
- package/dist/cjs/packages/date/dist/esm/display/DateDuration.js +178 -0
- package/dist/cjs/packages/date/dist/esm/hijri/DateConverter.js +154 -0
- package/dist/cjs/packages/date/dist/esm/hijri/FormatDate.js +116 -0
- package/dist/cjs/packages/date/dist/esm/hijri/HijriDate.js +531 -0
- package/dist/cjs/packages/date/dist/esm/hijri/StringDateParser.js +74 -0
- package/dist/cjs/packages/date/dist/esm/hijri/index.js +21 -0
- package/dist/cjs/packages/date/dist/esm/hijri/initializer.js +113 -0
- package/dist/cjs/packages/date/dist/esm/hijri/locales.js +19 -0
- package/dist/cjs/packages/date/dist/esm/hijri/safe.js +17 -0
- package/dist/cjs/packages/date/dist/esm/i18n/ar/date.json.js +213 -0
- package/dist/cjs/packages/date/dist/esm/i18n/en/date.json.js +83 -0
- package/{src/plugins/StickyPlugin.ts → dist/cjs/packages/date/dist/esm/i18n/index.js} +10 -15
- package/dist/cjs/packages/date/dist/esm/types/index.js +46 -0
- package/dist/cjs/packages/date/dist/esm/utils/dateUtil.js +472 -0
- package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +36 -13
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +101 -95
- package/dist/cjs/packages/lexical/src/i18n/ar/lexical.json.js +30 -0
- package/dist/cjs/packages/lexical/src/i18n/en/lexical.json.js +30 -0
- package/dist/cjs/packages/lexical/src/i18n/index.js +33 -0
- package/dist/cjs/packages/lexical/src/index.js +1 -0
- package/dist/cjs/packages/lexical/src/plugins/CommentPlugin.js +477 -0
- package/dist/cjs/packages/lexical/src/plugins/DraggableBlockPlugin.js +13 -16
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +35 -22
- package/dist/esm/node_modules/date-fns/_lib/addLeadingZeros.js +9 -0
- package/dist/esm/node_modules/date-fns/_lib/defaultOptions.js +9 -0
- package/dist/esm/node_modules/date-fns/_lib/format/formatters.js +779 -0
- package/dist/esm/node_modules/date-fns/_lib/format/lightFormatters.js +96 -0
- package/dist/esm/node_modules/date-fns/_lib/format/longFormatters.js +68 -0
- package/dist/esm/node_modules/date-fns/_lib/getRoundingMethod.js +12 -0
- package/dist/esm/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +33 -0
- package/dist/esm/node_modules/date-fns/_lib/normalizeDates.js +13 -0
- package/dist/esm/node_modules/date-fns/_lib/normalizeInterval.js +10 -0
- package/dist/esm/node_modules/date-fns/_lib/protectedTokens.js +27 -0
- package/dist/esm/node_modules/date-fns/add.js +70 -0
- package/dist/esm/node_modules/date-fns/addDays.js +43 -0
- package/dist/esm/node_modules/date-fns/addHours.js +36 -0
- package/dist/esm/node_modules/date-fns/addMilliseconds.js +36 -0
- package/dist/esm/node_modules/date-fns/addMinutes.js +38 -0
- package/dist/esm/node_modules/date-fns/addMonths.js +77 -0
- package/dist/esm/node_modules/date-fns/addQuarters.js +35 -0
- package/dist/esm/node_modules/date-fns/addWeeks.js +35 -0
- package/dist/esm/node_modules/date-fns/addYears.js +35 -0
- package/dist/esm/node_modules/date-fns/compareAsc.js +47 -0
- package/dist/esm/node_modules/date-fns/constants.js +62 -0
- package/dist/esm/node_modules/date-fns/constructFrom.js +51 -0
- package/dist/esm/node_modules/date-fns/differenceInCalendarDays.js +64 -0
- package/dist/esm/node_modules/date-fns/differenceInCalendarMonths.js +44 -0
- package/dist/esm/node_modules/date-fns/differenceInCalendarYears.js +40 -0
- package/dist/esm/node_modules/date-fns/differenceInDays.js +109 -0
- package/dist/esm/node_modules/date-fns/differenceInHours.js +43 -0
- package/dist/esm/node_modules/date-fns/differenceInMilliseconds.js +31 -0
- package/dist/esm/node_modules/date-fns/differenceInMinutes.js +47 -0
- package/dist/esm/node_modules/date-fns/differenceInMonths.js +62 -0
- package/dist/esm/node_modules/date-fns/differenceInSeconds.js +38 -0
- package/dist/esm/node_modules/date-fns/differenceInYears.js +64 -0
- package/dist/esm/node_modules/date-fns/endOfDay.js +37 -0
- package/dist/esm/node_modules/date-fns/endOfDecade.js +42 -0
- package/dist/esm/node_modules/date-fns/endOfHour.js +37 -0
- package/dist/esm/node_modules/date-fns/endOfMinute.js +37 -0
- package/dist/esm/node_modules/date-fns/endOfMonth.js +39 -0
- package/dist/esm/node_modules/date-fns/endOfQuarter.js +40 -0
- package/dist/esm/node_modules/date-fns/endOfWeek.js +55 -0
- package/dist/esm/node_modules/date-fns/endOfYear.js +39 -0
- package/dist/esm/node_modules/date-fns/format.js +425 -0
- package/dist/esm/node_modules/date-fns/getDayOfYear.js +36 -0
- package/dist/esm/node_modules/date-fns/getISOWeek.js +42 -0
- package/dist/esm/node_modules/date-fns/getISOWeekYear.js +54 -0
- package/dist/esm/node_modules/date-fns/getWeek.js +56 -0
- package/dist/esm/node_modules/date-fns/getWeekYear.js +77 -0
- package/dist/esm/node_modules/date-fns/intervalToDuration.js +67 -0
- package/dist/esm/node_modules/date-fns/isAfter.js +27 -0
- package/dist/esm/node_modules/date-fns/isBefore.js +27 -0
- package/dist/esm/node_modules/date-fns/isDate.js +43 -0
- package/dist/esm/node_modules/date-fns/isLastDayOfMonth.js +30 -0
- package/dist/esm/node_modules/date-fns/isSameMonth.js +45 -0
- package/dist/esm/node_modules/date-fns/isSameWeek.js +53 -0
- package/dist/esm/node_modules/date-fns/isSameYear.js +37 -0
- package/dist/esm/node_modules/date-fns/isValid.js +41 -0
- package/dist/esm/node_modules/date-fns/locale/_lib/buildFormatLongFn.js +12 -0
- package/dist/esm/node_modules/date-fns/locale/_lib/buildLocalizeFn.js +66 -0
- package/dist/esm/node_modules/date-fns/locale/_lib/buildMatchFn.js +61 -0
- package/dist/esm/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js +24 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/formatDistance.js +139 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/localize.js +166 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA/_lib/match.js +146 -0
- package/dist/esm/node_modules/date-fns/locale/ar-SA.js +29 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/formatDistance.js +200 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/formatLong.js +44 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/localize.js +195 -0
- package/dist/esm/node_modules/date-fns/locale/de/_lib/match.js +138 -0
- package/dist/esm/node_modules/date-fns/locale/de.js +33 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/localize.js +191 -0
- package/dist/esm/node_modules/date-fns/locale/en-US/_lib/match.js +136 -0
- package/dist/esm/node_modules/date-fns/locale/en-US.js +30 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/formatRelative.js +29 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/localize.js +168 -0
- package/dist/esm/node_modules/date-fns/locale/es/_lib/match.js +142 -0
- package/dist/esm/node_modules/date-fns/locale/es.js +33 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/formatDistance.js +104 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/localize.js +169 -0
- package/dist/esm/node_modules/date-fns/locale/fr/_lib/match.js +137 -0
- package/dist/esm/node_modules/date-fns/locale/fr.js +30 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/formatDistance.js +109 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/localize.js +231 -0
- package/dist/esm/node_modules/date-fns/locale/hi/_lib/match.js +141 -0
- package/dist/esm/node_modules/date-fns/locale/hi.js +29 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/formatRelative.js +70 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/localize.js +168 -0
- package/dist/esm/node_modules/date-fns/locale/it/_lib/match.js +137 -0
- package/dist/esm/node_modules/date-fns/locale/it.js +31 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/formatDistance.js +119 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/formatRelative.js +16 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/localize.js +181 -0
- package/dist/esm/node_modules/date-fns/locale/ja/_lib/match.js +122 -0
- package/dist/esm/node_modules/date-fns/locale/ja.js +33 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/formatRelative.js +15 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/localize.js +171 -0
- package/dist/esm/node_modules/date-fns/locale/ko/_lib/match.js +119 -0
- package/dist/esm/node_modules/date-fns/locale/ko.js +31 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/formatRelative.js +26 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/localize.js +168 -0
- package/dist/esm/node_modules/date-fns/locale/pt/_lib/match.js +141 -0
- package/dist/esm/node_modules/date-fns/locale/pt.js +30 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/formatDistance.js +250 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/formatLong.js +40 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/formatRelative.js +92 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/localize.js +214 -0
- package/dist/esm/node_modules/date-fns/locale/ru/_lib/match.js +142 -0
- package/dist/esm/node_modules/date-fns/locale/ru.js +30 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/formatDistance.js +105 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/formatLong.js +43 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/formatRelative.js +35 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/localize.js +187 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN/_lib/match.js +134 -0
- package/dist/esm/node_modules/date-fns/locale/zh-CN.js +33 -0
- package/dist/esm/node_modules/date-fns/startOfDay.js +37 -0
- package/dist/esm/node_modules/date-fns/startOfDecade.js +42 -0
- package/dist/esm/node_modules/date-fns/startOfHour.js +37 -0
- package/dist/esm/node_modules/date-fns/startOfISOWeek.js +37 -0
- package/dist/esm/node_modules/date-fns/startOfISOWeekYear.js +44 -0
- package/dist/esm/node_modules/date-fns/startOfMinute.js +37 -0
- package/dist/esm/node_modules/date-fns/startOfMonth.js +39 -0
- package/dist/esm/node_modules/date-fns/startOfQuarter.js +40 -0
- package/dist/esm/node_modules/date-fns/startOfWeek.js +55 -0
- package/dist/esm/node_modules/date-fns/startOfWeekYear.js +66 -0
- package/dist/esm/node_modules/date-fns/startOfYear.js +38 -0
- package/dist/esm/node_modules/date-fns/toDate.js +48 -0
- package/dist/esm/packages/date/dist/esm/display/DateDuration.js +178 -0
- package/dist/esm/packages/date/dist/esm/hijri/DateConverter.js +152 -0
- package/dist/esm/packages/date/dist/esm/hijri/FormatDate.js +113 -0
- package/dist/esm/packages/date/dist/esm/hijri/HijriDate.js +528 -0
- package/dist/esm/packages/date/dist/esm/hijri/StringDateParser.js +74 -0
- package/dist/esm/packages/date/dist/esm/hijri/index.js +21 -0
- package/dist/esm/packages/date/dist/esm/hijri/initializer.js +113 -0
- package/dist/esm/packages/date/dist/esm/hijri/locales.js +18 -0
- package/dist/esm/packages/date/dist/esm/hijri/safe.js +14 -0
- package/dist/esm/packages/date/dist/esm/i18n/ar/date.json.js +209 -0
- package/dist/esm/packages/date/dist/esm/i18n/en/date.json.js +79 -0
- package/dist/esm/packages/date/dist/esm/i18n/index.js +33 -0
- package/dist/esm/packages/date/dist/esm/types/index.js +45 -0
- package/dist/esm/packages/date/dist/esm/utils/dateUtil.js +474 -0
- package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +37 -14
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +43 -37
- package/dist/esm/packages/lexical/src/i18n/ar/lexical.json.js +25 -0
- package/dist/esm/packages/lexical/src/i18n/en/lexical.json.js +25 -0
- package/dist/esm/packages/lexical/src/i18n/index.js +33 -0
- package/dist/esm/packages/lexical/src/index.js +1 -0
- package/dist/esm/packages/lexical/src/plugins/CommentPlugin.js +477 -0
- package/dist/esm/packages/lexical/src/plugins/DraggableBlockPlugin.js +11 -14
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +36 -23
- package/dist/types/editor/LexicalEditor.d.ts +12 -3
- package/dist/types/hooks/useFormatWatcher.d.ts +2 -1
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugins/CommentPlugin.d.ts +5 -0
- package/dist/types/plugins/DraggableBlockPlugin.d.ts +2 -1
- package/package.json +5 -5
- package/src/editor/LexicalEditor.tsx +65 -18
- package/src/hooks/useFormatWatcher.ts +3 -0
- package/src/i18n/ar/lexical.json +18 -0
- package/src/i18n/en/lexical.json +18 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +2 -0
- package/src/plugins/CommentPlugin.tsx +554 -0
- package/src/plugins/DraggableBlockPlugin.tsx +5 -10
- package/src/plugins/ToolbarPlugin.tsx +34 -23
- package/dist/cjs/_virtual/prism.js +0 -5
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -474
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1537
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -57
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -252
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -572
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -25
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1614
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -36
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -838
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -1057
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -39
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -45
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -4207
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -68
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -1166
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -47
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -81
- package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +0 -218
- package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/esm/_virtual/prism.js +0 -5
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -465
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1512
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -251
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -563
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1595
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -830
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -1028
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -28
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -4156
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -1102
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -32
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
- package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
- package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/esm/node_modules/prismjs/prism.js +0 -1951
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/esm/packages/lexical/src/nodes/StickyNode.js +0 -216
- package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/types/components/StickyComponent.d.ts +0 -9
- package/dist/types/nodes/StickyNode.d.ts +0 -34
- package/dist/types/plugins/StickyPlugin.d.ts +0 -1
- package/src/components/StickyComponent.tsx +0 -271
- package/src/nodes/StickyNode.tsx +0 -249
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { addLeadingZeros } from '../addLeadingZeros.js';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* | | Unit | | Unit |
|
|
7
|
+
* |-----|--------------------------------|-----|--------------------------------|
|
|
8
|
+
* | a | AM, PM | A* | |
|
|
9
|
+
* | d | Day of month | D | |
|
|
10
|
+
* | h | Hour [1-12] | H | Hour [0-23] |
|
|
11
|
+
* | m | Minute | M | Month |
|
|
12
|
+
* | s | Second | S | Fraction of second |
|
|
13
|
+
* | y | Year (abs) | Y | |
|
|
14
|
+
*
|
|
15
|
+
* Letters marked by * are not implemented but reserved by Unicode standard.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const lightFormatters = {
|
|
19
|
+
// Year
|
|
20
|
+
y(date, token) {
|
|
21
|
+
// From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
|
|
22
|
+
// | Year | y | yy | yyy | yyyy | yyyyy |
|
|
23
|
+
// |----------|-------|----|-------|-------|-------|
|
|
24
|
+
// | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
|
|
25
|
+
// | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
|
|
26
|
+
// | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
|
|
27
|
+
// | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
|
|
28
|
+
// | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
|
|
29
|
+
|
|
30
|
+
const signedYear = date.getFullYear();
|
|
31
|
+
// Returns 1 for 1 BC (which is year 0 in JavaScript)
|
|
32
|
+
const year = signedYear > 0 ? signedYear : 1 - signedYear;
|
|
33
|
+
return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// Month
|
|
37
|
+
M(date, token) {
|
|
38
|
+
const month = date.getMonth();
|
|
39
|
+
return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// Day of the month
|
|
43
|
+
d(date, token) {
|
|
44
|
+
return addLeadingZeros(date.getDate(), token.length);
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// AM or PM
|
|
48
|
+
a(date, token) {
|
|
49
|
+
const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
|
|
50
|
+
|
|
51
|
+
switch (token) {
|
|
52
|
+
case "a":
|
|
53
|
+
case "aa":
|
|
54
|
+
return dayPeriodEnumValue.toUpperCase();
|
|
55
|
+
case "aaa":
|
|
56
|
+
return dayPeriodEnumValue;
|
|
57
|
+
case "aaaaa":
|
|
58
|
+
return dayPeriodEnumValue[0];
|
|
59
|
+
case "aaaa":
|
|
60
|
+
default:
|
|
61
|
+
return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
// Hour [1-12]
|
|
66
|
+
h(date, token) {
|
|
67
|
+
return addLeadingZeros(date.getHours() % 12 || 12, token.length);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
// Hour [0-23]
|
|
71
|
+
H(date, token) {
|
|
72
|
+
return addLeadingZeros(date.getHours(), token.length);
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// Minute
|
|
76
|
+
m(date, token) {
|
|
77
|
+
return addLeadingZeros(date.getMinutes(), token.length);
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// Second
|
|
81
|
+
s(date, token) {
|
|
82
|
+
return addLeadingZeros(date.getSeconds(), token.length);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
// Fraction of second
|
|
86
|
+
S(date, token) {
|
|
87
|
+
const numberOfDigits = token.length;
|
|
88
|
+
const milliseconds = date.getMilliseconds();
|
|
89
|
+
const fractionalSeconds = Math.trunc(
|
|
90
|
+
milliseconds * Math.pow(10, numberOfDigits - 3),
|
|
91
|
+
);
|
|
92
|
+
return addLeadingZeros(fractionalSeconds, token.length);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export { lightFormatters };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
const dateLongFormatter = (pattern, formatLong) => {
|
|
4
|
+
switch (pattern) {
|
|
5
|
+
case "P":
|
|
6
|
+
return formatLong.date({ width: "short" });
|
|
7
|
+
case "PP":
|
|
8
|
+
return formatLong.date({ width: "medium" });
|
|
9
|
+
case "PPP":
|
|
10
|
+
return formatLong.date({ width: "long" });
|
|
11
|
+
case "PPPP":
|
|
12
|
+
default:
|
|
13
|
+
return formatLong.date({ width: "full" });
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const timeLongFormatter = (pattern, formatLong) => {
|
|
18
|
+
switch (pattern) {
|
|
19
|
+
case "p":
|
|
20
|
+
return formatLong.time({ width: "short" });
|
|
21
|
+
case "pp":
|
|
22
|
+
return formatLong.time({ width: "medium" });
|
|
23
|
+
case "ppp":
|
|
24
|
+
return formatLong.time({ width: "long" });
|
|
25
|
+
case "pppp":
|
|
26
|
+
default:
|
|
27
|
+
return formatLong.time({ width: "full" });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const dateTimeLongFormatter = (pattern, formatLong) => {
|
|
32
|
+
const matchResult = pattern.match(/(P+)(p+)?/) || [];
|
|
33
|
+
const datePattern = matchResult[1];
|
|
34
|
+
const timePattern = matchResult[2];
|
|
35
|
+
|
|
36
|
+
if (!timePattern) {
|
|
37
|
+
return dateLongFormatter(pattern, formatLong);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let dateTimeFormat;
|
|
41
|
+
|
|
42
|
+
switch (datePattern) {
|
|
43
|
+
case "P":
|
|
44
|
+
dateTimeFormat = formatLong.dateTime({ width: "short" });
|
|
45
|
+
break;
|
|
46
|
+
case "PP":
|
|
47
|
+
dateTimeFormat = formatLong.dateTime({ width: "medium" });
|
|
48
|
+
break;
|
|
49
|
+
case "PPP":
|
|
50
|
+
dateTimeFormat = formatLong.dateTime({ width: "long" });
|
|
51
|
+
break;
|
|
52
|
+
case "PPPP":
|
|
53
|
+
default:
|
|
54
|
+
dateTimeFormat = formatLong.dateTime({ width: "full" });
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return dateTimeFormat
|
|
59
|
+
.replace("{{date}}", dateLongFormatter(datePattern, formatLong))
|
|
60
|
+
.replace("{{time}}", timeLongFormatter(timePattern, formatLong));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const longFormatters = {
|
|
64
|
+
p: timeLongFormatter,
|
|
65
|
+
P: dateTimeLongFormatter,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { longFormatters };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function getRoundingMethod(method) {
|
|
4
|
+
return (number) => {
|
|
5
|
+
const round = method ? Math[method] : Math.trunc;
|
|
6
|
+
const result = round(number);
|
|
7
|
+
// Prevent negative zero
|
|
8
|
+
return result === 0 ? 0 : result;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { getRoundingMethod };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { toDate } from '../toDate.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
|
|
7
|
+
* They usually appear for dates that denote time before the timezones were introduced
|
|
8
|
+
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
|
|
9
|
+
* and GMT+01:00:00 after that date)
|
|
10
|
+
*
|
|
11
|
+
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
|
|
12
|
+
* which would lead to incorrect calculations.
|
|
13
|
+
*
|
|
14
|
+
* This function returns the timezone offset in milliseconds that takes seconds in account.
|
|
15
|
+
*/
|
|
16
|
+
function getTimezoneOffsetInMilliseconds(date) {
|
|
17
|
+
const _date = toDate(date);
|
|
18
|
+
const utcDate = new Date(
|
|
19
|
+
Date.UTC(
|
|
20
|
+
_date.getFullYear(),
|
|
21
|
+
_date.getMonth(),
|
|
22
|
+
_date.getDate(),
|
|
23
|
+
_date.getHours(),
|
|
24
|
+
_date.getMinutes(),
|
|
25
|
+
_date.getSeconds(),
|
|
26
|
+
_date.getMilliseconds(),
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
utcDate.setUTCFullYear(_date.getFullYear());
|
|
30
|
+
return +date - +utcDate;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { getTimezoneOffsetInMilliseconds };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { constructFrom } from '../constructFrom.js';
|
|
4
|
+
|
|
5
|
+
function normalizeDates(context, ...dates) {
|
|
6
|
+
const normalize = constructFrom.bind(
|
|
7
|
+
null,
|
|
8
|
+
context || dates.find((date) => typeof date === "object"),
|
|
9
|
+
);
|
|
10
|
+
return dates.map(normalize);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { normalizeDates };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { normalizeDates } from './normalizeDates.js';
|
|
4
|
+
|
|
5
|
+
function normalizeInterval(context, interval) {
|
|
6
|
+
const [start, end] = normalizeDates(context, interval.start, interval.end);
|
|
7
|
+
return { start, end };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { normalizeInterval };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
const dayOfYearTokenRE = /^D+$/;
|
|
4
|
+
const weekYearTokenRE = /^Y+$/;
|
|
5
|
+
|
|
6
|
+
const throwTokens = ["D", "DD", "YY", "YYYY"];
|
|
7
|
+
|
|
8
|
+
function isProtectedDayOfYearToken(token) {
|
|
9
|
+
return dayOfYearTokenRE.test(token);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isProtectedWeekYearToken(token) {
|
|
13
|
+
return weekYearTokenRE.test(token);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function warnOrThrowProtectedError(token, format, input) {
|
|
17
|
+
const _message = message(token, format, input);
|
|
18
|
+
console.warn(_message);
|
|
19
|
+
if (throwTokens.includes(token)) throw new RangeError(_message);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function message(token, format, input) {
|
|
23
|
+
const subject = token[0] === "Y" ? "years" : "days of the month";
|
|
24
|
+
return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { isProtectedDayOfYearToken, isProtectedWeekYearToken, warnOrThrowProtectedError };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { addDays } from './addDays.js';
|
|
4
|
+
import { addMonths } from './addMonths.js';
|
|
5
|
+
import { constructFrom } from './constructFrom.js';
|
|
6
|
+
import { toDate } from './toDate.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The {@link add} function options.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @name add
|
|
14
|
+
* @category Common Helpers
|
|
15
|
+
* @summary Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
|
|
16
|
+
*
|
|
17
|
+
* @description
|
|
18
|
+
* Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
|
|
19
|
+
*
|
|
20
|
+
* @typeParam DateType - The `Date` type the function operates on. Gets inferred from passed arguments. Allows using extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
21
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
22
|
+
*
|
|
23
|
+
* @param date - The date to be changed
|
|
24
|
+
* @param duration - The object with years, months, weeks, days, hours, minutes, and seconds to be added.
|
|
25
|
+
* @param options - An object with options
|
|
26
|
+
*
|
|
27
|
+
* @returns The new date with the seconds added
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Add the following duration to 1 September 2014, 10:19:50
|
|
31
|
+
* const result = add(new Date(2014, 8, 1, 10, 19, 50), {
|
|
32
|
+
* years: 2,
|
|
33
|
+
* months: 9,
|
|
34
|
+
* weeks: 1,
|
|
35
|
+
* days: 7,
|
|
36
|
+
* hours: 5,
|
|
37
|
+
* minutes: 9,
|
|
38
|
+
* seconds: 30,
|
|
39
|
+
* })
|
|
40
|
+
* //=> Thu Jun 15 2017 15:29:20
|
|
41
|
+
*/
|
|
42
|
+
function add(date, duration, options) {
|
|
43
|
+
const {
|
|
44
|
+
years = 0,
|
|
45
|
+
months = 0,
|
|
46
|
+
weeks = 0,
|
|
47
|
+
days = 0,
|
|
48
|
+
hours = 0,
|
|
49
|
+
minutes = 0,
|
|
50
|
+
seconds = 0,
|
|
51
|
+
} = duration;
|
|
52
|
+
|
|
53
|
+
// Add years and months
|
|
54
|
+
const _date = toDate(date, options?.in);
|
|
55
|
+
const dateWithMonths =
|
|
56
|
+
months || years ? addMonths(_date, months + years * 12) : _date;
|
|
57
|
+
|
|
58
|
+
// Add weeks and days
|
|
59
|
+
const dateWithDays =
|
|
60
|
+
days || weeks ? addDays(dateWithMonths, days + weeks * 7) : dateWithMonths;
|
|
61
|
+
|
|
62
|
+
// Add days, hours, minutes, and seconds
|
|
63
|
+
const minutesToAdd = minutes + hours * 60;
|
|
64
|
+
const secondsToAdd = seconds + minutesToAdd * 60;
|
|
65
|
+
const msToAdd = secondsToAdd * 1000;
|
|
66
|
+
|
|
67
|
+
return constructFrom(options?.in || date, +dateWithDays + msToAdd);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { add, add as default };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { constructFrom } from './constructFrom.js';
|
|
4
|
+
import { toDate } from './toDate.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The {@link addDays} function options.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @name addDays
|
|
12
|
+
* @category Day Helpers
|
|
13
|
+
* @summary Add the specified number of days to the given date.
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Add the specified number of days to the given date.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
19
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
20
|
+
*
|
|
21
|
+
* @param date - The date to be changed
|
|
22
|
+
* @param amount - The amount of days to be added.
|
|
23
|
+
* @param options - An object with options
|
|
24
|
+
*
|
|
25
|
+
* @returns The new date with the days added
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Add 10 days to 1 September 2014:
|
|
29
|
+
* const result = addDays(new Date(2014, 8, 1), 10)
|
|
30
|
+
* //=> Thu Sep 11 2014 00:00:00
|
|
31
|
+
*/
|
|
32
|
+
function addDays(date, amount, options) {
|
|
33
|
+
const _date = toDate(date, options?.in);
|
|
34
|
+
if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
|
|
35
|
+
|
|
36
|
+
// If 0 days, no-op to avoid changing times in the hour before end of DST
|
|
37
|
+
if (!amount) return _date;
|
|
38
|
+
|
|
39
|
+
_date.setDate(_date.getDate() + amount);
|
|
40
|
+
return _date;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { addDays, addDays as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { addMilliseconds } from './addMilliseconds.js';
|
|
4
|
+
import { millisecondsInHour } from './constants.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The {@link addHours} function options.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @name addHours
|
|
12
|
+
* @category Hour Helpers
|
|
13
|
+
* @summary Add the specified number of hours to the given date.
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Add the specified number of hours to the given date.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
19
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
20
|
+
*
|
|
21
|
+
* @param date - The date to be changed
|
|
22
|
+
* @param amount - The amount of hours to be added
|
|
23
|
+
* @param options - An object with options
|
|
24
|
+
*
|
|
25
|
+
* @returns The new date with the hours added
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Add 2 hours to 10 July 2014 23:00:00:
|
|
29
|
+
* const result = addHours(new Date(2014, 6, 10, 23, 0), 2)
|
|
30
|
+
* //=> Fri Jul 11 2014 01:00:00
|
|
31
|
+
*/
|
|
32
|
+
function addHours(date, amount, options) {
|
|
33
|
+
return addMilliseconds(date, amount * millisecondsInHour, options);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { addHours, addHours as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { constructFrom } from './constructFrom.js';
|
|
4
|
+
import { toDate } from './toDate.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The {@link addMilliseconds} function options.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @name addMilliseconds
|
|
12
|
+
* @category Millisecond Helpers
|
|
13
|
+
* @summary Add the specified number of milliseconds to the given date.
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Add the specified number of milliseconds to the given date.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
19
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
20
|
+
*
|
|
21
|
+
* @param date - The date to be changed
|
|
22
|
+
* @param amount - The amount of milliseconds to be added.
|
|
23
|
+
* @param options - The options object
|
|
24
|
+
*
|
|
25
|
+
* @returns The new date with the milliseconds added
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Add 750 milliseconds to 10 July 2014 12:45:30.000:
|
|
29
|
+
* const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
|
|
30
|
+
* //=> Thu Jul 10 2014 12:45:30.750
|
|
31
|
+
*/
|
|
32
|
+
function addMilliseconds(date, amount, options) {
|
|
33
|
+
return constructFrom(options?.in || date, +toDate(date) + amount);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { addMilliseconds, addMilliseconds as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { millisecondsInMinute } from './constants.js';
|
|
4
|
+
import { toDate } from './toDate.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The {@link addMinutes} function options.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @name addMinutes
|
|
12
|
+
* @category Minute Helpers
|
|
13
|
+
* @summary Add the specified number of minutes to the given date.
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Add the specified number of minutes to the given date.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
19
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
20
|
+
*
|
|
21
|
+
* @param date - The date to be changed
|
|
22
|
+
* @param amount - The amount of minutes to be added.
|
|
23
|
+
* @param options - An object with options
|
|
24
|
+
*
|
|
25
|
+
* @returns The new date with the minutes added
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Add 30 minutes to 10 July 2014 12:00:00:
|
|
29
|
+
* const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
|
|
30
|
+
* //=> Thu Jul 10 2014 12:30:00
|
|
31
|
+
*/
|
|
32
|
+
function addMinutes(date, amount, options) {
|
|
33
|
+
const _date = toDate(date, options?.in);
|
|
34
|
+
_date.setTime(_date.getTime() + amount * millisecondsInMinute);
|
|
35
|
+
return _date;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { addMinutes, addMinutes as default };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { constructFrom } from './constructFrom.js';
|
|
4
|
+
import { toDate } from './toDate.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The {@link addMonths} function options.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @name addMonths
|
|
12
|
+
* @category Month Helpers
|
|
13
|
+
* @summary Add the specified number of months to the given date.
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Add the specified number of months to the given date.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
19
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
20
|
+
*
|
|
21
|
+
* @param date - The date to be changed
|
|
22
|
+
* @param amount - The amount of months to be added.
|
|
23
|
+
* @param options - The options object
|
|
24
|
+
*
|
|
25
|
+
* @returns The new date with the months added
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Add 5 months to 1 September 2014:
|
|
29
|
+
* const result = addMonths(new Date(2014, 8, 1), 5)
|
|
30
|
+
* //=> Sun Feb 01 2015 00:00:00
|
|
31
|
+
*
|
|
32
|
+
* // Add one month to 30 January 2023:
|
|
33
|
+
* const result = addMonths(new Date(2023, 0, 30), 1)
|
|
34
|
+
* //=> Tue Feb 28 2023 00:00:00
|
|
35
|
+
*/
|
|
36
|
+
function addMonths(date, amount, options) {
|
|
37
|
+
const _date = toDate(date, options?.in);
|
|
38
|
+
if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
|
|
39
|
+
if (!amount) {
|
|
40
|
+
// If 0 months, no-op to avoid changing times in the hour before end of DST
|
|
41
|
+
return _date;
|
|
42
|
+
}
|
|
43
|
+
const dayOfMonth = _date.getDate();
|
|
44
|
+
|
|
45
|
+
// The JS Date object supports date math by accepting out-of-bounds values for
|
|
46
|
+
// month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
|
|
47
|
+
// new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
|
|
48
|
+
// want except that dates will wrap around the end of a month, meaning that
|
|
49
|
+
// new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
|
|
50
|
+
// we'll default to the end of the desired month by adding 1 to the desired
|
|
51
|
+
// month and using a date of 0 to back up one day to the end of the desired
|
|
52
|
+
// month.
|
|
53
|
+
const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
|
|
54
|
+
endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
|
|
55
|
+
const daysInMonth = endOfDesiredMonth.getDate();
|
|
56
|
+
if (dayOfMonth >= daysInMonth) {
|
|
57
|
+
// If we're already at the end of the month, then this is the correct date
|
|
58
|
+
// and we're done.
|
|
59
|
+
return endOfDesiredMonth;
|
|
60
|
+
} else {
|
|
61
|
+
// Otherwise, we now know that setting the original day-of-month value won't
|
|
62
|
+
// cause an overflow, so set the desired day-of-month. Note that we can't
|
|
63
|
+
// just set the date of `endOfDesiredMonth` because that object may have had
|
|
64
|
+
// its time changed in the unusual case where where a DST transition was on
|
|
65
|
+
// the last day of the month and its local time was in the hour skipped or
|
|
66
|
+
// repeated next to a DST transition. So we use `date` instead which is
|
|
67
|
+
// guaranteed to still have the original time.
|
|
68
|
+
_date.setFullYear(
|
|
69
|
+
endOfDesiredMonth.getFullYear(),
|
|
70
|
+
endOfDesiredMonth.getMonth(),
|
|
71
|
+
dayOfMonth,
|
|
72
|
+
);
|
|
73
|
+
return _date;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { addMonths, addMonths as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { addMonths } from './addMonths.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The {@link addQuarters} function options.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @name addQuarters
|
|
11
|
+
* @category Quarter Helpers
|
|
12
|
+
* @summary Add the specified number of year quarters to the given date.
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Add the specified number of year quarters to the given date.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
18
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
19
|
+
*
|
|
20
|
+
* @param date - The date to be changed
|
|
21
|
+
* @param amount - The amount of quarters to be added.
|
|
22
|
+
* @param options - An object with options
|
|
23
|
+
*
|
|
24
|
+
* @returns The new date with the quarters added
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Add 1 quarter to 1 September 2014:
|
|
28
|
+
* const result = addQuarters(new Date(2014, 8, 1), 1)
|
|
29
|
+
* //=; Mon Dec 01 2014 00:00:00
|
|
30
|
+
*/
|
|
31
|
+
function addQuarters(date, amount, options) {
|
|
32
|
+
return addMonths(date, amount * 3, options);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { addQuarters, addQuarters as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { addDays } from './addDays.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The {@link addWeeks} function options.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @name addWeeks
|
|
11
|
+
* @category Week Helpers
|
|
12
|
+
* @summary Add the specified number of weeks to the given date.
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Add the specified number of weeks to the given date.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
18
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
19
|
+
*
|
|
20
|
+
* @param date - The date to be changed
|
|
21
|
+
* @param amount - The amount of weeks to be added.
|
|
22
|
+
* @param options - An object with options
|
|
23
|
+
*
|
|
24
|
+
* @returns The new date with the weeks added
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Add 4 weeks to 1 September 2014:
|
|
28
|
+
* const result = addWeeks(new Date(2014, 8, 1), 4)
|
|
29
|
+
* //=> Mon Sep 29 2014 00:00:00
|
|
30
|
+
*/
|
|
31
|
+
function addWeeks(date, amount, options) {
|
|
32
|
+
return addDays(date, amount * 7, options);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { addWeeks, addWeeks as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { addMonths } from './addMonths.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The {@link addYears} function options.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @name addYears
|
|
11
|
+
* @category Year Helpers
|
|
12
|
+
* @summary Add the specified number of years to the given date.
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Add the specified number of years to the given date.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
18
|
+
* @typeParam ResultDate - The result `Date` type.
|
|
19
|
+
*
|
|
20
|
+
* @param date - The date to be changed
|
|
21
|
+
* @param amount - The amount of years to be added.
|
|
22
|
+
* @param options - The options
|
|
23
|
+
*
|
|
24
|
+
* @returns The new date with the years added
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Add 5 years to 1 September 2014:
|
|
28
|
+
* const result = addYears(new Date(2014, 8, 1), 5)
|
|
29
|
+
* //=> Sun Sep 01 2019 00:00:00
|
|
30
|
+
*/
|
|
31
|
+
function addYears(date, amount, options) {
|
|
32
|
+
return addMonths(date, amount * 12, options);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { addYears, addYears as default };
|