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.

feat: field label tooltips (#932)

Anshul sharmaa604bd739f64
diff --git a/apps/erp/app/components/Form/ConversionFactor.tsx b/apps/erp/app/components/Form/ConversionFactor.tsx
index c093fd3634..3e1d68c972 100644
--- a/apps/erp/app/components/Form/ConversionFactor.tsx
+++ b/apps/erp/app/components/Form/ConversionFactor.tsx
@@ -1,4 +1,5 @@
import { useControlField, useField } from "@carbon/form";
+import type { TermId } from "@carbon/glossary";
import {
Button,
CommandTrigger,
@@ -8,6 +9,7 @@ import {
FormHelperText,
FormLabel,
HStack,
+ LabelWithHelp,
Modal,
ModalBody,
ModalContent,
@@ -40,6 +42,7 @@ enum ConversionDirection {
type ConversionFactorProps = {
name: string;
label?: string;
+ termId?: TermId;
inventoryCode?: string;
purchasingCode?: string;
isReadOnly?: boolean;
@@ -57,6 +60,7 @@ const ConversionFactor = forwardRef<
{
name,
label = "Conversion Factor",
+ termId,
isRequired,
isReadOnly,
helperText,
@@ -192,7 +196,7 @@ const ConversionFactor = forwardRef<
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input
diff --git a/apps/erp/app/components/Form/SequenceOrCustomId.tsx b/apps/erp/app/components/Form/SequenceOrCustomId.tsx
index dd04e25618..99454f40b1 100644
--- a/apps/erp/app/components/Form/SequenceOrCustomId.tsx
+++ b/apps/erp/app/components/Form/SequenceOrCustomId.tsx
@@ -1,4 +1,5 @@
import { useField } from "@carbon/form";
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
Button,
@@ -8,7 +9,8 @@ import {
FormHelperText,
FormLabel,
IconButton,
- Input
+ Input,
+ LabelWithHelp
} from "@carbon/react";
import { useLingui } from "@lingui/react/macro";
import { forwardRef, useState } from "react";
@@ -17,6 +19,7 @@ import { LuToggleLeft, LuToggleRight } from "react-icons/lu";
type SequenceOrCustomIdProps = InputProps & {
name: string;
label: string;
+ termId?: TermId;
table: string;
placeholder?: string;
isOptional?: boolean;
@@ -31,6 +34,7 @@ const SequenceOrCustomId = forwardRef<
{
name,
label,
+ termId,
table,
isOptional,
helperText,
@@ -53,7 +57,7 @@ const SequenceOrCustomId = forwardRef<
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<div className="flex flex-grow items-start min-w-0 relative">
diff --git a/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx b/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
index 4ec4a21983..549349fbdb 100644
--- a/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/CostCenters/CostCenterForm.tsx
@@ -100,10 +100,12 @@ const CostCenterForm = ({
<CostCenter
name="parentCostCenterId"
label="Parent Cost Center"
+ termId="parent-cost-center"
/>
<Employee
name="ownerId"
label="Owner"
+ termId="cost-center-owner"
isOptional={!approvalsActive}
/>
<CustomFormFields table="costCenter" />
diff --git a/apps/erp/app/modules/accounting/ui/FixedAssets/AssetClassForm.tsx b/apps/erp/app/modules/accounting/ui/FixedAssets/AssetClassForm.tsx
index 53ce5b5ad6..c21680785a 100644
--- a/apps/erp/app/modules/accounting/ui/FixedAssets/AssetClassForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/FixedAssets/AssetClassForm.tsx
@@ -106,6 +106,7 @@ const AssetClassForm = ({
<Select
name="depreciationMethod"
label="Depreciation Method"
+ termId="depreciation"
options={depreciationMethods.map((m) => ({
label: m,
value: m
@@ -119,6 +120,7 @@ const AssetClassForm = ({
<Number
name="residualValuePercent"
label="Residual Value %"
+ termId="residual-value"
minValue={0}
maxValue={100}
/>
@@ -130,11 +132,13 @@ const AssetClassForm = ({
<Account
name="accumulatedDepreciationAccountId"
label="Accumulated Depreciation Account"
+ termId="depreciation"
classes={["Asset"]}
/>
<Account
name="depreciationExpenseAccountId"
label="Depreciation Expense Account"
+ termId="depreciation"
classes={["Expense"]}
/>
<Account
@@ -150,6 +154,7 @@ const AssetClassForm = ({
<Account
name="disposalAccountId"
label="Disposal Account"
+ termId="disposal"
classes={["Revenue", "Expense"]}
/>
@@ -163,6 +168,7 @@ const AssetClassForm = ({
<Select
name="taxDepreciationMethod"
label="Tax Method"
+ termId="depreciation"
placeholder="Same as Book"
isOptional
options={taxDepreciationMethods.map((m) => ({
@@ -177,6 +183,7 @@ const AssetClassForm = ({
<Select
name="macrsPropertyClass"
label="Recovery Period"
+ termId="macrs"
options={macrsPropertyClasses.map((c) => ({
label: `${c}-Year Property`,
value: c
@@ -185,6 +192,7 @@ const AssetClassForm = ({
<Select
name="macrsConvention"
label="Convention"
+ termId="macrs"
options={macrsConventions.map((c) => ({
label: c,
value: c
@@ -193,6 +201,7 @@ const AssetClassForm = ({
<Number
name="bonusDepreciationPercent"
label="Bonus Depreciation %"
+ termId="depreciation"
minValue={0}
maxValue={100}
/>
@@ -210,6 +219,7 @@ const AssetClassForm = ({
<Number
name="taxResidualValuePercent"
label="Tax Residual Value %"
+ termId="residual-value"
minValue={0}
maxValue={100}
/>
diff --git a/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetDisposalForm.tsx b/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetDisposalForm.tsx
index 2bbbd333dd..e89a14dc41 100644
--- a/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetDisposalForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetDisposalForm.tsx
@@ -65,7 +65,11 @@ const FixedAssetDisposalForm = ({
<p className="text-sm text-muted-foreground">
This will write off the remaining book value of the asset.
</p>
- <DatePicker name="disposalDate" label="Disposal Date" />
+ <DatePicker
+ name="disposalDate"
+ label="Disposal Date"
+ termId="disposal"
+ />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetForm.tsx b/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetForm.tsx
index ed9a2a132a..2188f12cab 100644
--- a/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetForm.tsx
@@ -134,6 +134,7 @@ const FixedAssetForm = ({ initialValues, onClose }: FixedAssetFormProps) => {
<AssetClass
name="fixedAssetClassId"
label="Asset Class"
+ termId="asset-class"
value={assetData.fixedAssetClassId}
onChange={onAssetClassChange}
/>
@@ -142,6 +143,7 @@ const FixedAssetForm = ({ initialValues, onClose }: FixedAssetFormProps) => {
<SelectControlled
name="depreciationMethod"
label="Depreciation Method"
+ termId="depreciation"
options={depreciationMethods.map((m) => ({
label: m,
value: m
@@ -167,6 +169,7 @@ const FixedAssetForm = ({ initialValues, onClose }: FixedAssetFormProps) => {
<NumberControlled
name="residualValuePercent"
label="Residual Value %"
+ termId="residual-value"
minValue={0}
maxValue={100}
value={assetData.residualValuePercent}
@@ -191,6 +194,7 @@ const FixedAssetForm = ({ initialValues, onClose }: FixedAssetFormProps) => {
<SelectControlled
name="taxDepreciationMethod"
label="Tax Depreciation Method"
+ termId="depreciation"
placeholder="None"
options={taxDepreciationMethods.map((m) => ({
label: m,
@@ -214,6 +218,7 @@ const FixedAssetForm = ({ initialValues, onClose }: FixedAssetFormProps) => {
<SelectControlled
name="macrsPropertyClass"
label="MACRS Property Class"
+ termId="macrs"
isOptional={false}
options={macrsPropertyClasses.map((c) => ({
label: `${c}-Year`,
@@ -231,6 +236,7 @@ const FixedAssetForm = ({ initialValues, onClose }: FixedAssetFormProps) => {
<SelectControlled
name="macrsConvention"
label="MACRS Convention"
+ termId="macrs"
isOptional={false}
options={macrsConventions.map((c) => ({
label: c,
@@ -248,6 +254,7 @@ const FixedAssetForm = ({ initialValues, onClose }: FixedAssetFormProps) => {
<NumberControlled
name="bonusDepreciationPercent"
label="Bonus Depreciation %"
+ termId="depreciation"
minValue={0}
maxValue={100}
value={assetData.bonusDepreciationPercent}
@@ -282,6 +289,7 @@ const FixedAssetForm = ({ initialValues, onClose }: FixedAssetFormProps) => {
<NumberControlled
name="taxResidualValuePercent"
label="Tax Residual Value %"
+ termId="residual-value"
minValue={0}
maxValue={100}
value={assetData.taxResidualValuePercent}
diff --git a/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetRegisterForm.tsx b/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetRegisterForm.tsx
index 35a0eb0c3b..87eba16cd6 100644
--- a/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetRegisterForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/FixedAssets/FixedAssetRegisterForm.tsx
@@ -64,6 +64,7 @@ const FixedAssetRegisterForm = ({ onClose }: FixedAssetRegisterFormProps) => {
<Number
name="accumulatedDepreciation"
label="Accumulated Depreciation"
+ termId="depreciation"
minValue={0}
formatOptions={{
style: "currency",
@@ -73,6 +74,7 @@ const FixedAssetRegisterForm = ({ onClose }: FixedAssetRegisterFormProps) => {
<DatePicker
name="depreciationStartDate"
label="Depreciation Start Date"
+ termId="depreciation"
/>
</VStack>
</ModalDrawerBody>
diff --git a/apps/erp/app/modules/accounting/ui/Intercompany/IntercompanyTransactionForm.tsx b/apps/erp/app/modules/accounting/ui/Intercompany/IntercompanyTransactionForm.tsx
index 4a8edb72fa..e6cc465340 100644
--- a/apps/erp/app/modules/accounting/ui/Intercompany/IntercompanyTransactionForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/Intercompany/IntercompanyTransactionForm.tsx
@@ -80,7 +80,12 @@ const IntercompanyTransactionForm = ({
<Input name="description" label="Description" />
<Account name="debitAccountId" label="Debit Account" />
<Account name="creditAccountId" label="Credit Account" />
- <Input name="postingDate" label="Posting Date" type="date" />
+ <Input
+ name="postingDate"
+ label="Posting Date"
+ termId="posting"
+ type="date"
+ />
</VStack>
</ModalDrawerBody>
<ModalDrawerFooter>
diff --git a/apps/erp/app/modules/accounting/ui/JournalEntries/JournalEntryForm.tsx b/apps/erp/app/modules/accounting/ui/JournalEntries/JournalEntryForm.tsx
index 2810bd2c99..22b539c581 100644
--- a/apps/erp/app/modules/accounting/ui/JournalEntries/JournalEntryForm.tsx
+++ b/apps/erp/app/modules/accounting/ui/JournalEntries/JournalEntryForm.tsx
@@ -283,6 +283,7 @@ const JournalEntryForm = ({
<DatePicker
name="postingDate"
label="Posting Date"
+ termId="posting"
isDisabled={isDisabled}
/>
</div>
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx
index ea281845ac..56971e97ac 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryStorageUnits.tsx
@@ -427,11 +427,13 @@ const InventoryStorageUnits = ({
<Input
name="readableId"
label={isSerial ? t`Serial Number` : t`Batch Number`}
+ termId={isSerial ? "serial" : "batch"}
/>
{showExpirationField && (
<DatePicker
name="expirationDate"
label={t`Expiration Date`}
+ termId="shelf-life"
/>
)}
</>
diff --git a/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx b/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
index f2d28e762e..48118ac0f2 100644
--- a/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/Kanbans/KanbanForm.tsx
@@ -221,6 +221,7 @@ const KanbanForm = ({ initialValues, onClose }: KanbanFormProps) => {
value={selectedReplenishmentSystem}
name="replenishmentSystem"
label={t`Replenishment System`}
+ termId="replenishment-system"
onChange={(value) => {
if (value) {
setSelectedReplenishmentSystem(value.value);
diff --git a/apps/erp/app/modules/inventory/ui/Traceability/EditExpiryModal.tsx b/apps/erp/app/modules/inventory/ui/Traceability/EditExpiryModal.tsx
index 1d84869192..a3606379cd 100644
--- a/apps/erp/app/modules/inventory/ui/Traceability/EditExpiryModal.tsx
+++ b/apps/erp/app/modules/inventory/ui/Traceability/EditExpiryModal.tsx
@@ -75,6 +75,7 @@ export function EditExpiryModal({
<DatePicker
name="expirationDate"
label={t`New expiration date`}
+ termId="shelf-life"
helperText={t`Pick a date or leave blank to clear it.`}
/>
<TextArea
diff --git a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferForm.tsx b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferForm.tsx
index 24f9e63671..b0b439810a 100644
--- a/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferForm.tsx
+++ b/apps/erp/app/modules/inventory/ui/WarehouseTransfers/WarehouseTransferForm.tsx
@@ -364,6 +364,7 @@ const WarehouseTransferForm = ({
<DatePicker
name="expectedReceiptDate"
label={t`Expected Receipt Date`}
+ termId="receipt"
/>
</>
)}
diff --git a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
index 37638d553c..925f49a9cf 100644
--- a/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
+++ b/apps/erp/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm.tsx
@@ -794,6 +794,7 @@ const PurchaseInvoiceLineForm = ({
<CostCenter
name="costCenterId"
label={t`Cost Center`}
+ termId="cost-center"
isOptional
/>
</>
@@ -802,6 +803,7 @@ const PurchaseInvoiceLineForm = ({
<Combobox
name="assetId"
label={t`Fixed Asset`}
+ termId="fixed-asset"
isOptional={false}
options={assetOptions}
value={indirectData.assetId}
diff --git a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
index 24d5d687af..3b1268f8f0 100644
--- a/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
+++ b/apps/erp/app/modules/invoicing/ui/SalesInvoice/SalesInvoiceLineForm.tsx
@@ -530,6 +530,7 @@ const SalesInvoiceLineForm = ({
<SelectControlled
name="methodType"
label={t`Method`}
+ termId="method-type"
options={
methodType.map((m) => ({
label: (
@@ -778,6 +779,7 @@ const SalesInvoiceLineForm = ({
<Combobox
name="assetId"
label={t`Fixed Asset`}
+ termId="fixed-asset"
isOptional={false}
options={assetOptions}
value={assetData.assetId}
diff --git a/apps/erp/app/modules/items/ui/Consumables/ConsumableForm.tsx b/apps/erp/app/modules/items/ui/Consumables/ConsumableForm.tsx
index 822a1388cf..9a74c91d1f 100644
--- a/apps/erp/app/modules/items/ui/Consumables/ConsumableForm.tsx
+++ b/apps/erp/app/modules/items/ui/Consumables/ConsumableForm.tsx
@@ -155,12 +155,14 @@ const ConsumableForm = ({
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
options={itemTrackingTypeOptions}
/>
<DefaultMethodType
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
replenishmentSystem="Buy"
value={defaultMethodType}
onChange={(newValue) =>
diff --git a/apps/erp/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/erp/app/modules/items/ui/Consumables/ConsumableProperties.tsx
index 6752ff767d..fb32199d86 100644
--- a/apps/erp/app/modules/items/ui/Consumables/ConsumableProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Consumables/ConsumableProperties.tsx
@@ -330,6 +330,7 @@ const ConsumableProperties = ({ data }: ConsumablePropertiesProps) => {
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
inline={(value) => (
<Badge variant="secondary">
<TrackingTypeIcon type={value} className="mr-2" />
@@ -364,6 +365,7 @@ const ConsumableProperties = ({ data }: ConsumablePropertiesProps) => {
<Select
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
inline={(value) => (
<Badge variant="secondary">
<MethodIcon type={value} className="mr-2" />
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
index 4865630633..fe5a0e1e76 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfMaterial.tsx
@@ -988,6 +988,7 @@ function MaterialForm({
<DefaultMethodType
name="methodType"
label={t`Method Type`}
+ termId="method-type"
value={itemData.methodType}
isReadOnly
isConfigured={rulesByField.has(key("methodType"))}
diff --git a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
index c745fa0277..670af24e56 100644
--- a/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
+++ b/apps/erp/app/modules/items/ui/Item/BillOfProcess.tsx
@@ -1244,6 +1244,7 @@ function OperationForm({
<WorkCenter
name="workCenterId"
label={t`Work Center`}
+ termId="work-center"
isOptional
processId={processData.processId}
isConfigured={rulesByField.has(key("workCenterId"))}
diff --git a/apps/erp/app/modules/items/ui/Item/ItemCostingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemCostingForm.tsx
index a4fc8ea21f..ace24a1d93 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemCostingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemCostingForm.tsx
@@ -65,6 +65,7 @@ const ItemCostingForm = ({ initialValues }: ItemCostingFormProps) => {
<Select
name="costingMethod"
label={t`Costing Method`}
+ termId="costing-method"
options={itemCostingMethods.map((method) => ({
label: method,
value: method
diff --git a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
index 4631ed4f31..5f94a8bdd9 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemForm.tsx
@@ -152,12 +152,14 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
options={itemTrackingTypeOptions}
/>
<Select
name="replenishmentSystem"
label={t`Replenishment System`}
+ termId="replenishment-system"
options={itemReplenishmentSystemOptions}
onChange={(newValue) => {
setReplenishmentSystem(newValue?.value ?? "Buy");
@@ -171,6 +173,7 @@ const ItemForm = ({ initialValues, type }: ItemFormProps) => {
<DefaultMethodType
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
replenishmentSystem={replenishmentSystem}
value={defaultMethodType}
onChange={(newValue) =>
diff --git a/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
index 8a50b5c647..e9446423c8 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemManufacturingForm.tsx
@@ -58,11 +58,16 @@ const ItemManufacturingForm = ({
<Number
name="scrapPercentage"
label={t`Scrap Percent`}
+ termId="scrap"
formatOptions={{
style: "percent"
}}
/>
- <Number name="leadTime" label={t`Lead Time (Days)`} />
+ <Number
+ name="leadTime"
+ label={t`Lead Time (Days)`}
+ termId="lead-time"
+ />
{/* <Boolean
name="manufacturingBlocked"
label={t`Manufacturing Blocked`}
diff --git a/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
index 122d78fa9c..70d404acc2 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemPlanningForm.tsx
@@ -85,6 +85,7 @@ const ItemPlanningForm = ({
<SelectForm
name="reorderingPolicy"
label={t`Reordering Policy`}
+ termId="reordering-policy"
options={itemReorderingPolicies.map((policy) => ({
label: <ItemReorderPolicy reorderingPolicy={policy} />,
value: policy
@@ -99,6 +100,7 @@ const ItemPlanningForm = ({
<Number
name="reorderPoint"
label={t`Reorder Point`}
+ termId="reorder-point"
minValue={0}
/>
<Number
@@ -128,6 +130,7 @@ const ItemPlanningForm = ({
<Number
name="reorderPoint"
label={t`Reorder Point`}
+ termId="reorder-point"
minValue={0}
/>
<Number
diff --git a/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx b/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
index afae0bb039..c62e8dfd36 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemPurchasingForm.tsx
@@ -98,7 +98,11 @@ const ItemPurchasingForm = ({
</div>
}
/>
- <Number name="leadTime" label={t`Lead Time (Days)`} />
+ <Number
+ name="leadTime"
+ label={t`Lead Time (Days)`}
+ termId="lead-time"
+ />
<UnitOfMeasure
name="purchasingUnitOfMeasureCode"
label={t`Purchasing Unit of Measure`}
diff --git a/apps/erp/app/modules/items/ui/Item/PickMethodForm.tsx b/apps/erp/app/modules/items/ui/Item/PickMethodForm.tsx
index b2f7773c69..d4a8d94b00 100644
--- a/apps/erp/app/modules/items/ui/Item/PickMethodForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/PickMethodForm.tsx
@@ -413,6 +413,7 @@ function ShelfLifeFields({
<NumberControlled
name="shelfLifeDays"
label={t`Shelf Life (Days)`}
+ termId="shelf-life"
minValue={1}
value={shelfLifeDays ?? defaultShelfLifeDays}
/>
@@ -439,6 +440,7 @@ function ShelfLifeFields({
<Boolean
name="shelfLifeCalculateFromBom"
label={t`Calculate from BOM`}
+ termId="bom"
description={t`Output never outlasts its raw materials. Falls back to the fixed duration when no input has an expiry date.`}
value={!!shelfLifeCalculateFromBom}
onChange={(v) => setShelfLifeCalculateFromBom(v)}
diff --git a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
index 61cf4b582e..b8393f31e5 100644
--- a/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
+++ b/apps/erp/app/modules/items/ui/Item/SupplierPartForm.tsx
@@ -199,6 +199,7 @@ const SupplierPartForm = ({
<ConversionFactor
name="conversionFactor"
label={t`Conversion Factor`}
+ termId="conversion-factor"
inventoryCode={unitOfMeasureCode ?? undefined}
purchasingCode={purchaseUnitOfMeasure}
/>
diff --git a/apps/erp/app/modules/items/ui/Materials/MaterialForm.tsx b/apps/erp/app/modules/items/ui/Materials/MaterialForm.tsx
index f042674787..4bb7dfab52 100644
--- a/apps/erp/app/modules/items/ui/Materials/MaterialForm.tsx
+++ b/apps/erp/app/modules/items/ui/Materials/MaterialForm.tsx
@@ -289,12 +289,14 @@ const MaterialForm = ({
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
options={itemTrackingTypeOptions}
/>
<DefaultMethodType
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
replenishmentSystem="Buy"
value={defaultMethodType}
onChange={(newValue) =>
diff --git a/apps/erp/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/erp/app/modules/items/ui/Materials/MaterialProperties.tsx
index c46ec1ee42..1db1274067 100644
--- a/apps/erp/app/modules/items/ui/Materials/MaterialProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Materials/MaterialProperties.tsx
@@ -453,6 +453,7 @@ const MaterialProperties = ({ data }: MaterialPropertiesProps) => {
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
inline={(value) => (
<Badge variant="secondary">
<TrackingTypeIcon type={value} className="mr-2" />
@@ -487,6 +488,7 @@ const MaterialProperties = ({ data }: MaterialPropertiesProps) => {
<Select
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
inline={(value) => (
<Badge variant="secondary">
<MethodIcon type={value} className="mr-2" />
diff --git a/apps/erp/app/modules/items/ui/Parts/PartForm.tsx b/apps/erp/app/modules/items/ui/Parts/PartForm.tsx
index 5e47989e2f..f1b739651c 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartForm.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartForm.tsx
@@ -284,6 +284,7 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
<Select
name="replenishmentSystem"
label={t`Replenishment System`}
+ termId="replenishment-system"
options={itemReplenishmentSystemOptions}
onChange={(newValue) => {
setReplenishmentSystem(newValue?.value ?? "Buy");
@@ -297,11 +298,13 @@ const PartForm = ({ initialValues, type = "card", onClose }: PartFormProps) => {
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
options={itemTrackingTypeOptions}
/>
<DefaultMethodType
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
replenishmentSystem={replenishmentSystem}
value={defaultMethodType}
onChange={(newValue) =>
diff --git a/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx b/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
index 60ed92d7c0..9c2d4293b1 100644
--- a/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Parts/PartProperties.tsx
@@ -355,6 +355,7 @@ const PartProperties = ({ data }: PartPropertiesProps) => {
<Select
name="replenishmentSystem"
label={t`Replenishment`}
+ termId="replenishment-system"
inline={(value) => (
<Badge variant="secondary">
<ReplenishmentSystemIcon type={value} className="mr-2" />
@@ -399,6 +400,7 @@ const PartProperties = ({ data }: PartPropertiesProps) => {
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
inline={(value) => (
<Badge variant="secondary">
<TrackingTypeIcon type={value} className="mr-2" />
@@ -447,6 +449,7 @@ const PartProperties = ({ data }: PartPropertiesProps) => {
<Select
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
inline={(value) => (
<Badge variant="secondary">
<MethodIcon type={value} className="mr-2" />
diff --git a/apps/erp/app/modules/items/ui/Tools/ToolForm.tsx b/apps/erp/app/modules/items/ui/Tools/ToolForm.tsx
index 66ef2f11d8..1f68c93abb 100644
--- a/apps/erp/app/modules/items/ui/Tools/ToolForm.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/ToolForm.tsx
@@ -277,6 +277,7 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
<Select
name="replenishmentSystem"
label={t`Replenishment System`}
+ termId="replenishment-system"
options={itemReplenishmentSystemOptions}
onChange={(newValue) => {
setReplenishmentSystem(newValue?.value ?? "Buy");
@@ -290,11 +291,13 @@ const ToolForm = ({ initialValues, type = "card", onClose }: ToolFormProps) => {
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
options={itemTrackingTypeOptions}
/>
<DefaultMethodType
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
replenishmentSystem={replenishmentSystem}
value={defaultMethodType}
onChange={(newValue) =>
diff --git a/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
index 0351b2a349..ae62662574 100644
--- a/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
+++ b/apps/erp/app/modules/items/ui/Tools/ToolProperties.tsx
@@ -333,6 +333,7 @@ const ToolProperties = ({ data }: ToolPropertiesProps) => {
<Select
name="replenishmentSystem"
label={t`Replenishment`}
+ termId="replenishment-system"
inline={(value) => (
<Badge variant="secondary">
<ReplenishmentSystemIcon type={value} className="mr-2" />
@@ -377,6 +378,7 @@ const ToolProperties = ({ data }: ToolPropertiesProps) => {
<Select
name="itemTrackingType"
label={t`Tracking Type`}
+ termId="tracked-entity"
inline={(value) => (
<Badge variant="secondary">
<TrackingTypeIcon type={value} className="mr-2" />
@@ -425,6 +427,7 @@ const ToolProperties = ({ data }: ToolPropertiesProps) => {
<Select
name="defaultMethodType"
label={t`Default Method Type`}
+ termId="method-type"
inline={(value) => (
<Badge variant="secondary">
<MethodIcon type={value} className="mr-2" />
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
index 9542c311f0..eaa59d79a1 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfMaterial.tsx
@@ -960,6 +960,7 @@ function MaterialForm({
<DefaultMethodType
name="methodType"
label={t`Method Type`}
+ termId="method-type"
value={itemData.methodType}
onChange={(value) => {
setItemData((d) => ({
@@ -1033,6 +1034,7 @@ function MaterialForm({
<Select
name="jobOperationId"
label={t`Operation`}
+ termId="operation"
isClearable
options={jobOperations.map((o) => ({
value: o.id!,
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
index 16569d1f14..2a2bb68150 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobBillOfProcess.tsx
@@ -2442,6 +2442,7 @@ function OperationForm({
<WorkCenter
name="workCenterId"
label={t`Work Center`}
+ termId="work-center"
autoSelectSingleOption={Boolean(processData.processId)}
locationId={locationId}
isOptional={["Draft", "Planned"].includes(job?.status ?? "")}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
index 449e4c190e..eea7f37084 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMakeMethodTools.tsx
@@ -366,6 +366,7 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
<Item
name="sourceId"
label={t`Source Method`}
+ termId="method"
type={(routeData?.job.itemType ?? "Part") as "Part"}
blacklist={configurableItemIds}
includeInactive={includeInactive === true}
@@ -471,6 +472,7 @@ const JobMakeMethodTools = ({ makeMethod }: { makeMethod?: JobMakeMethod }) => {
<Item
name="itemId"
label={t`Target Method`}
+ termId="method"
type={(routeData?.job?.itemType ?? "Part") as "Part"}
blacklist={configurableItemIds}
locationId={routeData?.job?.locationId ?? undefined}
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx b/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
index e8b84fa086..52c1ef38cf 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobMaterialForm.tsx
@@ -201,6 +201,7 @@ const JobMaterialForm = ({
<Select
name="jobOperationId"
label={t`Operation`}
+ termId="operation"
isClearable
options={operations.map((o) => ({
value: o.id!,
@@ -211,6 +212,7 @@ const JobMaterialForm = ({
<DefaultMethodType
name="methodType"
label={t`Method Type`}
+ termId="method-type"
value={itemData.methodType}
replenishmentSystem={itemData.itemReplenishmentSystem}
/>
diff --git a/apps/erp/app/modules/production/ui/Jobs/ProductionEventForm.tsx b/apps/erp/app/modules/production/ui/Jobs/ProductionEventForm.tsx
index 4952e6cca7..2ce75e3813 100644
--- a/apps/erp/app/modules/production/ui/Jobs/ProductionEventForm.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/ProductionEventForm.tsx
@@ -91,12 +91,14 @@ const ProductionEventForm = ({
<Select
name="jobOperationId"
label={t`Operation`}
+ termId="operation"
options={operationOptions ?? []}
/>
<Employee name="employeeId" label={t`Employee`} />
<WorkCenter
name="workCenterId"
label={t`Work Center`}
+ termId="work-center"
processId={initialValues.jobOperationId}
/>
<Select
diff --git a/apps/erp/app/modules/production/ui/Jobs/ProductionQuantityForm.tsx b/apps/erp/app/modules/production/ui/Jobs/ProductionQuantityForm.tsx
index f644ba6e5b..7fb12a87ed 100644
--- a/apps/erp/app/modules/production/ui/Jobs/ProductionQuantityForm.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/ProductionQuantityForm.tsx
@@ -82,6 +82,7 @@ const ProductionQuantityForm = ({
<Select
name="jobOperationId"
label={t`Operation`}
+ termId="operation"
options={operationOptions ?? []}
/>
)}
@@ -100,7 +101,11 @@ const ProductionQuantityForm = ({
}
/>
{type === "Scrap" && (
- <ScrapReason name="scrapReasonId" label={t`Scrap Reason`} />
+ <ScrapReason
+ name="scrapReasonId"
+ label={t`Scrap Reason`}
+ termId="scrap"
+ />
)}
<TextArea name="notes" label={t`Notes`} />
</VStack>
diff --git a/apps/erp/app/modules/production/ui/ScrapReasons/ScrapReasonForm.tsx b/apps/erp/app/modules/production/ui/ScrapReasons/ScrapReasonForm.tsx
index ebd3d146e6..1cec2b0aac 100644
--- a/apps/erp/app/modules/production/ui/ScrapReasons/ScrapReasonForm.tsx
+++ b/apps/erp/app/modules/production/ui/ScrapReasons/ScrapReasonForm.tsx
@@ -87,7 +87,7 @@ const ScrapReasonForm = ({
<Hidden name="id" />
<Hidden name="type" value={type} />
<VStack spacing={4}>
- <Input name="name" label={t`Scrap Reason`} />
+ <Input name="name" label={t`Scrap Reason`} termId="scrap" />
<CustomFormFields table="scrapReason" />
</VStack>
</ModalDrawerBody>
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
index 2804617155..5dd2d4ff22 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm.tsx
@@ -152,6 +152,7 @@ const PurchaseOrderDeliveryForm = forwardRef<
<Boolean
name="dropShipment"
label={t`Drop Shipment`}
+ termId="drop-ship"
bordered
onChange={setDropShip}
/>
diff --git a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
index 97b718de3e..d93bba114f 100644
--- a/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm.tsx
@@ -883,6 +883,7 @@ const PurchaseOrderLineForm = ({
<CostCenter
name="costCenterId"
label={t`Cost Center`}
+ termId="cost-center"
isOptional
/>
</>
diff --git a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
index 0d7f5f356d..fab41e7bdd 100644
--- a/apps/erp/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/Supplier/SupplierProcessForm.tsx
@@ -127,6 +127,7 @@ const SupplierProcessForm = ({
<Number
name="leadTime"
label={t`Standard Lead Time`}
+ termId="lead-time"
minValue={0}
/>
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
index 47f16f2322..c0a5e7cabc 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteLineForm.tsx
@@ -405,6 +405,7 @@ const SupplierQuoteLineForm = ({
<CostCenter
name="costCenterId"
label={t`Cost Center`}
+ termId="cost-center"
isOptional
/>
<DatePicker
diff --git a/apps/erp/app/modules/quality/ui/Issue/IssueForm.tsx b/apps/erp/app/modules/quality/ui/Issue/IssueForm.tsx
index 71bac2fff1..415940b0f9 100644
--- a/apps/erp/app/modules/quality/ui/Issue/IssueForm.tsx
+++ b/apps/erp/app/modules/quality/ui/Issue/IssueForm.tsx
@@ -131,6 +131,7 @@ const IssueForm = ({
<Select
name="nonConformanceTypeId"
label={t`Issue Type`}
+ termId="nonconformance"
options={nonConformanceTypes.map((type) => ({
label: type.name,
value: type.id
diff --git a/apps/erp/app/modules/quality/ui/Issue/IssueProperties.tsx b/apps/erp/app/modules/quality/ui/Issue/IssueProperties.tsx
index c0e89039db..dc5e7596de 100644
--- a/apps/erp/app/modules/quality/ui/Issue/IssueProperties.tsx
+++ b/apps/erp/app/modules/quality/ui/Issue/IssueProperties.tsx
@@ -291,6 +291,7 @@ const IssueProperties = () => {
}))}
isReadOnly={disableStructureUpdate}
label={t`Issue Type`}
+ termId="nonconformance"
name="nonConformanceTypeId"
inline={(value, options) => {
return (
diff --git a/apps/erp/app/modules/quality/ui/IssueTypes/IssueTypeForm.tsx b/apps/erp/app/modules/quality/ui/IssueTypes/IssueTypeForm.tsx
index b8bb73d8e0..e49c15c649 100644
--- a/apps/erp/app/modules/quality/ui/IssueTypes/IssueTypeForm.tsx
+++ b/apps/erp/app/modules/quality/ui/IssueTypes/IssueTypeForm.tsx
@@ -89,7 +89,11 @@ const IssueTypeForm = ({
<Hidden name="id" />
<Hidden name="type" value={type} />
<VStack spacing={4}>
- <Input name="name" label={t`Non Conformance Type`} />
+ <Input
+ name="name"
+ label={t`Non Conformance Type`}
+ termId="nonconformance"
+ />
<CustomFormFields table="nonConformanceType" />
</VStack>
</ModalDrawerBody>
diff --git a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchExplorer.tsx b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchExplorer.tsx
index 43c2d0c45b..bdceac1a81 100644
--- a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchExplorer.tsx
+++ b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchExplorer.tsx
@@ -448,7 +448,11 @@ function NewTimecardModal({
<Hidden name="maintenanceDispatchId" value={dispatchId} />
<VStack spacing={4}>
<Employee name="employeeId" label={t`Employee`} />
- <WorkCenter name="workCenterId" label={t`Work Center`} />
+ <WorkCenter
+ name="workCenterId"
+ label={t`Work Center`}
+ termId="work-center"
+ />
<DateTimePicker name="startTime" label={t`Start Time`} />
<DateTimePicker name="endTime" label={t`End Time`} />
<TextArea name="notes" label={t`Notes`} />
@@ -519,7 +523,11 @@ function EditTimecardModal({
<Hidden name="maintenanceDispatchId" value={dispatchId} />
<VStack spacing={4}>
<Employee name="employeeId" label={t`Employee`} />
- <WorkCenter name="workCenterId" label={t`Work Center`} />
+ <WorkCenter
+ name="workCenterId"
+ label={t`Work Center`}
+ termId="work-center"
+ />
<DateTimePicker name="startTime" label={t`Start Time`} />
<DateTimePicker name="endTime" label={t`End Time`} />
<TextArea name="notes" label={t`Notes`} />
diff --git a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchForm.tsx b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchForm.tsx
index 2e667d1ace..836c9105d2 100644
--- a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchForm.tsx
+++ b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchForm.tsx
@@ -184,7 +184,11 @@ const MaintenanceDispatchForm = ({
label: <MaintenanceSeverity severity={severity} />
}))}
/>
- <WorkCenter name="workCenterId" label={t`Work Center`} />
+ <WorkCenter
+ name="workCenterId"
+ label={t`Work Center`}
+ termId="work-center"
+ />
<Location name="locationId" label={t`Location`} />
<Select
name="oeeImpact"
diff --git a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx
index 5305fba5b3..8922cb505c 100644
--- a/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx
+++ b/apps/erp/app/modules/resources/ui/Maintenance/MaintenanceDispatchProperties.tsx
@@ -253,6 +253,7 @@ const MaintenanceDispatchProperties = () => {
isReadOnly={isLocked || !permissions.can("update", "resources")}
label={t`Work Center`}
name="workCenterId"
+ termId="work-center"
inline
isClearable
onChange={(value) => {
diff --git a/apps/erp/app/modules/resources/ui/MaintenanceSchedule/MaintenanceScheduleForm.tsx b/apps/erp/app/modules/resources/ui/MaintenanceSchedule/MaintenanceScheduleForm.tsx
index 471b108467..20d1d05f26 100644
--- a/apps/erp/app/modules/resources/ui/MaintenanceSchedule/MaintenanceScheduleForm.tsx
+++ b/apps/erp/app/modules/resources/ui/MaintenanceSchedule/MaintenanceScheduleForm.tsx
@@ -164,7 +164,11 @@ const MaintenanceScheduleForm = ({
<Hidden name="type" value={type} />
<VStack spacing={4}>
<Input name="name" label={t`Schedule Name`} />
- <WorkCenter name="workCenterId" label={t`Work Center`} />
+ <WorkCenter
+ name="workCenterId"
+ label={t`Work Center`}
+ termId="work-center"
+ />
<Location name="locationId" label={t`Location`} />
<Select
name="frequency"
diff --git a/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx b/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
index bf2b1eb017..fb361d647d 100644
--- a/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
+++ b/apps/erp/app/modules/resources/ui/Processes/ProcessForm.tsx
@@ -139,7 +139,11 @@ const ProcessForm = ({
label={t`Default Unit`}
value={initialValues.defaultStandardFactor}
/>
- <WorkCenters name="workCenters" label={t`Work Centers`} />
+ <WorkCenters
+ name="workCenters"
+ label={t`Work Centers`}
+ termId="work-center"
+ />
</>
)}
{processType !== "Inside" && (
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
index b0c15d4b56..41e5d75b9f 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfMaterial.tsx
@@ -981,6 +981,7 @@ function MaterialForm({
}));
}}
replenishmentSystem={itemData.itemReplenishmentSystem}
+ termId="method-type"
/>
<StorageUnit
name="storageUnitId"
@@ -1050,6 +1051,7 @@ function MaterialForm({
quoteOperationId: newValue?.value as string
}));
}}
+ termId="operation"
/>
</div>
</div>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
index 73be049ab8..39b2e0f69e 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteBillOfProcess.tsx
@@ -2087,6 +2087,7 @@ function OperationForm({
onWorkCenterChange(value?.value as string);
}
}}
+ termId="work-center"
/>
)}
</div>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteForm.tsx
index 20fd14a748..72755ef270 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteForm.tsx
@@ -168,7 +168,11 @@ const QuoteForm = ({ initialValues }: QuoteFormProps) => {
}
}}
/>
- <Input name="customerReference" label={t`Customer RFQ`} />
+ <Input
+ name="customerReference"
+ label={t`Customer RFQ`}
+ termId="rfq"
+ />
<CustomerContact
name="customerContactId"
label={t`Purchasing Contact`}
@@ -195,7 +199,11 @@ const QuoteForm = ({ initialValues }: QuoteFormProps) => {
isOptional
/>
<Employee name="estimatorId" label={t`Estimator`} isOptional />
- <Location name="locationId" label={t`Quote Location`} />
+ <Location
+ name="locationId"
+ label={t`Quote Location`}
+ termId="quote"
+ />
<DatePicker
name="dueDate"
label={t`Due Date`}
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineMethodForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineMethodForm.tsx
index fc6a1ae444..9ca0cd8bee 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLineMethodForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLineMethodForm.tsx
@@ -71,6 +71,7 @@ export function QuoteLineMethodForm() {
setQuoteLine(null);
}
}}
+ termId="quote"
/>
<SelectControlled
name="quoteLineId"
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
index 523a162487..b46a4274e6 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteMaterialForm.tsx
@@ -240,6 +240,7 @@ const QuoteMaterialForm = ({
value: o.id!,
label: o.description
}))}
+ termId="operation"
/>
<DefaultMethodType
@@ -247,6 +248,7 @@ const QuoteMaterialForm = ({
label={t`Method Type`}
value={itemData.methodType}
replenishmentSystem={itemData.itemReplenishmentSystem}
+ termId="method-type"
/>
<NumberControlled
name="quantity"
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteProperties.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteProperties.tsx
index 51d8245d86..bd61eb5d1a 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteProperties.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteProperties.tsx
@@ -349,6 +349,7 @@ const QuoteProperties = () => {
onUpdate("locationId", value.value);
}
}}
+ termId="quote"
/>
</ValidatedForm>
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
index 90ea29bf47..275447738c 100644
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteShipmentForm.tsx
@@ -112,6 +112,7 @@ const QuoteShipmentForm = forwardRef<
label={t`Shipment Location`}
isReadOnly={isCustomer}
isClearable
+ termId="shipment"
/>
<ShippingMethod
name="shippingMethodId"
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx
index d51b7d3eed..9551239d30 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderProperties.tsx
@@ -373,6 +373,7 @@ const SalesOrderProperties = () => {
onUpdate("locationId", value.value);
}
}}
+ termId="sales-order"
/>
</ValidatedForm>
diff --git a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
index 4dfc92ff18..a1f459fb82 100644
--- a/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesOrder/SalesOrderShipmentForm.tsx
@@ -126,6 +126,7 @@ const SalesOrderShipmentForm = forwardRef<
label={t`Shipment Location`}
isReadOnly={isCustomer}
isClearable
+ termId="shipment"
/>
<ShippingMethod
name="shippingMethodId"
@@ -144,7 +145,11 @@ const SalesOrderShipmentForm = forwardRef<
<DatePicker name="receiptRequestedDate" label={t`Requested Date`} />
<DatePicker name="receiptPromisedDate" label={t`Promised Date`} />
- <DatePicker name="shipmentDate" label={t`Shipment Date`} />
+ <DatePicker
+ name="shipmentDate"
+ label={t`Shipment Date`}
+ termId="shipment"
+ />
<Input name="trackingNumber" label={t`Tracking Number`} />
<div className="col-span-3">
@@ -153,6 +158,7 @@ const SalesOrderShipmentForm = forwardRef<
label={t`Drop Shipment`}
bordered
onChange={setDropShip}
+ termId="drop-ship"
/>
</div>
{dropShip && (
diff --git a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx
index 01e0f8335c..d883262560 100644
--- a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQForm.tsx
@@ -156,7 +156,11 @@ const SalesRFQForm = ({ initialValues }: SalesRFQFormProps) => {
label={t`Customer`}
onChange={onCustomerChange}
/>
- <Input name="customerReference" label={t`Customer RFQ`} />
+ <Input
+ name="customerReference"
+ label={t`Customer RFQ`}
+ termId="rfq"
+ />
<CustomerContact
name="customerContactId"
label={t`Purchasing Contact`}
@@ -179,6 +183,7 @@ const SalesRFQForm = ({ initialValues }: SalesRFQFormProps) => {
label={t`RFQ Date`}
helperText={t`The date you received this RFQ from the customer. Defaults to today.`}
isDisabled={isCustomer}
+ termId="rfq"
/>
<DatePicker
name="expirationDate"
@@ -186,7 +191,11 @@ const SalesRFQForm = ({ initialValues }: SalesRFQFormProps) => {
helperText={t`The deadline to send your quote to the customer.`}
isDisabled={isCustomer}
/>
- <Location name="locationId" label={t`RFQ Location`} />
+ <Location
+ name="locationId"
+ label={t`RFQ Location`}
+ termId="rfq"
+ />
<Employee name="salesPersonId" label={t`Sales Person`} />
<CustomFormFields table="salesRfq" />
</div>
diff --git a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
index 28638ea0c4..89f7763034 100644
--- a/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
+++ b/apps/erp/app/modules/sales/ui/SalesRFQ/SalesRFQProperties.tsx
@@ -292,6 +292,7 @@ const SalesRFQProperties = () => {
onChange={(date) => {
onUpdate("rfqDate", date);
}}
+ termId="rfq"
/>
</ValidatedForm>
@@ -332,6 +333,7 @@ const SalesRFQProperties = () => {
onUpdate("locationId", value.value);
}
}}
+ termId="rfq"
/>
</ValidatedForm>
diff --git a/apps/erp/app/routes/x+/settings+/inventory.tsx b/apps/erp/app/routes/x+/settings+/inventory.tsx
index 9826934cbf..7e116a6802 100644
--- a/apps/erp/app/routes/x+/settings+/inventory.tsx
+++ b/apps/erp/app/routes/x+/settings+/inventory.tsx
@@ -299,6 +299,7 @@ function ShelfLifeNumbers() {
minValue={0}
maxValue={365}
helperText={t`Items inside this window get a yellow badge.`}
+ termId="shelf-life"
/>
<Number
name="defaultShelfLifeDays"
@@ -306,6 +307,7 @@ function ShelfLifeNumbers() {
minValue={1}
maxValue={365}
helperText={t`Pre-filled for a new item when expiry is Fixed Duration.`}
+ termId="shelf-life"
/>
</div>
);
diff --git a/apps/erp/package.json b/apps/erp/package.json
index 4d31400daa..4c30096340 100644
--- a/apps/erp/package.json
+++ b/apps/erp/package.json
@@ -17,6 +17,7 @@
"@carbon/ee": "workspace:*",
"@carbon/env": "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..84cd92e3d2 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 { lookupEntry } 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 = lookupEntry(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/form/package.json b/packages/form/package.json
index 91f31052c5..022474e17f 100644
--- a/packages/form/package.json
+++ b/packages/form/package.json
@@ -25,6 +25,7 @@
"vitest": "catalog:"
},
"dependencies": {
+ "@carbon/glossary": "workspace:*",
"@internationalized/date": "catalog:",
"@react-aria/i18n": "catalog:",
"cookie": "catalog:",
diff --git a/packages/form/src/components/Array.tsx b/packages/form/src/components/Array.tsx
index fccd59f13e..3d1640936e 100644
--- a/packages/form/src/components/Array.tsx
+++ b/packages/form/src/components/Array.tsx
@@ -1,3 +1,4 @@
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
Button,
@@ -7,6 +8,7 @@ import {
HStack,
IconButton,
Input as InputBase,
+ LabelWithHelp,
VStack
} from "@carbon/react";
import { forwardRef, useRef } from "react";
@@ -19,6 +21,7 @@ import { useFieldArray } from "../internal/state/fieldArray";
type FormArrayProps = InputProps & {
name: string;
label?: string;
+ termId?: TermId;
isRequired?: boolean;
};
@@ -27,6 +30,7 @@ const Array = forwardRef<HTMLInputElement, FormArrayProps>(
{
name,
label,
+ termId,
isRequired,
isDisabled: isDisabledProp,
isReadOnly: isReadOnlyProp,
@@ -55,7 +59,7 @@ const Array = forwardRef<HTMLInputElement, FormArrayProps>(
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={`${name}`} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<VStack className="mb-4" ref={listRef}>
diff --git a/packages/form/src/components/ArrayNumeric.tsx b/packages/form/src/components/ArrayNumeric.tsx
index 797978d6d6..c545819076 100644
--- a/packages/form/src/components/ArrayNumeric.tsx
+++ b/packages/form/src/components/ArrayNumeric.tsx
@@ -1,3 +1,4 @@
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
Button,
@@ -6,6 +7,7 @@ import {
FormLabel,
HStack,
IconButton,
+ LabelWithHelp,
NumberDecrementStepper,
NumberField,
NumberIncrementStepper,
@@ -25,6 +27,7 @@ import { useFieldArray } from "../internal/state/fieldArray";
type FormArrayNumericProps = InputProps & {
name: string;
label?: string;
+ termId?: TermId;
isRequired?: boolean;
defaults?: number[];
};
@@ -34,6 +37,7 @@ const ArrayNumeric = forwardRef<HTMLInputElement, FormArrayNumericProps>(
{
name,
label,
+ termId,
isDisabled: isDisabledProp,
isReadOnly: isReadOnlyProp,
isRequired,
@@ -65,7 +69,7 @@ const ArrayNumeric = forwardRef<HTMLInputElement, FormArrayNumericProps>(
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={`${name}`} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<VStack className="mb-4" ref={listRef}>
diff --git a/packages/form/src/components/Boolean.tsx b/packages/form/src/components/Boolean.tsx
index 06e13eda5a..0a9b3d6f3d 100644
--- a/packages/form/src/components/Boolean.tsx
+++ b/packages/form/src/components/Boolean.tsx
@@ -1,3 +1,4 @@
+import type { TermId } from "@carbon/glossary";
import {
cn,
FormControl,
@@ -6,6 +7,7 @@ import {
FormLabel,
HStack,
Label,
+ LabelWithHelp,
Switch,
VStack
} from "@carbon/react";
@@ -17,6 +19,7 @@ type FormBooleanProps = {
name: string;
variant?: "large" | "small";
label?: string;
+ termId?: TermId;
value?: boolean;
helperText?: string;
isDisabled?: boolean;
@@ -31,6 +34,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
{
name,
label,
+ termId,
description,
helperText,
onChange,
@@ -68,7 +72,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
htmlFor={name}
className="text-sm text-foreground cursor-pointer"
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</Label>
)}
{description && (
@@ -102,7 +106,7 @@ const Boolean = forwardRef<HTMLInputElement, FormBooleanProps>(
<FormControl isInvalid={!!error} className={cn("pt-2", className)}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<HStack>
diff --git a/packages/form/src/components/Choice.tsx b/packages/form/src/components/Choice.tsx
index 48a98f91e3..408d2459db 100644
--- a/packages/form/src/components/Choice.tsx
+++ b/packages/form/src/components/Choice.tsx
@@ -1,4 +1,5 @@
-import { cn, RadioGroup, RadioGroupItem } from "@carbon/react";
+import type { TermId } from "@carbon/glossary";
+import { cn, LabelWithHelp, RadioGroup, RadioGroupItem } from "@carbon/react";
import type { ReactNode } from "react";
/**
@@ -21,6 +22,8 @@ export type ChoiceCardOption<V extends string = string> = {
type ChoiceCardGroupProps<V extends string = string> = {
/** Optional small label rendered above the stack of cards. */
label?: string;
+ /** Glossary term id; renders a help-icon tooltip next to the label. */
+ termId?: TermId;
/** Currently selected value. */
value: V;
/** Called with the new value when the user picks a different card. */
@@ -51,6 +54,7 @@ type ChoiceCardGroupProps<V extends string = string> = {
*/
export function ChoiceCardGroup<V extends string = string>({
label,
+ termId,
value,
onChange,
options,
@@ -60,7 +64,7 @@ export function ChoiceCardGroup<V extends string = string>({
<div className={cn("space-y-2 w-full", className)}>
{label && (
<span className="text-xs font-medium text-muted-foreground">
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</span>
)}
<RadioGroup
diff --git a/packages/form/src/components/Combobox.tsx b/packages/form/src/components/Combobox.tsx
index 87e40dbcff..887725bd26 100644
--- a/packages/form/src/components/Combobox.tsx
+++ b/packages/form/src/components/Combobox.tsx
@@ -1,10 +1,12 @@
+import type { TermId } from "@carbon/glossary";
import type { ComboboxProps as ComboboxBaseProps } from "@carbon/react";
import {
Combobox as ComboboxBase,
FormControl,
FormErrorMessage,
FormHelperText,
- FormLabel
+ FormLabel,
+ LabelWithHelp
} from "@carbon/react";
import { useEffect } from "react";
import { flushSync } from "react-dom";
@@ -14,6 +16,7 @@ import { useFormStateContext } from "../internal/formStateContext";
export type ComboboxProps = Omit<ComboboxBaseProps, "onChange"> & {
name: string;
label?: string;
+ termId?: TermId;
isLoading?: boolean;
isOptional?: boolean;
isRequired?: boolean;
@@ -34,6 +37,7 @@ export type ComboboxProps = Omit<ComboboxBaseProps, "onChange"> & {
const Combobox = ({
name,
label,
+ termId,
isLoading = false,
isOptional,
isRequired,
@@ -65,7 +69,7 @@ const Combobox = ({
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input
diff --git a/packages/form/src/components/CreatableCombobox.tsx b/packages/form/src/components/CreatableCombobox.tsx
index 73940755ef..5bded8f1ee 100644
--- a/packages/form/src/components/CreatableCombobox.tsx
+++ b/packages/form/src/components/CreatableCombobox.tsx
@@ -1,10 +1,12 @@
+import type { TermId } from "@carbon/glossary";
import type { CreatableComboboxProps as CreatableComboboxBaseProps } from "@carbon/react";
import {
CreatableCombobox as CreatableComboboxBase,
FormControl,
FormErrorMessage,
FormHelperText,
- FormLabel
+ FormLabel,
+ LabelWithHelp
} from "@carbon/react";
import { forwardRef, useEffect } from "react";
@@ -19,7 +21,8 @@ export type CreatableComboboxProps = Omit<
autoSelectSingleOption?: boolean;
isClearable?: boolean;
name: string;
- label?: string | JSX.Element;
+ label?: string;
+ termId?: TermId;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
@@ -41,6 +44,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
isClearable,
name,
label,
+ termId,
helperText,
isConfigured = false,
isOptional,
@@ -94,7 +98,7 @@ const CreatableCombobox = forwardRef<HTMLButtonElement, CreatableComboboxProps>(
onConfigure={onConfigure}
isOptional={resolvedIsOptional}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input
diff --git a/packages/form/src/components/CreatableMultiSelect.tsx b/packages/form/src/components/CreatableMultiSelect.tsx
index 3c49220c57..3985b1094e 100644
--- a/packages/form/src/components/CreatableMultiSelect.tsx
+++ b/packages/form/src/components/CreatableMultiSelect.tsx
@@ -1,10 +1,12 @@
+import type { TermId } from "@carbon/glossary";
import type { CreatableMultiSelectProps as CreatableMultiSelectBaseProps } from "@carbon/react";
import {
CreatableMultiSelect as CreatableMultiSelectBase,
FormControl,
FormErrorMessage,
FormHelperText,
- FormLabel
+ FormLabel,
+ LabelWithHelp
} from "@carbon/react";
import { forwardRef, useEffect, useMemo } from "react";
@@ -17,6 +19,7 @@ export type CreatableMultiSelectProps = Omit<
> & {
name: string;
label?: string;
+ termId?: TermId;
helperText?: string;
isOptional?: boolean;
value?: string[];
@@ -26,77 +29,84 @@ export type CreatableMultiSelectProps = Omit<
const CreatableMultiSelect = forwardRef<
HTMLButtonElement,
CreatableMultiSelectProps
->(({ name, label, helperText, isOptional, options = [], ...props }, ref) => {
- const { error, isOptional: fieldIsOptional } = useField(name);
- const [value, setValue] = useControlField<string[] | undefined>(name);
- const formState = useFormStateContext();
- const isReadOnly =
- formState.isReadOnly || formState.isDisabled || props.isReadOnly;
- const resolvedIsOptional = isOptional ?? fieldIsOptional ?? false;
+>(
+ (
+ { name, label, termId, helperText, isOptional, options = [], ...props },
+ ref
+ ) => {
+ const { error, isOptional: fieldIsOptional } = useField(name);
+ const [value, setValue] = useControlField<string[] | undefined>(name);
+ const formState = useFormStateContext();
+ const isReadOnly =
+ formState.isReadOnly || formState.isDisabled || props.isReadOnly;
+ const resolvedIsOptional = isOptional ?? fieldIsOptional ?? false;
- useEffect(() => {
- if (props.value !== null && props.value !== undefined)
- setValue(props.value);
- }, [props.value, setValue]);
+ useEffect(() => {
+ if (props.value !== null && props.value !== undefined)
+ setValue(props.value);
+ }, [props.value, setValue]);
- const onChange = (value: string[]) => {
- setValue(value);
- props.onChange?.(value);
- };
+ const onChange = (value: string[]) => {
+ setValue(value);
+ props.onChange?.(value);
+ };
- const sortedOptions = useMemo(() => {
- // Split options into selected and unselected
- const selectedOptions = options.filter((opt) => value?.includes(opt.value));
- const unselectedOptions = options.filter(
- (opt) => !value?.includes(opt.value)
- );
+ const sortedOptions = useMemo(() => {
+ // Split options into selected and unselected
+ const selectedOptions = options.filter((opt) =>
+ value?.includes(opt.value)
+ );
+ const unselectedOptions = options.filter(
+ (opt) => !value?.includes(opt.value)
+ );
- // Sort unselected options alphabetically by label
- const sortedUnselected = [...unselectedOptions].sort((a, b) =>
- a.label.localeCompare(b.label)
- );
+ // Sort unselected options alphabetically by label
+ const sortedUnselected = [...unselectedOptions].sort((a, b) =>
+ a.label.localeCompare(b.label)
+ );
- // Combine selected options first, followed by sorted unselected options
- return [...selectedOptions, ...sortedUnselected];
- }, [options, value]);
+ // Combine selected options first, followed by sorted unselected options
+ return [...selectedOptions, ...sortedUnselected];
+ }, [options, value]);
- return (
- <FormControl isInvalid={!!error}>
- {label && (
- <FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
- </FormLabel>
- )}
- {(value ?? []).filter(Boolean).map((selection, index) => (
- <input
- key={`${name}[${index}]`}
- type="hidden"
- name={`${name}[${index}]`}
- value={selection}
+ return (
+ <FormControl isInvalid={!!error}>
+ {label && (
+ <FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
+ </FormLabel>
+ )}
+ {(value ?? []).filter(Boolean).map((selection, index) => (
+ <input
+ key={`${name}[${index}]`}
+ type="hidden"
+ name={`${name}[${index}]`}
+ value={selection}
+ />
+ ))}
+ <CreatableMultiSelectBase
+ ref={ref}
+ {...props}
+ options={sortedOptions}
+ value={value ?? []}
+ onChange={(newValue) => {
+ setValue(newValue ?? []);
+ onChange(newValue ?? []);
+ }}
+ isReadOnly={isReadOnly}
+ label={label}
+ className="w-full"
/>
- ))}
- <CreatableMultiSelectBase
- ref={ref}
- {...props}
- options={sortedOptions}
- value={value ?? []}
- onChange={(newValue) => {
- setValue(newValue ?? []);
- onChange(newValue ?? []);
- }}
- isReadOnly={isReadOnly}
- label={label}
- className="w-full"
- />
- {error ? (
- <FormErrorMessage>{error}</FormErrorMessage>
- ) : (
- helperText && <FormHelperText>{helperText}</FormHelperText>
- )}
- </FormControl>
- );
-});
+ {error ? (
+ <FormErrorMessage>{error}</FormErrorMessage>
+ ) : (
+ helperText && <FormHelperText>{helperText}</FormHelperText>
+ )}
+ </FormControl>
+ );
+ }
+);
CreatableMultiSelect.displayName = "CreatableMultiSelect";
diff --git a/packages/form/src/components/DatePicker.tsx b/packages/form/src/components/DatePicker.tsx
index 834476b0ec..b75f8d06ed 100644
--- a/packages/form/src/components/DatePicker.tsx
+++ b/packages/form/src/components/DatePicker.tsx
@@ -1,9 +1,11 @@
import { useFormContext } from "@carbon/form";
+import type { TermId } from "@carbon/glossary";
import {
DatePicker as DatePickerBase,
FormControl,
FormErrorMessage,
- FormLabel
+ FormLabel,
+ LabelWithHelp
} from "@carbon/react";
import { formatDate } from "@carbon/utils";
import type { CalendarDate } from "@internationalized/date";
@@ -17,6 +19,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type DatePickerProps = {
name: string;
label?: string;
+ termId?: TermId;
isDisabled?: boolean;
isRequired?: boolean;
minValue?: CalendarDate;
@@ -30,6 +33,7 @@ type DatePickerProps = {
const DatePicker = ({
name,
label,
+ termId,
isDisabled: isDisabledProp = false,
isRequired,
minValue,
@@ -98,7 +102,7 @@ const DatePicker = ({
htmlFor={name}
isOptional={isRequired ? false : (fieldIsOptional ?? false)}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input type="hidden" name={name} value={utcValue} />
diff --git a/packages/form/src/components/DateTimePicker.tsx b/packages/form/src/components/DateTimePicker.tsx
index dab0bb3431..9ded276a31 100644
--- a/packages/form/src/components/DateTimePicker.tsx
+++ b/packages/form/src/components/DateTimePicker.tsx
@@ -1,9 +1,11 @@
import { useFormContext } from "@carbon/form";
+import type { TermId } from "@carbon/glossary";
import {
DateTimePicker as DateTimePickerBase,
FormControl,
FormErrorMessage,
- FormLabel
+ FormLabel,
+ LabelWithHelp
} from "@carbon/react";
import { formatDateTime } from "@carbon/utils";
import type { CalendarDateTime } from "@internationalized/date";
@@ -22,6 +24,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type DateTimePickerProps = {
name: string;
label?: string;
+ termId?: TermId;
size?: "sm" | "md" | "lg";
isDisabled?: boolean;
minValue?: CalendarDateTime;
@@ -34,6 +37,7 @@ type DateTimePickerProps = {
const DateTimePicker = ({
name,
label,
+ termId,
size,
isDisabled: isDisabledProp = false,
minValue,
@@ -91,7 +95,7 @@ const DateTimePicker = ({
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input type="hidden" name={name} value={utcValue} />
diff --git a/packages/form/src/components/Input.tsx b/packages/form/src/components/Input.tsx
index ca88077ca9..05a34ec3e8 100644
--- a/packages/form/src/components/Input.tsx
+++ b/packages/form/src/components/Input.tsx
@@ -1,3 +1,4 @@
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
FormControl,
@@ -7,7 +8,8 @@ import {
Input as InputBase,
InputGroup,
InputLeftAddon,
- InputRightAddon
+ InputRightAddon,
+ LabelWithHelp
} from "@carbon/react";
import type { ChangeEvent, ReactNode } from "react";
import { forwardRef, useState } from "react";
@@ -18,6 +20,7 @@ import type { ValidationBehaviorOptions } from "../internal/getInputProps";
type FormInputProps = InputProps & {
name: string;
label?: ReactNode;
+ termId?: TermId;
isConfigured?: boolean;
isOptional?: boolean;
isRequired?: boolean;
@@ -34,6 +37,7 @@ const Input = forwardRef<HTMLInputElement, FormInputProps>(
{
name,
label,
+ termId,
isConfigured,
isOptional,
isRequired,
@@ -81,7 +85,7 @@ const Input = forwardRef<HTMLInputElement, FormInputProps>(
isConfigured={isConfigured}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
) : (
<label htmlFor={name} className="sr-only">
diff --git a/packages/form/src/components/InputControlled.tsx b/packages/form/src/components/InputControlled.tsx
index 74d8ba93c7..1e42469339 100644
--- a/packages/form/src/components/InputControlled.tsx
+++ b/packages/form/src/components/InputControlled.tsx
@@ -1,4 +1,5 @@
import { useFormContext } from "@carbon/form";
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
FormControl,
@@ -11,6 +12,7 @@ import {
InputGroup,
InputLeftAddon,
InputRightAddon,
+ LabelWithHelp,
VStack
} from "@carbon/react";
import type { ChangeEvent, ReactNode } from "react";
@@ -22,6 +24,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormInputControlledProps = Omit<InputProps, "value" | "onChange"> & {
name: string;
label?: ReactNode;
+ termId?: TermId;
isConfigured?: boolean;
isOptional?: boolean;
isUppercase?: boolean;
@@ -41,6 +44,7 @@ const InputControlled = forwardRef<HTMLInputElement, FormInputControlledProps>(
{
name,
label,
+ termId,
isConfigured,
isOptional,
isRequired,
@@ -128,7 +132,7 @@ const InputControlled = forwardRef<HTMLInputElement, FormInputControlledProps>(
isConfigured={isConfigured}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
{prefix || suffix ? (
diff --git a/packages/form/src/components/MultiSelect.tsx b/packages/form/src/components/MultiSelect.tsx
index 44fba97fd1..80a2ef01d0 100644
--- a/packages/form/src/components/MultiSelect.tsx
+++ b/packages/form/src/components/MultiSelect.tsx
@@ -1,3 +1,4 @@
+import type { TermId } from "@carbon/glossary";
import type { MultiSelectProps as MultiSelectBaseProps } from "@carbon/react";
import {
Badge,
@@ -5,6 +6,7 @@ import {
FormErrorMessage,
FormHelperText,
FormLabel,
+ LabelWithHelp,
MultiSelect as MultiSelectBase
} from "@carbon/react";
@@ -18,6 +20,7 @@ export type MultiSelectProps = Omit<
> & {
name: string;
label?: string;
+ termId?: TermId;
helperText?: string;
value?: string[];
onChange?: (newValue: { value: string; label: string }[]) => void;
@@ -62,6 +65,7 @@ const MultiSelectPreview = (
const MultiSelect = ({
name,
label,
+ termId,
helperText,
maxPreview,
...props
@@ -85,7 +89,7 @@ const MultiSelect = ({
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
{(value ?? []).filter(Boolean).map((selection, index) => (
diff --git a/packages/form/src/components/Number.tsx b/packages/form/src/components/Number.tsx
index 20807b6634..04c96d8c7f 100644
--- a/packages/form/src/components/Number.tsx
+++ b/packages/form/src/components/Number.tsx
@@ -1,9 +1,11 @@
+import type { TermId } from "@carbon/glossary";
import type { NumberFieldProps } from "@carbon/react";
import {
FormControl,
FormErrorMessage,
FormHelperText,
FormLabel,
+ LabelWithHelp,
NumberDecrementStepper,
NumberField,
NumberIncrementStepper,
@@ -21,6 +23,7 @@ type FormNumberProps = NumberFieldProps & {
name: string;
size?: "sm" | "md" | "lg";
label?: string;
+ termId?: TermId;
isConfigured?: boolean;
isOptional?: boolean;
isRequired?: boolean;
@@ -34,6 +37,7 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(
name,
size = "md",
label,
+ termId,
isConfigured = false,
isOptional,
isRequired,
@@ -76,7 +80,7 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(
isConfigured={isConfigured}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<NumberField
diff --git a/packages/form/src/components/NumberControlled.tsx b/packages/form/src/components/NumberControlled.tsx
index ee243e880e..e6f08f82f4 100644
--- a/packages/form/src/components/NumberControlled.tsx
+++ b/packages/form/src/components/NumberControlled.tsx
@@ -1,4 +1,5 @@
import { useFormContext } from "@carbon/form";
+import type { TermId } from "@carbon/glossary";
import type { NumberFieldProps } from "@carbon/react";
import {
FormControl,
@@ -7,6 +8,7 @@ import {
FormLabel,
HStack,
IconButton,
+ LabelWithHelp,
NumberDecrementStepper,
NumberField,
NumberIncrementStepper,
@@ -29,6 +31,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormNumberProps = NumberFieldProps & {
name: string;
label?: ReactNode;
+ termId?: TermId;
size?: "sm" | "md" | "lg";
isOptional?: boolean;
isRequired?: boolean;
@@ -45,6 +48,7 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(
{
name,
label,
+ termId,
size,
isConfigured,
isOptional,
@@ -132,7 +136,7 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(
isConfigured={isConfigured}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<NumberField
diff --git a/packages/form/src/components/Password.tsx b/packages/form/src/components/Password.tsx
index 32b6418be3..c05d96b2b0 100644
--- a/packages/form/src/components/Password.tsx
+++ b/packages/form/src/components/Password.tsx
@@ -1,3 +1,4 @@
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
FormControl,
@@ -6,7 +7,8 @@ import {
IconButton,
Input,
InputGroup,
- InputRightElement
+ InputRightElement,
+ LabelWithHelp
} from "@carbon/react";
import { forwardRef, useState } from "react";
import { BiHide, BiShowAlt } from "react-icons/bi";
@@ -16,11 +18,12 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormPasswordProps = InputProps & {
name: string;
label?: string;
+ termId?: TermId;
isRequired?: boolean;
};
const Password = forwardRef<HTMLInputElement, FormPasswordProps>(
- ({ name, label, isRequired, ...rest }, ref) => {
+ ({ name, label, termId, isRequired, ...rest }, ref) => {
const {
getInputProps,
error,
@@ -36,7 +39,7 @@ const Password = forwardRef<HTMLInputElement, FormPasswordProps>(
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<InputGroup>
diff --git a/packages/form/src/components/PhoneInput.tsx b/packages/form/src/components/PhoneInput.tsx
index 788c8f1d88..5238c41fc9 100644
--- a/packages/form/src/components/PhoneInput.tsx
+++ b/packages/form/src/components/PhoneInput.tsx
@@ -1,3 +1,4 @@
+import type { TermId } from "@carbon/glossary";
import type { InputProps } from "@carbon/react";
import {
Button,
@@ -12,6 +13,7 @@ import {
FormErrorMessage,
FormLabel,
Input,
+ LabelWithHelp,
Popover,
PopoverContent,
PopoverTrigger
@@ -33,6 +35,7 @@ const PhoneInputComponent = ReactPhoneInput.default;
type PhoneInputProps = InputProps & {
name: string;
label?: string;
+ termId?: TermId;
isRequired?: boolean;
} & Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> &
Omit<ReactPhoneInput.Props<typeof ReactPhoneInput.default>, "onChange"> & {
@@ -43,7 +46,7 @@ type PhoneInputProps = InputProps & {
const PhoneInput: ForwardRefExoticComponent<PhoneInputProps> = forwardRef<
ElementRef<typeof ReactPhoneInput.default>,
PhoneInputProps
->(({ name, label, isRequired, className, ...props }, ref) => {
+>(({ name, label, termId, isRequired, className, ...props }, ref) => {
const { getInputProps, error, isOptional: fieldIsOptional } = useField(name);
const [value, setValue] = useControlField<string>(name);
const formState = useFormStateContext();
@@ -61,7 +64,7 @@ const PhoneInput: ForwardRefExoticComponent<PhoneInputProps> = forwardRef<
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<PhoneInputComponent
diff --git a/packages/form/src/components/Radios.tsx b/packages/form/src/components/Radios.tsx
index 3ce96f42b3..646dcd09cd 100644
--- a/packages/form/src/components/Radios.tsx
+++ b/packages/form/src/components/Radios.tsx
@@ -1,7 +1,9 @@
+import type { TermId } from "@carbon/glossary";
import {
FormControl,
FormErrorMessage,
FormLabel,
+ LabelWithHelp,
RadioGroup,
RadioGroupItem
} from "@carbon/react";
@@ -12,6 +14,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type RadiosProps = {
name: string;
label?: string;
+ termId?: TermId;
options: { label: string; value: string }[];
orientation?: "horizontal" | "vertical";
};
@@ -19,6 +22,7 @@ type RadiosProps = {
const Radios = ({
name,
label,
+ termId,
options,
orientation = "vertical"
}: RadiosProps) => {
@@ -31,7 +35,7 @@ const Radios = ({
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<RadioGroup
diff --git a/packages/form/src/components/Select.tsx b/packages/form/src/components/Select.tsx
index 1a49fb0b00..94e3c7ff25 100644
--- a/packages/form/src/components/Select.tsx
+++ b/packages/form/src/components/Select.tsx
@@ -1,3 +1,4 @@
+import type { TermId } from "@carbon/glossary";
import {
buttonVariants,
Select as CarbonSelect,
@@ -8,6 +9,7 @@ import {
FormLabel,
HStack,
IconButton,
+ LabelWithHelp,
SelectContent,
SelectItem,
SelectTrigger,
@@ -24,6 +26,7 @@ import { useFormStateContext } from "../internal/formStateContext";
export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
name: string;
label?: string;
+ termId?: TermId;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
@@ -42,6 +45,7 @@ export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
const Select = ({
name,
label,
+ termId,
helperText,
isConfigured = false,
isOptional,
@@ -80,7 +84,7 @@ const Select = ({
isConfigured={isConfigured}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
diff --git a/packages/form/src/components/SelectControlled.tsx b/packages/form/src/components/SelectControlled.tsx
index 85f986c679..4b47b4d6e9 100644
--- a/packages/form/src/components/SelectControlled.tsx
+++ b/packages/form/src/components/SelectControlled.tsx
@@ -1,8 +1,10 @@
+import type { TermId } from "@carbon/glossary";
import {
FormControl,
FormErrorMessage,
FormHelperText,
- FormLabel
+ FormLabel,
+ LabelWithHelp
} from "@carbon/react";
import { useEffect } from "react";
@@ -14,6 +16,7 @@ import { SelectBase } from "./Select";
export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
name: string;
label?: string;
+ termId?: TermId;
helperText?: string;
isConfigured?: boolean;
isOptional?: boolean;
@@ -27,6 +30,7 @@ export type SelectProps = Omit<SelectBaseProps, "onChange"> & {
const SelectControlled = ({
name,
label,
+ termId,
helperText,
options,
isConfigured,
@@ -65,7 +69,7 @@ const SelectControlled = ({
isOptional={resolvedIsOptional}
onConfigure={onConfigure}
>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input
diff --git a/packages/form/src/components/Textarea.tsx b/packages/form/src/components/Textarea.tsx
index 72691a9fd0..c074aa72b1 100644
--- a/packages/form/src/components/Textarea.tsx
+++ b/packages/form/src/components/Textarea.tsx
@@ -1,8 +1,10 @@
+import type { TermId } from "@carbon/glossary";
import type { TextareaProps } from "@carbon/react";
import {
FormControl,
FormErrorMessage,
FormLabel,
+ LabelWithHelp,
Textarea as TextAreaBase
} from "@carbon/react";
import type { ChangeEvent } from "react";
@@ -13,6 +15,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormTextArea = TextareaProps & {
name: string;
label?: string;
+ termId?: TermId;
size?: "sm" | "md" | "lg";
characterLimit?: number;
isRequired?: boolean;
@@ -24,6 +27,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, FormTextArea>(
{
name,
label,
+ termId,
size,
characterLimit,
isRequired,
@@ -54,7 +58,7 @@ const TextArea = forwardRef<HTMLTextAreaElement, FormTextArea>(
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<TextAreaBase
diff --git a/packages/form/src/components/TextareaControlled.tsx b/packages/form/src/components/TextareaControlled.tsx
index 7871b07010..759207d7de 100644
--- a/packages/form/src/components/TextareaControlled.tsx
+++ b/packages/form/src/components/TextareaControlled.tsx
@@ -1,9 +1,11 @@
+import type { TermId } from "@carbon/glossary";
import type { TextareaProps } from "@carbon/react";
import {
FormControl,
FormErrorMessage,
FormHelperText,
FormLabel,
+ LabelWithHelp,
Textarea as TextAreaBase
} from "@carbon/react";
import type { ChangeEvent } from "react";
@@ -14,6 +16,7 @@ import { useFormStateContext } from "../internal/formStateContext";
type FormTextAreaControlledProps = Omit<TextareaProps, "value" | "onChange"> & {
name: string;
label?: string;
+ termId?: TermId;
characterLimit?: number;
isOptional?: boolean;
isRequired?: boolean;
@@ -31,6 +34,7 @@ const TextAreaControlled = forwardRef<
{
name,
label,
+ termId,
characterLimit,
isOptional,
isRequired,
@@ -77,7 +81,7 @@ const TextAreaControlled = forwardRef<
>
{label && (
<FormLabel htmlFor={name} isOptional={resolvedIsOptional}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<TextAreaBase
diff --git a/packages/form/src/components/TimePicker.tsx b/packages/form/src/components/TimePicker.tsx
index 029cfb4679..e3a6b4d90a 100644
--- a/packages/form/src/components/TimePicker.tsx
+++ b/packages/form/src/components/TimePicker.tsx
@@ -1,7 +1,9 @@
+import type { TermId } from "@carbon/glossary";
import {
FormControl,
FormErrorMessage,
FormLabel,
+ LabelWithHelp,
TimePicker as TimePickerBase
} from "@carbon/react";
import type {
@@ -17,13 +19,14 @@ import { useFormStateContext } from "../internal/formStateContext";
type TimePickerProps = {
name: string;
label?: string;
+ termId?: TermId;
minValue?: TimeValue;
maxValue?: TimeValue;
onChange?: (time: TimeValue) => void;
};
type TimeValue = Time | CalendarDateTime | ZonedDateTime;
-const TimePicker = ({ name, label, onChange }: TimePickerProps) => {
+const TimePicker = ({ name, label, termId, onChange }: TimePickerProps) => {
const formState = useFormStateContext();
const isDisabled = formState.isDisabled || formState.isReadOnly;
const {
@@ -46,7 +49,7 @@ const TimePicker = ({ name, label, onChange }: TimePickerProps) => {
<FormControl isInvalid={!!error}>
{label && (
<FormLabel htmlFor={name} isOptional={fieldIsOptional ?? false}>
- {label}
+ <LabelWithHelp termId={termId}>{label}</LabelWithHelp>
</FormLabel>
)}
<input type="hidden" name={name} value={time?.toString()} />
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..8ec244aecc
--- /dev/null
+++ b/packages/glossary/src/helpers.ts
@@ -0,0 +1,77 @@
+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;
+}
+
+/** Canonical lookup — total over `TermId`. Every member of `keyof typeof terms`
+ * is a key of `terms`, so this can't return `undefined`; call-sites that have a
+ * literal-typed id (e.g. `LabelWithHelp` props) don't have to handle a missing
+ * entry. For free-text or alias slugs use `lookupEntry` instead. */
+export function getEntry(id: TermId): GlossaryEntry {
+ return terms[id];
+}
+
+/** Partial lookup for free-text or alias slugs — e.g. the docs MDX
+ * `<Term>purchase to order</Term>` slugifies the text and probes the glossary.
+ * Returns the canonical entry for a known alias, `undefined` for an unknown
+ * slug. App code with a `TermId` should call `getEntry` instead. */
+export function lookupEntry(id: 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..f0a7c0449c
--- /dev/null
+++ b/packages/glossary/src/index.ts
@@ -0,0 +1,11 @@
+export {
+ getEntry,
+ glossaryEntries,
+ hasEntry,
+ listEntries,
+ lookupEntry,
+ 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..6ff1ca27a0
--- /dev/null
+++ b/packages/glossary/src/terms.test.ts
@@ -0,0 +1,88 @@
+import { describe, expect, it } from "vitest";
+import { getEntry, hasEntry, lookupEntry, 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("getEntry is total over TermId", () => {
+ // `getEntry` is typed as `(id: TermId) => GlossaryEntry` — no undefined.
+ // Free-text/alias probes go through `lookupEntry` instead.
+ expect(getEntry("method").term).toBe("Method");
+ });
+
+ it("hasEntry / lookupEntry resolve unknown slugs to nothing", () => {
+ expect(hasEntry("method")).toBe(true);
+ expect(hasEntry("not-a-real-slug")).toBe(false);
+ expect(lookupEntry("method")?.term).toBe("Method");
+ expect(lookupEntry("not-a-real-slug")).toBeUndefined();
+ });
+
+ it("hasEntry / lookupEntry 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(lookupEntry("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/package.json b/packages/react/package.json
index cde5da7955..c12c1b19f5 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -3,6 +3,7 @@
"dependencies": {
"@carbon/database": "workspace:*",
"@carbon/env": "workspace:*",
+ "@carbon/glossary": "workspace:*",
"@carbon/tiptap": "workspace:*",
"@nanostores/react": "catalog:",
"@carbon/utils": "workspace:*",
diff --git a/packages/react/src/LabelWithHelp.tsx b/packages/react/src/LabelWithHelp.tsx
new file mode 100644
index 0000000000..432c00be73
--- /dev/null
+++ b/packages/react/src/LabelWithHelp.tsx
@@ -0,0 +1,74 @@
+import { getEntry, type TermId } from "@carbon/glossary";
+import type { ReactNode } from "react";
+import { LuInfo } from "react-icons/lu";
+import { HStack } from "./HStack";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger
+} from "./Tooltip";
+import { cn } from "./utils/cn";
+
+const DOCS_BASE_URL = "https://docs.carbon.ms";
+
+type LabelWithHelpProps = {
+ termId: TermId | undefined;
+ children: ReactNode;
+ description?: ReactNode;
+ className?: string;
+ tooltipDelayDuration?: number;
+};
+
+export function LabelWithHelp({
+ termId,
+ children,
+ description,
+ className,
+ tooltipDelayDuration = 200
+}: LabelWithHelpProps) {
+ if (termId === undefined) return <>{children}</>;
+ const entry = getEntry(termId);
+
+ 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/react/src/index.tsx b/packages/react/src/index.tsx
index ddd7c4af18..bae8734ad0 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -172,6 +172,7 @@ import {
} from "./InputOTP";
import { Kbd } from "./Kbd";
import { Label } from "./Label";
+import { LabelWithHelp } from "./LabelWithHelp";
import { Loading } from "./Loading";
import { LoadingBars } from "./LoadingBars";
import {
@@ -474,6 +475,7 @@ export {
InputRightElement,
Kbd,
Label,
+ LabelWithHelp,
Loading,
LoadingBars,
Menu,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5473a09f30..2b17d4a9c3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -569,6 +569,9 @@ importers:
'@carbon/form':
specifier: workspace:*
version: link:../../packages/form
+ '@carbon/glossary':
+ specifier: workspace:*
+ version: link:../../packages/glossary
'@carbon/jobs':
specifier: workspace:*
version: link:../../packages/jobs
@@ -1604,6 +1607,9 @@ importers:
docs:
dependencies:
+ '@carbon/glossary':
+ specifier: workspace:*
+ version: link:../packages/glossary
'@carbon/utils':
specifier: workspace:*
version: link:../packages/utils
@@ -2173,6 +2179,9 @@ importers:
packages/form:
dependencies:
+ '@carbon/glossary':
+ specifier: workspace:*
+ version: link:../glossary
'@carbon/react':
specifier: workspace:*
version: link:../react
@@ -2262,6 +2271,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':
@@ -2587,6 +2614,9 @@ importers:
'@carbon/env':
specifier: workspace:*
version: link:../env
+ '@carbon/glossary':
+ specifier: workspace:*
+ version: link:../glossary
'@carbon/tiptap':
specifier: workspace:*
version: link:../tiptap
@@ -27600,7 +27630,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
@@ -27628,7 +27658,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