Skip to content

formCategoriesSubstore

Manages the hierarchical category tree used to browse and filter forms. Provides both raw state (path, current category) and two ready-to-use UI strategies — breadcrumbs for drill-down navigation and filter for flat category selection.

Table of contents

Properties

Methods


Properties

formCategories

formCategories: ApiResource<TCategoriesTree[]>

API resource containing the hierarchical category tree, including loading and error state.

Each TCategoriesTree node has an id, a name, and a children array of nested sub-categories. The tree is fetched once and cached. See ApiResource for the shape of loading/error state.

Related


categoriesPath

categoriesPath: TCategoriesTree[]

The current navigation breadcrumb path of selected categories, from root to current.

Updated automatically by setCurrentCategory. The first element is the root category, the last element is the currentCategory. An empty array means no category is selected.

Related


currentCategory

currentCategory: TCategoriesTree | undefined

The currently active/selected category, or undefined when none is selected.

When undefined, the forms list is unfiltered by category. Setting a category via setCurrentCategory also updates categoriesPath.

Related


strategies

strategies: {
breadcrumbs: (args: { homeText: string }) => {
formCategories: TCategoriesTree[];
categoriesPath: TCategoriesTree[];
shouldShowForms: boolean;
currentCategory: TCategoriesTree;
setCurrentCategory: (category: TCategoriesTree) => void;
back: () => void;
};
filter: (args: { allText: string }) => {
formCategories: TCategoriesTree[];
categoriesPath: TCategoriesTree[];
currentCategory: TCategoriesTree;
setCurrentCategory: (category: TCategoriesTree) => void;
isSelectedCategory: (category: TCategoriesTree) => boolean;
};
}

Pre-built UI interaction strategies for category navigation.

strategies.breadcrumbs

Drill-down navigation pattern. The user selects a category to go deeper; a back() helper navigates up one level. shouldShowForms is true when the current category has no children (leaf node) — use this to decide whether to render the forms list or the sub-category list.

PropertyTypeDescription
formCategoriesTCategoriesTree[]Root-level categories
categoriesPathTCategoriesTree[]Breadcrumb trail from root to current
shouldShowFormsbooleantrue when at a leaf category
currentCategoryTCategoriesTreeActive category (uses home if none selected)
setCurrentCategory(c) => voidNavigate into a category
back() => voidNavigate up one level

strategies.filter

Flat filter pattern. All root categories are shown simultaneously; clicking one toggles the forms filter. isSelectedCategory returns true for the currently active category.

PropertyTypeDescription
formCategoriesTCategoriesTree[]Root-level categories
categoriesPathTCategoriesTree[]Current breadcrumb path
currentCategoryTCategoriesTreeActive category
setCurrentCategory(c) => voidSelect / deselect a category
isSelectedCategory(c) => booleanReturns true if c is the active category

Related


Methods

setCurrentCategory

setCurrentCategory: (category: TCategoriesTree | undefined) => void

Sets the current category and updates the breadcrumb path accordingly.

Passing undefined clears the selection and resets categoriesPath to [].

Parameters

NameTypeDescription
categoryTCategoriesTree | undefinedCategory to select, or undefined to clear

Related


findFormsByCurrentCategory

findFormsByCurrentCategory: () => void

Applies the current category as a filter on the forms list.

Reads currentCategory and calls the appropriate method on formsSubstore to update the category filter. If no category is selected, the filter is cleared.

Related