@frame-kit/utils
v0.2.22
Published
Framework-agnostic colour, date and i18n utilities for FrameKit. Ships both ESM and CommonJS.
Readme
@frame-kit/utils
Framework-agnostic color, date and i18n utilities for FrameKit — no Angular, no framework dependency, fully tree-shakeable.
Ships both ESM and CommonJS. That matters because these run outside the browser as well as
in it: the i18n engine renders server-side auth pages in a NestJS app, and a CommonJS project —
most notably one testing through ts-jest — has to be able to require this package without
adding transformIgnorePatterns to work around it. import gets the ESM build, require gets
the CommonJS one, and the build fails if either stops loading.
Install
npm i @frame-kit/utilsUsage
import { Color, DateUtil } from '@frame-kit/utils';
// Color — parse, convert, manipulate, contrast, palette generation
const c = new Color('#2563eb');
c.toRgb(); // { r, g, b }
c.lighten(0.2).toHex();
c.contrastRatio('#ffffff'); // WCAG ratio
// DateUtil — parse, format, relative time, contextual labels, ranges
DateUtil.format(Date.now(), 'medium');
DateUtil.relative('2026-01-01'); // "5 months ago"
DateUtil.expiresIn(expiry); // contextual "Expires in 3 days"Exposes Color and DateUtil plus their supporting types (RgbColor, HslColor,
TailwindPalette, DateInput, DateFormatPreset, ExpiryStatus).
These were previously bundled inside
@frame-kit/ui-ngas Angular services. They now live here, framework-agnostic — wrap them in your own DI service if you want injectable access.
License
MIT
