@rtkelly-labs/design-system 0.18.0 → 0.19.0

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @rtkelly-labs/design-system main entrypoint\n\nexport * from './tokens';\n\n// The theme ladder — the single source for level names, level colours, and the\n// contrast arithmetic that gates them.\nexport * from './theme/levels';\nexport {\n MEDIA,\n CSS_MEDIUM,\n MEDIA_DEFINITIONS,\n isMedium,\n} from './theme/media';\nexport type {\n Medium,\n MediumDefinition,\n TypeStep,\n TypeStepName,\n Motion,\n} from './theme/media';\nexport * from './theme/contrast';\nexport { ANSI_SLOTS, SLOTS, ansiScheme } from './theme/ansi';\nexport type { AnsiSlot, AnsiScheme, AnsiChrome } from './theme/ansi';\n\n// Semantic theming — prefer these over the raw palette in `tokens`.\nexport * from './lib/theme';\nexport * from './theme/recommended';\n// Only `cn` is public. `recipe`'s type comes from the library that implements\n// it, so exporting it would put that library back into the published .d.ts and\n// make replacing it a breaking change. Components import it directly.\nexport { cn } from './lib/recipe';\nexport type { ClassInput } from './lib/recipe';\nexport * from './lib/slug';\n\n// Hooks\nexport * from './hooks/useCopyToClipboard';\nexport * from './hooks/useActiveHeading';\nexport * from './hooks/useTraceClock';\nexport * from './hooks/useTraceReplay';\n\n// Primitives & Callouts\nexport * from './components/Button';\nexport * from './components/Card';\nexport * from './components/Badge';\n// The report frame — the page a generated report is built in. Separate from\n// the docs components because a report is written by a tool and read once,\n// where a docs page is written by a person and read often: the frame owns the\n// measure, the header strip and the print behaviour, and everything inside it\n// is ordinary composition.\nexport * from './components/ReportDocument';\n\n// The colour-instead-of-role rules, and the scanner over them. Published\n// because a tool generating markup against this system should be able to hold\n// itself to the same rule the system holds itself to — the report generator\n// lints at budget zero with exactly these.\nexport { TOKEN_RULES, scanRules, scanTokenRules } from './lib/tokenRules';\nexport type { Finding, TokenRule } from './lib/tokenRules';\nexport * from './components/Avatar';\nexport * from './components/PageTitle';\nexport * from './components/PageHeader';\nexport * from './components/Tag';\nexport * from './components/Pagination';\n// The tablist. There is exactly one in this tree: `CodeTabs` renders through\n// it rather than hand-rolling a second keyboard model — see #240, and #163 for\n// why it is first-party rather than a wrapper over Base UI.\nexport * from './components/Tabs';\nexport * from './components/SectionContainer';\nexport * from './components/Divider';\nexport * from './components/AsciiDivider';\nexport * from './components/ThemeProvider';\n// Server-safe: a root layout calls `getThemeInitScript`, and that layout is a\n// server component under the Next App Router. See the module's header.\nexport * from './components/themeInitScript';\nexport * from './components/BracketText';\nexport * from './components/NoteBlock';\nexport * from './components/TLDR';\n// Named rather than `export *`: `Input.tsx` also exports the field recipe\n// `Select` draws its trigger with, and a recipe's type is `tailwind-variants`'.\nexport { Input, TextArea } from './components/Input';\nexport type { InputProps, TextAreaProps } from './components/Input';\n// One of a fixed set (#164): the same field as `Input`, with a listbox this\n// system paints instead of the operating system's, and `native` for the\n// platform picker when that is the better phone experience.\nexport * from './components/Select';\n// The booleans, added together: one capability in two presentations,\n// composing the same Field as the text controls above.\nexport * from './components/Checkbox';\nexport * from './components/Switch';\n// The groups (#239): `Fieldset` and `Legend` are the set's label, description\n// and error on the same Field contract, and `RadioGroup` / `Radio` are the\n// choose-one control built on that frame rather than beside it.\nexport * from './components/Fieldset';\nexport * from './components/RadioGroup';\n// The form-level half of validation (issue 50): the field errors above,\n// gathered at the top of the form as links that move focus to each field.\nexport * from './components/ErrorSummary';\nexport * from './components/Swatch';\nexport * from './components/StatCard';\nexport * from './components/Table';\nexport * from './components/DataTable';\nexport * from './components/Modal';\nexport * from './components/AlertDialog';\nexport * from './components/Drawer';\n\n// The application layout (#247): sidebar, topbar and main as five composable\n// pieces, with the sidebar off-canvas in a `Drawer` below desktop width.\nexport * from './components/AppShell';\n\n// System feedback — the three states an application has besides \"loaded\".\n// One vocabulary on purpose: the same motion tokens, the same reduced-motion\n// rule, the same muted surface, so a loading card and an empty table read as\n// the same system rather than as two consumers' guesses.\nexport * from './components/Spinner';\nexport * from './components/Skeleton';\nexport * from './components/Progress';\nexport * from './components/EmptyState';\n// The page-level states (#251) — 404, 500, maintenance, offline, unauthorized\n// — as `EmptyState` in a page frame, not a component family of their own.\nexport * from './components/StatusPage';\n\n// The floating set (#166): anchored to a trigger, positioned by the same\n// engine, dismissed by the same stack as the dialogs above. `Tooltip` labels,\n// `Popover` shows content, `Menu` offers actions.\nexport * from './components/Tooltip';\nexport * from './components/Popover';\nexport * from './components/Menu';\n\n// Site chrome (issue 246): the banner, the navigation in its two widths, and\n// the footer — layouts and landmarks that hold no items of their own. The\n// link adapter is the package's one, shared with the docs chrome: a router's\n// `Link` and its current-route test are injected once and reach both.\nexport {\n LinkProvider,\n SiteLink,\n isExternalHref,\n useIsCurrentHref,\n useLinkComponent,\n} from './components/LinkProvider';\nexport type {\n LinkComponentProps,\n LinkProviderProps,\n SiteLinkProps,\n} from './components/LinkProvider';\nexport * from './components/SiteHeader';\nexport * from './components/SiteNav';\nexport * from './components/MobileNav';\nexport * from './components/SiteFooter';\n\n// Marketing sections (issue 248): the parts a landing page is composed from.\n// Layouts that hold no copy — `SaasLandingPage` below is one composition of\n// them, and the `SaaS/LandingPage` stories build two more.\nexport * from './components/marketing/Hero';\nexport * from './components/marketing/FeatureGrid';\nexport * from './components/marketing/PricingGrid';\nexport * from './components/marketing/CTASection';\n\n// Transient notifications. Not an overlay: a toast shares neither the\n// positioning nor the dismissal model of Tooltip/Popover/Menu — it is a queue,\n// a live region and a lifetime (#243).\nexport * from './components/Toast';\n\nexport * from './components/NerdIcon';\nexport * from './components/SocialIcon';\nexport * from './components/Glyph';\n\n// Terminal & Monospace Telemetry Primitives\nexport * from './components/AsciiGauge';\nexport * from './components/TelemetryGauge';\nexport * from './components/TickerTape';\n\n// Chart Primitives & Trend Visualizers\nexport * from './components/BarChart';\nexport * from './components/Sparkline';\nexport * from './components/ChartTooltip';\nexport * from './components/BulletChart';\n// Traces: one React-free model (`lib/trace`) — layout, critical path, OTLP\n// parsing — drawn by the waterfall and the viewer around it.\nexport * from './lib/trace';\nexport * from './components/TraceWaterfall';\nexport * from './components/TraceViewer';\n// Observability (#407): one time window and hover cursor that every view on a\n// page shares, and the views that follow it. Each works standalone too.\nexport * from './lib/timeRange';\nexport * from './components/TimeRange';\nexport * from './lib/severity';\nexport * from './components/SeverityBadge';\nexport * from './components/TimeSeriesChart';\nexport * from './lib/latency';\nexport * from './components/LatencyHistogram';\nexport * from './components/LatencyHeatmap';\nexport * from './lib/logs';\nexport * from './components/LogViewer';\nexport * from './lib/filters';\nexport * from './components/FilterBar';\nexport * from './lib/serviceGraph';\nexport * from './components/ServiceMap';\nexport * from './components/AlertList';\nexport * from './components/IncidentTimeline';\nexport * from './components/FreshnessIndicator';\nexport * from './lib/ids';\nexport * from './components/IdChip';\n\n// Slides & Presentation Deck Engine\nexport * from './components/slides/Slide';\nexport * from './components/slides/SlideDeck';\n\n// Blog & Editorial Post Foundations\nexport * from './components/blog/BlogPost';\nexport * from './components/blog/LoremIpsumPost';\nexport * from './components/MetadataGrid';\nexport * from './components/TrackCard';\nexport * from './components/ColophonCard';\n\n// Experiments Page & Design System Sandbox\nexport * from './components/experiments/ExperimentsView';\nexport * from './components/experiments/DesignSandbox';\n\n// SaaS Landing Pages\nexport * from './components/saas/SaasLandingPage';\nexport * from './components/saas/ObservabilityConsole';\n\n// Documentation Portal Chrome & MDX Rendering\nexport * from './components/docs';\n"],"mappings":";AAEA,cAAc;AAId,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,cAAc;AACd,SAAS,YAAY,OAAO,kBAAkB;AAI9C,cAAc;AACd,cAAc;AAId,SAAS,UAAU;AAEnB,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAMd,cAAc;AAMd,SAAS,aAAa,WAAW,sBAAsB;AAEvD,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,SAAS,OAAO,gBAAgB;AAKhC,cAAc;AAGd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AAMd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AAMd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAKd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// @rtkelly-labs/design-system main entrypoint\n\nexport * from './tokens';\n\n// The theme ladder — the single source for level names, level colours, and the\n// contrast arithmetic that gates them.\nexport * from './theme/levels';\nexport {\n MEDIA,\n CSS_MEDIUM,\n MEDIA_DEFINITIONS,\n isMedium,\n} from './theme/media';\nexport type {\n Medium,\n MediumDefinition,\n TypeStep,\n TypeStepName,\n Motion,\n} from './theme/media';\nexport * from './theme/contrast';\nexport { ANSI_SLOTS, SLOTS, ansiScheme } from './theme/ansi';\nexport type { AnsiSlot, AnsiScheme, AnsiChrome } from './theme/ansi';\n\n// Semantic theming — prefer these over the raw palette in `tokens`.\nexport * from './lib/theme';\nexport * from './theme/recommended';\n// Only `cn` is public. `recipe`'s type comes from the library that implements\n// it, so exporting it would put that library back into the published .d.ts and\n// make replacing it a breaking change. Components import it directly.\nexport { cn } from './lib/recipe';\nexport type { ClassInput } from './lib/recipe';\nexport * from './lib/slug';\nexport * from './lib/units';\n\n// Hooks\nexport * from './hooks/useCopyToClipboard';\nexport * from './hooks/useActiveHeading';\nexport * from './hooks/useTraceClock';\nexport * from './hooks/useTraceReplay';\nexport * from './hooks/usePolledResource';\n\n// Primitives & Callouts\nexport * from './components/Button';\nexport * from './components/InlineAction';\nexport * from './components/Card';\nexport * from './components/Badge';\n// The report frame — the page a generated report is built in. Separate from\n// the docs components because a report is written by a tool and read once,\n// where a docs page is written by a person and read often: the frame owns the\n// measure, the header strip and the print behaviour, and everything inside it\n// is ordinary composition.\nexport * from './components/ReportDocument';\n\n// The colour-instead-of-role rules, and the scanner over them. Published\n// because a tool generating markup against this system should be able to hold\n// itself to the same rule the system holds itself to — the report generator\n// lints at budget zero with exactly these.\nexport { TOKEN_RULES, scanRules, scanTokenRules } from './lib/tokenRules';\nexport type { Finding, TokenRule } from './lib/tokenRules';\nexport * from './components/Avatar';\nexport * from './components/PageTitle';\nexport * from './components/PageHeader';\nexport * from './components/Tag';\nexport * from './components/Pagination';\n// The tablist. There is exactly one in this tree: `CodeTabs` renders through\n// it rather than hand-rolling a second keyboard model — see #240, and #163 for\n// why it is first-party rather than a wrapper over Base UI.\nexport * from './components/Tabs';\nexport * from './components/SectionContainer';\nexport * from './components/Divider';\nexport * from './components/AsciiDivider';\nexport * from './components/ThemeProvider';\n// Server-safe: a root layout calls `getThemeInitScript`, and that layout is a\n// server component under the Next App Router. See the module's header.\nexport * from './components/themeInitScript';\nexport * from './components/BracketText';\nexport * from './components/NoteBlock';\nexport * from './components/TLDR';\n// Named rather than `export *`: `Input.tsx` also exports the field recipe\n// `Select` draws its trigger with, and a recipe's type is `tailwind-variants`'.\nexport { Input, TextArea } from './components/Input';\nexport type { InputProps, TextAreaProps } from './components/Input';\n// One of a fixed set (#164): the same field as `Input`, with a listbox this\n// system paints instead of the operating system's, and `native` for the\n// platform picker when that is the better phone experience.\nexport * from './components/Select';\n// The booleans, added together: one capability in two presentations,\n// composing the same Field as the text controls above.\nexport * from './components/Checkbox';\nexport * from './components/Switch';\n// The groups (#239): `Fieldset` and `Legend` are the set's label, description\n// and error on the same Field contract, and `RadioGroup` / `Radio` are the\n// choose-one control built on that frame rather than beside it.\nexport * from './components/Fieldset';\nexport * from './components/RadioGroup';\n// The form-level half of validation (issue 50): the field errors above,\n// gathered at the top of the form as links that move focus to each field.\nexport * from './components/ErrorSummary';\nexport * from './components/Swatch';\nexport * from './components/StatCard';\nexport * from './components/Table';\nexport * from './components/DataTable';\nexport * from './components/Modal';\nexport * from './components/AlertDialog';\nexport * from './components/Drawer';\n\n// The application layout (#247): sidebar, topbar and main as five composable\n// pieces, with the sidebar off-canvas in a `Drawer` below desktop width.\nexport * from './components/AppShell';\n\n// System feedback — the three states an application has besides \"loaded\".\n// One vocabulary on purpose: the same motion tokens, the same reduced-motion\n// rule, the same muted surface, so a loading card and an empty table read as\n// the same system rather than as two consumers' guesses.\nexport * from './components/Spinner';\nexport * from './components/Skeleton';\nexport * from './components/Progress';\nexport * from './components/EmptyState';\n// The page-level states (#251) — 404, 500, maintenance, offline, unauthorized\n// — as `EmptyState` in a page frame, not a component family of their own.\nexport * from './components/StatusPage';\n\n// The floating set (#166): anchored to a trigger, positioned by the same\n// engine, dismissed by the same stack as the dialogs above. `Tooltip` labels,\n// `Popover` shows content, `Menu` offers actions.\nexport * from './components/Tooltip';\nexport * from './components/Popover';\nexport * from './components/Menu';\n\n// Site chrome (issue 246): the banner, the navigation in its two widths, and\n// the footer — layouts and landmarks that hold no items of their own. The\n// link adapter is the package's one, shared with the docs chrome: a router's\n// `Link` and its current-route test are injected once and reach both.\nexport {\n LinkProvider,\n SiteLink,\n isExternalHref,\n useIsCurrentHref,\n useLinkComponent,\n} from './components/LinkProvider';\nexport type {\n LinkComponentProps,\n LinkProviderProps,\n SiteLinkProps,\n} from './components/LinkProvider';\nexport * from './components/SiteHeader';\nexport * from './components/SiteNav';\nexport * from './components/MobileNav';\nexport * from './components/SiteFooter';\n\n// Marketing sections (issue 248): the parts a landing page is composed from.\n// Layouts that hold no copy — `SaasLandingPage` below is one composition of\n// them, and the `SaaS/LandingPage` stories build two more.\nexport * from './components/marketing/Hero';\nexport * from './components/marketing/FeatureGrid';\nexport * from './components/marketing/PricingGrid';\nexport * from './components/marketing/CTASection';\n\n// Transient notifications. Not an overlay: a toast shares neither the\n// positioning nor the dismissal model of Tooltip/Popover/Menu — it is a queue,\n// a live region and a lifetime (#243).\nexport * from './components/Toast';\n\nexport * from './components/NerdIcon';\nexport * from './components/SocialIcon';\nexport * from './components/Glyph';\n\n// Terminal & Monospace Telemetry Primitives\nexport * from './components/AsciiGauge';\nexport * from './components/TelemetryGauge';\nexport * from './components/TickerTape';\n\n// Chart Primitives & Trend Visualizers\nexport * from './components/BarChart';\nexport * from './components/Sparkline';\nexport * from './components/ChartTooltip';\nexport * from './components/BulletChart';\n// Traces: one React-free model (`lib/trace`) — layout, critical path, OTLP\n// parsing — drawn by the waterfall and the viewer around it.\nexport * from './lib/trace';\nexport * from './components/TraceWaterfall';\nexport * from './components/TraceViewer';\n// Observability (#407): one time window and hover cursor that every view on a\n// page shares, and the views that follow it. Each works standalone too.\nexport * from './lib/timeRange';\nexport * from './components/TimeRange';\nexport * from './lib/severity';\nexport * from './components/SeverityBadge';\nexport * from './components/TimeSeriesChart';\nexport * from './lib/latency';\nexport * from './components/LatencyHistogram';\nexport * from './components/LatencyHeatmap';\nexport * from './lib/logs';\nexport * from './components/LogViewer';\nexport * from './lib/filters';\nexport * from './components/FilterBar';\nexport * from './lib/serviceGraph';\nexport * from './components/ServiceMap';\nexport * from './components/AlertList';\nexport * from './components/IncidentTimeline';\nexport * from './components/FreshnessIndicator';\nexport * from './components/ResourceState';\nexport * from './lib/ids';\nexport * from './components/IdChip';\n\n// Slides & Presentation Deck Engine\nexport * from './components/slides/Slide';\nexport * from './components/slides/SlideDeck';\n\n// Blog & Editorial Post Foundations\nexport * from './components/blog/BlogPost';\nexport * from './components/blog/LoremIpsumPost';\nexport * from './components/MetadataGrid';\nexport * from './components/TrackCard';\nexport * from './components/ColophonCard';\n\n// Experiments Page & Design System Sandbox\nexport * from './components/experiments/ExperimentsView';\nexport * from './components/experiments/DesignSandbox';\n\n// SaaS Landing Pages\nexport * from './components/saas/SaasLandingPage';\nexport * from './components/saas/ObservabilityConsole';\n\n// Documentation Portal Chrome & MDX Rendering\nexport * from './components/docs';\n"],"mappings":";AAEA,cAAc;AAId,cAAc;AACd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,cAAc;AACd,SAAS,YAAY,OAAO,kBAAkB;AAI9C,cAAc;AACd,cAAc;AAId,SAAS,UAAU;AAEnB,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAMd,cAAc;AAMd,SAAS,aAAa,WAAW,sBAAsB;AAEvD,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,SAAS,OAAO,gBAAgB;AAKhC,cAAc;AAGd,cAAc;AACd,cAAc;AAId,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AAMd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AAMd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAKd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAKd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;AACd,cAAc;AAGd,cAAc;","names":[]}
@@ -0,0 +1,25 @@
1
+ // src/lib/units.ts
2
+ var IEC = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
3
+ var SI = ["B", "kB", "MB", "GB", "TB", "PB"];
4
+ function render(size, unit) {
5
+ return unit === 0 ? String(Math.round(size)) : size.toFixed(1).replace(/\.0$/, "");
6
+ }
7
+ function formatBytes(bytes, options = {}) {
8
+ if (typeof bytes !== "number" || !Number.isFinite(bytes)) return "\u2014";
9
+ const base = options.base === 1e3 ? 1e3 : 1024;
10
+ const labels = base === 1e3 ? SI : IEC;
11
+ const top = labels.length - 1;
12
+ let size = Math.abs(bytes);
13
+ let unit = 0;
14
+ while (unit < top && Number(render(size, unit)) >= base) {
15
+ size /= base;
16
+ unit += 1;
17
+ }
18
+ const text = render(size, unit);
19
+ const sign = bytes < 0 && Number(text) !== 0 ? "-" : "";
20
+ return `${sign}${text} ${labels[unit]}`;
21
+ }
22
+ export {
23
+ formatBytes
24
+ };
25
+ //# sourceMappingURL=units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/units.ts"],"sourcesContent":["/**\n * Quantities with a unit ladder: a byte count written in the largest unit that\n * keeps it under the next one.\n *\n * Everything here is pure and React-free, so a server component or a script\n * can call it.\n */\n\n/** Options for {@link formatBytes}. */\nexport interface FormatBytesOptions {\n /**\n * The step between units. `1024` (the default) labels them with IEC binary\n * prefixes — `KiB`, `MiB`, `GiB`; `1000` with SI decimal prefixes — `kB`,\n * `MB`, `GB`.\n */\n base?: 1024 | 1000;\n}\n\nconst IEC = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'] as const;\nconst SI = ['B', 'kB', 'MB', 'GB', 'TB', 'PB'] as const;\n\n/** Whole bytes, one decimal above them, with a trailing `.0` dropped. */\nfunction render(size: number, unit: number): string {\n return unit === 0 ? String(Math.round(size)) : size.toFixed(1).replace(/\\.0$/, '');\n}\n\n/**\n * `512 B`, `1.5 KiB`, `20 MiB`, `3.2 TiB`: a byte count in the largest unit\n * that keeps it below the next one, whole for bytes and to one decimal above\n * them, with a trailing `.0` dropped as `formatShare` and `formatTraceDuration`\n * do. A space separates number and unit, as the SI and IEC conventions write\n * them.\n *\n * **Binary by default, and labelled as binary.** The counts this formats come\n * from the file system, memory and process accounting, which count in powers\n * of two — and Windows and most dashboards already divide by 1024. What they\n * get wrong is the label: `KB` for 1024 bytes is the JEDEC usage SI reserves\n * for 1000, so the same string means two numbers 2.4% apart at `KB` and 10%\n * apart at `TB`. `KiB` cannot be misread. Pass `{ base: 1000 }` for sizes\n * that are decimal by nature — network transfer, storage as a vendor states it\n * — and the labels become `kB`, `MB`, `GB`.\n *\n * The unit is chosen *after* rounding, so a value that would round up to the\n * base moves to the next unit: 1023.96 KiB is `1 MiB`, never `1024 KiB`, and\n * 1023.6 B is `1 KiB`. Petabytes are the top of the ladder; anything larger\n * stays in them (`2048 PiB`).\n *\n * A negative count — a size delta — keeps its sign (`-1.5 KiB`); `-0` is\n * `0 B`. `NaN` and `±Infinity` are `—`, as the other formatters here write a\n * value they cannot.\n */\nexport function formatBytes(bytes: number, options: FormatBytesOptions = {}): string {\n if (typeof bytes !== 'number' || !Number.isFinite(bytes)) return '—';\n const base = options.base === 1000 ? 1000 : 1024;\n const labels = base === 1000 ? SI : IEC;\n const top = labels.length - 1;\n let size = Math.abs(bytes);\n let unit = 0;\n // Step up while the value, as it would be printed, reaches the base.\n while (unit < top && Number(render(size, unit)) >= base) {\n size /= base;\n unit += 1;\n }\n const text = render(size, unit);\n const sign = bytes < 0 && Number(text) !== 0 ? '-' : '';\n return `${sign}${text} ${labels[unit]}`;\n}\n"],"mappings":";AAkBA,IAAM,MAAM,CAAC,KAAK,OAAO,OAAO,OAAO,OAAO,KAAK;AACnD,IAAM,KAAK,CAAC,KAAK,MAAM,MAAM,MAAM,MAAM,IAAI;AAG7C,SAAS,OAAO,MAAc,MAAsB;AAClD,SAAO,SAAS,IAAI,OAAO,KAAK,MAAM,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,QAAQ,QAAQ,EAAE;AACnF;AA2BO,SAAS,YAAY,OAAe,UAA8B,CAAC,GAAW;AACnF,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACjE,QAAM,OAAO,QAAQ,SAAS,MAAO,MAAO;AAC5C,QAAM,SAAS,SAAS,MAAO,KAAK;AACpC,QAAM,MAAM,OAAO,SAAS;AAC5B,MAAI,OAAO,KAAK,IAAI,KAAK;AACzB,MAAI,OAAO;AAEX,SAAO,OAAO,OAAO,OAAO,OAAO,MAAM,IAAI,CAAC,KAAK,MAAM;AACvD,YAAQ;AACR,YAAQ;AAAA,EACV;AACA,QAAM,OAAO,OAAO,MAAM,IAAI;AAC9B,QAAM,OAAO,QAAQ,KAAK,OAAO,IAAI,MAAM,IAAI,MAAM;AACrD,SAAO,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,IAAI,CAAC;AACvC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtkelly-labs/design-system",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Brutalist design system for Ryan Kelly websites: a two-level theme ladder, role-addressed tokens, and Base UI-backed components",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -97,7 +97,7 @@
97
97
  "test:watch": "vitest",
98
98
  "test:coverage": "vitest run --coverage",
99
99
  "test:leaks": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/vitest-leaks.mjs",
100
- "storybook": "storybook dev -p 6006",
100
+ "storybook": "storybook dev -p 8100",
101
101
  "build-storybook": "storybook build -o storybook-static",
102
102
  "test:a11y": "playwright test tests/a11y.spec.ts",
103
103
  "test:visual": "playwright test tests/visual.spec.ts",