@cdx-ui/formatters 0.0.1-beta.132
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/README.md +108 -0
- package/lib/commonjs/dates/calendar/formatCalendarMonthYear.js +28 -0
- package/lib/commonjs/dates/calendar/formatCalendarMonthYear.js.map +1 -0
- package/lib/commonjs/dates/calendar/formatDateTimeListDateRow.js +40 -0
- package/lib/commonjs/dates/calendar/formatDateTimeListDateRow.js.map +1 -0
- package/lib/commonjs/dates/calendar/formatMonthCalendarMonth.js +28 -0
- package/lib/commonjs/dates/calendar/formatMonthCalendarMonth.js.map +1 -0
- package/lib/commonjs/dates/calendar/formatMonthCalendarYear.js +16 -0
- package/lib/commonjs/dates/calendar/formatMonthCalendarYear.js.map +1 -0
- package/lib/commonjs/dates/calendar/getCalendarWeekdayLabels.js +23 -0
- package/lib/commonjs/dates/calendar/getCalendarWeekdayLabels.js.map +1 -0
- package/lib/commonjs/dates/datetime/clampDateTimeId.js +27 -0
- package/lib/commonjs/dates/datetime/clampDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/compareDateTimeIds.js +28 -0
- package/lib/commonjs/dates/datetime/compareDateTimeIds.js.map +1 -0
- package/lib/commonjs/dates/datetime/dateTimeId.js +38 -0
- package/lib/commonjs/dates/datetime/dateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/formatDateTimeId.js +27 -0
- package/lib/commonjs/dates/datetime/formatDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListHour.js +21 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListHour.js.map +1 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListMinute.js +16 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListMinute.js.map +1 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListPeriod.js +17 -0
- package/lib/commonjs/dates/datetime/formatDateTimeListPeriod.js.map +1 -0
- package/lib/commonjs/dates/datetime/isLocaleHour12.js +30 -0
- package/lib/commonjs/dates/datetime/isLocaleHour12.js.map +1 -0
- package/lib/commonjs/dates/datetime/isValidDateTimeId.js +23 -0
- package/lib/commonjs/dates/datetime/isValidDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/nowDateTimeId.js +57 -0
- package/lib/commonjs/dates/datetime/nowDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/datetime/parseDateTimeId.js +29 -0
- package/lib/commonjs/dates/datetime/parseDateTimeId.js.map +1 -0
- package/lib/commonjs/dates/display/formatDateForDisplay.js +28 -0
- package/lib/commonjs/dates/display/formatDateForDisplay.js.map +1 -0
- package/lib/commonjs/dates/display/formatDateRangeForDisplay.js +25 -0
- package/lib/commonjs/dates/display/formatDateRangeForDisplay.js.map +1 -0
- package/lib/commonjs/dates/display/formatDateTimeForDisplay.js +34 -0
- package/lib/commonjs/dates/display/formatDateTimeForDisplay.js.map +1 -0
- package/lib/commonjs/dates/display/formatMonthForDisplay.js +33 -0
- package/lib/commonjs/dates/display/formatMonthForDisplay.js.map +1 -0
- package/lib/commonjs/dates/index.js +367 -0
- package/lib/commonjs/dates/index.js.map +1 -0
- package/lib/commonjs/dates/internal/brand.js +19 -0
- package/lib/commonjs/dates/internal/brand.js.map +1 -0
- package/lib/commonjs/dates/internal/calendarHelpers.js +22 -0
- package/lib/commonjs/dates/internal/calendarHelpers.js.map +1 -0
- package/lib/commonjs/dates/internal/clampHelpers.js +20 -0
- package/lib/commonjs/dates/internal/clampHelpers.js.map +1 -0
- package/lib/commonjs/dates/internal/dateIdToNativeDate.js +20 -0
- package/lib/commonjs/dates/internal/dateIdToNativeDate.js.map +1 -0
- package/lib/commonjs/dates/internal/intlCache.js +52 -0
- package/lib/commonjs/dates/internal/intlCache.js.map +1 -0
- package/lib/commonjs/dates/internal/intlCopy.js +72 -0
- package/lib/commonjs/dates/internal/intlCopy.js.map +1 -0
- package/lib/commonjs/dates/internal/segmentBuilders.js +98 -0
- package/lib/commonjs/dates/internal/segmentBuilders.js.map +1 -0
- package/lib/commonjs/dates/labels/dateComponentLabels.js +57 -0
- package/lib/commonjs/dates/labels/dateComponentLabels.js.map +1 -0
- package/lib/commonjs/dates/ranges/compareDateIds.js +26 -0
- package/lib/commonjs/dates/ranges/compareDateIds.js.map +1 -0
- package/lib/commonjs/dates/ranges/compareMonthIds.js +31 -0
- package/lib/commonjs/dates/ranges/compareMonthIds.js.map +1 -0
- package/lib/commonjs/dates/ranges/dateRangeAroundDay.js +25 -0
- package/lib/commonjs/dates/ranges/dateRangeAroundDay.js.map +1 -0
- package/lib/commonjs/dates/ranges/dateRangeFromLastNDays.js +28 -0
- package/lib/commonjs/dates/ranges/dateRangeFromLastNDays.js.map +1 -0
- package/lib/commonjs/dates/ranges/eachDateIdInRange.js +29 -0
- package/lib/commonjs/dates/ranges/eachDateIdInRange.js.map +1 -0
- package/lib/commonjs/dates/ranges/normalizeDateRange.js +23 -0
- package/lib/commonjs/dates/ranges/normalizeDateRange.js.map +1 -0
- package/lib/commonjs/dates/segments/applyDateSegmentChange.js +77 -0
- package/lib/commonjs/dates/segments/applyDateSegmentChange.js.map +1 -0
- package/lib/commonjs/dates/segments/formatDateSegment.js +19 -0
- package/lib/commonjs/dates/segments/formatDateSegment.js.map +1 -0
- package/lib/commonjs/dates/segments/getDateFieldSegments.js +44 -0
- package/lib/commonjs/dates/segments/getDateFieldSegments.js.map +1 -0
- package/lib/commonjs/dates/segments/getDateTimeFieldSegments.js +150 -0
- package/lib/commonjs/dates/segments/getDateTimeFieldSegments.js.map +1 -0
- package/lib/commonjs/dates/segments/getDateTimeSegmentVisibility.js +15 -0
- package/lib/commonjs/dates/segments/getDateTimeSegmentVisibility.js.map +1 -0
- package/lib/commonjs/dates/segments/getEmptyDateSegmentText.js +17 -0
- package/lib/commonjs/dates/segments/getEmptyDateSegmentText.js.map +1 -0
- package/lib/commonjs/dates/segments/parseDateSegment.js +26 -0
- package/lib/commonjs/dates/segments/parseDateSegment.js.map +1 -0
- package/lib/commonjs/dates/types.js +2 -0
- package/lib/commonjs/dates/types.js.map +1 -0
- package/lib/commonjs/dates/wire/clampDateParts.js +26 -0
- package/lib/commonjs/dates/wire/clampDateParts.js.map +1 -0
- package/lib/commonjs/dates/wire/clampMonthParts.js +23 -0
- package/lib/commonjs/dates/wire/clampMonthParts.js.map +1 -0
- package/lib/commonjs/dates/wire/dateId.js +50 -0
- package/lib/commonjs/dates/wire/dateId.js.map +1 -0
- package/lib/commonjs/dates/wire/formatDateId.js +25 -0
- package/lib/commonjs/dates/wire/formatDateId.js.map +1 -0
- package/lib/commonjs/dates/wire/formatMonthId.js +21 -0
- package/lib/commonjs/dates/wire/formatMonthId.js.map +1 -0
- package/lib/commonjs/dates/wire/isValidDateId.js +27 -0
- package/lib/commonjs/dates/wire/isValidDateId.js.map +1 -0
- package/lib/commonjs/dates/wire/isValidDateParts.js +18 -0
- package/lib/commonjs/dates/wire/isValidDateParts.js.map +1 -0
- package/lib/commonjs/dates/wire/isValidMonthId.js +27 -0
- package/lib/commonjs/dates/wire/isValidMonthId.js.map +1 -0
- package/lib/commonjs/dates/wire/isValidMonthParts.js +16 -0
- package/lib/commonjs/dates/wire/isValidMonthParts.js.map +1 -0
- package/lib/commonjs/dates/wire/monthId.js +47 -0
- package/lib/commonjs/dates/wire/monthId.js.map +1 -0
- package/lib/commonjs/dates/wire/parseDateId.js +29 -0
- package/lib/commonjs/dates/wire/parseDateId.js.map +1 -0
- package/lib/commonjs/dates/wire/parseMonthId.js +28 -0
- package/lib/commonjs/dates/wire/parseMonthId.js.map +1 -0
- package/lib/commonjs/dates/wire/toMonthId.js +22 -0
- package/lib/commonjs/dates/wire/toMonthId.js.map +1 -0
- package/lib/commonjs/dates/wire/todayDateId.js +17 -0
- package/lib/commonjs/dates/wire/todayDateId.js.map +1 -0
- package/lib/commonjs/dates/wire/todayMonthId.js +17 -0
- package/lib/commonjs/dates/wire/todayMonthId.js.map +1 -0
- package/lib/commonjs/formatNumber.js +50 -0
- package/lib/commonjs/formatNumber.js.map +1 -0
- package/lib/commonjs/index.js +326 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils.js +33 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/dates/calendar/formatCalendarMonthYear.js +24 -0
- package/lib/module/dates/calendar/formatCalendarMonthYear.js.map +1 -0
- package/lib/module/dates/calendar/formatDateTimeListDateRow.js +36 -0
- package/lib/module/dates/calendar/formatDateTimeListDateRow.js.map +1 -0
- package/lib/module/dates/calendar/formatMonthCalendarMonth.js +24 -0
- package/lib/module/dates/calendar/formatMonthCalendarMonth.js.map +1 -0
- package/lib/module/dates/calendar/formatMonthCalendarYear.js +12 -0
- package/lib/module/dates/calendar/formatMonthCalendarYear.js.map +1 -0
- package/lib/module/dates/calendar/getCalendarWeekdayLabels.js +19 -0
- package/lib/module/dates/calendar/getCalendarWeekdayLabels.js.map +1 -0
- package/lib/module/dates/datetime/clampDateTimeId.js +24 -0
- package/lib/module/dates/datetime/clampDateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/compareDateTimeIds.js +24 -0
- package/lib/module/dates/datetime/compareDateTimeIds.js.map +1 -0
- package/lib/module/dates/datetime/dateTimeId.js +35 -0
- package/lib/module/dates/datetime/dateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/formatDateTimeId.js +23 -0
- package/lib/module/dates/datetime/formatDateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/formatDateTimeListHour.js +17 -0
- package/lib/module/dates/datetime/formatDateTimeListHour.js.map +1 -0
- package/lib/module/dates/datetime/formatDateTimeListMinute.js +12 -0
- package/lib/module/dates/datetime/formatDateTimeListMinute.js.map +1 -0
- package/lib/module/dates/datetime/formatDateTimeListPeriod.js +13 -0
- package/lib/module/dates/datetime/formatDateTimeListPeriod.js.map +1 -0
- package/lib/module/dates/datetime/isLocaleHour12.js +26 -0
- package/lib/module/dates/datetime/isLocaleHour12.js.map +1 -0
- package/lib/module/dates/datetime/isValidDateTimeId.js +19 -0
- package/lib/module/dates/datetime/isValidDateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/nowDateTimeId.js +54 -0
- package/lib/module/dates/datetime/nowDateTimeId.js.map +1 -0
- package/lib/module/dates/datetime/parseDateTimeId.js +26 -0
- package/lib/module/dates/datetime/parseDateTimeId.js.map +1 -0
- package/lib/module/dates/display/formatDateForDisplay.js +24 -0
- package/lib/module/dates/display/formatDateForDisplay.js.map +1 -0
- package/lib/module/dates/display/formatDateRangeForDisplay.js +22 -0
- package/lib/module/dates/display/formatDateRangeForDisplay.js.map +1 -0
- package/lib/module/dates/display/formatDateTimeForDisplay.js +30 -0
- package/lib/module/dates/display/formatDateTimeForDisplay.js.map +1 -0
- package/lib/module/dates/display/formatMonthForDisplay.js +29 -0
- package/lib/module/dates/display/formatMonthForDisplay.js.map +1 -0
- package/lib/module/dates/index.js +59 -0
- package/lib/module/dates/index.js.map +1 -0
- package/lib/module/dates/internal/brand.js +12 -0
- package/lib/module/dates/internal/brand.js.map +1 -0
- package/lib/module/dates/internal/calendarHelpers.js +19 -0
- package/lib/module/dates/internal/calendarHelpers.js.map +1 -0
- package/lib/module/dates/internal/clampHelpers.js +14 -0
- package/lib/module/dates/internal/clampHelpers.js.map +1 -0
- package/lib/module/dates/internal/dateIdToNativeDate.js +16 -0
- package/lib/module/dates/internal/dateIdToNativeDate.js.map +1 -0
- package/lib/module/dates/internal/intlCache.js +47 -0
- package/lib/module/dates/internal/intlCache.js.map +1 -0
- package/lib/module/dates/internal/intlCopy.js +66 -0
- package/lib/module/dates/internal/intlCopy.js.map +1 -0
- package/lib/module/dates/internal/segmentBuilders.js +91 -0
- package/lib/module/dates/internal/segmentBuilders.js.map +1 -0
- package/lib/module/dates/labels/dateComponentLabels.js +50 -0
- package/lib/module/dates/labels/dateComponentLabels.js.map +1 -0
- package/lib/module/dates/ranges/compareDateIds.js +22 -0
- package/lib/module/dates/ranges/compareDateIds.js.map +1 -0
- package/lib/module/dates/ranges/compareMonthIds.js +27 -0
- package/lib/module/dates/ranges/compareMonthIds.js.map +1 -0
- package/lib/module/dates/ranges/dateRangeAroundDay.js +21 -0
- package/lib/module/dates/ranges/dateRangeAroundDay.js.map +1 -0
- package/lib/module/dates/ranges/dateRangeFromLastNDays.js +24 -0
- package/lib/module/dates/ranges/dateRangeFromLastNDays.js.map +1 -0
- package/lib/module/dates/ranges/eachDateIdInRange.js +26 -0
- package/lib/module/dates/ranges/eachDateIdInRange.js.map +1 -0
- package/lib/module/dates/ranges/normalizeDateRange.js +20 -0
- package/lib/module/dates/ranges/normalizeDateRange.js.map +1 -0
- package/lib/module/dates/segments/applyDateSegmentChange.js +73 -0
- package/lib/module/dates/segments/applyDateSegmentChange.js.map +1 -0
- package/lib/module/dates/segments/formatDateSegment.js +15 -0
- package/lib/module/dates/segments/formatDateSegment.js.map +1 -0
- package/lib/module/dates/segments/getDateFieldSegments.js +40 -0
- package/lib/module/dates/segments/getDateFieldSegments.js.map +1 -0
- package/lib/module/dates/segments/getDateTimeFieldSegments.js +147 -0
- package/lib/module/dates/segments/getDateTimeFieldSegments.js.map +1 -0
- package/lib/module/dates/segments/getDateTimeSegmentVisibility.js +11 -0
- package/lib/module/dates/segments/getDateTimeSegmentVisibility.js.map +1 -0
- package/lib/module/dates/segments/getEmptyDateSegmentText.js +13 -0
- package/lib/module/dates/segments/getEmptyDateSegmentText.js.map +1 -0
- package/lib/module/dates/segments/parseDateSegment.js +22 -0
- package/lib/module/dates/segments/parseDateSegment.js.map +1 -0
- package/lib/module/dates/types.js +2 -0
- package/lib/module/dates/types.js.map +1 -0
- package/lib/module/dates/wire/clampDateParts.js +22 -0
- package/lib/module/dates/wire/clampDateParts.js.map +1 -0
- package/lib/module/dates/wire/clampMonthParts.js +19 -0
- package/lib/module/dates/wire/clampMonthParts.js.map +1 -0
- package/lib/module/dates/wire/dateId.js +47 -0
- package/lib/module/dates/wire/dateId.js.map +1 -0
- package/lib/module/dates/wire/formatDateId.js +22 -0
- package/lib/module/dates/wire/formatDateId.js.map +1 -0
- package/lib/module/dates/wire/formatMonthId.js +17 -0
- package/lib/module/dates/wire/formatMonthId.js.map +1 -0
- package/lib/module/dates/wire/isValidDateId.js +23 -0
- package/lib/module/dates/wire/isValidDateId.js.map +1 -0
- package/lib/module/dates/wire/isValidDateParts.js +14 -0
- package/lib/module/dates/wire/isValidDateParts.js.map +1 -0
- package/lib/module/dates/wire/isValidMonthId.js +23 -0
- package/lib/module/dates/wire/isValidMonthId.js.map +1 -0
- package/lib/module/dates/wire/isValidMonthParts.js +12 -0
- package/lib/module/dates/wire/isValidMonthParts.js.map +1 -0
- package/lib/module/dates/wire/monthId.js +44 -0
- package/lib/module/dates/wire/monthId.js.map +1 -0
- package/lib/module/dates/wire/parseDateId.js +26 -0
- package/lib/module/dates/wire/parseDateId.js.map +1 -0
- package/lib/module/dates/wire/parseMonthId.js +25 -0
- package/lib/module/dates/wire/parseMonthId.js.map +1 -0
- package/lib/module/dates/wire/toMonthId.js +18 -0
- package/lib/module/dates/wire/toMonthId.js.map +1 -0
- package/lib/module/dates/wire/todayDateId.js +13 -0
- package/lib/module/dates/wire/todayDateId.js.map +1 -0
- package/lib/module/dates/wire/todayMonthId.js +13 -0
- package/lib/module/dates/wire/todayMonthId.js.map +1 -0
- package/lib/module/formatNumber.js +46 -0
- package/lib/module/formatNumber.js.map +1 -0
- package/lib/module/index.js +17 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils.js +29 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/dates/calendar/formatCalendarMonthYear.d.ts +12 -0
- package/lib/typescript/dates/calendar/formatCalendarMonthYear.d.ts.map +1 -0
- package/lib/typescript/dates/calendar/formatDateTimeListDateRow.d.ts +13 -0
- package/lib/typescript/dates/calendar/formatDateTimeListDateRow.d.ts.map +1 -0
- package/lib/typescript/dates/calendar/formatMonthCalendarMonth.d.ts +13 -0
- package/lib/typescript/dates/calendar/formatMonthCalendarMonth.d.ts.map +1 -0
- package/lib/typescript/dates/calendar/formatMonthCalendarYear.d.ts +8 -0
- package/lib/typescript/dates/calendar/formatMonthCalendarYear.d.ts.map +1 -0
- package/lib/typescript/dates/calendar/getCalendarWeekdayLabels.d.ts +12 -0
- package/lib/typescript/dates/calendar/getCalendarWeekdayLabels.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/clampDateTimeId.d.ts +16 -0
- package/lib/typescript/dates/datetime/clampDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/compareDateTimeIds.d.ts +13 -0
- package/lib/typescript/dates/datetime/compareDateTimeIds.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/dateTimeId.d.ts +18 -0
- package/lib/typescript/dates/datetime/dateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/formatDateTimeId.d.ts +12 -0
- package/lib/typescript/dates/datetime/formatDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/formatDateTimeListHour.d.ts +11 -0
- package/lib/typescript/dates/datetime/formatDateTimeListHour.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/formatDateTimeListMinute.d.ts +8 -0
- package/lib/typescript/dates/datetime/formatDateTimeListMinute.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/formatDateTimeListPeriod.d.ts +9 -0
- package/lib/typescript/dates/datetime/formatDateTimeListPeriod.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/isLocaleHour12.d.ts +12 -0
- package/lib/typescript/dates/datetime/isLocaleHour12.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/isValidDateTimeId.d.ts +9 -0
- package/lib/typescript/dates/datetime/isValidDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/nowDateTimeId.d.ts +14 -0
- package/lib/typescript/dates/datetime/nowDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/datetime/parseDateTimeId.d.ts +9 -0
- package/lib/typescript/dates/datetime/parseDateTimeId.d.ts.map +1 -0
- package/lib/typescript/dates/display/formatDateForDisplay.d.ts +13 -0
- package/lib/typescript/dates/display/formatDateForDisplay.d.ts.map +1 -0
- package/lib/typescript/dates/display/formatDateRangeForDisplay.d.ts +16 -0
- package/lib/typescript/dates/display/formatDateRangeForDisplay.d.ts.map +1 -0
- package/lib/typescript/dates/display/formatDateTimeForDisplay.d.ts +13 -0
- package/lib/typescript/dates/display/formatDateTimeForDisplay.d.ts.map +1 -0
- package/lib/typescript/dates/display/formatMonthForDisplay.d.ts +13 -0
- package/lib/typescript/dates/display/formatMonthForDisplay.d.ts.map +1 -0
- package/lib/typescript/dates/index.d.ts +58 -0
- package/lib/typescript/dates/index.d.ts.map +1 -0
- package/lib/typescript/dates/internal/brand.d.ts +11 -0
- package/lib/typescript/dates/internal/brand.d.ts.map +1 -0
- package/lib/typescript/dates/internal/calendarHelpers.d.ts +8 -0
- package/lib/typescript/dates/internal/calendarHelpers.d.ts.map +1 -0
- package/lib/typescript/dates/internal/clampHelpers.d.ts +5 -0
- package/lib/typescript/dates/internal/clampHelpers.d.ts.map +1 -0
- package/lib/typescript/dates/internal/dateIdToNativeDate.d.ts +12 -0
- package/lib/typescript/dates/internal/dateIdToNativeDate.d.ts.map +1 -0
- package/lib/typescript/dates/internal/intlCache.d.ts +12 -0
- package/lib/typescript/dates/internal/intlCache.d.ts.map +1 -0
- package/lib/typescript/dates/internal/intlCopy.d.ts +10 -0
- package/lib/typescript/dates/internal/intlCopy.d.ts.map +1 -0
- package/lib/typescript/dates/internal/segmentBuilders.d.ts +12 -0
- package/lib/typescript/dates/internal/segmentBuilders.d.ts.map +1 -0
- package/lib/typescript/dates/labels/dateComponentLabels.d.ts +31 -0
- package/lib/typescript/dates/labels/dateComponentLabels.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/compareDateIds.d.ts +10 -0
- package/lib/typescript/dates/ranges/compareDateIds.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/compareMonthIds.d.ts +10 -0
- package/lib/typescript/dates/ranges/compareMonthIds.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/dateRangeAroundDay.d.ts +14 -0
- package/lib/typescript/dates/ranges/dateRangeAroundDay.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/dateRangeFromLastNDays.d.ts +16 -0
- package/lib/typescript/dates/ranges/dateRangeFromLastNDays.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/eachDateIdInRange.d.ts +10 -0
- package/lib/typescript/dates/ranges/eachDateIdInRange.d.ts.map +1 -0
- package/lib/typescript/dates/ranges/normalizeDateRange.d.ts +15 -0
- package/lib/typescript/dates/ranges/normalizeDateRange.d.ts.map +1 -0
- package/lib/typescript/dates/segments/applyDateSegmentChange.d.ts +21 -0
- package/lib/typescript/dates/segments/applyDateSegmentChange.d.ts.map +1 -0
- package/lib/typescript/dates/segments/formatDateSegment.d.ts +13 -0
- package/lib/typescript/dates/segments/formatDateSegment.d.ts.map +1 -0
- package/lib/typescript/dates/segments/getDateFieldSegments.d.ts +13 -0
- package/lib/typescript/dates/segments/getDateFieldSegments.d.ts.map +1 -0
- package/lib/typescript/dates/segments/getDateTimeFieldSegments.d.ts +14 -0
- package/lib/typescript/dates/segments/getDateTimeFieldSegments.d.ts.map +1 -0
- package/lib/typescript/dates/segments/getDateTimeSegmentVisibility.d.ts +8 -0
- package/lib/typescript/dates/segments/getDateTimeSegmentVisibility.d.ts.map +1 -0
- package/lib/typescript/dates/segments/getEmptyDateSegmentText.d.ts +9 -0
- package/lib/typescript/dates/segments/getEmptyDateSegmentText.d.ts.map +1 -0
- package/lib/typescript/dates/segments/parseDateSegment.d.ts +13 -0
- package/lib/typescript/dates/segments/parseDateSegment.d.ts.map +1 -0
- package/lib/typescript/dates/types.d.ts +66 -0
- package/lib/typescript/dates/types.d.ts.map +1 -0
- package/lib/typescript/dates/wire/clampDateParts.d.ts +12 -0
- package/lib/typescript/dates/wire/clampDateParts.d.ts.map +1 -0
- package/lib/typescript/dates/wire/clampMonthParts.d.ts +12 -0
- package/lib/typescript/dates/wire/clampMonthParts.d.ts.map +1 -0
- package/lib/typescript/dates/wire/dateId.d.ts +24 -0
- package/lib/typescript/dates/wire/dateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/formatDateId.d.ts +12 -0
- package/lib/typescript/dates/wire/formatDateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/formatMonthId.d.ts +12 -0
- package/lib/typescript/dates/wire/formatMonthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/isValidDateId.d.ts +13 -0
- package/lib/typescript/dates/wire/isValidDateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/isValidDateParts.d.ts +9 -0
- package/lib/typescript/dates/wire/isValidDateParts.d.ts.map +1 -0
- package/lib/typescript/dates/wire/isValidMonthId.d.ts +13 -0
- package/lib/typescript/dates/wire/isValidMonthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/isValidMonthParts.d.ts +9 -0
- package/lib/typescript/dates/wire/isValidMonthParts.d.ts.map +1 -0
- package/lib/typescript/dates/wire/monthId.d.ts +22 -0
- package/lib/typescript/dates/wire/monthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/parseDateId.d.ts +12 -0
- package/lib/typescript/dates/wire/parseDateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/parseMonthId.d.ts +12 -0
- package/lib/typescript/dates/wire/parseMonthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/toMonthId.d.ts +12 -0
- package/lib/typescript/dates/wire/toMonthId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/todayDateId.d.ts +8 -0
- package/lib/typescript/dates/wire/todayDateId.d.ts.map +1 -0
- package/lib/typescript/dates/wire/todayMonthId.d.ts +8 -0
- package/lib/typescript/dates/wire/todayMonthId.d.ts.map +1 -0
- package/lib/typescript/formatNumber.d.ts +19 -0
- package/lib/typescript/formatNumber.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +2 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils.d.ts +10 -0
- package/lib/typescript/utils.d.ts.map +1 -0
- package/package.json +50 -0
- package/src/__tests__/applyDateSegmentChange.test.ts +26 -0
- package/src/__tests__/calendarFormatters.test.ts +35 -0
- package/src/__tests__/clampDateParts.test.ts +16 -0
- package/src/__tests__/compareDateIds.test.ts +7 -0
- package/src/__tests__/compareMonthIds.test.ts +19 -0
- package/src/__tests__/dateComponentLabels.test.ts +25 -0
- package/src/__tests__/dateRangeAroundDay.test.ts +10 -0
- package/src/__tests__/dateRangeFromLastNDays.test.ts +8 -0
- package/src/__tests__/dateSegmentHelpers.test.ts +24 -0
- package/src/__tests__/datetimeHelpers.test.ts +65 -0
- package/src/__tests__/displayFormatters.test.ts +34 -0
- package/src/__tests__/eachDateIdInRange.test.ts +11 -0
- package/src/__tests__/formatCalendarMonthYear.test.ts +9 -0
- package/src/__tests__/formatDateForDisplay.test.ts +11 -0
- package/src/__tests__/formatDateId.test.ts +15 -0
- package/src/__tests__/formatMonthId.test.ts +7 -0
- package/src/__tests__/formatNumber.test.ts +35 -0
- package/src/__tests__/getDateFieldSegments.test.ts +35 -0
- package/src/__tests__/getDateTimeFieldSegments.test.ts +140 -0
- package/src/__tests__/getDateTimeSegmentVisibility.test.ts +12 -0
- package/src/__tests__/intlCopy.test.ts +64 -0
- package/src/__tests__/isValidDateId.test.ts +8 -0
- package/src/__tests__/isValidMonthId.test.ts +8 -0
- package/src/__tests__/normalizeDateRange.test.ts +10 -0
- package/src/__tests__/toMonthId.test.ts +7 -0
- package/src/__tests__/todayDateId.test.ts +7 -0
- package/src/__tests__/wireConstructors.test.ts +74 -0
- package/src/dates/calendar/formatCalendarMonthYear.ts +21 -0
- package/src/dates/calendar/formatDateTimeListDateRow.ts +41 -0
- package/src/dates/calendar/formatMonthCalendarMonth.ts +21 -0
- package/src/dates/calendar/formatMonthCalendarYear.ts +9 -0
- package/src/dates/calendar/getCalendarWeekdayLabels.ts +23 -0
- package/src/dates/datetime/clampDateTimeId.ts +25 -0
- package/src/dates/datetime/compareDateTimeIds.ts +23 -0
- package/src/dates/datetime/dateTimeId.ts +36 -0
- package/src/dates/datetime/formatDateTimeId.ts +35 -0
- package/src/dates/datetime/formatDateTimeListHour.ts +14 -0
- package/src/dates/datetime/formatDateTimeListMinute.ts +9 -0
- package/src/dates/datetime/formatDateTimeListPeriod.ts +12 -0
- package/src/dates/datetime/isLocaleHour12.ts +23 -0
- package/src/dates/datetime/isValidDateTimeId.ts +18 -0
- package/src/dates/datetime/nowDateTimeId.ts +53 -0
- package/src/dates/datetime/parseDateTimeId.ts +24 -0
- package/src/dates/display/formatDateForDisplay.ts +21 -0
- package/src/dates/display/formatDateRangeForDisplay.ts +23 -0
- package/src/dates/display/formatDateTimeForDisplay.ts +37 -0
- package/src/dates/display/formatMonthForDisplay.ts +26 -0
- package/src/dates/index.ts +86 -0
- package/src/dates/internal/brand.ts +11 -0
- package/src/dates/internal/calendarHelpers.ts +18 -0
- package/src/dates/internal/clampHelpers.ts +15 -0
- package/src/dates/internal/dateIdToNativeDate.ts +15 -0
- package/src/dates/internal/intlCache.ts +40 -0
- package/src/dates/internal/intlCopy.ts +75 -0
- package/src/dates/internal/segmentBuilders.ts +94 -0
- package/src/dates/labels/dateComponentLabels.ts +79 -0
- package/src/dates/ranges/compareDateIds.ts +21 -0
- package/src/dates/ranges/compareMonthIds.ts +26 -0
- package/src/dates/ranges/dateRangeAroundDay.ts +24 -0
- package/src/dates/ranges/dateRangeFromLastNDays.ts +26 -0
- package/src/dates/ranges/eachDateIdInRange.ts +21 -0
- package/src/dates/ranges/normalizeDateRange.ts +18 -0
- package/src/dates/segments/applyDateSegmentChange.ts +57 -0
- package/src/dates/segments/formatDateSegment.ts +18 -0
- package/src/dates/segments/getDateFieldSegments.ts +45 -0
- package/src/dates/segments/getDateTimeFieldSegments.ts +126 -0
- package/src/dates/segments/getDateTimeSegmentVisibility.ts +14 -0
- package/src/dates/segments/getEmptyDateSegmentText.ts +12 -0
- package/src/dates/segments/parseDateSegment.ts +25 -0
- package/src/dates/types.ts +80 -0
- package/src/dates/wire/clampDateParts.ts +17 -0
- package/src/dates/wire/clampMonthParts.ts +15 -0
- package/src/dates/wire/dateId.ts +44 -0
- package/src/dates/wire/formatDateId.ts +20 -0
- package/src/dates/wire/formatMonthId.ts +16 -0
- package/src/dates/wire/isValidDateId.ts +22 -0
- package/src/dates/wire/isValidDateParts.ts +17 -0
- package/src/dates/wire/isValidMonthId.ts +22 -0
- package/src/dates/wire/isValidMonthParts.ts +11 -0
- package/src/dates/wire/monthId.ts +42 -0
- package/src/dates/wire/parseDateId.ts +20 -0
- package/src/dates/wire/parseMonthId.ts +20 -0
- package/src/dates/wire/toMonthId.ts +17 -0
- package/src/dates/wire/todayDateId.ts +12 -0
- package/src/dates/wire/todayMonthId.ts +12 -0
- package/src/formatNumber.ts +56 -0
- package/src/index.ts +82 -0
- package/src/types.ts +1 -0
- package/src/utils.ts +29 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MonthId, MonthParts } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a wire `MonthId` into numeric parts, or `null` when invalid.
|
|
4
|
+
*
|
|
5
|
+
* @param monthId - Wire month string (`YYYY-MM-01`).
|
|
6
|
+
* @returns Parsed parts, or `null` when `monthId` is invalid.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* parseMonthId('2026-07-01') // { year: 2026, month: 7 }
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseMonthId(monthId: MonthId): MonthParts | null;
|
|
12
|
+
//# sourceMappingURL=parseMonthId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseMonthId.d.ts","sourceRoot":"","sources":["../../../../src/dates/wire/parseMonthId.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGpD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAMhE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DateId, MonthId } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Truncates a `DateId` to its month wire id.
|
|
4
|
+
*
|
|
5
|
+
* @param dateId - Wire date string.
|
|
6
|
+
* @returns Wire `MonthId` for the same calendar month.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* toMonthId('2026-07-28') // '2026-07-01'
|
|
10
|
+
*/
|
|
11
|
+
export declare function toMonthId(dateId: DateId): MonthId;
|
|
12
|
+
//# sourceMappingURL=toMonthId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toMonthId.d.ts","sourceRoot":"","sources":["../../../../src/dates/wire/toMonthId.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todayDateId.d.ts","sourceRoot":"","sources":["../../../../src/dates/wire/todayDateId.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"todayMonthId.d.ts","sourceRoot":"","sources":["../../../../src/dates/wire/todayMonthId.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Nullable } from './types';
|
|
2
|
+
export interface FormatNumberOptions {
|
|
3
|
+
locale?: Nullable<Intl.LocalesArgument>;
|
|
4
|
+
decimalPlaces?: Nullable<number>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Formats a value as a number with decimal places for display.
|
|
8
|
+
*
|
|
9
|
+
* @param value - Value to format (`number`, plain numeric `string` like `'1234.56'`, `null`, or `undefined`).
|
|
10
|
+
* @param options - Formatting options.
|
|
11
|
+
* @param options.locale - BCP 47 locale; defaults to `en-US`.
|
|
12
|
+
* @param options.decimalPlaces - Fraction digits; defaults to `2`.
|
|
13
|
+
* @returns Locale-formatted decimal string, or `''` for nullish, blank, or non-numeric values.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* formatNumber(3247.19) // '3,247.19'
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatNumber(value: Nullable<number | string>, options?: Nullable<FormatNumberOptions>): string;
|
|
19
|
+
//# sourceMappingURL=formatNumber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatNumber.d.ts","sourceRoot":"","sources":["../../src/formatNumber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGxC,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACxC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAClC;AA0BD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,EAChC,OAAO,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GACtC,MAAM,CAQR"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { formatNumber, type FormatNumberOptions } from './formatNumber';
|
|
2
|
+
export type { DateFieldMode, DateFormatOptions, DateId, DateParts, DateRangeDisplayOptions, DateSegment, DateSegmentType, DateTimeGranularity, DateTimeId, DateTimeParts, FormatDateDisplayOptions, FormatDateTimeDisplayOptions, MonthId, MonthParts, TimeParts, } from './dates/types';
|
|
3
|
+
export { clampDateParts, clampMonthParts, dateId, monthId, formatDateId, formatMonthId, isValidDateId, isValidDateParts, isValidMonthId, isValidMonthParts, parseDateId, parseMonthId, toMonthId, todayDateId, todayMonthId, clampDateTimeId, compareDateTimeIds, dateTimeId, formatDateTimeId, isLocaleHour12, isValidDateTimeId, nowDateTimeId, parseDateTimeId, formatDateForDisplay, formatDateRangeForDisplay, formatDateTimeForDisplay, formatMonthForDisplay, compareDateIds, compareMonthIds, dateRangeAroundDay, dateRangeFromLastNDays, eachDateIdInRange, normalizeDateRange, applyDateSegmentChange, formatDateSegment, getDateFieldSegments, getDateTimeFieldSegments, getDateTimeSegmentVisibility, getEmptyDateSegmentText, parseDateSegment, formatCalendarMonthYear, formatDateTimeListDateRow, formatDateTimeListHour, formatDateTimeListMinute, formatDateTimeListPeriod, formatMonthCalendarMonth, formatMonthCalendarYear, getCalendarWeekdayLabels, DEFAULT_DATE_COMPONENT_LABELS, formatSelectYear, getDateSegmentAccessibilityLabel, resolveDateComponentLabels, } from './dates';
|
|
4
|
+
export type { DateComponentLabels } from './dates';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAExE,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,SAAS,EACT,uBAAuB,EACvB,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,wBAAwB,EACxB,4BAA4B,EAC5B,OAAO,EACP,UAAU,EACV,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEL,cAAc,EACd,eAAe,EACf,MAAM,EACN,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,EAEZ,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,eAAe,EAEf,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EAErB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAElB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC5B,uBAAuB,EACvB,gBAAgB,EAEhB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,gBAAgB,EAChB,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AAEjB,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Nullable } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Coerce a nullable number/string to a finite number for display formatters.
|
|
4
|
+
*
|
|
5
|
+
* Hermes does not support the `signDisplay` property on iOS (and is unreliable on Android 11),
|
|
6
|
+
* so `-0` can still format as `"-0.00"`. Normalize before Intl to avoid this issue.
|
|
7
|
+
* @see https://github.com/facebook/hermes/blob/main/doc/IntlAPIs.md#limited-ios-property-support
|
|
8
|
+
*/
|
|
9
|
+
export declare function toFiniteNumber(value: Nullable<number | string>): number | undefined;
|
|
10
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAmBnF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cdx-ui/formatters",
|
|
3
|
+
"version": "0.0.1-beta.132",
|
|
4
|
+
"main": "lib/commonjs/index.js",
|
|
5
|
+
"module": "lib/module/index.js",
|
|
6
|
+
"react-native": "src/index.ts",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"source": "src/index.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"react-native": "./src/index.ts",
|
|
12
|
+
"types": "./lib/typescript/index.d.ts",
|
|
13
|
+
"import": "./lib/module/index.js",
|
|
14
|
+
"require": "./lib/commonjs/index.js",
|
|
15
|
+
"default": "./lib/module/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"lib",
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
22
|
+
"react-native-builder-bob": {
|
|
23
|
+
"source": "src",
|
|
24
|
+
"output": "lib",
|
|
25
|
+
"exclude": "**/{__tests__/**,__fixtures__/**,__mocks__/**,*.test.ts,*.test.tsx,*.spec.ts,*.spec.tsx}",
|
|
26
|
+
"targets": [
|
|
27
|
+
"commonjs",
|
|
28
|
+
"module",
|
|
29
|
+
"typescript"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"date-fns": "4.1.0"
|
|
34
|
+
},
|
|
35
|
+
"nx": {
|
|
36
|
+
"tags": [
|
|
37
|
+
"type:lib",
|
|
38
|
+
"scope:formatters"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "bob build",
|
|
47
|
+
"lint": "eslint src/",
|
|
48
|
+
"test": "jest --config ../../jest.config.js --selectProjects formatters"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { applyDateSegmentChange } from '../dates/segments/applyDateSegmentChange';
|
|
2
|
+
import { formatDateId } from '../dates/wire/formatDateId';
|
|
3
|
+
import { parseDateId } from '../dates/wire/parseDateId';
|
|
4
|
+
import { parseMonthId } from '../dates/wire/parseMonthId';
|
|
5
|
+
|
|
6
|
+
describe('applyDateSegmentChange', () => {
|
|
7
|
+
it('clamps day when month segment changes to a shorter month', () => {
|
|
8
|
+
const current = parseDateId('2026-01-31');
|
|
9
|
+
const next = applyDateSegmentChange(current, 'month', 2, { mode: 'date' });
|
|
10
|
+
const expected = { year: 2026, month: 2, day: 28 };
|
|
11
|
+
expect(next).toEqual(expected);
|
|
12
|
+
expect(formatDateId(expected)).toBe('2026-02-28');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('clamps day segment to the current month length', () => {
|
|
16
|
+
const current = parseDateId('2026-02-01');
|
|
17
|
+
const next = applyDateSegmentChange(current, 'day', 31, { mode: 'date' });
|
|
18
|
+
expect(next).toEqual({ year: 2026, month: 2, day: 28 });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('clamps month segment in month mode', () => {
|
|
22
|
+
const current = parseMonthId('2026-07-01');
|
|
23
|
+
const next = applyDateSegmentChange(current, 'month', 13, { mode: 'month' });
|
|
24
|
+
expect(next).toEqual({ year: 2026, month: 12 });
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { formatMonthCalendarYear } from '../dates/calendar/formatMonthCalendarYear';
|
|
2
|
+
import { getCalendarWeekdayLabels } from '../dates/calendar/getCalendarWeekdayLabels';
|
|
3
|
+
import { formatDateTimeListDateRow } from '../dates/calendar/formatDateTimeListDateRow';
|
|
4
|
+
import { formatDateTimeListHour } from '../dates/datetime/formatDateTimeListHour';
|
|
5
|
+
import { formatDateTimeListMinute } from '../dates/datetime/formatDateTimeListMinute';
|
|
6
|
+
import { formatDateTimeListPeriod } from '../dates/datetime/formatDateTimeListPeriod';
|
|
7
|
+
|
|
8
|
+
describe('calendar formatters', () => {
|
|
9
|
+
it('formats month calendar year as string', () => {
|
|
10
|
+
expect(formatMonthCalendarYear(2026)).toBe('2026');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('returns seven weekday labels starting from first day of week', () => {
|
|
14
|
+
const labels = getCalendarWeekdayLabels({ locale: 'en-US', firstDayOfWeek: 1 });
|
|
15
|
+
expect(labels).toHaveLength(7);
|
|
16
|
+
expect(labels.every((label) => label.length > 0)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('formats date list row with today override', () => {
|
|
20
|
+
expect(
|
|
21
|
+
formatDateTimeListDateRow('2026-07-28', { locale: 'en-US', todayDateId: '2026-07-28' }),
|
|
22
|
+
).toBeTruthy();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('formats date list row for non-today dates', () => {
|
|
26
|
+
expect(formatDateTimeListDateRow('2026-01-15', { locale: 'en-US' })).toContain('15');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('formats date-time list hour, minute, and period', () => {
|
|
30
|
+
expect(formatDateTimeListHour(14, { hour12: true })).toBe('2');
|
|
31
|
+
expect(formatDateTimeListHour(14)).toBe('14');
|
|
32
|
+
expect(formatDateTimeListMinute(30)).toBe('30');
|
|
33
|
+
expect(formatDateTimeListPeriod(14, { locale: 'en-US' })).toMatch(/PM/i);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { clampDateParts } from '../dates/wire/clampDateParts';
|
|
2
|
+
|
|
3
|
+
describe('clampDateParts', () => {
|
|
4
|
+
it('clamps date parts to the month length', () => {
|
|
5
|
+
expect(clampDateParts({ year: 2026, month: 2, day: 31 })).toEqual({
|
|
6
|
+
year: 2026,
|
|
7
|
+
month: 2,
|
|
8
|
+
day: 28,
|
|
9
|
+
});
|
|
10
|
+
expect(clampDateParts({ year: 2024, month: 2, day: 31 })).toEqual({
|
|
11
|
+
year: 2024,
|
|
12
|
+
month: 2,
|
|
13
|
+
day: 29,
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { compareMonthIds } from '../dates/ranges/compareMonthIds';
|
|
2
|
+
|
|
3
|
+
describe('compareMonthIds', () => {
|
|
4
|
+
it('returns -1 when first month is earlier', () => {
|
|
5
|
+
expect(compareMonthIds('2026-01-01', '2026-07-01')).toBe(-1);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('returns 1 when first month is later', () => {
|
|
9
|
+
expect(compareMonthIds('2026-12-01', '2026-07-01')).toBe(1);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('returns 0 for equal months', () => {
|
|
13
|
+
expect(compareMonthIds('2026-07-01', '2026-07-01')).toBe(0);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('returns 0 when either month is invalid', () => {
|
|
17
|
+
expect(compareMonthIds('invalid', '2026-07-01')).toBe(0);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_DATE_COMPONENT_LABELS,
|
|
3
|
+
formatSelectYear,
|
|
4
|
+
getDateSegmentAccessibilityLabel,
|
|
5
|
+
resolveDateComponentLabels,
|
|
6
|
+
} from '../dates/labels/dateComponentLabels';
|
|
7
|
+
|
|
8
|
+
describe('dateComponentLabels', () => {
|
|
9
|
+
it('merges partial overrides with defaults', () => {
|
|
10
|
+
const labels = resolveDateComponentLabels({ previousMonth: 'Back' });
|
|
11
|
+
expect(labels.previousMonth).toBe('Back');
|
|
12
|
+
expect(labels.nextMonth).toBe(DEFAULT_DATE_COMPONENT_LABELS.nextMonth);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('formats select year with placeholder', () => {
|
|
16
|
+
const labels = resolveDateComponentLabels();
|
|
17
|
+
expect(formatSelectYear(labels, 2030)).toBe('Select year 2030');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('maps segment types to accessibility labels', () => {
|
|
21
|
+
const labels = resolveDateComponentLabels();
|
|
22
|
+
expect(getDateSegmentAccessibilityLabel('month', labels)).toBe('Month');
|
|
23
|
+
expect(getDateSegmentAccessibilityLabel('literal', labels)).toBeUndefined();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { dateRangeAroundDay } from '../dates/ranges/dateRangeAroundDay';
|
|
2
|
+
|
|
3
|
+
describe('dateRangeAroundDay', () => {
|
|
4
|
+
it('builds a window around an anchor day', () => {
|
|
5
|
+
expect(dateRangeAroundDay(1, 1, '2026-07-28')).toEqual({
|
|
6
|
+
startId: '2026-07-27',
|
|
7
|
+
endId: '2026-07-29',
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { dateRangeFromLastNDays } from '../dates/ranges/dateRangeFromLastNDays';
|
|
2
|
+
|
|
3
|
+
describe('dateRangeFromLastNDays', () => {
|
|
4
|
+
it('builds last N days preset inclusive of end', () => {
|
|
5
|
+
const range = dateRangeFromLastNDays(3, '2026-07-30');
|
|
6
|
+
expect(range).toEqual({ startId: '2026-07-28', endId: '2026-07-30' });
|
|
7
|
+
});
|
|
8
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getEmptyDateSegmentText } from '../dates/segments/getEmptyDateSegmentText';
|
|
2
|
+
import { formatDateSegment } from '../dates/segments/formatDateSegment';
|
|
3
|
+
import { parseDateSegment } from '../dates/segments/parseDateSegment';
|
|
4
|
+
|
|
5
|
+
describe('date segment helpers', () => {
|
|
6
|
+
it('returns placeholder text for empty segments', () => {
|
|
7
|
+
expect(getEmptyDateSegmentText('month')).toBe('MM');
|
|
8
|
+
expect(getEmptyDateSegmentText('day')).toBe('DD');
|
|
9
|
+
expect(getEmptyDateSegmentText('year')).toBe('YYYY');
|
|
10
|
+
expect(getEmptyDateSegmentText('literal')).toBe('');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('formats segment values with padding', () => {
|
|
14
|
+
expect(formatDateSegment('month', 7)).toBe('07');
|
|
15
|
+
expect(formatDateSegment('year', 2026)).toBe('2026');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('parses segment text to numbers', () => {
|
|
19
|
+
expect(parseDateSegment('month', '07')).toBe(7);
|
|
20
|
+
expect(parseDateSegment('day', '')).toBeNull();
|
|
21
|
+
expect(parseDateSegment('literal', ' / ')).toBeNull();
|
|
22
|
+
expect(parseDateSegment('month', 'abc')).toBeNull();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { compareDateTimeIds } from '../dates/datetime/compareDateTimeIds';
|
|
2
|
+
import { clampDateTimeId } from '../dates/datetime/clampDateTimeId';
|
|
3
|
+
import { nowDateTimeId } from '../dates/datetime/nowDateTimeId';
|
|
4
|
+
import { isLocaleHour12 } from '../dates/datetime/isLocaleHour12';
|
|
5
|
+
|
|
6
|
+
describe('datetime helpers', () => {
|
|
7
|
+
describe('compareDateTimeIds', () => {
|
|
8
|
+
it('compares chronologically', () => {
|
|
9
|
+
expect(compareDateTimeIds('2026-07-01T09:00', '2026-07-01T10:00')).toBe(-1);
|
|
10
|
+
expect(compareDateTimeIds('2026-07-02T09:00', '2026-07-01T10:00')).toBe(1);
|
|
11
|
+
expect(compareDateTimeIds('2026-07-01T10:00', '2026-07-01T10:00')).toBe(0);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
describe('clampDateTimeId', () => {
|
|
16
|
+
it('clamps to inclusive bounds', () => {
|
|
17
|
+
expect(
|
|
18
|
+
clampDateTimeId('2026-01-01T00:00', {
|
|
19
|
+
min: '2026-07-01T00:00',
|
|
20
|
+
max: '2026-12-31T23:59',
|
|
21
|
+
}),
|
|
22
|
+
).toBe('2026-07-01T00:00');
|
|
23
|
+
expect(
|
|
24
|
+
clampDateTimeId('2027-01-01T00:00', {
|
|
25
|
+
min: '2026-07-01T00:00',
|
|
26
|
+
max: '2026-12-31T23:59',
|
|
27
|
+
}),
|
|
28
|
+
).toBe('2026-12-31T23:59');
|
|
29
|
+
expect(
|
|
30
|
+
clampDateTimeId('2026-08-01T12:00', {
|
|
31
|
+
min: '2026-07-01T00:00',
|
|
32
|
+
max: '2026-12-31T23:59',
|
|
33
|
+
}),
|
|
34
|
+
).toBe('2026-08-01T12:00');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('nowDateTimeId', () => {
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
jest.useFakeTimers();
|
|
41
|
+
jest.setSystemTime(new Date(2026, 6, 28, 14, 30, 45));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterEach(() => {
|
|
45
|
+
jest.useRealTimers();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('returns current local time truncated by granularity', () => {
|
|
49
|
+
expect(nowDateTimeId({ granularity: 'minute' })).toBe('2026-07-28T14:30');
|
|
50
|
+
expect(nowDateTimeId({ granularity: 'hour' })).toBe('2026-07-28T14:00');
|
|
51
|
+
expect(nowDateTimeId({ granularity: 'day' })).toBe('2026-07-28T00:00');
|
|
52
|
+
expect(nowDateTimeId({ granularity: 'second' })).toBe('2026-07-28T14:30:45');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('isLocaleHour12', () => {
|
|
57
|
+
it('detects 12-hour locales', () => {
|
|
58
|
+
expect(isLocaleHour12('en-US')).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('falls back to true on invalid locale', () => {
|
|
62
|
+
expect(isLocaleHour12('invalid-locale-xyz')).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { formatDateRangeForDisplay } from '../dates/display/formatDateRangeForDisplay';
|
|
2
|
+
import { formatMonthForDisplay } from '../dates/display/formatMonthForDisplay';
|
|
3
|
+
import { formatDateTimeForDisplay } from '../dates/display/formatDateTimeForDisplay';
|
|
4
|
+
|
|
5
|
+
describe('display formatters', () => {
|
|
6
|
+
it('formats date range for display', () => {
|
|
7
|
+
const result = formatDateRangeForDisplay({
|
|
8
|
+
startId: '2026-07-01',
|
|
9
|
+
endId: '2026-07-28',
|
|
10
|
+
});
|
|
11
|
+
expect(result).toContain('7/1');
|
|
12
|
+
expect(result).toMatch(/–|—|-|to/i);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('uses custom range separator when provided', () => {
|
|
16
|
+
const result = formatDateRangeForDisplay(
|
|
17
|
+
{ startId: '2026-07-01', endId: '2026-07-28' },
|
|
18
|
+
{ rangeSeparator: ' to ' },
|
|
19
|
+
);
|
|
20
|
+
expect(result).toContain(' to ');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('formats month for display', () => {
|
|
24
|
+
expect(formatMonthForDisplay('2026-07-01', { locale: 'en-US' })).toContain('2026');
|
|
25
|
+
expect(formatMonthForDisplay('2026-07-01', { locale: 'en-US', dateStyle: 'long' })).toMatch(
|
|
26
|
+
/July/i,
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('formats date-time for display', () => {
|
|
31
|
+
expect(formatDateTimeForDisplay('2026-07-28T10:01', { locale: 'en-US' })).toContain('2026');
|
|
32
|
+
expect(formatDateTimeForDisplay('invalid', { locale: 'en-US' })).toBe('');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { eachDateIdInRange } from '../dates/ranges/eachDateIdInRange';
|
|
2
|
+
|
|
3
|
+
describe('eachDateIdInRange', () => {
|
|
4
|
+
it('lists each day in range', () => {
|
|
5
|
+
expect(eachDateIdInRange('2026-07-27', '2026-07-29')).toEqual([
|
|
6
|
+
'2026-07-27',
|
|
7
|
+
'2026-07-28',
|
|
8
|
+
'2026-07-29',
|
|
9
|
+
]);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { formatCalendarMonthYear } from '../dates/calendar/formatCalendarMonthYear';
|
|
2
|
+
import { formatMonthCalendarMonth } from '../dates/calendar/formatMonthCalendarMonth';
|
|
3
|
+
|
|
4
|
+
describe('formatCalendarMonthYear', () => {
|
|
5
|
+
it('formats calendar month/year with locale', () => {
|
|
6
|
+
expect(formatCalendarMonthYear('2026-07-01', { locale: 'en-US' })).toContain('2026');
|
|
7
|
+
expect(formatMonthCalendarMonth(7, { locale: 'en-US' })).toMatch(/Jul/i);
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { formatDateForDisplay } from '../dates/display/formatDateForDisplay';
|
|
2
|
+
|
|
3
|
+
describe('formatDateForDisplay', () => {
|
|
4
|
+
it('formats date for en-US locale', () => {
|
|
5
|
+
const formatted = formatDateForDisplay('2026-07-28', {
|
|
6
|
+
locale: 'en-US',
|
|
7
|
+
dateStyle: 'long',
|
|
8
|
+
});
|
|
9
|
+
expect(formatted).toContain('2026');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { formatDateId } from '../dates/wire/formatDateId';
|
|
2
|
+
import { parseDateId } from '../dates/wire/parseDateId';
|
|
3
|
+
|
|
4
|
+
describe('formatDateId', () => {
|
|
5
|
+
it('round-trips DateId', () => {
|
|
6
|
+
const id = formatDateId({ year: 2026, month: 7, day: 28 });
|
|
7
|
+
expect(id).toBe('2026-07-28');
|
|
8
|
+
expect(parseDateId(id)).toEqual({ year: 2026, month: 7, day: 28 });
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('clamps invalid day instead of rolling over via Date', () => {
|
|
12
|
+
expect(formatDateId({ year: 2026, month: 2, day: 31 })).toBe('2026-02-28');
|
|
13
|
+
expect(formatDateId({ year: 2024, month: 2, day: 31 })).toBe('2024-02-29');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { formatNumber } from '../formatNumber';
|
|
2
|
+
|
|
3
|
+
describe('formatNumber', () => {
|
|
4
|
+
it('should format with default decimal places', () => {
|
|
5
|
+
expect(formatNumber(99.95789)).toEqual('99.96');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('should format a string with custom decimal places', () => {
|
|
9
|
+
expect(formatNumber('-2000', { decimalPlaces: 3 })).toEqual('-2,000.000');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should format using locale', () => {
|
|
13
|
+
expect(formatNumber(1234.5, { locale: 'de-DE' })).toEqual('1.234,50');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should omit the sign for signed zero (-0)', () => {
|
|
17
|
+
expect(formatNumber(-0)).toEqual('0.00');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should use defaults when options is nullish or fields are null', () => {
|
|
21
|
+
expect(formatNumber(1234.5, null)).toEqual('1,234.50');
|
|
22
|
+
expect(formatNumber(1234.5, undefined)).toEqual('1,234.50');
|
|
23
|
+
expect(formatNumber(1234.5, { locale: null, decimalPlaces: null })).toEqual('1,234.50');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
[null, undefined, Number.NaN, 'asdf', '', ' '].forEach((value) => {
|
|
27
|
+
it(`should return empty string for ${JSON.stringify(value)}`, () => {
|
|
28
|
+
expect(formatNumber(value)).toEqual('');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should return empty string for already-formatted numbers', () => {
|
|
33
|
+
expect(formatNumber('1,234.56')).toEqual('');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getDateFieldSegments } from '../dates/segments/getDateFieldSegments';
|
|
2
|
+
|
|
3
|
+
describe('getDateFieldSegments', () => {
|
|
4
|
+
it('returns date field segments', () => {
|
|
5
|
+
const segments = getDateFieldSegments('2026-07-28', { mode: 'date', locale: 'en-US' });
|
|
6
|
+
expect(segments.map((s) => s.type)).toEqual(['month', 'literal', 'day', 'literal', 'year']);
|
|
7
|
+
expect(segments.filter((s) => s.type === 'literal').map((s) => s.text)).toEqual(['/', '/']);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('orders date field segments by locale', () => {
|
|
11
|
+
const deSegments = getDateFieldSegments('2026-07-28', { mode: 'date', locale: 'de-DE' });
|
|
12
|
+
expect(deSegments.map((s) => s.type)).toEqual(['day', 'literal', 'month', 'literal', 'year']);
|
|
13
|
+
expect(deSegments.filter((s) => s.type === 'literal').map((s) => s.text)).toEqual(['.', '.']);
|
|
14
|
+
|
|
15
|
+
const jpSegments = getDateFieldSegments('2026-07-28', { mode: 'date', locale: 'ja-JP' });
|
|
16
|
+
expect(jpSegments.map((s) => s.type)).toEqual(['year', 'literal', 'month', 'literal', 'day']);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('orders month field segments by locale', () => {
|
|
20
|
+
const deSegments = getDateFieldSegments('2026-07-01', { mode: 'month', locale: 'de-DE' });
|
|
21
|
+
expect(deSegments.map((s) => s.type)).toEqual(['month', 'literal', 'year']);
|
|
22
|
+
const expectedLiteral = new Intl.DateTimeFormat('de-DE', { year: 'numeric', month: '2-digit' })
|
|
23
|
+
.formatToParts(new Date(2026, 6, 1))
|
|
24
|
+
.find((part) => part.type === 'literal')?.value;
|
|
25
|
+
expect(deSegments.find((s) => s.type === 'literal')?.text).toBe(expectedLiteral);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('returns placeholder segments when value is empty', () => {
|
|
29
|
+
const segments = getDateFieldSegments(undefined, { mode: 'date', locale: 'en-US' });
|
|
30
|
+
expect(segments.find((s) => s.type === 'month')?.text).toBe('MM');
|
|
31
|
+
expect(segments.find((s) => s.type === 'month')?.value).toBeUndefined();
|
|
32
|
+
expect(segments.find((s) => s.type === 'day')?.text).toBe('DD');
|
|
33
|
+
expect(segments.find((s) => s.type === 'year')?.text).toBe('YYYY');
|
|
34
|
+
});
|
|
35
|
+
});
|