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

paper-roll-pallet

v0.2.1

Published

Roll/pallet palletization: a framework-free packing solver and data model, plus an optional React SVG visualization at './react'.

Downloads

475

Readme

paper-roll-pallet

Roll/pallet palletization: a framework-free packing solver and data model, plus an optional React SVG visualization at the ./react subpath. Import just the main entry to get pure logic with zero dependencies, or add paper-roll-pallet/react when you also want the component (React is a peer dependency only for that subpath).

Model

A roll stands on its circular end, so its contribution to a pallet's stack height equals its width (mm), and its footprint is its diameter. A pallet is a single vertical tower of rolls (no side-by-side stacking). A tower's height must not exceed maxStackHeightMm (equipment internal height minus pallet height).

Main entry (paper-roll-pallet)

No dependencies, no React.

  • typesPalletizationRowInput, PalletizationConfig, PlannedRoll, PlannedPallet, PalletizationPlan.
  • rollMath — wound-roll length/weight math, kg ↔ roll-count conversion.
  • rollColors — deterministic colour-per-roll-type palette.
  • solversolvePalletization(rows, config): FFD + maximal-pattern enumeration bin-packing into pallets/trucks.
  • palletPatterns — groups solved pallets into { count, rolls } patterns for display/editing, plus pure edit operations (changeCount, addRollToPattern, removeRollFromPattern, …).
  • planDocument — serializable plan document with schema versioning, staleness detection, and approval tracking.
  • rollAssignment — matches the PHYSICAL rolls of a pallet being packed (roll number + measured width) to the planned slots: assignRollsToPattern, stackOrder.
import { solvePalletization, groupIntoPatterns, buildPlanFromPatterns } from 'paper-roll-pallet';

const plan = solvePalletization(rows, config);
const patterns = plan.feasible ? groupIntoPatterns(plan) : [];

paper-roll-pallet/react

<PackagingPlanGraphic> — draws a plan as SVG (roll towers with cylindrical shading, a pallet glyph, engineering-style dimension lines, a legend, optional drag-and-drop editing). No MUI, no CSS framework.

import { PackagingPlanGraphic, type RollType } from 'paper-roll-pallet/react';

<PackagingPlanGraphic
  patterns={patterns}
  maxStackHeightMm={config.maxStackHeightMm}
  palletHeightMm={palletHeightMm}
  palletLongerSideMm={palletLongerSideMm}
  rollTypes={rollTypes}
/>

Pass editing plus the onCountDelta/onAddPattern/onDeletePattern/ onDropRoll/onRemoveRoll callbacks to enable interactive editing.

Packaging mode — physical roll numbers on a pallet

While a pallet is actually being built, the operator enters the roll number and measured width of every roll that goes on it. Pass those per pallet as assignmentsByPattern and the graphic shows how far the pallet has got: rolls that have a physical roll are drawn solid with their roll number written across them, and every planned roll still missing is faded (50 % by default). With nothing entered yet the whole tower is faded.

<PackagingPlanGraphic
  patterns={[{ id: 'pallet-1', diameterMm: 600, count: 1, rolls: sixRollsOf395 }]}
  maxStackHeightMm={2550}
  rollTypes={rollTypes}
  patternTitles={{ 'pallet-1': 'Pallet 1' }}
  assignmentsByPattern={{
    'pallet-1': [
      { rollNumber: '1234', widthMm: 395 },
      { rollNumber: '1235', widthMm: 395 },
    ],
  }}
/>

Roll numbers belong to one physical pallet, so in packaging mode pass one pattern per pallet with count: 1 and key the assignments by its id — a pattern with count: 6 is six different pallets. Passing the prop at all switches the graphic into packaging mode, so a pattern with no entry is drawn entirely faded.

Slots are filled bottom-up, and a roll takes the lowest free slot whose planned width matches its own — so a mixed 900 + 900 + 390 pallet stays correct no matter what order the rolls are entered in. A roll whose width matches no free slot still takes the lowest free one but is outlined in the error colour and shows its measured width; rolls left over once the pallet is full are listed under the card as extras. Use widthToleranceMm to allow a measurement margin, unassignedOpacity to change the fade, and formatAssignedCount / labels.extraRolls to localize the texts.

Roll numbers are drawn on a translucent plate in a monospace font, and the type size shrinks to fit both the segment height and the roll width, so long codes stay legible whatever the host theme is. Override with theme.rollNumberBackground, theme.rollNumberColor and rollNumberFontFamily.

The same matching is available without React:

import { assignRollsToPattern } from 'paper-roll-pallet';

const { slots, extras, assignedCount, complete } = assignRollsToPattern(
  pattern.rolls,
  [{ rollNumber: '1234', widthMm: 395 }],
);

Customizing strings, number formatting, and colours

<PackagingPlanGraphic
  {...props}
  labels={{ legend: 'Rullatyypit', addPattern: 'Uusi lavotus' }}
  formatValue={(mm) => `${mm.toLocaleString('fi-FI')} mm`}
  theme={{ hoverBorderColor: '#0057b8' }}
/>

Development

npm run build       # tsup -> dist/{index,react}.{js,cjs,d.ts}
npm test             # vitest run — pure-logic tests only

No component tests are included for PackagingPlanGraphic — UI is verified manually via a dev server in the consuming app.