Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

init for tooltip arch

aashu26667369ab49
diff --git a/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx b/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
index 4ec4a21983..a3e00f8084 100644
--- a/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
@@ -1,3 +1,4 @@
+import { LabelWithHelp } from "@carbon/field-help";
import { ValidatedForm } from "@carbon/form";
import {
Button,
@@ -99,11 +100,19 @@ const CostCenterForm = ({
<Input name="name" label="Cost Center Name" />
<CostCenter
name="parentCostCenterId"
- label="Parent Cost Center"
+ label={
+ <LabelWithHelp termId="parent-cost-center">
+ Parent Cost Center
+ </LabelWithHelp>
+ }
/>
<Employee
name="ownerId"
- label="Owner"
+ label={
+ <LabelWithHelp termId="cost-center-owner">
+ Owner
+ </LabelWithHelp>
+ }
isOptional={!approvalsActive}
/>
<CustomFormFields table="costCenter" />
diff --git a/apps/erp/package.json b/apps/erp/package.json
index 4d31400daa..80632e9927 100644
--- a/apps/erp/package.json
+++ b/apps/erp/package.json
@@ -16,7 +16,9 @@
"@carbon/documents": "workspace:*",
"@carbon/ee": "workspace:*",
"@carbon/env": "workspace:*",
+ "@carbon/field-help": "workspace:*",
"@carbon/form": "workspace:*",
+ "@carbon/glossary": "workspace:*",
"@carbon/jobs": "workspace:*",
"@carbon/kv": "workspace:*",
"@carbon/lib": "workspace:*",
diff --git a/docs/components/editorial/glossary.tsx b/docs/components/editorial/glossary.tsx
index 7cf574a25b..cd33d8f1b5 100644
--- a/docs/components/editorial/glossary.tsx
+++ b/docs/components/editorial/glossary.tsx
@@ -1,5 +1,5 @@
import Link from "next/link";
-import { glossaryEntries, termSlug } from "@/lib/glossary";
+import { glossaryEntries, termSlug } from "@carbon/glossary";
/**
* Glossary — the whole `lib/glossary.ts` rendered as one reference page, in the
diff --git a/docs/components/editorial/term.tsx b/docs/components/editorial/term.tsx
index a0f1ab0e71..0b48883281 100644
--- a/docs/components/editorial/term.tsx
+++ b/docs/components/editorial/term.tsx
@@ -15,7 +15,7 @@
import * as Popover from "@radix-ui/react-popover";
import Link from "next/link";
import type { ReactNode } from "react";
-import { glossary } from "@/lib/glossary";
+import { getEntry } from "@carbon/glossary";
function slugify(text: string) {
return text
@@ -27,7 +27,7 @@ function slugify(text: string) {
export function Term({ id, children }: { id?: string; children: ReactNode }) {
const key = id ?? (typeof children === "string" ? slugify(children) : "");
- const entry = glossary[key];
+ const entry = getEntry(key);
if (!entry) return <>{children}</>;
diff --git a/docs/lib/search-index.ts b/docs/lib/search-index.ts
index dc5fb5baf3..27d676f522 100644
--- a/docs/lib/search-index.ts
+++ b/docs/lib/search-index.ts
@@ -1,7 +1,7 @@
import "server-only";
import type { AdvancedIndex } from "fumadocs-core/search/server";
import { apiModules } from "@/lib/api-data";
-import { glossaryEntries, termSlug } from "@/lib/glossary";
+import { glossaryEntries, termSlug } from "@carbon/glossary";
import { guideSource, source } from "@/lib/source";
import { toolModules } from "@/lib/tools-data";
diff --git a/docs/package.json b/docs/package.json
index 91ec0e354d..5ae3c2ec91 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -15,6 +15,7 @@
"typecheck": "node scripts/generate-api-docs.mjs && fumadocs-mdx && tsc --noEmit"
},
"dependencies": {
+ "@carbon/glossary": "workspace:*",
"@carbon/utils": "workspace:*",
"@radix-ui/react-dialog": "1.1.15",
"@radix-ui/react-popover": "1.1.15",
diff --git a/packages/field-help/package.json b/packages/field-help/package.json
new file mode 100644
index 0000000000..c6bf0568e7
--- /dev/null
+++ b/packages/field-help/package.json
@@ -0,0 +1,33 @@
+{
+ "name": "@carbon/field-help",
+ "private": true,
+ "version": "0.0.0",
+ "sideEffects": false,
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "dependencies": {
+ "@carbon/glossary": "workspace:*"
+ },
+ "peerDependencies": {
+ "@carbon/react": "workspace:*",
+ "react": "catalog:",
+ "react-icons": "catalog:"
+ },
+ "devDependencies": {
+ "@carbon/config": "workspace:*",
+ "@carbon/react": "workspace:*",
+ "@types/react": "catalog:",
+ "react": "catalog:",
+ "react-icons": "catalog:",
+ "rimraf": "catalog:",
+ "tsup": "catalog:",
+ "typescript": "catalog:"
+ },
+ "scripts": {
+ "clean": "rimraf .turbo node_modules dist",
+ "dev": "tsup src/index.ts --format esm,cjs --watch --dts --external react",
+ "lint": "biome lint --write ",
+ "typecheck": "tsgo --noEmit"
+ }
+}
diff --git a/packages/field-help/src/LabelWithHelp.tsx b/packages/field-help/src/LabelWithHelp.tsx
new file mode 100644
index 0000000000..ec13c66271
--- /dev/null
+++ b/packages/field-help/src/LabelWithHelp.tsx
@@ -0,0 +1,128 @@
+import { getEntry, type TermId } from "@carbon/glossary";
+import {
+ cn,
+ HStack,
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger
+} from "@carbon/react";
+import type { ReactNode } from "react";
+import { LuInfo } from "react-icons/lu";
+
+/**
+ * Docs base URL for the inline "Learn more" link. Hardcoded here rather than
+ * exposed from `@carbon/glossary` because it's one constant with minimal drift
+ * risk and exporting it would invite touching `docs/lib/seo.ts`.
+ */
+const DOCS_BASE_URL = "https://docs.carbon.ms";
+
+type LabelWithHelpProps = {
+ /**
+ * Glossary term id. Typed as `TermId` so a typo at the call site is a compile
+ * error. Pass `undefined` to render the label without the help affordance.
+ */
+ termId: TermId | undefined;
+ /**
+ * The visible label text — typically a string, but any ReactNode works
+ * (Lingui `<Trans>`, emoji, etc.).
+ */
+ children: ReactNode;
+ /**
+ * Optional override for the tooltip body. When set, replaces `entry.definition`
+ * so the call-site can inline interactive React Router `<Link>`s, modal
+ * triggers, or other JSX. When set, the auto "Learn more" link is suppressed —
+ * the override is expected to handle its own in-app routing.
+ *
+ * Note: Radix Tooltip's hoverable content keeps the tooltip open while the
+ * cursor is inside it, so links/buttons inside the body are reachable for
+ * mouse users. Keyboard/touch reach is degraded; if a field needs guaranteed
+ * keyboard-reachable actions, render them as helper text next to the input,
+ * not inside this tooltip.
+ *
+ * Example:
+ * description={
+ * <>An employee accountable for this center — when approvals are on,
+ * they sign off on spend.{" "}
+ * <Link to="../approvals" className="text-primary font-medium underline decoration-dashed underline-offset-4 hover:decoration-solid">
+ * Configure approvals
+ * </Link>.
+ * </>
+ * }
+ */
+ description?: ReactNode;
+ className?: string;
+ tooltipDelayDuration?: number;
+};
+
+/**
+ * Renders a form label with a small info icon next to it. Hovering (or focusing)
+ * the icon shows a lightweight tooltip with the term's one-sentence definition.
+ * When the term has a docs anchor, "Learn more" is appended inline with a dashed
+ * underline — same line as the definition, not a separate footer link.
+ *
+ * Screen-reader coverage is built in: a visually-hidden span sits inside the
+ * label (alongside the visible text + icon). Because the whole `LabelWithHelp`
+ * JSX is rendered inside the form field's `<FormLabel>`, the sr-only span lives
+ * inside the label scope — so the SR reads the definition as part of the
+ * accessible name when the associated input is focused, with no need for an
+ * `aria-describedby` wiring at the call-site.
+ *
+ * When `termId` is undefined or unknown, renders the children alone — safe to
+ * drop into a label slot whether or not the term is in the glossary.
+ */
+export function LabelWithHelp({
+ termId,
+ children,
+ description,
+ className,
+ tooltipDelayDuration = 200
+}: LabelWithHelpProps) {
+ const entry = termId !== undefined ? getEntry(termId) : undefined;
+ if (!entry) return <>{children}</>;
+
+ // When the call-site provides a JSX override, it's responsible for any
+ // in-app routing it wants to surface — auto-appending "Learn more" would
+ // duplicate that or muddy the call-site's intent.
+ const showLearnMore = description === undefined && entry.href !== undefined;
+
+ return (
+ <HStack spacing={1} className={cn("items-center", className)}>
+ <span>{children}</span>
+ <TooltipProvider delayDuration={tooltipDelayDuration}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <button
+ type="button"
+ aria-label={`What is ${entry.term}?`}
+ className="inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <LuInfo className="h-3.5 w-3.5" aria-hidden />
+ </button>
+ </TooltipTrigger>
+ <TooltipContent
+ side="top"
+ align="start"
+ className="max-w-xs text-pretty leading-relaxed text-muted-foreground"
+ >
+ {description ?? entry.definition}
+ {showLearnMore && (
+ <>
+ {" "}
+ <a
+ href={`${DOCS_BASE_URL}${entry.href}`}
+ target="_blank"
+ rel="noreferrer"
+ className="text-primary font-medium underline decoration-dashed underline-offset-4 hover:decoration-solid"
+ >
+ Learn more
+ </a>
+ </>
+ )}
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ <span className="sr-only">{entry.definition}</span>
+ </HStack>
+ );
+}
diff --git a/packages/field-help/src/index.ts b/packages/field-help/src/index.ts
new file mode 100644
index 0000000000..cd5fa2ffe0
--- /dev/null
+++ b/packages/field-help/src/index.ts
@@ -0,0 +1 @@
+export { LabelWithHelp } from "./LabelWithHelp";
diff --git a/packages/field-help/tsconfig.json b/packages/field-help/tsconfig.json
new file mode 100644
index 0000000000..de18fe95cb
--- /dev/null
+++ b/packages/field-help/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@carbon/config/tsconfig/react-library.json",
+ "include": ["src"],
+ "exclude": ["**/*.d.ts", "./dist", "node_modules"]
+}
diff --git a/packages/field-help/tsup.config.ts b/packages/field-help/tsup.config.ts
new file mode 100644
index 0000000000..ee8f96541e
--- /dev/null
+++ b/packages/field-help/tsup.config.ts
@@ -0,0 +1,13 @@
+import { defineConfig } from "tsup";
+
+const isProduction = process.env.VERCEL_ENV === "production";
+
+export default defineConfig({
+ clean: true,
+ dts: true,
+ entry: ["src/index.ts"],
+ external: ["react", "react-dom", "react-icons", "@carbon/react"],
+ format: ["cjs", "esm"],
+ minify: isProduction,
+ sourcemap: !isProduction,
+});
diff --git a/packages/form/src/components/Array.tsx b/packages/form/src/components/Array.tsx
index fccd59f13e..3d35bf4902 100644
--- a/packages/form/src/components/Array.tsx
+++ b/packages/form/src/components/Array.tsx
@@ -18,7 +18,7 @@ import { useFieldArray } from "../internal/state/fieldArray";
type FormArrayProps = InputProps & {
name: string;
- label?: string;
+ label?: React.ReactNode;
isRequired?: boolean;
};
diff --git a/packages/form/src/components/ArrayNumeric.tsx b/packages/form/src/components/ArrayNumeric.tsx
index 797978d6d6..85af21aad6 100644
--- a/packages/form/src/components/ArrayNumeric.tsx
+++ b/packages/form/src/components/ArrayNumeric.tsx
@@ -24,7 +24,7 @@ import { useFieldArray } from "../internal/state/fieldArray";
type FormArrayNumericProps = InputProps & {
name: string;
- label?: string;
+ label?: React.ReactNode;
isRequired?: boolean;
defaults?: number[];
};
diff --git a/packages/form/src/components/Boolean.tsx b/packages/form/src/components/Boolean.tsx
index 06e13eda5a..b84bb013b2 100644
--- a/packages/form/src/components/Boolean.tsx
+++ b/packages/form/src/components/Boolean.tsx
@@ -16,7 +16,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormBooleanProps = {
name: string;
variant?: "large" | "small";
- label?: string;
+ label?: React.ReactNode;
value?: boolean;
helperText?: string;
isDisabled?: boolean;
@@ -85,7 +85,11 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
setValue(checked);
onChange?.(checked);
}}
- aria-label={label}
+ // `aria-label` requires a plain string; when `label` is JSX
+ // (e.g. wrapped in a `<LabelWithHelp>`), there's no sensible
+ // single-string accessible name to derive — fall back to the
+ // associated `<FormLabel>` for accessibility.
+ aria-label={typeof label === "string" ? label : undefined}
{...props}
/>
</HStack>
@@ -115,7 +119,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
setValue(checked);
onChange?.(checked);
}}
- aria-label={label}
+ aria-label={typeof label === "string" ? label : undefined}
{...props}
/>
{description && (
diff --git a/packages/form/src/components/Choice.tsx b/packages/form/src/components/Choice.tsx
index 48a98f91e3..e88ec9df7c 100644
--- a/packages/form/src/components/Choice.tsx
+++ b/packages/form/src/components/Choice.tsx
@@ -20,7 +20,7 @@ export type ChoiceCardOption<V extends string = string> = {
type ChoiceCardGroupProps<V extends string = string> = {
/** Optional small label rendered above the stack of cards. */
- label?: string;
+ label?: React.ReactNode;
/** Currently selected value. */
value: V;
/** Called with the new value when the user picks a different card. */
diff --git a/packages/form/src/components/Combobox.tsx b/packages/form/src/components/Combobox.tsx
index 87e40dbcff..09a2b2c767 100644
--- a/packages/form/src/components/Combobox.tsx
+++ b/packages/form/src/components/Combobox.tsx
@@ -13,7 +13,7 @@ import { useFormStateContext } from "../internal/formStateContext";
export type ComboboxProps = Omit<ComboboxBaseProps, "onChange"> & {
name: string;
- label?: string;
+ label?: React.ReactNode;
isLoading?: boolean;
isOptional?: boolean;
isRequired?: boolean;
diff --git a/packages/form/src/components/CreatableCombobox.tsx b/packages/form/src/components/CreatableCombobox.tsx
index 73940755ef..5e1b53d0cc 100644
--- a/packages/form/src/components/CreatableCombobox.tsx
+++ b/packages/form/src/components/CreatableCombobox.tsx
@@ -19,7 +19,7 @@ export type CreatableComboboxProps = Omit<
autoSelectSingleOption?: boolean;
isClearable?: boolean;
name: string;
- label?: string | JSX.Element;
+ label?: React.ReactNode;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
diff --git a/packages/form/src/components/CreatableMultiSelect.tsx b/packages/form/src/components/CreatableMultiSelect.tsx
index 3c49220c57..c0f125c063 100644
--- a/packages/form/src/components/CreatableMultiSelect.tsx
+++ b/packages/form/src/components/CreatableMultiSelect.tsx
@@ -16,7 +16,7 @@ export type CreatableMultiSelectProps = Omit<
"onChange" | "value"
> & {
name: string;
- label?: string;
+ label?: React.ReactNode;
helperText?: string;
isOptional?: boolean;
value?: string[];
diff --git a/packages/form/src/components/DatePicker.tsx b/packages/form/src/components/DatePicker.tsx
index 834476b0ec..72700485b8 100644
--- a/packages/form/src/components/DatePicker.tsx
+++ b/packages/form/src/components/DatePicker.tsx
@@ -16,7 +16,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type DatePickerProps = {
name: string;
- label?: string;
+ label?: React.ReactNode;
isDisabled?: boolean;
isRequired?: boolean;
minValue?: CalendarDate;
diff --git a/packages/form/src/components/DateTimePicker.tsx b/packages/form/src/components/DateTimePicker.tsx
index dab0bb3431..39d4b4e420 100644
--- a/packages/form/src/components/DateTimePicker.tsx
+++ b/packages/form/src/components/DateTimePicker.tsx
@@ -21,7 +21,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type DateTimePickerProps = {
name: string;
- label?: string;
+ label?: React.ReactNode;
size?: "sm" | "md" | "lg";
isDisabled?: boolean;
minValue?: CalendarDateTime;
diff --git a/packages/form/src/components/MultiSelect.tsx b/packages/form/src/components/MultiSelect.tsx
index 44fba97fd1..8a9f5b9462 100644
--- a/packages/form/src/components/MultiSelect.tsx
+++ b/packages/form/src/components/MultiSelect.tsx
@@ -17,7 +17,7 @@ export type MultiSelectProps = Omit<
"onChange" | "value" | "inline"
> & {
name: string;
- label?: string;
+ label?: React.ReactNode;
helperText?: string;
value?: string[];
onChange?: (newValue: { value: string; label: string }[]) => void;
diff --git a/packages/form/src/components/Number.tsx b/packages/form/src/components/Number.tsx
index 20807b6634..432df353c0 100644
--- a/packages/form/src/components/Number.tsx
+++ b/packages/form/src/components/Number.tsx
@@ -20,7 +20,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormNumberProps = NumberFieldProps & {
name: string;
size?: "sm" | "md" | "lg";
- label?: string;
+ label?: React.ReactNode;
isConfigured?: boolean;
isOptional?: boolean;
isRequired?: boolean;
diff --git a/packages/form/src/components/Password.tsx b/packages/form/src/components/Password.tsx
index 32b6418be3..79167691fd 100644
--- a/packages/form/src/components/Password.tsx
+++ b/packages/form/src/components/Password.tsx
@@ -15,7 +15,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormPasswordProps = InputProps & {
name: string;
- label?: string;
+ label?: React.ReactNode;
isRequired?: boolean;
};
diff --git a/packages/form/src/components/PhoneInput.tsx b/packages/form/src/components/PhoneInput.tsx
index 788c8f1d88..2f94eaf3a3 100644
--- a/packages/form/src/components/PhoneInput.tsx
+++ b/packages/form/src/components/PhoneInput.tsx
@@ -32,7 +32,7 @@ const PhoneInputComponent = ReactPhoneInput.default;
type PhoneInputProps = InputProps & {
name: string;
- label?: string;
+ label?: React.ReactNode;
isRequired?: boolean;
} & Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> &
Omit<ReactPhoneInput.Props<typeof ReactPhoneInput.default>, "onChange"> & {
diff --git a/packages/form/src/components/Radios.tsx b/packages/form/src/components/Radios.tsx
index 3ce96f42b3..5fe9157a95 100644
--- a/packages/form/src/components/Radios.tsx
+++ b/packages/form/src/components/Radios.tsx
@@ -11,7 +11,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type RadiosProps = {
name: string;
- label?: string;
+ label?: React.ReactNode;
options: { label: string; value: string }[];
orientation?: "horizontal" | "vertical";
};
diff --git a/packages/form/src/components/Select.tsx b/packages/form/src/components/Select.tsx
index 1a49fb0b00..1183a1b9a4 100644
--- a/packages/form/src/components/Select.tsx
+++ b/packages/form/src/components/Select.tsx
@@ -23,7 +23,7 @@ import { useFormStateContext } from "../internal/formStateContext";
export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
name: string;
- label?: string;
+ label?: React.ReactNode;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
diff --git a/packages/form/src/components/SelectControlled.tsx b/packages/form/src/components/SelectControlled.tsx
index 85f986c679..180aedf0bd 100644
--- a/packages/form/src/components/SelectControlled.tsx
+++ b/packages/form/src/components/SelectControlled.tsx
@@ -13,7 +13,7 @@ import { SelectBase } from "./Select";
export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
name: string;
- label?: string;
+ label?: React.ReactNode;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
diff --git a/packages/form/src/components/Textarea.tsx b/packages/form/src/components/Textarea.tsx
index 72691a9fd0..e8f8f3d4c3 100644
--- a/packages/form/src/components/Textarea.tsx
+++ b/packages/form/src/components/Textarea.tsx
@@ -12,7 +12,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormTextArea = TextareaProps & {
name: string;
- label?: string;
+ label?: React.ReactNode;
size?: "sm" | "md" | "lg";
characterLimit?: number;
isRequired?: boolean;
diff --git a/packages/form/src/components/TextareaControlled.tsx b/packages/form/src/components/TextareaControlled.tsx
index 7871b07010..3bb6f02ceb 100644
--- a/packages/form/src/components/TextareaControlled.tsx
+++ b/packages/form/src/components/TextareaControlled.tsx
@@ -13,7 +13,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormTextAreaControlledProps = Omit<TextareaProps, "value" | "onChange"> & {
name: string;
- label?: string;
+ label?: React.ReactNode;
characterLimit?: number;
isOptional?: boolean;
isRequired?: boolean;
diff --git a/packages/form/src/components/TimePicker.tsx b/packages/form/src/components/TimePicker.tsx
index 029cfb4679..12d2686f96 100644
--- a/packages/form/src/components/TimePicker.tsx
+++ b/packages/form/src/components/TimePicker.tsx
@@ -16,7 +16,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type TimePickerProps = {
name: string;
- label?: string;
+ label?: React.ReactNode;
minValue?: TimeValue;
maxValue?: TimeValue;
onChange?: (time: TimeValue) => void;
diff --git a/packages/glossary/package.json b/packages/glossary/package.json
new file mode 100644
index 0000000000..3c3bf558ca
--- /dev/null
+++ b/packages/glossary/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "@carbon/glossary",
+ "private": true,
+ "version": "0.0.0",
+ "sideEffects": false,
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "scripts": {
+ "clean": "rimraf .turbo node_modules dist",
+ "dev": "tsup src/index.ts --format esm,cjs --watch --dts",
+ "lint": "biome lint --write ",
+ "test": "vitest run",
+ "test:watch": "vitest",
+ "typecheck": "tsgo --noEmit"
+ },
+ "devDependencies": {
+ "@carbon/config": "workspace:*",
+ "rimraf": "catalog:",
+ "tsup": "catalog:",
+ "typescript": "catalog:",
+ "vitest": "catalog:"
+ }
+}
diff --git a/packages/glossary/src/helpers.ts b/packages/glossary/src/helpers.ts
new file mode 100644
index 0000000000..45bc0d626b
--- /dev/null
+++ b/packages/glossary/src/helpers.ts
@@ -0,0 +1,69 @@
+import { terms } from "./terms";
+import type { GlossaryEntry } from "./types";
+
+/** Slugify a term name into a stable anchor id. Mirrors the slug rule the docs
+ * `<Term>` component uses, so authoring `<Term>purchase to order</Term>` finds
+ * the `purchase-to-order` entry. */
+export function termSlug(term: string): string {
+ return term
+ .toLowerCase()
+ .replace(/[^a-z0-9]+/g, "-")
+ .replace(/^-+|-+$/g, "");
+}
+
+/** Literal union of every canonical term id in the glossary — gives compile-time
+ * typo protection at the call site (`useFieldHelp("typo")` is a type error).
+ * Note: aliases (e.g. `cost-of-goods-sold` for `cogs`) are NOT in this union —
+ * they resolve at runtime via `hasEntry`/`getEntry`. App call-sites should use
+ * the canonical id; aliases exist so docs prose can write the spelled-out form. */
+export type TermId = keyof typeof terms;
+
+/** Lazy-built alias → canonical id index. Built once on first call. */
+let aliasIndex: Map<string, TermId> | undefined;
+function getAliasIndex(): Map<string, TermId> {
+ if (aliasIndex) return aliasIndex;
+ const index = new Map<string, TermId>();
+ for (const [id, entry] of Object.entries(terms) as Array<
+ [TermId, GlossaryEntry]
+ >) {
+ for (const alias of entry.aliases ?? []) index.set(alias, id);
+ }
+ aliasIndex = index;
+ return index;
+}
+
+/** Type-safe lookup. The id can be a canonical `TermId` or a known alias
+ * (typed as `string` since aliases aren't in the literal union). Returns
+ * `undefined` for an unknown alias — call `hasEntry` first if you need
+ * that narrowed away. */
+export function getEntry(id: TermId | string): GlossaryEntry | undefined {
+ if (Object.hasOwn(terms, id)) return terms[id as TermId];
+ const canonical = getAliasIndex().get(id);
+ return canonical ? terms[canonical] : undefined;
+}
+
+/** Runtime guard — true when `id` resolves to an entry, either as a canonical
+ * slug or a known alias. Doesn't narrow to `TermId` because aliases aren't in
+ * the literal union; if you need narrowing, pass a literal-typed id. */
+export function hasEntry(id: string): boolean {
+ return Object.hasOwn(terms, id) || getAliasIndex().has(id);
+}
+
+/** Every canonical entry tagged with its slug, in insertion order. Aliases are
+ * not included as separate rows. Useful for tables or list renders that need
+ * both pieces. */
+export function listEntries(): Array<{ id: TermId; entry: GlossaryEntry }> {
+ return (Object.keys(terms) as TermId[]).map((id) => ({
+ id,
+ entry: terms[id]
+ }));
+}
+
+/** Canonical entries, alphabetically sorted by display term. The on-page docs
+ * glossary and the search index both consume this. Aliases are not surfaced
+ * as separate rows. */
+export function glossaryEntries(): GlossaryEntry[] {
+ return Object.values(terms).sort((a, b) =>
+ a.term.toLowerCase().localeCompare(b.term.toLowerCase())
+ );
+}
diff --git a/packages/glossary/src/index.ts b/packages/glossary/src/index.ts
new file mode 100644
index 0000000000..fa8f246b2f
--- /dev/null
+++ b/packages/glossary/src/index.ts
@@ -0,0 +1,10 @@
+export {
+ getEntry,
+ glossaryEntries,
+ hasEntry,
+ listEntries,
+ type TermId,
+ termSlug
+} from "./helpers";
+export { terms } from "./terms";
+export type { GlossaryEntry } from "./types";
diff --git a/packages/glossary/src/terms.test.ts b/packages/glossary/src/terms.test.ts
new file mode 100644
index 0000000000..b973e2447e
--- /dev/null
+++ b/packages/glossary/src/terms.test.ts
@@ -0,0 +1,82 @@
+import { describe, expect, it } from "vitest";
+import { getEntry, hasEntry, termSlug } from "./helpers";
+import { terms } from "./terms";
+import type { GlossaryEntry } from "./types";
+
+// `terms` is `as const satisfies ...`, so each entry has its narrowed literal
+// shape — optional fields are absent on entries that don't set them, which
+// makes loop-style checks awkward. The data still satisfies GlossaryEntry, so
+// widen to that uniform shape for the iteration helpers below.
+const entriesById = Object.entries(terms) as Array<[string, GlossaryEntry]>;
+
+describe("glossary", () => {
+ it("every entry has a non-empty term and definition", () => {
+ for (const [id, entry] of entriesById) {
+ expect(entry.term, `${id}.term`).toMatch(/\S/);
+ expect(entry.definition, `${id}.definition`).toMatch(/\S/);
+ }
+ });
+
+ it("slugs are unique", () => {
+ const ids = Object.keys(terms);
+ expect(new Set(ids).size).toBe(ids.length);
+ });
+
+ it("href, if set, points at /docs, /guides, or an absolute URL — shape only", () => {
+ // Shape check only. We do NOT verify the docs anchor actually resolves —
+ // that belongs in a docs-site link checker, not this package's test.
+ const shape = /^\/(docs|guides)\/|^https?:\/\//;
+ for (const [id, entry] of entriesById) {
+ if (entry.href !== undefined) {
+ expect(entry.href, `${id}.href`).toMatch(shape);
+ }
+ }
+ });
+
+ it("slug ids are valid lowercase-hyphen tokens", () => {
+ // We don't enforce `termSlug(entry.term) === id` — many canonical ids are
+ // intentional abbreviations of a spelled-out term (oem, wip, bom, mrp,
+ // cogs, rfq, fefo, macrs, 8d, gr-ir). Just check the id shape.
+ const shape = /^[a-z0-9]+(-[a-z0-9]+)*$/;
+ for (const [id] of entriesById) {
+ expect(id, `id "${id}"`).toMatch(shape);
+ }
+ });
+
+ it("termSlug() round-trips a normal term name", () => {
+ expect(termSlug("Make to Order")).toBe("make-to-order");
+ expect(termSlug(" Mixed-Case TEXT ")).toBe("mixed-case-text");
+ });
+
+ it("hasEntry / getEntry resolve canonical ids", () => {
+ expect(hasEntry("method")).toBe(true);
+ expect(hasEntry("not-a-real-slug")).toBe(false);
+ expect(getEntry("method")?.term).toBe("Method");
+ expect(getEntry("not-a-real-slug")).toBeUndefined();
+ });
+
+ it("hasEntry / getEntry resolve aliases to the canonical entry", () => {
+ // `cogs` declares `aliases: ["cost-of-goods-sold"]`. The spelled-out slug
+ // is not in `terms` but must resolve to the same canonical entry — that's
+ // the whole point of the alias mechanism (lets MDX prose write either
+ // form and land on the same definition).
+ expect(hasEntry("cost-of-goods-sold")).toBe(true);
+ expect(getEntry("cost-of-goods-sold")).toBe(getEntry("cogs"));
+ });
+
+ it("every declared alias points at exactly one canonical entry", () => {
+ // Aliases must be globally unique — if two entries declared the same alias,
+ // the lookup result would depend on insertion order. Catch that here.
+ const seen = new Map<string, string>();
+ for (const [id, entry] of entriesById) {
+ for (const alias of entry.aliases ?? []) {
+ const prior = seen.get(alias);
+ expect(
+ prior,
+ `alias "${alias}" is declared on both "${prior}" and "${id}"`
+ ).toBeUndefined();
+ seen.set(alias, id);
+ }
+ }
+ });
+});
diff --git a/docs/lib/glossary.ts b/packages/glossary/src/terms.ts
similarity index 78%
rename from docs/lib/glossary.ts
rename to packages/glossary/src/terms.ts
index 5602e3eae8..fe3f14a5cd 100644
--- a/docs/lib/glossary.ts
+++ b/packages/glossary/src/terms.ts
@@ -1,7 +1,8 @@
/**
- * The docs glossary — one source of truth for the inline <Term> popovers.
+ * The Carbon glossary — one source of truth for term definitions, used by both
+ * the docs site's inline <Term> popovers and the ERP/MES field-help affordance.
*
- * Keys are slugs (lowercase, hyphenated). Author usage in MDX:
+ * Keys are slugs (lowercase, hyphenated). Author usage in docs MDX:
* <Term>purchase to order</Term> — slugifies the text to find the entry
* <Term id="purchase-to-order">bought</Term> — explicit key when display text differs
*
@@ -16,125 +17,96 @@
* itemReplenishmentSystem → "Buy" | "Make" | "Buy and Make"
* (packages/database/.../20230330024716_parts.sql)
*/
-export type GlossaryEntry = {
- /** Canonical name shown as the popover heading. */
- term: string;
- /** One crisp, grounded sentence. */
- definition: string;
- /** Optional internal route + section anchor for the "Learn more" link. */
- href?: string;
-};
+import type { GlossaryEntry } from "./types";
-/** Slugify a term name into a stable anchor id (used for glossary row ids + search
- * deep-links). Mirrors the slug rule the <Term> component uses. */
-export function termSlug(term: string): string {
- return term
- .toLowerCase()
- .replace(/[^a-z0-9]+/g, "-")
- .replace(/^-+|-+$/g, "");
-}
-
-/** The glossary as a deduped, alphabetically-sorted list. Several slugs are aliases
- * of one term (cogs / cost-of-goods-sold), so dedupe by display name. One source for
- * both the on-page <Glossary> render and the search index. */
-export function glossaryEntries(): GlossaryEntry[] {
- const byTerm = new Map<string, GlossaryEntry>();
- for (const entry of Object.values(glossary)) {
- if (!byTerm.has(entry.term)) byTerm.set(entry.term, entry);
- }
- return [...byTerm.values()].sort((a, b) =>
- a.term.toLowerCase().localeCompare(b.term.toLowerCase()),
- );
-}
-
-export const glossary: Record<string, GlossaryEntry> = {
+export const terms = {
oem: {
term: "OEM (original equipment manufacturer)",
definition:
- "A company that designs and builds its own finished products end to end (here, the shop building humanoid robots) rather than making parts to another company's specification.",
+ "A company that designs and builds its own finished products end to end (here, the shop building humanoid robots) rather than making parts to another company's specification."
},
"method-type": {
term: "Method type",
definition:
"How a part gets into its parent, set per line: Make to Order, Purchase to Order, or Pull from Inventory.",
- href: "/docs/reference/methods#method-type",
+ href: "/docs/reference/methods#method-type"
},
"make-to-order": {
term: "Make to Order",
definition:
"The part is manufactured as its own job when the parent that needs it is built.",
- href: "/docs/reference/methods#method-type",
+ href: "/docs/reference/methods#method-type"
},
"purchase-to-order": {
term: "Purchase to Order",
definition:
"The material is purchased from a supplier for that specific order, rather than made or pulled from stock.",
- href: "/docs/reference/methods#method-type",
+ href: "/docs/reference/methods#method-type"
},
"pull-from-inventory": {
term: "Pull from Inventory",
definition:
"The part is taken from existing stock when its parent is built — no new job or purchase order.",
- href: "/docs/reference/methods#method-type",
+ href: "/docs/reference/methods#method-type"
},
"replenishment-system": {
term: "Replenishment system",
definition:
"How an item is replenished overall (Buy, Make, or Buy and Make), set per item, unlike the per-line method type.",
- href: "/docs/reference/methods#method-type-vs-replenishment-system",
+ href: "/docs/reference/methods#method-type-vs-replenishment-system"
},
method: {
term: "Method",
definition:
"Carbon's name for a bill of materials: the components plus the operations that make a part.",
- href: "/docs/reference/methods",
+ href: "/docs/reference/methods"
},
bom: {
term: "Bill of materials",
definition:
"Called a method in Carbon — the components plus operations that produce a part.",
- href: "/docs/reference/methods",
+ href: "/docs/reference/methods"
},
wip: {
term: "Work in process (WIP)",
definition:
"Not a table but a general-ledger balance: cost accumulates as job materials are issued and clears when the job is received to stock.",
- href: "/guides/job-costing#wip-isnt-a-table",
+ href: "/guides/job-costing#wip-isnt-a-table"
},
"outside-operation": {
term: "Outside operation",
definition:
- "An operation done by an outside supplier rather than an in-house work center, covered by a subcontracting purchase order.",
+ "An operation done by an outside supplier rather than an in-house work center, covered by a subcontracting purchase order."
},
subassembly: {
term: "Subassembly",
definition:
"A Make to Order component that gets its own job and routing inside the parent's build.",
- href: "/docs/reference/methods#kit-or-subassembly",
+ href: "/docs/reference/methods#kit-or-subassembly"
},
kit: {
term: "Kit",
definition:
"A Make to Order component whose parts are issued together into the parent job — no separate build.",
- href: "/docs/reference/methods#kit-or-subassembly",
+ href: "/docs/reference/methods#kit-or-subassembly"
},
"lead-time": {
term: "Lead time",
definition:
"Days from ordering a part to having it available; planning offsets demand backward by this much.",
- href: "/docs/reference/reordering#fields",
+ href: "/docs/reference/reordering#fields"
},
"reorder-point": {
term: "Reorder point",
definition:
"The on-hand level that triggers a new replenishment order under the quantity-based policies.",
- href: "/docs/reference/reordering#policies",
+ href: "/docs/reference/reordering#policies"
},
"reordering-policy": {
term: "Reordering policy",
definition:
"How an item is replenished: Manual Reorder, Demand-Based Reorder, Fixed Reorder Quantity, or Maximum Quantity.",
- href: "/docs/reference/reordering#policies",
+ href: "/docs/reference/reordering#policies"
},
// ── Production & the floor ──────────────────────────────────────────────
@@ -145,53 +117,53 @@ export const glossary: Record<string, GlossaryEntry> = {
term: "Job",
definition:
"Carbon's production order — one job builds a quantity of one item from its own copied method and routing.",
- href: "/docs/reference/jobs",
+ href: "/docs/reference/jobs"
},
routing: {
term: "Routing",
definition:
"The ordered sequence of operations a job runs through, copied from the method's bill of process.",
- href: "/docs/reference/routings",
+ href: "/docs/reference/routings"
},
operation: {
term: "Operation",
definition:
"One step in a job's routing, naming a process and a work center and carrying its own setup, labor, and machine times and rates.",
- href: "/docs/reference/routings",
+ href: "/docs/reference/routings"
},
"work-center": {
term: "Work center",
definition:
"Where an operation runs; carries labor and quoting rates, with overhead the difference between them.",
- href: "/docs/reference/work-centers",
+ href: "/docs/reference/work-centers"
},
backflush: {
term: "Backflush",
definition:
"Automatic, prorated consumption of a job's untracked materials when output is reported — tracked materials are issued manually.",
- href: "/guides/job-costing#issued-or-backflushed",
+ href: "/guides/job-costing#issued-or-backflushed"
},
"material-issue": {
term: "Issue (material)",
definition:
"Consuming material from inventory into a job, which writes a Consumption entry to the item ledger.",
- href: "/docs/reference/jobs",
+ href: "/docs/reference/jobs"
},
"get-method": {
term: "Get Method",
definition:
"The action that copies a saved method (its materials, operations, and work instructions) onto a job or quote line.",
- href: "/docs/reference/methods#get-method",
+ href: "/docs/reference/methods#get-method"
},
scrap: {
term: "Scrap",
definition:
- "Units reported as unrecoverable at an operation, with a reason — the alternative to rework.",
+ "Units reported as unrecoverable at an operation, with a reason — the alternative to rework."
},
rework: {
term: "Rework",
definition:
- "Sending defective units back to an earlier operation to be corrected instead of scrapping them.",
+ "Sending defective units back to an earlier operation to be corrected instead of scrapping them."
},
// ── Sales & purchasing ──────────────────────────────────────────────────
@@ -202,55 +174,55 @@ export const glossary: Record<string, GlossaryEntry> = {
term: "Sales order",
definition:
"A firm customer commitment to deliver; fulfillment status splits across ship and invoice before reaching Completed.",
- href: "/docs/reference/sales-orders",
+ href: "/docs/reference/sales-orders"
},
"purchase-order": {
term: "Purchase order",
definition:
"A firm order to a supplier; status moves through receive and invoice before Completed as goods and bills arrive.",
- href: "/docs/reference/purchase-orders",
+ href: "/docs/reference/purchase-orders"
},
quote: {
term: "Quote",
definition:
"A priced sales quotation; Draft → Sent → Ordered, or ends Lost, Expired, or Cancelled.",
- href: "/docs/reference/quotes",
+ href: "/docs/reference/quotes"
},
rfq: {
term: "RFQ (request for quote)",
definition:
"A sales RFQ (a customer asks you to quote) or a purchasing RFQ (you ask suppliers); both feed the opportunity thread.",
- href: "/guides/quote-to-cash#one-opportunity-many-documents",
+ href: "/guides/quote-to-cash#one-opportunity-many-documents"
},
opportunity: {
term: "Opportunity",
definition:
"The thread linking a sales RFQ, its quote, and the resulting sales order — a join, not a document with its own status.",
- href: "/guides/quote-to-cash#one-opportunity-many-documents",
+ href: "/guides/quote-to-cash#one-opportunity-many-documents"
},
"quote-to-cash": {
term: "Quote to cash",
definition:
"The end-to-end commercial flow from quoting a customer to collecting payment: RFQ to quote to sales order, then shipment, invoice, and settled payment.",
- href: "/guides/quote-to-cash",
+ href: "/guides/quote-to-cash"
},
"drop-ship": {
term: "Drop-ship",
definition:
"A shipment line sent straight from supplier to customer, bypassing your warehouse — set per line, not on the header.",
- href: "/docs/reference/sales-orders#line-fields",
+ href: "/docs/reference/sales-orders#line-fields"
},
"three-way-match": {
term: "Three-way match",
definition:
"Reconciling a purchase order against what was received and invoiced — implicit in Carbon, via the line quantities and GR/IR balance.",
- href: "/guides/receive-and-bill#match-and-post",
+ href: "/guides/receive-and-bill#match-and-post"
},
"gr-ir": {
term: "GR/IR (goods received, not invoiced)",
definition:
"A clearing account holding the value of goods received but not yet billed; the supplier invoice clears it.",
- href: "/docs/reference/accounting",
+ href: "/docs/reference/accounting"
},
// ── Inventory, tracking & costing ───────────────────────────────────────
@@ -261,74 +233,70 @@ export const glossary: Record<string, GlossaryEntry> = {
term: "Tracked entity",
definition:
"One serial unit or one batch that Carbon follows individually, carrying its own status and attributes such as an expiry date.",
- href: "/docs/reference/traceability#tracked-entities",
+ href: "/docs/reference/traceability#tracked-entities"
},
serial: {
term: "Serial tracking",
definition:
"Each physical unit gets its own tracked entity and unique number — one entity, one unit.",
- href: "/docs/reference/traceability#tracked-entities",
+ href: "/docs/reference/traceability#tracked-entities"
},
batch: {
term: "Batch tracking",
definition:
"A quantity of identical units shares one tracked entity and batch number — one entity, many units.",
- href: "/docs/reference/traceability#tracked-entities",
+ href: "/docs/reference/traceability#tracked-entities"
},
traceability: {
term: "Traceability",
definition:
"The recorded genealogy of tracked entities — which inputs were consumed to produce which outputs, receipt through shipment.",
- href: "/docs/reference/traceability",
+ href: "/docs/reference/traceability"
},
genealogy: {
term: "Genealogy",
definition:
"The parent-child chain of tracked entities — what a unit was built from and what it became.",
- href: "/docs/reference/traceability#genealogy",
+ href: "/docs/reference/traceability#genealogy"
},
"costing-method": {
term: "Costing method",
definition:
"How an item's unit cost is valued: Standard, Average, FIFO, or LIFO. Set per item.",
- href: "/docs/reference/items#fields",
+ href: "/docs/reference/items#fields"
},
cogs: {
term: "Cost of goods sold (COGS)",
definition:
"The inventory cost recognized when a shipment posts, valued by the item's costing method.",
href: "/docs/reference/accounting",
- },
- // Alias of "cogs" so the spelled-out term also resolves — keep the definition in sync with it.
- "cost-of-goods-sold": {
- term: "Cost of goods sold (COGS)",
- definition:
- "The inventory cost recognized when a shipment posts, valued by the item's costing method.",
- href: "/docs/reference/accounting",
+ // The spelled-out slug also resolves via `getEntry("cost-of-goods-sold")`
+ // and `hasEntry("cost-of-goods-sold")` — both surface this canonical entry.
+ aliases: ["cost-of-goods-sold"]
},
"conversion-factor": {
term: "Conversion factor",
definition:
"Converts a supplier's purchase unit to your inventory unit on a PO, receipt, or bill line — buy in cartons of 12, stock in eaches.",
- href: "/guides/receive-and-bill#buy-by-the-box-stock-by-the-each",
+ href: "/guides/receive-and-bill#buy-by-the-box-stock-by-the-each"
},
posting: {
term: "Posting",
definition:
"Committing a receipt, shipment, or invoice: quantities move, journal entries hit the ledger, and status becomes Posted.",
- href: "/docs/reference/accounting",
+ href: "/docs/reference/accounting"
},
receipt: {
term: "Receipt",
definition:
"The inbound posting document that takes goods into stock (from a PO, transfer, or job output) and creates any tracked entities.",
- href: "/docs/reference/receipts",
+ href: "/docs/reference/receipts"
},
shipment: {
term: "Shipment",
definition:
"The outbound posting document that takes goods out of stock to a customer, posting COGS as it goes.",
- href: "/docs/reference/shipments",
+ href: "/docs/reference/shipments"
},
// ── Planning, quality & accounting ──────────────────────────────────────
@@ -339,61 +307,83 @@ export const glossary: Record<string, GlossaryEntry> = {
term: "Demand forecast",
definition:
"Expected future demand for an item, bucketed by period, populated by the planning run alongside actual demand.",
- href: "/docs/reference/planning#what-feeds-it",
+ href: "/docs/reference/planning#what-feeds-it"
},
mrp: {
term: "MRP (planning)",
definition:
"Carbon's planning run nets supply against demand and explodes methods, surfacing shortfalls — but it creates no orders itself.",
- href: "/docs/reference/planning",
+ href: "/docs/reference/planning"
},
nonconformance: {
term: "Nonconformance (issue)",
definition:
"Carbon's quality issue — a logged deviation or defect with a configurable workflow of investigation and action tasks.",
- href: "/docs/reference/quality#issues",
+ href: "/docs/reference/quality#issues"
},
"8d": {
term: "8D",
definition:
"The eight-disciplines quality method, modeled with the nonconformance workflow's tasks rather than hard-coded.",
- href: "/docs/reference/quality#workflows-and-actions",
+ href: "/docs/reference/quality#workflows-and-actions"
},
"corrective-action": {
term: "Corrective action",
definition:
"A nonconformance task that fixes a confirmed root cause — as opposed to a preventive or immediate containment action.",
- href: "/docs/reference/quality#workflows-and-actions",
+ href: "/docs/reference/quality#workflows-and-actions"
},
"preventive-action": {
term: "Preventive action",
definition:
"A nonconformance task that stops the problem recurring elsewhere — distinct from the corrective fix and containment.",
- href: "/docs/reference/quality#workflows-and-actions",
+ href: "/docs/reference/quality#workflows-and-actions"
},
"containment-action": {
term: "Containment action",
definition:
"The immediate nonconformance task that quarantines affected stock or work before the root cause is known.",
- href: "/docs/reference/quality#workflows-and-actions",
+ href: "/docs/reference/quality#workflows-and-actions"
},
journal: {
term: "Journal",
definition:
"A posted accounting entry: a header plus balanced debit and credit lines against GL accounts.",
- href: "/docs/reference/accounting#the-journal",
+ href: "/docs/reference/accounting#the-journal"
},
"general-ledger": {
term: "General ledger",
definition:
"The book of all posted journal lines, summed by account — written only when the company has accounting enabled.",
- href: "/docs/reference/accounting",
+ href: "/docs/reference/accounting"
},
"accounting-period": {
term: "Accounting period",
definition:
"A dated window postings fall into (Active or Inactive, not open or closed), opened automatically when needed.",
- href: "/docs/reference/accounting#periods",
+ href: "/docs/reference/accounting#periods"
+ },
+
+ // ── Cost centers ────────────────────────────────────────────────────────
+ // Grounded: costCenter table (apps/erp/app/modules/accounting/accounting.models.ts L399);
+ // owner is referenced in purchasing approval workflows when purchaseOrderApprovalsActive.
+ "cost-center": {
+ term: "Cost center",
+ definition:
+ "An accounting bucket that groups expenses by department or function so the GL can report spend by group, not just by account.",
+ href: "/docs/reference/accounting"
+ },
+ "parent-cost-center": {
+ term: "Parent cost center",
+ definition:
+ "Another cost center this one rolls up into, letting you nest a sub-department under its parent for hierarchical cost reporting.",
+ href: "/docs/reference/accounting"
+ },
+ "cost-center-owner": {
+ term: "Owner (cost center)",
+ definition:
+ "The employee accountable for this cost center — when purchase order approvals are on, they're the approver for spend posted against it.",
+ href: "/docs/reference/accounting"
},
// ── Documents & variances (batch 2) ─────────────────────────────────────
@@ -404,31 +394,31 @@ export const glossary: Record<string, GlossaryEntry> = {
term: "Supplier quote",
definition:
"A supplier's priced response to a purchasing RFQ — one per supplier; Draft → Active when they submit, or Declined.",
- href: "/guides/rfq-to-po#suppliers-quote-back",
+ href: "/guides/rfq-to-po#suppliers-quote-back"
},
invoice: {
term: "Invoice",
definition:
"A sales invoice (you bill a customer) or purchase invoice (a supplier bills you); payment is a field, not a separate record.",
- href: "/docs/reference/invoices",
+ href: "/docs/reference/invoices"
},
"finished-goods": {
term: "Finished goods",
definition:
"A completed job's output, received into inventory at the job's actual accumulated WIP cost.",
- href: "/guides/job-finish-close#finish-into-inventory",
+ href: "/guides/job-finish-close#finish-into-inventory"
},
"production-variance": {
term: "Production variance",
definition:
"The residual WIP a job has left at close, swept to a Production Variance account — the only variance Carbon books for a job.",
- href: "/guides/job-finish-close#close-the-job",
+ href: "/guides/job-finish-close#close-the-job"
},
"purchase-price-variance": {
term: "Purchase price variance",
definition:
"The gap between a purchase order's price and the supplier's bill, posted to a variance account when the invoice posts.",
- href: "/guides/receive-and-bill#match-and-post",
+ href: "/guides/receive-and-bill#match-and-post"
},
// ── Fixed assets ────────────────────────────────────────────────────────
@@ -439,55 +429,55 @@ export const glossary: Record<string, GlossaryEntry> = {
term: "Fixed asset",
definition:
"An accounting record for a capitalized item you depreciate rather than expense; Draft → Active → Fully Depreciated → Disposed.",
- href: "/docs/reference/fixed-assets",
+ href: "/docs/reference/fixed-assets"
},
"asset-class": {
term: "Asset class",
definition:
"The category a fixed asset belongs to, carrying the GL accounts every asset of that kind posts to.",
- href: "/docs/reference/fixed-assets",
+ href: "/docs/reference/fixed-assets"
},
depreciation: {
term: "Depreciation",
definition:
"Writing an asset's value down over its life — a monthly batch you create, review as a draft, then post.",
- href: "/docs/reference/fixed-assets#depreciating",
+ href: "/docs/reference/fixed-assets#depreciating"
},
"net-book-value": {
term: "Net book value",
definition:
"An asset's acquisition cost minus accumulated depreciation — what it's still worth on the books, and the figure it's disposed at.",
- href: "/docs/reference/fixed-assets#selling-vs-disposing",
+ href: "/docs/reference/fixed-assets#selling-vs-disposing"
},
"straight-line": {
term: "Straight line",
definition:
"A depreciation method that charges an equal amount each period across the asset's useful life.",
- href: "/docs/reference/fixed-assets#depreciating",
+ href: "/docs/reference/fixed-assets#depreciating"
},
"declining-balance": {
term: "Declining balance",
definition:
"A depreciation method that charges a fixed percentage of remaining book value each period — heavier early, lighter later.",
- href: "/docs/reference/fixed-assets#depreciating",
+ href: "/docs/reference/fixed-assets#depreciating"
},
"residual-value": {
term: "Residual value",
definition:
"The floor an asset depreciates down to; when net book value reaches it, the asset flips to Fully Depreciated.",
- href: "/docs/reference/fixed-assets#depreciating",
+ href: "/docs/reference/fixed-assets#depreciating"
},
macrs: {
term: "MACRS",
definition:
"The US tax depreciation system with IRS property-class tables, run as a separate tax schedule alongside the book schedule.",
- href: "/docs/reference/fixed-assets#depreciating",
+ href: "/docs/reference/fixed-assets#depreciating"
},
disposal: {
term: "Disposal",
definition:
"Retiring an asset by write-off instead of sale, booking the remaining net book value as a loss — status becomes Disposed.",
- href: "/docs/reference/fixed-assets#selling-vs-disposing",
+ href: "/docs/reference/fixed-assets#selling-vs-disposing"
},
// ── Inventory ledger ────────────────────────────────────────────────────
@@ -495,7 +485,7 @@ export const glossary: Record<string, GlossaryEntry> = {
term: "Item ledger",
definition:
"The append-only record of every stock movement; on-hand is the sum of its signed entries and the source of truth.",
- href: "/docs/reference/inventory#on-hand-is-a-ledger",
+ href: "/docs/reference/inventory#on-hand-is-a-ledger"
},
// ── Shelf life ──────────────────────────────────────────────────────────
@@ -505,12 +495,12 @@ export const glossary: Record<string, GlossaryEntry> = {
term: "Shelf life",
definition:
"When a serial or batch expires, and what happens if used after — a company policy can Warn, Block, or BlockWithOverride.",
- href: "/docs/reference/shelf-life",
+ href: "/docs/reference/shelf-life"
},
fefo: {
term: "FEFO (first-expiry-first-out)",
definition:
"Picking offers tracked entities earliest-expiry-first, so the soonest-to-expire stock leaves first by default.",
- href: "/docs/reference/shelf-life",
- },
-};
+ href: "/docs/reference/shelf-life"
+ }
+} as const satisfies Record<string, GlossaryEntry>;
diff --git a/packages/glossary/src/types.ts b/packages/glossary/src/types.ts
new file mode 100644
index 0000000000..4684dfc001
--- /dev/null
+++ b/packages/glossary/src/types.ts
@@ -0,0 +1,20 @@
+/**
+ * One glossary entry: a domain term, a one-sentence definition, and an optional
+ * link to where it's explained in the docs.
+ *
+ * Definitions are deliberately short — one crisp, grounded sentence to identify
+ * the term — the full story lives behind the "Learn more" link.
+ */
+export type GlossaryEntry = {
+ /** Canonical name shown as the popover heading. */
+ term: string;
+ /** One crisp, grounded sentence. */
+ definition: string;
+ /** Optional internal route + section anchor for the "Learn more" link. */
+ href?: string;
+ /**
+ * Alternate slugs that resolve to this entry. Used so the term→slug round-trip
+ * test in `terms.test.ts` can skip alias keys without false negatives.
+ */
+ aliases?: readonly string[];
+};
diff --git a/packages/glossary/tsconfig.json b/packages/glossary/tsconfig.json
new file mode 100644
index 0000000000..2abfcdfcc8
--- /dev/null
+++ b/packages/glossary/tsconfig.json
@@ -0,0 +1,5 @@
+{
+ "$schema": "https://json.schemastore.org/tsconfig",
+ "extends": "@carbon/config/tsconfig/base.json",
+ "include": ["src/**/*.ts"]
+}
diff --git a/packages/glossary/tsup.config.ts b/packages/glossary/tsup.config.ts
new file mode 100644
index 0000000000..2d970f62ea
--- /dev/null
+++ b/packages/glossary/tsup.config.ts
@@ -0,0 +1,12 @@
+import { defineConfig } from "tsup";
+
+const isProduction = process.env.VERCEL_ENV === "production";
+
+export default defineConfig({
+ clean: true,
+ dts: true,
+ entry: ["src/index.ts"],
+ format: ["cjs", "esm"],
+ minify: isProduction,
+ sourcemap: !isProduction,
+});
diff --git a/packages/glossary/vitest.config.ts b/packages/glossary/vitest.config.ts
new file mode 100644
index 0000000000..bcc9169167
--- /dev/null
+++ b/packages/glossary/vitest.config.ts
@@ -0,0 +1,3 @@
+import baseConfig from "@carbon/config/vitest";
+
+export default baseConfig;
diff --git a/packages/react/src/CreateableCombobox.tsx b/packages/react/src/CreateableCombobox.tsx
index 6a2f36a400..19008bf228 100644
--- a/packages/react/src/CreateableCombobox.tsx
+++ b/packages/react/src/CreateableCombobox.tsx
@@ -32,7 +32,7 @@ export type CreatableComboboxProps = Omit<
selected?: string[];
isClearable?: boolean;
isReadOnly?: boolean;
- label?: string;
+ label?: React.ReactNode;
placeholder?: string;
inline?: (
value: string,
@@ -172,7 +172,11 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
}}
>
<VirtualizedCommand
- label={label}
+ // Used inside a templated "Create ${label}" hint string, so we
+ // can only pass it through when `label` is plain text. JSX labels
+ // (e.g. `<LabelWithHelp>…</LabelWithHelp>`) fall back to the
+ // bare "Create" hint — acceptable tradeoff to keep one prop.
+ label={typeof label === "string" ? label : undefined}
options={options}
selected={selected}
value={value}
diff --git a/packages/react/src/CreateableMultiSelect.tsx b/packages/react/src/CreateableMultiSelect.tsx
index 8851b05573..ed8890ad10 100644
--- a/packages/react/src/CreateableMultiSelect.tsx
+++ b/packages/react/src/CreateableMultiSelect.tsx
@@ -35,7 +35,7 @@ export type CreatableMultiSelectProps = Omit<
}[];
selected?: string[];
isReadOnly?: boolean;
- label?: string;
+ label?: React.ReactNode;
createLabel?: string;
placeholder?: string;
maxPreview?: number;
@@ -201,7 +201,11 @@ const CreatableMultiSelect = forwardRef<
onCreateOption={onCreateOption}
itemHeight={itemHeight}
setOpen={setOpen}
- label={label}
+ // Used inside a templated "Create ${label}" hint string, so we
+ // can only pass it through when `label` is plain text. JSX labels
+ // (e.g. `<LabelWithHelp>…</LabelWithHelp>`) fall back to the
+ // bare "Create" hint — acceptable tradeoff to keep one prop.
+ label={typeof label === "string" ? label : undefined}
createLabel={createLabel}
search={search}
setSearch={setSearch}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2e86680974..307fb9edef 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -568,9 +568,15 @@ importers:
'@carbon/env':
specifier: workspace:*
version: link:../../packages/env
+ '@carbon/field-help':
+ specifier: workspace:*
+ version: link:../../packages/field-help
'@carbon/form':
specifier: workspace:*
version: link:../../packages/form
+ '@carbon/glossary':
+ specifier: workspace:*
+ version: link:../../packages/glossary
'@carbon/jobs':
specifier: workspace:*
version: link:../../packages/jobs
@@ -654,7 +660,7 @@ importers:
version: 3.4.5([email protected])
'@react-router/remix-routes-option-adapter':
specifier: 'catalog:'
'@react-router/serve':
specifier: 'catalog:'
@@ -699,7 +705,7 @@ importers:
'@vercel/react-router':
specifier: 'catalog:'
'@visx/responsive':
specifier: 2.17.0
version: 2.17.0([email protected])
@@ -925,16 +931,16 @@ importers:
'@lingui/vite-plugin':
specifier: 'catalog:'
'@react-router/dev':
specifier: 'catalog:'
'@tailwindcss/typography':
specifier: 'catalog:'
version: 0.5.19([email protected])
'@tailwindcss/vite':
specifier: 'catalog:'
'@types/d3':
specifier: 7.4.3
version: 7.4.3
@@ -991,13 +997,13 @@ importers:
version: 5.8.3
vite:
specifier: 'catalog:'
vite-plugin-babel-macros:
specifier: 'catalog:'
vitest:
specifier: 'catalog:'
apps/mes:
dependencies:
@@ -1606,6 +1612,9 @@ importers:
docs:
dependencies:
+ '@carbon/glossary':
+ specifier: workspace:*
+ version: link:../packages/glossary
'@carbon/utils':
specifier: workspace:*
version: link:../packages/utils
@@ -2149,6 +2158,37 @@ importers:
specifier: 'catalog:'
version: 5.8.3
+ packages/field-help:
+ dependencies:
+ '@carbon/glossary':
+ specifier: workspace:*
+ version: link:../glossary
+ devDependencies:
+ '@carbon/config':
+ specifier: workspace:*
+ version: link:../config
+ '@carbon/react':
+ specifier: workspace:*
+ version: link:../react
+ '@types/react':
+ specifier: 'catalog:'
+ version: 18.3.28
+ react:
+ specifier: 'catalog:'
+ version: 18.3.1
+ react-icons:
+ specifier: 'catalog:'
+ version: 5.6.0([email protected])
+ rimraf:
+ specifier: 'catalog:'
+ version: 5.0.10
+ tsup:
+ specifier: 'catalog:'
+ typescript:
+ specifier: 'catalog:'
+ version: 5.8.3
+
packages/form:
dependencies:
'@carbon/react':
@@ -2240,6 +2280,24 @@ importers:
specifier: 'catalog:'
+ packages/glossary:
+ devDependencies:
+ '@carbon/config':
+ specifier: workspace:*
+ version: link:../config
+ rimraf:
+ specifier: 'catalog:'
+ version: 5.0.10
+ tsup:
+ specifier: 'catalog:'
+ typescript:
+ specifier: 'catalog:'
+ version: 5.8.3
+ vitest:
+ specifier: 'catalog:'
+
packages/jobs:
dependencies:
'@ai-sdk/openai':
@@ -15688,16 +15746,6 @@ snapshots:
'@lingui/babel-plugin-lingui-macro': 5.9.4([email protected])([email protected])
babel-plugin-macros: 3.1.0
- dependencies:
- '@lingui/cli': 5.9.4([email protected])([email protected])
- '@lingui/conf': 5.9.4([email protected])
- transitivePeerDependencies:
- - babel-plugin-macros
- - supports-color
- - typescript
-
dependencies:
'@lingui/cli': 5.9.4([email protected])([email protected])
@@ -19240,56 +19288,6 @@ snapshots:
'@react-pdf/primitives': 4.2.0
'@react-pdf/stylesheet': 6.1.4
- dependencies:
- '@babel/core': 7.29.0
- '@babel/generator': 7.29.1
- '@babel/parser': 7.29.2
- '@babel/plugin-syntax-jsx': 7.28.6(@babel/[email protected])
- '@babel/preset-typescript': 7.28.5(@babel/[email protected])
- '@babel/traverse': 7.29.0
- '@babel/types': 7.29.0
- '@remix-run/node-fetch-server': 0.13.1
- arg: 5.0.2
- babel-dead-code-elimination: 1.0.12
- chokidar: 4.0.3
- dedent: 1.7.2([email protected])
- es-module-lexer: 1.7.0
- exit-hook: 2.2.1
- isbot: 5.1.37
- jsesc: 3.0.2
- lodash: 4.17.21
- p-map: 7.0.4
- pathe: 1.1.2
- picocolors: 1.1.1
- pkg-types: 2.3.0
- prettier: 3.8.1
- react-refresh: 0.14.2
- semver: 7.7.4
- tinyglobby: 0.2.16
- valibot: 1.3.1([email protected])
- optionalDependencies:
- typescript: 5.8.3
- transitivePeerDependencies:
- - '@types/node'
- - babel-plugin-macros
- - jiti
- - less
- - lightningcss
- - sass
- - sass-embedded
- - stylus
- - sugarss
- - supports-color
- - terser
- - tsx
- - yaml
-
dependencies:
'@babel/core': 7.29.0
@@ -19494,12 +19492,6 @@ snapshots:
optionalDependencies:
typescript: 5.8.3
- dependencies:
- optionalDependencies:
- typescript: 5.8.3
-
dependencies:
@@ -20731,13 +20723,6 @@ snapshots:
postcss-selector-parser: 6.0.10
tailwindcss: 4.3.0
- dependencies:
- '@tailwindcss/node': 4.3.0
- '@tailwindcss/oxide': 4.3.0
- tailwindcss: 4.3.0
-
dependencies:
'@tailwindcss/node': 4.3.0
@@ -21566,16 +21551,6 @@ snapshots:
'@vercel/[email protected]': {}
- dependencies:
- '@vercel/static-config': 3.2.0
- isbot: 5.1.37
- react: 18.3.1
- react-dom: 18.3.1([email protected])
- ts-morph: 12.0.0
-
dependencies:
@@ -21716,14 +21691,6 @@ snapshots:
optionalDependencies:
- dependencies:
- '@vitest/spy': 4.1.6
- estree-walker: 3.0.3
- magic-string: 0.30.21
- optionalDependencies:
-
dependencies:
'@vitest/spy': 4.1.6
@@ -27491,7 +27458,7 @@ snapshots:
source-map: 0.7.6
sucrase: 3.35.1
tinyexec: 0.3.2
- tinyglobby: 0.2.16
+ tinyglobby: 0.2.17
tree-kill: 1.2.2
optionalDependencies:
postcss: 8.5.15
@@ -27519,7 +27486,7 @@ snapshots:
source-map: 0.7.6
sucrase: 3.35.1
tinyexec: 0.3.2
- tinyglobby: 0.2.16
+ tinyglobby: 0.2.17
tree-kill: 1.2.2
optionalDependencies:
postcss: 8.5.15
@@ -27807,17 +27774,6 @@ snapshots:
- tsx
- yaml
- dependencies:
- '@babel/core': 7.29.0
- '@babel/plugin-syntax-jsx': 7.28.6(@babel/[email protected])
- '@babel/plugin-syntax-typescript': 7.28.6(@babel/[email protected])
- '@types/babel__core': 7.20.5
- babel-plugin-macros: 3.1.0
- transitivePeerDependencies:
- - supports-color
-
dependencies:
'@babel/core': 7.29.0
@@ -27891,21 +27847,6 @@ snapshots:
tsx: 4.21.0
yaml: 2.8.3
- dependencies:
- lightningcss: 1.32.0
- picomatch: 4.0.4
- postcss: 8.5.14
- rolldown: 1.0.0-rc.17
- tinyglobby: 0.2.16
- optionalDependencies:
- '@types/node': 24.12.2
- esbuild: 0.27.7
- fsevents: 2.3.3
- jiti: 2.7.0
- tsx: 4.21.0
- yaml: 2.8.3
-
dependencies:
lightningcss: 1.32.0
@@ -28020,34 +27961,6 @@ snapshots:
transitivePeerDependencies:
- msw
- dependencies:
- '@vitest/expect': 4.1.6
- '@vitest/pretty-format': 4.1.6
- '@vitest/runner': 4.1.6
- '@vitest/snapshot': 4.1.6
- '@vitest/spy': 4.1.6
- '@vitest/utils': 4.1.6
- es-module-lexer: 2.0.0
- expect-type: 1.3.0
- magic-string: 0.30.21
- obug: 2.1.1
- pathe: 2.0.3
- picomatch: 4.0.4
- std-env: 4.0.0
- tinybench: 2.9.0
- tinyexec: 1.1.1
- tinyglobby: 0.2.16
- tinyrainbow: 3.1.0
- why-is-node-running: 2.3.0
- optionalDependencies:
- '@opentelemetry/api': 1.9.0
- '@types/node': 24.12.2
- transitivePeerDependencies:
- - msw
-
dependencies:
'@vitest/expect': 4.1.6