@printhive/react
v0.3.0
Published
PrintHive components for React, one import path for each feature
Readme
@printhive/react
React components that put PrintHive inside your own app. Each feature has its own import path, so your bundle holds only the features you use.
The package ships filament management and the action pill today. A filament component shows a printer's nozzles, AMS units, and spools, and lets a person assign or clear a filament and ask for an RFID reread. The action pill is PrintHive's button for an operator command. Printer status, load plan, job status, and operator ready components will follow, each under its own path.
Your server holds the PrintHive API key. The browser talks to a small handler on your server, which checks your user's session and calls PrintHive. The key never reaches the browser.
Install
bun add @printhive/react @printhive/api @tanstack/react-query @ui-sdk/corereact and react-dom are required peer dependencies. @tanstack/react-query and @printhive/api are optional peers, so your package manager does not warn when one is missing, and the entry that needs it fails to load without it. Install the ones your entries use.
| Package | Range | Used for | Needed by |
| ----------------------- | ------- | ------------------------------------------------------------ | -------------------------------------------------- |
| react, react-dom | >=19 | Components | Every entry |
| @tanstack/react-query | ^5.56.2 | Server state. You may pass your own QueryClient | @printhive/react (the provider) and /filaments |
| @printhive/api | ^0.9.0 | Response guards in the browser and the client on your server | /filaments and /server |
@printhive/react/glance-pill needs neither optional peer, so an app that only wants the action pill runs bun add @printhive/react @ui-sdk/core.
Install @ui-sdk/core yourself, because your entry imports its stylesheet and strict layouts do not expose it through this package. TypeScript projects need @types/react 19.2.10 or later.
Import only what you use
| Import | Exports | Runs in |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------- |
| @printhive/react | PrintHiveProvider, PrintHiveProviderProps, PrintHiveConnection, PrintHiveColorScheme | Browser |
| @printhive/react/filaments | FilamentManagement, createFilamentManagementDataSource, FilamentManagementError, and the filament types | Browser |
| @printhive/react/glance-pill | GlancePill and its types: GlancePillProps, GlancePillKind, GlancePillFeedback, GlancePillHold | Browser |
| @printhive/react/server | createPrintHiveHandler, filaments, and the handler types | Server |
The root entry holds the provider and no feature code. Import a feature from its own path and nothing else comes along. ESM and CommonJS builds both ship, and TypeScript resolves each path under moduleResolution node10, node16, and bundler. Zod is a dependency of /server only, so the browser entries never load it.
require() of a browser entry needs Node 20.19 or 22.12 or later, because @ui-sdk/react ships as ESM only and the CommonJS build loads it with require(esm). Load one format per process. The ESM and CommonJS builds each hold their own provider context, so a provider from one build does not reach a component from the other.
Show filament management
Wrap your features in one provider and point it at your backend route. Then render the component with a printer ID.
import "@ui-sdk/core/web.css";
import "@printhive/react/base.css";
import "@printhive/react/filaments.css";
import { PrintHiveProvider } from "@printhive/react";
import { FilamentManagement } from "@printhive/react/filaments";
export function PrinterFilaments({ printerId }: { printerId: string }) {
return (
<PrintHiveProvider connection={{ baseUrl: "/api/printhive" }}>
<FilamentManagement printerId={printerId} />
</PrintHiveProvider>
);
}The browser entries start with "use client", so a React Server Component can render them directly. Props that cross that boundary must be serializable. A custom fetch or a dataSource is a function, so pass those from a client component.
connection takes baseUrl and an optional fetch. The browser sends credentials: "same-origin". Pass your own fetch when your backend needs a CSRF header or another credential policy. A new connection object or a new inline fetch on every render is fine. The component keeps its state, such as an open editor, and later requests go through the newest fetch. A request already in flight finishes through the fetch it started with, so remount on a credential change as described below. Only a changed baseUrl starts a new cache scope. Two providers that share your queryClient and baseUrl also share cache entries.
The provider creates a QueryClient with no retries, no refetch on window focus, and a gcTime of 0. Pass queryClient to use your own. Either way, your application's QueryClientProvider stays untouched. The layout and catalog queries set their own retry, refetch, stale time, and cache time, so they behave the same under your client's defaults. Queries and writes never throw to an error boundary; the component shows the error itself.
Cache keys carry the connection's baseUrl, so a changed baseUrl reads fresh data. The user and organization are not part of the key, because your backend decides them from the session. When the user or organization changes, remount the provider with a key that changes, and it creates a fresh client unless you passed one. Clear a client you passed in:
queryClient.removeQueries({
predicate: (query) => String(query.queryKey[0]).startsWith("printhive-"),
});FilamentManagement builds its data source from the provider's connection. Pass a dataSource prop to use your own backend functions, a test double, or a demo fixture. The provider still needs a connection, which a custom data source never uses. Keep the dataSource object stable, for example with useMemo or at module scope. A new object starts a new cache scope and remounts the component.
<FilamentManagement printerId={printerId} dataSource={myDataSource} />A FilamentManagementDataSource implements read, search, assign, clear, and refreshRfid.
Show an action pill
GlancePill is PrintHive's button for an operator command: a pill with an icon and a label. It is a ui-sdk Button, so it keeps ui-sdk's press, focus and disabled behavior. It needs no data source and no connection, and it works without a PrintHiveProvider. A provider above it sets the color scheme.
import "@ui-sdk/core/web.css";
import "@printhive/react/base.css";
import "@printhive/react/glance-pill.css";
import { GlancePill } from "@printhive/react/glance-pill";
export function ResumeButton({ feedback, resume }: ResumeButtonProps) {
return (
<GlancePill
kind="physical"
icon={<PlayIcon />}
label="Resume"
pendingLabel="Resuming…"
feedback={feedback}
onClick={resume}
/>
);
}| Prop | Sets |
| ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| kind | What the command does: neutral, physical (sends a command to the printer), recovery (repairs a state), danger (can not be undone) or primary. |
| feedback | How far the command has got: idle, pending, confirmed or unconfirmed. The default is idle. |
| icon, label | The icon, and the text that names the pill. A labelled pill has no aria-label, so its name is its text. |
| pendingLabel | Replaces label on screen while feedback is pending. The pill is as wide as the longer of the two, so it does not jump. See Names and announcements. |
| hold | { ms, onComplete, opensConfirmation? }. The pill needs a press held for ms before it calls onComplete. |
| shortcut | ui-sdk keys such as r or mod+r, with + or mod++ for the plus key. The pill shows them for the platform and sets aria-keyshortcuts. It does not listen for them. A string with an empty key, such as a+, shows nothing. |
| iconOnly | The icon alone in a 28 px circle, 32 px on a touch screen, with a 44 px hit area. label is its aria-label, and it never changes. |
| pendingAnnouncement, confirmedAnnouncement, unconfirmedAnnouncement | What a screen reader hears. See Names and announcements. |
| disabled and the rest | The attributes of a native button, plus ui-sdk's focusableWhenDisabled and type, and onClick(event, { source }), which may return a Promise. aria-disabled="true" counts as disabled with focusableWhenDisabled. aria-pressed draws a pressed look. There is no children or render. |
className takes a string and style takes an object. Both join the pill's own. The pill sets data-kind, data-ring, data-pending, aria-busy and its data-say-* messages itself, and a prop of the same name is dropped.
Feedback and the pending state
Your code owns the command, so it sets feedback. A pill with feedback="pending" does what a pending ui-sdk Button does. It sets aria-busy, aria-disabled and data-pending, keeps focus, and ignores presses. It shows the pending label and a turning trace around its edge. When you set confirmed, the trace closes into a ring with a short glow. The ring holds for 1.2 seconds, even if you have returned to idle, and then fades over 200 ms. unconfirmed draws an amber ring that stays while you report it and fades 200 ms after you return to idle.
A click handler that returns a Promise gives the pill ui-sdk's own pending state, which keeps it from being pressed twice and announces after a second. That state ends when the Promise settles, which is the click and not the command. Use feedback when the printer must confirm the command after the click.
Names and announcements
A swap of text is a rename, and ui-sdk's Button docs say a screen reader does not reliably announce a new name on the focused button. So the pill keeps the name where it can. An iconOnly pill is named by label through aria-label, in every state. A labelled pill has no aria-label. Without a pendingLabel its name is its text, in every state.
With a pendingLabel the pill uses ui-sdk's data-show swap, the one the Button docs show for text that has to change. The two labels sit in one cell. The one that does not apply is visibility: hidden, not display: none, so the pill keeps its width and the hidden text leaves the accessibility tree. The name follows the text on screen, as WCAG 2.5.3 asks, and it changes while pending. Drop pendingLabel for a name that never changes. The announcement below tells assistive technology that the command is running either way.
The pill announces through ui-sdk's announce, in the document that holds it. It makes ui-sdk's live regions when it mounts, as the ui-sdk docs advise for a component that announces soon after it appears.
- Pending. A busy period that lasts one second, as Button's does, is announced once with
pendingAnnouncement. That defaults topendingLabel, then to "Loading". An empty string says nothing. A wait that ends sooner says nothing. - Confirmed and unconfirmed. When
feedbackbecomesconfirmedorunconfirmed, it announcesconfirmedAnnouncementorunconfirmedAnnouncementif you set it. Without the prop it says nothing, because your app usually shows the result elsewhere. Set both when the pill is the only feedback. A pill that mounts already confirmed or unconfirmed draws its ring and says nothing, because it did not see the outcome arrive, and a remount, a tab switch or hydration would otherwise say it again. A caller whose pill mounts because of the outcome, such as a pill that appears when a command finishes, announces the outcome itself.
The pill owns the pending announcement for both ways of being pending, and it gives ui-sdk's Button an empty pendingAnnouncement, so Button never says it too. Busy means feedback is pending, or a Promise that onClick returned is running, or both. The pill watches the data-pending attribute that both set, so a Promise followed by feedback="pending" is one busy period and one announcement, at one second after the first of them began. The announcement is skipped when an outcome lands during the busy period, so a Promise that outlives its outcome does not say "Pausing…" after it, even when the outcome arrives in the same update that starts the Promise. A ring that is older than the period does not skip it: a retry whose wait is only a Promise is announced while the amber ring of the attempt before it still shows. A change to a label or to any message prop while the pill is busy or holding a ring changes what the pill says next, and does not say anything again or restart the ring.
Hold to confirm
A hold uses ui-sdk's bindHold. A pointer, Enter or Space starts it, and data-holding marks it while it runs. A fill crosses the pill over ms, and releasing early drains it. A press ends without calling onComplete when the pointer leaves the pill, moves more than 10 pixels, or is cancelled by the browser, when the window or the pill loses focus, and on Escape. A short press does nothing, and a held pill never submits its form, whatever its type. A fresh onComplete on each render does not restart a hold, and a hold calls the onComplete of the render that was current when the press began, however the key repeats and whatever else is pressed during it. A hold that begins after a re-render uses that render's.
Say in the label that the button needs holding, as ui-sdk advises: "Hold to stop", not "Stop". A press that is cancelled does not click, and a person who only taps gets no other hint.
Set opensConfirmation when onComplete only opens a confirmation step. A pointer still holds. The keyboard and assistive technology do not: Enter, Space or a screen reader's activation calls onComplete on release, with no timed hold, and a key that repeats from another element does not call it. A key pressed before the pill became pending or disabled does nothing when it is released after the pill is available again. Without opensConfirmation, a screen reader that sends a plain click can not complete the hold, so prefer it whenever a confirmation follows.
A hold works when the pill is the element of another ui-sdk part, such as <TooltipTrigger render={<GlancePill … />} /> or a ToolbarButton, or when you pass onKeyDown or onPointerDown. The pill records its callback in capture handlers, which run before those handlers and before ui-sdk's native listener. bindHold binds natively, ahead of React, so a caller's onPointerDown that calls preventDefault does not stop a hold. To make a pill refuse a hold, pass disabled or aria-disabled, which end a hold under way without calling onComplete.
Known limits
- A ref callback that you write inline, such as
ref={(node) => …}, gets a new identity on every render, so React runs it again and ends a hold that is under way. Pass a stable ref, such as auseRefobject. The web pill behaves the same. - A pointer that leaves the pill's box ends a hold at once, even by a pixel, where ui-sdk alone allows 10 pixels. A press on the very edge can cancel itself. The web pill behaves the same.
useShortcutHintin ui-sdk throws on an empty key, so the pill drops a shortcut with one instead of passing it on.
Pill tokens, motion and support
The pill is its own root. It carries the ph-root class and reads the tokens in the table above, so a host that sets --ph-accent, --ph-warning or --ph-danger restyles it. The kinds map onto them: the accent for physical icons, the ring and the primary fill, the warning for recovery and an unconfirmed ring, and the danger color for danger icons and a hold. The hold fill mixes the danger color with the surface, 60 percent in light and 48 percent in dark, so it is 3.3:1 against the surface in both schemes and the label on it is 6.0:1 in light and 5.1:1 in dark. The icon and the shortcut hint take the text color while a hold runs, because a colored icon would not hold 3:1 on the fill. With the default tokens, contrast holds in both schemes: 4.5:1 for text and 3:1 for icons, borders, rings, fills and the focus outline. A host that changes a token checks its own pairs.
The pill resets min-height, text-transform, letter-spacing, box-shadow and background-image, so a host's button rules do not reshape it, and filaments.css leaves it out of its generic button rules. On a touch screen a labelled pill is 44 px tall and an icon-only circle is 32 px.
A press scales the pill to 0.97 and a fine pointer gets a hover tint. A pill with aria-pressed="true" shows the accent as a tint and an edge, and a hover does not undo it. Keyboard activation does not animate, apart from a hold. Under prefers-reduced-motion: reduce the trace is a still ring that fades, the glow and the press scale stop, and a hold appears as a fill that fades in without moving. Under forced-colors: active each state keeps a shape that needs no hue and changes no size: a dashed border on the ring's own element for pending, a solid one for confirmed, a double one for unconfirmed, and a bar of progress for a hold. The pill's own border keeps its width. Idle primary is the one filled pill, ButtonText with a ButtonFace label, and a pressed pill is the one that paints Highlight. Both turn forced-color-adjust off, because Chromium puts a Canvas backplate behind the text of an adjusted element and the label would go blank on a fill. A primary pill under a ring or a hold, and a disabled one, falls back to ButtonFace. The kinds other than primary differ by the system link, active and visited colors alone, which some palettes make alike.
The turning trace needs @property (Chrome 85, Safari 16.4, Firefox 128) and mask-composite (Chrome 85 with a prefix, Safari 15.4, Firefox 53). A browser without @property draws the trace as a still arc and closes the ring at once. A browser without mask-composite draws a plain ring and no trace.
The pill sets font-size in rem, so it follows the font size of the page. Its label ends in an ellipsis when the container is too narrow, so it never overflows.
Mount the server handler
Create one handler with the features you serve. It routes only those features.
import { PrintHive } from "@printhive/api";
import { createPrintHiveHandler, filaments } from "@printhive/react/server";
const apiKey = process.env.PRINTHIVE_API_KEY;
if (!apiKey) throw new Error("PRINTHIVE_API_KEY is required");
export const printhive = createPrintHiveHandler({
client: new PrintHive({ apiKey }),
features: [filaments()],
authorize: async (request, { printerId }) => {
const user = await getSessionUser(request);
if (!user || printerId === null) return null;
if (!(await canUsePrinter(user, printerId))) return null;
return user.canControlPrinters ? "control" : "read";
},
});Mount printhive as a catch-all for everything under /api/printhive/. Pass the original Fetch Request, including its session headers, and return the handler's Response. In Next.js that is app/api/printhive/[...path]/route.ts:
import { printhive } from "@/lib/printhive";
export { printhive as GET, printhive as POST };Mount the whole path instead of one route, because a feature may serve other paths, take no printer, or stream its answer.
authorize runs on every request, including catalog searches. Verify the user's session, their access to that printer, and your CSRF policy there. Return "read" for reads, "control" for reads and writes, or null to refuse. The second argument is { feature, printerId }. feature names the feature that matched, so one function can apply a different rule to each. printerId is null for a route that has no printer in its path, and every filament route has one. A "read" user gets a layout with every action marked unavailable, and the handler refuses their writes. PrintHive's API checks the key's organization, its capabilities, and the printer's current state again.
To mount the handler elsewhere, set basePath on it and the same path in the browser's connection.baseUrl. Keep the PrintHive API key on the server.
Filament routes
filaments() serves these routes under ${basePath}/printers/:printerId/. :printerId is the printer's UUID. A POST must send application/json.
| Route | Method | Access |
| ------------------------ | ------ | --------- |
| filaments | GET | read |
| filaments/catalog?q= | GET | read |
| filaments/assign | POST | control |
| filaments/clear | POST | control |
| filaments/refresh-rfid | POST | control |
filaments/ and filaments/read also read the layout. A path with no match answers 404, and a known path with the wrong method answers 405.
Style the components
Import the stylesheets next to your component imports.
| Import | Holds |
| --------------------------------------- | --------------------------------------------------------------- |
| @printhive/react/base.css | The shared --ph-* tokens, a reset, the swatch, and focus ring |
| @printhive/react/filaments.css | Filament management. Import it after base.css |
| @printhive/react/glance-pill.css | The action pill. Import it after base.css |
| @printhive/react/styles.css | base.css and every feature stylesheet in one file |
| @printhive/react/themes/printhive.css | PrintHive's own look. Optional. Import it after base.css |
Import base.css first, then the feature files. Use styles.css when you want every feature and accept the extra CSS.
Every component's root carries the ph-root class, which declares the tokens. Override a token with a rule of your own that loads after the package stylesheet.
.ph-root {
--ph-accent: #6d28d9;
--ph-accent-text: #ffffff;
--ph-radius: 0;
}| Token | Default | Sets |
| ----------------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| --ph-font | Not set. The component uses the font of your page. | The font family |
| --ph-background, --ph-surface, --ph-text | light-dark() pairs | The root, the cards and editor, and the text |
| --ph-muted | light-dark(#475569, #94a3b8) | Secondary text |
| --ph-border | light-dark(#64748b, #7c8ba1) | Borders. 4.8:1 on the surface and 4.3:1 on the background in light, 5.2:1 and 4.2:1 in dark |
| --ph-accent | light-dark(#2563eb, #60a5fa) | The fill of the primary button |
| --ph-accent-text | light-dark(#ffffff, #0f172a) | Text on the accent. 5.2:1 in light and 7.0:1 in dark. Set it with --ph-accent |
| --ph-accent-border | The accent mixed with 25 percent black | The border of the primary button. It follows --ph-accent |
| --ph-backdrop | light-dark(rgb(15 23 42 / 0.45), rgb(0 0 0 / 0.7)) | The scrim behind the slot editor |
| --ph-radius, --ph-radius-lg | 4px, 8px | Cards, controls and inputs, and the root and the editor |
| --ph-focus, --ph-danger, --ph-warning, --ph-success | light-dark() pairs | The focus ring and the status colors |
The default colors are a neutral slate with a blue accent, so the components sit in most apps without a theme of their own. The accent changes with the scheme, and each one holds at least 4.5:1 against its text. A color you pick for --ph-accent needs its own --ph-accent-text that holds 4.5:1 against it.
The tokens also include the motion curve --ph-ease-out, the durations --ph-duration-press, --ph-duration-fast, --ph-duration-base and --ph-duration-slow, and the loading placeholder's --ph-duration-pulse and --ph-delay-loading. The slot editor and the catalog list fade and scale in and out. Buttons and slot cards shrink slightly while pressed, and a fine pointer gets a hover tint. The primary button's accent fill shifts a little toward the text color instead. A catalog list that the keyboard opens or closes does not animate. Under prefers-reduced-motion: reduce the scaling stops and only the short fades stay.
Use the PrintHive look
themes/printhive.css replaces the neutral colors with PrintHive's ink, bone and neon, and sets --ph-font to Space Grotesk. Import it after base.css and before your own overrides.
import "@printhive/react/base.css";
import "@printhive/react/filaments.css";
import "@printhive/react/themes/printhive.css";The package does not load Space Grotesk. Load the font yourself, or the components fall back to the system sans serif. The light accent is a green that holds 5.0:1 against white text, and the dark accent is the neon #39ff14. styles.css does not include the theme.
Choose light or dark
The components follow the operating system's setting through prefers-color-scheme. They do not read the color-scheme of your page. To follow your own theme switch, pass colorScheme to the provider.
<PrintHiveProvider
connection={{ baseUrl: "/api/printhive" }}
colorScheme={theme} // "light", "dark" or "system"
>"system" is the default. A forced scheme sets data-ph-color-scheme="light" or "dark" on each component root, and base.css turns that into a literal color-scheme rule. The provider adds no element to your page. A build that lowers light-dark() with Lightning CSS reads literal color-scheme rules to set up its color variables, which is why the switch is an attribute and not a variable. To switch without the prop, write that rule yourself, such as .ph-root { color-scheme: dark; }. Changing the prop does not read the printer again.
Layout and states
The compact layout follows the width of the container that holds the component, so a narrow sidebar gets it on a wide screen. The padding sits on an inner .ph-filament-body element, because a container cannot query its own padding. It is 20px, and 12px in a container 480px wide or narrower. The slot editor is a modal that the window sizes, so its compact layout follows the window.
While the first read runs, the component shows a placeholder shaped like one AMS unit of four slots. It stays transparent for 150 ms, so a fast answer shows nothing. Then it fades in and its bars pulse. It has the loaded view's line heights, and it shows more name bars as a card narrows, because a long name wraps onto more lines. For the one-AMS P1S fixture the content below moves by 11.5 px or less with macOS fonts in a column from 300 px to 1000 px wide, and by up to one line of a slot name (21.5 px on Linux CI) with fonts that wrap names differently. A name of another length can also differ by a line, and a printer with a second nozzle or AMS unit adds the height of that unit. The root is aria-busy and holds a visually hidden status with the text "Loading printer filaments…", and the placeholder is hidden from assistive technology. Under prefers-reduced-motion: reduce the placeholder does not pulse, and under forced colors its shapes use GrayText.
A button that runs a request keeps full opacity, shows a spinner and keeps focus while it runs. That covers Save assignment, Read RFID, Confirm clear assignment, Refresh and Retry loading filaments. It carries aria-busy and data-pending. The spinner sits in the 18px of padding that these buttons have on each side, so nothing moves when it appears. It fades in after 150 ms, so a quick request shows none. While a save, clear or RFID request runs, every other action in the editor is disabled and dimmed. Refresh shows the same busy look when you press it, and it stays enabled during a read that a write started, because pressing it only restarts that read. Under prefers-reduced-motion: reduce the spinner is a still dot. Under forced colors it keeps its gap, or its fill for the dot, in ButtonText.
Each of these buttons announces its request once, through its pendingAnnouncement after a second, so a quick request is silent. The text that shows while it runs, such as "Saving assignment…" and "Refreshing printer filaments…", is plain and not a live region. A refresh that a save started has no pressed button, so it is silent, and the result of the save is what is announced. When a save or a clear finishes, the saved or cleared notice takes focus, because Save disables itself and the confirmation unmounts. A failed result keeps focus on its button, and an alert reads it. An RFID reread keeps focus on its button too, so its result is said once through ui-sdk's announce when its notice appears. The notice has no role, because a live region inserted with its text is missed by some screen readers.
What the filament component promises
The component renders the API's nozzle, source, slot, and hotend-rack hierarchy. It does not infer a printer's layout from its model name or slot numbers.
- A saved assignment and the printer's observation stay separate. A saved record is not confirmation that the printer accepted it.
- A slot whose saved assignment differs from the printer shows the saved filament's name and color, and a "Printer has" line with the material and color that the printer reports. A slot card's accessible name is its label. Its filament name, status, that line and its remaining percentage are its description, and a hex color is read as a basic color name such as "orange".
- Assignment uses the automatic metadata-sync policy. Clearing an assignment sends no printer command and forwards the assignment version that the person reviewed.
ClearFilamentInput.expectedVersionis required. A custom data source must forward the{ id, updatedAt }version captured from the displayed assignment, and must not swap in a later one. The server handler requires it even though the SDK'sclearAssignmentsalso accepts an unversioned clear.- An accepted RFID request does not mean the tag read finished.
PrinterMaterialLayout.freshnessisfresh,stale, orunavailable. Unknown presence does not mean an empty slot.unmappedAssignmentskeeps saved assignments whose hardware location is unconfirmed. The hotend rack is read-only hardware information, separate from filament positions.- Each slot has independent
assign,clearAssignment,writePrinterMetadata, andrefreshRfidcapabilities. An unavailable capability carries acodeand amessage. The server handler rereads the layout before each write, and the API checks the operation against current state again. - The component reads a snapshot on mount, on Refresh, and after a write settles. It does not poll, subscribe to live events, or refetch on window focus. A failed refresh keeps the previous snapshot and shows an error.
- Physical load and unload are outside this package.
Upgrade from 0.2
Version 0.3.0 makes the default colors neutral. The 0.2 colors moved to an optional theme.
| 0.2 | 0.3 |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
| Ink and bone surfaces, with a green accent in light and the neon in dark | Slate surfaces with a blue accent. Import themes/printhive.css after base.css to keep the 0.2 look |
| --ph-font was not set | Still not set in base.css. themes/printhive.css sets it to Space Grotesk |
Upgrade from 0.1
Version 0.2.0 moves the filament exports and changes the provider and the handler.
| 0.1 | 0.2 |
| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| import { FilamentManagement } from "@printhive/react" | import { FilamentManagement } from "@printhive/react/filaments". The root has no re-export |
| <PrintHiveProvider dataSource={source}> | <PrintHiveProvider connection={{ baseUrl }}>, or a dataSource prop on the component |
| createFilamentManagementDataSource({ baseUrl, fetch }) | Same call, from @printhive/react/filaments |
| createFilamentManagementHandler({ client, authorize }) | createPrintHiveHandler({ client, authorize, features: [filaments()] }) |
| authorize(request, printerId) | authorize(request, { feature, printerId }). printerId can be null for other features |
| FilamentManagementDataSourceOptions | PrintHiveConnection, from @printhive/react |
| FilamentManagementHandlerOptions | PrintHiveHandlerOptions, from @printhive/react/server |
| @tanstack/react-query installed with the package | Install it yourself. It is an optional peer dependency, needed by the root and /filaments |
| --ph-filament-* tokens | --ph-* tokens |
| ph-filament-swatch class | ph-swatch, with ph-swatch-small |
| styles.css | Still ships. base.css and filaments.css split it |
| The font token defaulted to a Space Grotesk stack | --ph-font is not set, and the component inherits your font. Set it for the old look. See Style the components |
| The accent was #39ff14 in both schemes, with #0a0a0a text | --ph-accent is #15803d in light and the neon in dark. Set --ph-accent-text with --ph-accent. New --ph-accent-border |
| The border token was #848c8c in both schemes | Light is #7b8383, which holds 3:1 on both surfaces. Dark is unchanged |
| The backdrop was a fixed #0a0a0a99 | --ph-backdrop, light-dark(rgb(10 10 10 / 0.45), rgb(0 0 0 / 0.7)) |
| The root set color-scheme: light dark | colorScheme on the provider sets data-ph-color-scheme on each root. A rule that sets color-scheme on .ph-root still works |
| padding: 20px on the root, .ph-filament-management | The padding is on .ph-filament-body, inside the root, and a container query trims it to 12px at 480px wide or narrower. Move a padding override there. A selector with a child combinator from the root, such as .ph-filament-management > header, needs a descendant combinator |
| The loading view was a visible <p role="status"> | The status text is visually hidden, and an aria-hidden .ph-filament-skeleton shows the layout |
| A running Save, Read RFID or Confirm clear was disabled and dimmed, and Refresh was disabled while it read | The running button is enabled with aria-busy, aria-disabled and data-pending. Select [data-pending] in place of :disabled. Refresh is enabled during a read that a write started. The buttons that can run a request have .ph-filament-runs and 18px of inline padding in place of 12px, so each is 12px wider |
| The pending text under Save, Read RFID and Confirm clear was role="status", and focus fell to the page after a save or a clear | The text is plain, because the button announces the request. The saved or cleared notice takes focus and has tabIndex="-1" |
| A slot card's description was empty | The card describes its filament, status, "Printer has" line and remaining percentage |
| Save assignment looked like a plain button, and a disabled button showed a pointer cursor | Save assignment uses the accent tokens, Confirm clear assignment uses --ph-danger, and disabled controls show not-allowed. The disabled rule matches [data-slot]:is([data-disabled], [disabled]), so an override such as .ph-filament-management [disabled] needs [data-slot] too |
| A card that differed from the printer said only "Different from printer" | The card adds a "Printer has" line, so it is taller than before |
