@get-asset/sdkComponents
Classification Rules
List active and archived business classification rules, read their conditions and actions, and archive, restore or undo an archive. Add and Edit hand off to your own editor.
Anatomy
Import the primitive and compose the parts you need.
<ClassificationRules.Root onAddRule={openCreate} onEditRule={openEdit}> <ClassificationRules.HasRules> <ClassificationRules.ViewTrigger view="active" /> <ClassificationRules.ViewTrigger view="archived" /> </ClassificationRules.HasRules> <ClassificationRules.AddRuleTrigger /> <ClassificationRules.Loading>Loading rules…</ClassificationRules.Loading> <ClassificationRules.Error> <ClassificationRules.ErrorMessage /> <ClassificationRules.Retry>Try again</ClassificationRules.Retry> </ClassificationRules.Error> <ClassificationRules.Empty>No rules</ClassificationRules.Empty> <ClassificationRules.Success> <ClassificationRules.Rules> <ClassificationRules.Rule> <ClassificationRules.Sentence> <ClassificationRules.Clause> <ClassificationRules.ClauseConnector /> <ClassificationRules.ClauseValues><ClassificationRules.ClauseValue /></ClassificationRules.ClauseValues> </ClassificationRules.Clause> </ClassificationRules.Sentence> <ClassificationRules.MatchCount /> <ClassificationRules.LastMatched /> <ClassificationRules.CreatedAt /> <ClassificationRules.EditTrigger /> <ClassificationRules.ArchiveTrigger /> <ClassificationRules.RestoreTrigger /> </ClassificationRules.Rule> </ClassificationRules.Rules> <ClassificationRules.HasMore><ClassificationRules.LoadMore>Load more</ClassificationRules.LoadMore></ClassificationRules.HasMore> <ClassificationRules.LoadMoreError /> </ClassificationRules.Success> <ClassificationRules.UndoToast><ClassificationRules.UndoMessage /><ClassificationRules.UndoTrigger /></ClassificationRules.UndoToast> <ClassificationRules.WriteErrorToast><ClassificationRules.WriteError /></ClassificationRules.WriteErrorToast></ClassificationRules.Root>Required scopes
The access token used by AssetProvider must include these scopes for this primitive to fetch data successfully:
classification_rule:readclassification_rule:updateexternal_account:readledger:read
API reference
Root props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Compound parts. Required on the SDK Root. |
state | "loading" | "error" | "empty" | — | Force a state and skip API reads. |
rules | TxnClassificationRulePublic[] | — | Override rules and skip API reads; archive and restore operate locally. |
missingLedgerIds | string[] | — | Additional ledger ids treated as missing. Applies to overridden and fetched rules. |
view | "active" | "archived" | — | Current view. Pair with onViewChange to control it. |
defaultView | "active" | "archived" | — | Initial uncontrolled view; defaults to active. |
onViewChange | (view: ClassificationRulesView) => void | — | Called when the selected view changes. |
onAddRule | () => void | — | Open the host editor in create mode. |
onEditRule | (ruleId: string) => void | — | Open the host editor for the selected rule. |
pageSize | number | — | Rules per API request; defaults to 25. |
hasMore | boolean | — | Override pagination availability when rules is provided. |
hasRules | boolean | — | Override whether either view has rules when rules is provided; controls view tabs. |
formatAmount | (value: number) => string | — | Money formatting in rule sentences. Defaults to US dollars. |
formatDate | (value: string) => string | — | ISO date formatting. SDK defaults to Jan 31, 2026; React defaults to Jan 31. |
Parts
Compound parts
Value, wrapper and action parts support asChild. Gates and iterators take children. Select bindings clone a child accepting value, onValueChange and disabled. Row parts must be nested inside their iterator.
| Part | Description |
|---|---|
ClassificationRules.Root | Owns business-scoped fetching, view selection, pagination, archive/restore and undo. |
ClassificationRules.Loading | Renders during the initial read. |
ClassificationRules.Error | Renders on initial read failure. |
ClassificationRules.Success | Renders when the selected view contains rules. |
ClassificationRules.Empty | Renders when the selected view has no rules. |
ClassificationRules.ActiveView | Renders while active is selected. |
ClassificationRules.ArchivedView | Renders while archived is selected. |
ClassificationRules.HasRules | Renders when either view contains a rule. |
ClassificationRules.NoRules | Renders when the business has no rules. |
ClassificationRules.ErrorMessage | Friendly load-error copy; accepts format(error). |
ClassificationRules.Retry | Retry the failed initial reads. |
ClassificationRules.ViewTrigger | Selects a view; requires view="active" or view="archived" and exposes data-selected. |
ClassificationRules.AddRuleTrigger | Calls onAddRule to open the host editor. |
ClassificationRules.Rules | Iterates the current rules, providing row context. |
ClassificationRules.Rule | Row wrapper with data-rule-id and data-active. |
ClassificationRules.Sentence | Iterates the current rule sentence clauses. |
ClassificationRules.Clause | Clause wrapper with data-clause. |
ClassificationRules.ClauseConnector | Renders the words connecting clause values. |
ClassificationRules.ClauseValues | Iterates the current clause values. |
ClassificationRules.ClauseValue | Renders one chip value, with data-kind and data-missing for unavailable categories. |
ClassificationRules.MatchCount | Renders transaction match count; accepts format(number). |
ClassificationRules.LastMatched | Last match date; accepts format(ISO string) and placeholder for never matched. |
ClassificationRules.CreatedAt | Creation date; accepts format(ISO string). |
ClassificationRules.EditTrigger | Calls onEditRule with the current rule id. |
ClassificationRules.ArchiveTrigger | Archives the current active rule; disabled while a write is pending. |
ClassificationRules.RestoreTrigger | Restores the current archived rule. |
ClassificationRules.UndoToast | Gate for the latest archive undo notification. |
ClassificationRules.UndoMessage | Archive notification copy; accepts format(sentence: RuleSentenceClause[]). |
ClassificationRules.UndoTrigger | Restores the most recently archived rule. |
ClassificationRules.DismissUndo | Dismisses the undo notification. |
ClassificationRules.WriteErrorToast | Gate for an archive/restore error. |
ClassificationRules.WriteError | Friendly write-error copy; accepts format(error). |
ClassificationRules.DismissWriteError | Dismisses the write error. |
ClassificationRules.HasMore | Gate while another page exists. |
ClassificationRules.LoadMore | Requests the next page, or retries a failed page. |
ClassificationRules.AutoLoadMore | IntersectionObserver sentinel; pauses on page failure until manual retry. |
ClassificationRules.HasLoadMoreError | Gate for a failed next page while retaining loaded rows. |
ClassificationRules.LoadMoreError | Next-page error copy; accepts format(error). |
ClassificationRules.useClassificationRules | Root context hook for view, loading, errors and actions. |
ClassificationRules.useClassificationRule | Current rule context hook; use within Rules. |
ClassificationRules.useClause | Current sentence clause hook; use within Sentence. |
ClassificationRules.useClauseValue | Current chip value hook; use within ClauseValues. |
ClassificationRules.scopes | Required OAuth scope array. |