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

@rokkit/core

v1.2.0

Published

Contains core utility functions and classes that can be used in various components.

Readme

@rokkit/core

Core utilities for the Rokkit design system — field mapping, constants, calendar, color palette, and event utilities.

Install

npm install @rokkit/core
# or
bun add @rokkit/core

Overview

@rokkit/core is the foundation layer shared across all Rokkit packages. It provides:

  • Field mapping — map arbitrary data object shapes to semantic field names
  • ConstantsBASE_FIELDS, DEFAULT_STATE_ICONS, DEFAULT_KEYMAP, and more
  • Color palette — default colors, shades, and theme color mapping
  • Calendar utilities — calendar day generation and weekday labels
  • Event utilities — lightweight emitter factory
  • Direction detection — RTL/LTR helpers
  • Tick generation — axis tick utilities for chart packages

No runtime dependencies on other @rokkit/* packages.

Usage

Field mapping

FieldMapper maps semantic field names (label, value, icon, etc.) to the actual keys present in your data objects. Pass a fields override to adapt any data shape.

import { FieldMapper } from '@rokkit/core'

const mapper = new FieldMapper({ label: 'name', value: 'id', icon: 'iconClass' })

const item = { id: 42, name: 'Settings', iconClass: 'i-settings' }

mapper.get('label', item) // 'Settings'
mapper.get('value', item) // 42
mapper.get('icon', item) // 'i-settings'

normalizeFields

Merge user-supplied field overrides with BASE_FIELDS defaults, remapping any legacy key names automatically.

import { normalizeFields, BASE_FIELDS } from '@rokkit/core'

const fields = normalizeFields({ label: 'title', value: 'slug' })
// { label: 'title', value: 'slug', icon: 'icon', children: 'children', ... }

BASE_FIELDS reference

import { BASE_FIELDS } from '@rokkit/core'

// {
//   id: 'id',         value: 'value',       label: 'label',
//   icon: 'icon',     avatar: 'image',       subtext: 'description',
//   tooltip: 'title', badge: 'badge',        shortcut: 'shortcut',
//   children: 'children',  type: 'type',    snippet: 'snippet',
//   href: 'href',     hrefTarget: 'target',
//   disabled: 'disabled',  expanded: 'expanded', selected: 'selected'
// }

Event emitter

import { createEmitter } from '@rokkit/core'

const emitter = createEmitter()
emitter.on('select', (item) => console.log('selected', item))
emitter.emit('select', myItem)

Calendar utilities

import { getCalendarDays, weekdays } from '@rokkit/core'

const days = getCalendarDays(2025, 2) // February 2025
// weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']

Tick generation

import { generateTicks } from '@rokkit/core'

const ticks = generateTicks(0, 100, 5)
// [0, 25, 50, 75, 100]

API

| Export | Description | | -------------------------------- | ------------------------------------------------------------- | | BASE_FIELDS | Canonical semantic-to-data-key field mapping | | normalizeFields(fields) | Merge overrides with BASE_FIELDS defaults | | FieldMapper | Class that resolves semantic field reads from data objects | | DEFAULT_STATE_ICONS | Icon name map grouped by category (action, state, sort, etc.) | | DEFAULT_KEYMAP | Default keyboard navigation key mapping | | DEFAULT_THEME_MAPPING | Default semantic color → palette color mapping | | createEmitter() | Lightweight event emitter factory | | getCalendarDays(year, month) | Calendar day array for a given month | | weekdays | Localized weekday label array | | generateTicks(min, max, count) | Evenly spaced axis tick values | | defaultColors | Default color palette array | | shades | Available shade scale values | | ITEM_SNIPPET | Constant: default item snippet key ('itemContent') | | GROUP_SNIPPET | Constant: default group snippet key ('groupContent') | | stateIconsFromNames(names) | Build a state icon map from an array of icon name strings |


Part of Rokkit — a Svelte 5 component library and design system.