npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cdx-ui/formatters

v0.0.1-beta.179

Published

![coverage](https://unpkg.com/@cdx-ui/formatters/coverage.svg)

Downloads

6,592

Readme

@cdx-ui/formatters

coverage

Pure formatters for Forge UI and FI apps — turn wire values into human-readable UI strings (and the reverse for date wire ids). No React dependency.

Aligned in style with @candescent/ui-formatters (display helpers at package root; date helpers under dates/). Prefer named imports from @cdx-ui/formatters only — do not import date-fns or Intl wrappers from this package’s internals.

Wire vs display (dates)

| Representation | Example | Use for | | -------------------------------------------- | ---------------------------- | ----------------------------- | | Wire DateId / MonthId / DateTimeId | '2026-07-28' | Form state, APIs, pickers | | Display string | '7/28/26' / '28/07/2026' | Labels, headers — never store |

Exports

Display (shared with banking UI formatters)

| Import | Purpose | | -------------- | ------------------------------------------------------ | | formatNumber | Locale decimal formatting (cached Intl.NumberFormat) |

Date wire

| Import | Purpose | | ------------------------------------------------------------ | ------------------------ | | parseDateId / formatDateId / isValidDateId | YYYY-MM-DD round-trip | | parseMonthId / formatMonthId / isValidMonthId | YYYY-MM-01 month ids | | parseDateTimeId / formatDateTimeId / isValidDateTimeId | Local YYYY-MM-DDTHH:mm | | todayDateId / todayMonthId / nowDateTimeId | Device-local “now” | | toMonthId / clampDateParts / clampMonthParts | Conversions / clamping |

Date display

| Import | Purpose | | --------------------------- | ------------------------------------ | | formatDateForDisplay | Locale dateStyle short/medium/long | | formatMonthForDisplay | Month + year label | | formatDateTimeForDisplay | Date + time label | | formatDateRangeForDisplay | Inclusive range label |

Ranges & segments

| Import | Purpose | | ------------------------------------------------------------------- | ------------------------ | | normalizeDateRange / compareDateIds / eachDateIdInRange | Range math | | dateRangeFromLastNDays / dateRangeAroundDay | Presets | | getDateFieldSegments / getDateTimeFieldSegments | Segmented field metadata | | parseDateSegment / formatDateSegment / applyDateSegmentChange | Segment edits |

Calendar / list copy

| Import | Purpose | | ---------------------------------------------------------- | --------------------- | | formatCalendarMonthYear / getCalendarWeekdayLabels | Calendar chrome | | formatMonthCalendarMonth / formatMonthCalendarYear | Month grid | | formatDateTimeListDateRow / formatDateTimeListHour / … | DateTime list columns |

Usage

import {
  formatDateId,
  formatDateForDisplay,
  formatNumber,
  normalizeDateRange,
  type DateId,
} from '@cdx-ui/formatters';

formatNumber(3247.19); // '3,247.19'

const id: DateId = formatDateId({ year: 2026, month: 7, day: 28 }); // '2026-07-28'
formatDateForDisplay(id, { locale: 'en-US' }); // e.g. '7/28/26'

normalizeDateRange({ startId: '2026-07-28', endId: '2026-07-01' });
// → { startId: '2026-07-01', endId: '2026-07-28' }
pnpm --filter @cdx-ui/formatters test

File layout

src/
  formatNumber.ts          # shared display helper (merge target with ui-formatters)
  types.ts / utils.ts      # package-private (not barrel-exported)
  __tests__/               # one test file per public helper
  dates/
    types.ts
    index.ts               # date barrel (re-exported from package root)
    wire/                  # DateId / MonthId parse, format, validate, today
    display/               # locale-aware format*ForDisplay
    ranges/                # compare, normalize, presets
    segments/              # segmented field helpers
    calendar/              # calendar + list row copy
    datetime/              # DateTimeId + list hour/minute/period
    internal/              # private adapters (not public API)

Design notes

  • date-fns is used internally for wire parse/math; Intl for user-facing display and calendar labels.
  • Invalid / nullish inputs return '' or null as documented per helper — never throw for bad display input.
  • Package internals under dates/internal/ are not part of the public API.

License

License: MIT

MIT © 2026 Digital First Holdings LLC. See LICENSE for details.