Data Entry
SearchFilter
Search, filter, group and saved searches in one control.
searchFilter is a ketjs-view island that owns the query of a collection: free text, filter rules,
grouping and favourites, shown as chips that can be removed one by one. createSearchFilterView
renders the same control on the server.
#When to use
- Use it as the query slot of a
ListChromefor collections with many facets. - Offer only the presets a collection supports; custom rules, grouping and favourites are omitted when they are not configured.
#Examples
Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.
#Search filter
Search, filter/group/favorite controls and applied chips share a component-owned 48rem maximum width and fill narrower containers. This hydrated island owns query state; mobile opens the same sections in a sheet. Try the applied facets and a long search phrase to check wrapping. The manager is omitted, so toggling a control updates its chip locally without a server round trip.
Filters1
Filters (1)
Created on
Group by (1)
- 1Customer
Add grouping field
Favorites (1)
- Open
- Group by: Customer
- My open orders
Show codeHide code
import { createSearchFilterView } from 'faifo-design'
// searchFilterDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/search-filter/demo.ts
export const Example = () => (
createSearchFilterView({ id: 'demo-search-filter', config: searchFilterDemoConfig }).view()
)#Expanded search filter
Two-row search toolbar: visible labelled preset values, independent grouping/saved searches and an on-demand custom-rule editor. Applied preset/group state stays in its control; only custom rules and field searches use chips. Compact consumers remain unchanged.
Group by:Customer
Group by (1)
- 1Customer
Add grouping field
Favorites:My open orders
Favorites (1)
Status:Open
Created on:All
Created on
Show codeHide code
import { createSearchFilterView } from 'faifo-design'
// searchFilterDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/search-filter/demo.ts
export const Example = () => (
createSearchFilterView({
id: 'demo-search-filter-expanded',
config: {
...searchFilterDemoConfig,
labels: { ...searchFilterDemoConfig.labels, customFilterToggle: 'Condition' },
presentation: 'expanded',
filters: searchFilterDemoConfig.filters.map((option) => ({
...option,
groupLabel: option.group === 'status' ? 'Status' : 'Created on',
})),
},
}).view()
)#Search filter in list chrome
ListChrome query slot: the expanded search filter leads the row at its own width; the view switch and a saved-filter action end the row level with the search bar and move under it as one group where the row runs out.
Group by:Customer
Group by (1)
- 1Customer
Add grouping field
Favorites:My open orders
Favorites (1)
Filters:Open
Created on:All
Created on
Show codeHide code
import { LinkButton, ListChrome, createSearchFilterView } from 'faifo-design'
// searchFilterDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/search-filter/demo.ts
export const Example = () => (
<ListChrome
query={createSearchFilterView({
id: 'demo-search-filter-chrome',
config: { ...searchFilterDemoConfig, presentation: 'expanded' },
}).view()}
viewsLabel="View"
views={[
{ id: 'table', label: 'Table', href: '#search-filter-list-chrome', active: true },
{ id: 'cards', label: 'Cards', href: '#search-filter-list-chrome' },
]}
actions={<LinkButton label="Edit saved filter" href="#search-filter-list-chrome" />}
/>
)#Preset search filter
The same compact search with only supported preset facets; unsupported custom rules, grouping and favorites are omitted.
Filters1
Filters (1)
Created on
- Open
Show codeHide code
import { createSearchFilterView } from 'faifo-design'
// searchFilterDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/search-filter/demo.ts
export const Example = () => (
createSearchFilterView({
id: 'demo-search-filter-presets',
config: {
...searchFilterDemoConfig,
size: 'compact',
capabilities: { groupBy: false, favorites: false, customFilters: false },
facets: searchFilterDemoConfig.facets.filter((facet) => facet.type === 'filter'),
groupBy: [],
favorites: [],
customFilterFields: [],
},
}).view()
)#Contract
#Expanded SearchFilter
SearchFilterConfig.presentation?: 'compact' | 'expanded' is an additive presentation contract. Omit it to preserve the existing compact desktop popups and combined mobile sheet. With presentation: 'expanded', labelled preset values remain visible in a second toolbar row. Search, grouping and saved searches lead the first row; the custom-rule editor mounts only when its add-condition control is opened. Grouping and saved searches have independently anchored disclosures at every viewport. Only custom rules and field searches render chips; preset/group/favorite state stays in its own control. SearchFilterLabels.allValues? and noGrouping? translate unselected values; customFilterToggle? optionally names the editor launcher separately from the existing add action. The grouping trigger shows the applied fields in order. SearchFilterOption.groupLabel? names an expanded preset group; existing IDs, OR-within-group semantics, facets, managers and navigation callbacks are unchanged. Clearing filters still preserves grouping.
An expanded filter section's panel is as wide as its longest value, at least its trigger and 12rem and at most 26rem, so a one-value section does not open a wide empty popup. Grouping and saved-search panels keep the 26rem their forms need.
SearchFilterConfig.applyOnInput?: boolean makes the typed text apply after a 250 ms pause, and at once on Enter, through the same apply payload (query). The text stays in the field, no generic query chip or suggestion list is created, and a pending pause apply is cancelled by Enter or disposal. Presets and grouping already apply as they are chosen, so a collection using this option has no separate apply step. Omitting it keeps the suggestion-then-chip behaviour.
RecordFormProps.applyOnInput?: boolean gives a GET filter form the same behaviour outside SearchFilter. The form carries data-apply="input"; the runtime (attachDesignSystemInteractions) submits it with requestSubmit() when a select, checkbox or radio changes, and 400 ms after the last keystroke in a text, search or number field. The blur change of a typed field is not a second submit, and an Enter submit cancels the pending pause. The visible submit button is replaced by a hidden default button, so Enter applies without JavaScript too; form-actions renders only when cancelHref is set. The typed field keeps focus across the submit, caret at the end: after a reload the runtime restores it from a sessionStorage entry (kept for 10 s, read once); when an island redraws the form in place, focus moves to the redrawn field with the same id, unless the reader has already left the field.
A POST RecordForm may opt in too when it holds one on/off choice that saves by itself, such as a setting card's switch: give the field type: 'switch' (the control Switch draws, role="switch", posting value, default 1, only while on) and put what identifies the setting in hidden. Changing the switch submits the form at once; the route answers with a redirect back to the page. Keep anything else the reader must fill in out of that form, in a dialog with its own save.
FilterBar({ action }) is the same kind of form for a few choices that read as one phrase in a page's controls, such as a report's period, measure and grouping (Select with labelHidden, so the options name themselves: "Year 2026", "By month"). With action the bar renders <form data-ui="filter-bar" method="get" data-apply="input">, carries hidden query values such as the company scope, and ends with a hidden default button named by submitLabel; the runtime applies a changed choice at once. Use it instead of stacked Tabs rows when a report has more than one choice. Without action the bar is a <section> that only groups controls.
The search-filter-expanded catalogue specimen exercises the opt-in layout. Consumers should select the presentation through this public configuration rather than restyling private descendants. Density (size) remains independent of presentation.
A collection with an existing data controller may compose createSearchFilterView(props, { apply(input, signal) }). This optional integration receives the same query, facet, filter, ordered grouping and favorite payload as the RPC manager; it leaves data reads, history and pagination with the collection. The one-argument factory and serialized searchFilter island keep their manager behavior. Compose the controller's view, mount it at its own root and dispose it with the owner. Its standard update({ id, config }) synchronizes query/facets/rules/favorites after Back or an external read while retaining unsubmitted text when the applied query did not change. Labels, presentation, capabilities and field/group vocabulary are fixed for that instance; remount when that structural configuration changes. Expanded selection returns keyboard focus to its own menu trigger.
A collection's data-backed choices (its vendors, its locations, its saved favorites) may arrive with its read's answer rather than with the page the server rendered. controller.update(nextProps) with new config.filters redraws the filter menus in place: a group that arrives later gets its own menu, the typed query, chips and open state stay. The book passes those choices on every answer; it does not rebuild the view to add them. Test: search filter: choices that arrive with a later answer get their own menu.
A list that also switches views (table/cards) or links to its saved filter puts the search filter in ListChrome.query rather than stacking a second toolbar row under it. The slot leads the query row at the search filter's own width (up to 48rem); views, sort and actions end that row level with the search bar (data-query="slot", top-aligned because the expanded filter is two rows tall) and move under it as one group where the row runs out. query replaces the plain search form; lists without it are unchanged. Specimen: search-filter-list-chrome.
#CSR accounting consumers
AppTopbar.search.mode="link" leads directly to a search workspace and emits no
native dialog/template/noscript subtree; dialog remains the default. ListPage
accepts busy and dimmed: an island owns delay, stale reads and disposal; the
pattern owns aria-busy and --faifo-opacity-pending. Peek.closeControl accepts a
public client trigger while keeping the summary non-modal. ConfirmDialog accepts
mode="client"; its cancel command is handled by the client modal owner.
Client-read record pages own tab, dialog and dialogId in browser history and
retain their list trail. Record commands retain an idempotency intent across an
uncertain response; changed input receives another intent, and success clears it.
recordChanged exposes captured parent edits to a child decision; a posting
confirmation must require saving those edits first. Each read of the record
(the re-read after a command, a refresh, a cached first frame) drops the
baselines of fields no capture holds, in the same batch as the new data, so
draft() seeds them from the record as read now; a value just saved therefore
never counts as an edit. Runtime effects remain in the
island. Static SSR shell props never carry business data, rights or field options.
Peer Sections inside one Surface or modal use Stack({ divided: true }); its
existing token hairline is mandatory, including in CSR presenters.
#Exact values in adaptive metric cards
Use CardGrid with minimum="wide" for long currency metrics. Metric owns a bounded text column and wraps long labels and exact values; consumers do not truncate financial totals or override metric descendants. Specimen: metric-exact-long-value; focused producer checks and mutations: design/account/producer-contracts.test.mjs and tools/design/verify-account-producer-mutations.mjs.
A metric that opens what it counts (a queue, a filtered collection) passes href: the whole card is that link, focusable and named by its label and value. Do not add a separate "View list" button under the number. Inside a titled Surface a group of metrics is plain figures without href, so one card never holds several competing links.
#Side-by-side cards follow the room they have
Grid collapses to one column only below the 48rem viewport, so beside an open sidebar at 768px a
columns={2} grid gives each card about 14rem: a BarChart track shrinks to nothing and a list wraps
every line. Pass minimum (compact 12rem, default 17rem, wide 23rem, the CardGrid widths):
the grid keeps at most columns but drops one whenever a column would be narrower than the minimum,
measured on the grid itself rather than the viewport. Without minimum the fixed columns are unchanged.
Dashboard pairs (a work queue beside closing checks, two aging charts) use columns={2} minimum="wide".
Specimen: Columns by room in the layout rhythm primitives.
A BarChart shares one label and one value column across its rows from 48rem, so every track starts
and ends on one line however wide each printed value is.
#Change against a period and series over time
Metric.change ({ label, direction: 'up' | 'down' | 'flat', tone? }) compares the figure with an earlier
period. The label carries the signed amount and the period in words ("+12.4% vs previous 7 days"); a
trending-up/trending-down/minus arrow repeats the direction and tone says whether that
direction is good, so a cost that rose is danger with an upward arrow. The figure keeps the page's ink.
ColumnChart shows one magnitude over ordered periods (spend per day, orders per week). Each column is a
list item whose reading (label · value(point)) is real text; pointer hover shows it above the plot and the
bars, ticks and gridlines are decorative. Points carry optional segments with keys, exactly as a stacked
BarChart. reference draws one dashed level (a daily budget, a target) with a printed label and raises
the default top to include it. labelEvery prints every n-th period label, counted back from the latest
one; tick supplies short axis text. The scale starts at zero; negative values draw as zero. The plot is
11rem high with a 3.5rem axis gutter, and columns tighten their gap below a 32rem chart width. A column is
at most 4rem wide, so a few periods (one month, a quarter) spread evenly across the plot instead of one bar
filling it. Specimen: column-chart.
QrCode draws a QR code a phone can scan: a bank-transfer request on an invoice, a link, a pairing
code. The package encodes it itself (QR Model 2, byte mode over UTF-8, versions 1 to 40, levels
L/M/Q/H, default M) and renders one server-side <svg role="img"> named by label, so it
prints, scales and needs no script or dependency. The symbol is always black on a white plate with its
four-module quiet zone, in both themes and in print, because scanners need that contrast; do not tint it.
Whatever a person needs to read without scanning (the account, the amount, the reference) goes in
caption, never only in the code. size is small (7.5rem), default (10rem) or large (13rem) and
never exceeds its container. Text too long for version 40 throws a RangeError, so callers bound what
they encode. The consumer builds the payload (for example an EMVCo merchant-presented string); the
component does not interpret it. Specimen: qr-code; test: test/design-system-qr-code.test.tsx reads
symbols back from the standard's tables. qrSvg(value, { label }) returns the same symbol as a standalone SVG file, its
white plate and black modules drawn in and label as its <title>, for an <img>, a download or a
document without the stylesheet; show it inside the same qr-code figure so the caption rule holds.
SignatureBlock is where one person signs a printed document (a delivery or receipt voucher, a
handover): label (who signs), an optional hint (how to sign, such as "(Signature, full name)"), then
4rem of room to sign by hand, then name when the books know who it is, or a dotted line 10rem wide to
write it on. The room to sign is the component's geometry, the same on screen and on paper, and a block
is not split across printed pages; do not pad it with empty elements or line breaks. Set several side by
side in a Grid (columns={4}, mobileColumns={2}), which owns the gap between them. Specimen:
signature-block; test: test/design-system-signature-block.test.tsx.
A printed document spans as many sheets as it needs. On paper a Grid keeps its columns (it narrows only
on a phone screen), a Surface leaves its border, fill and inset to the sheet, and a DataTable wraps
long text within the printable width, never cuts a row and repeats its header row on each page. Stack
takes print: keep moves the whole stack to the next page rather than splitting it while it fits on one
(one line of the document with its figures; the last line with the closing and its signatures), and
omit leaves out what only serves the screen (a way back, a printing hint). Test:
test/design-system-print-layout.test.tsx; the A4 page breaks themselves are checked from a PDF by
e2e/commerce_supply/count-minutes-a4.spec.ts.
#Sidebar island slot height
AppShell gives its sidebar's only child the available block size, including a disposable island wrapper. Navigation keeps its viewport geometry and internal scrolling; consumers do not patch sidebar descendants. Producer CSS check/mutation and Account browser geometry cover this contract. Account's breadcrumb-free canvas is an explicit user choice and still exposes a separate list-return link.
Record runtime exposes draftScope (record / dialog) to namespace input IDs by owning layer. Route dialog metadata is present on both layers and must not determine control IDs. A refused submit focuses the first invalid control after rendering the retained draft.
Button and LinkButton accept optional truncateLabel for single-line record
values inside constrained layouts. The Action owns the shrink boundary and a
full-label tooltip; its public Text owns the ellipsis. Keep the nested Text when
updating the label at runtime, and update the tooltip to the complete value.
Default actions continue to wrap. See the long-label catalogue specimen and
test/design-system-action-truncate.test.tsx.
Button.logo={{src}} opts into a named brand choice. It replaces the visible
label with an 80×24 contained image on a 112×48 minimum stage, keeps label as
the accessible name/tooltip, and shows a check icon when pressed. Consumers
own selection and ordering; the public component owns geometry, frame, focus
and original brand colours on white in both themes. Ordinary controls are unchanged.
See test/design-system-logo-button.test.ts and the Button specimen.
ModalSheet.size="workspace" fills the available viewport width inside the
desktop overlay margin. It preserves the existing fullscreen phone behavior,
native close route, focus return and height="fixed" bands. Layer clipping
prevents focus/fragment navigation from scrolling the title or footer away;
the body retains its scroll. See test/design-system-workspace-modal.test.ts.
Menu label entries expose a stable ${menuId}-${entryId}-label ID and optional
hidden state. A filtered menu can toggle its empty message inside the owned
panel without moving unrelated page content into the popup. The consumer owns
search results and live announcements; the Menu owns the label's spacing and
typography. See test/design-system-menu-label.test.tsx.
Menu choices and headings wrap long words within the panel. The shared runtime
measures the trigger and enclosing scroll regions, keeps the popup inside their
visible bounds, and opens above when more room is available. Resize updates the
measurement; closing/disposal clears it. The native disclosure remains available
without JavaScript. See test/design-system-menu-fit.test.ts.
Menu takes triggerAppearance="plain" when its trigger content draws the
face itself, such as an avatar or a tile matching the plain tiles beside it.
The trigger keeps its name, disclosure semantics, focus ring and panel but
drops the button frame, padding and fill, also at size="compact". Style the
trigger content, never [data-ui="menu-trigger"]. See
test/design-system-menu-trigger.test.tsx.
Keyboard navigation skips hidden and disabled Menu choices after filtering.
A disabled trigger blocks activation and navigation keys while preserving Tab
and Escape. See test/design-system-menu-keyboard.test.ts.
#Screen help and ecosystem Mermaid
Field({ type: 'date' | 'datetime-local', locale: 'vi' | 'en' }) forwards the
host locale to the public picker, including fields passed through RecordModalForm.
Omitting locale retains the existing Vietnamese picker default; native ISO values
and input names remain unchanged. See the English host Field in DatePickerExamples.
When a trigger belongs to a ModalSheet, RecordPage or Peek, help resolves the guide inside that nearest content owner. A background screen's previously bound guide must not override the record guide. Shell triggers retain their screen guide; content-slot navigation resolves replacement guides at request time.
AppSwitcherHelp({ label }) exports the rail's Help trigger for standalone app
navigation. Pair it with a screen-owned HelpDrawer; the existing runtime owns
faifo:screen-help-request, association, Escape and focus return. It reuses the
same hook and geometry as AppSwitcher.helpLabel, without adding a second rail.
Standalone apps that already own their other interactions can attach the same
Help producer with attachHelpDrawers(root) from
faifo-design/help/runtime. It includes the trigger bridge,
Escape/focus and disposal; do not also attach the full runtime to the same root.
Hosts with an existing navigation implementation may pass beforeOpen(trigger)
as the second argument. Close the host's compact navigation there and return its
visible toggle for focus restoration. The DS runtime continues to own the dialog,
scroll lock, Escape and modal focus boundary. Keep the trigger and drawer inside
the host's data-faifo-design style scope.
In the Suite shell a List or Workspace page puts no Help trigger in its header: the rail's
AppSwitcher.helpLabel is that screen's trigger, passed only when the screen has a guide, and the
header keeps the screen's own commands (none when it has none, rather than an empty ActionGroup).
Each screen names its own guide, while fragment navigation keeps the rail: a host that swaps the
content passes AppSwitcher.helpSlot (a data-ket-slot name) and sends the rail's Help again, as
AppSwitcherHelp, in that slot with every navigation, so ? names the screen now shown, Back included.
RecordPage, ModalSheet and Peek may carry their own trigger, whose guide resolves inside them.
One without a guide of its own opens the screen guide that the content slot renders beside it, so
a page-level ? still works on a phone, where the rail's ? is out of reach.
For shell ownership, persistent navigation and host integration, read the shell integration guide for agents.
Agents working on any screen must check its guide. If it is missing, author and
integrate a real Vietnamese/English Markdown guide in the same task and PR; update
existing guides when workflows change. A touched screen is not complete while its
guide is missing. Explain implemented tasks, states and relevant recovery; use
Mermaid when it clarifies a workflow, with the ecosystem theme below.
Render the screen-owned drawer in the changing content slot and enable the
shell's AppSwitcher.helpLabel only when that screen's guide works. The shared
faifo:screen-help-request hook binds it; do not build a separate drawer or listener.
Verify open/close, Escape,
focus return, Markdown/diagrams and guide replacement on navigation in the current
deployment at desktop/mobile widths. This rule does not require migrating untouched
screens as part of an unrelated task.
HelpDrawer is the standard screen guide: 512px (--faifo-help-width: 32rem) at the
right edge on desktop, modeless so the current screen remains interactive. Below
768px it uses a native modal dialog at full viewport width/height; navigation
closes first, body scrolling locks, native dialog focus containment applies and
closing returns focus to the navigation toggle. Desktop closing returns focus to
?. Escape, the close control and pressing ? again dismiss it, and so does a
primary press anywhere outside the guide on desktop; that light dismissal leaves
focus where the pointer put it. A text selection dragged out of the guide and
keyboard activation elsewhere do not dismiss it. The header stays
fixed while only the body scrolls. Fragment navigation disposes the old guide and
binds the new screen content; the SSR shell is not replaced.
Hosts supply the translated id, label, screen title, closeLabel and body.
A page-owned public Button/IconButton can also launch the same guide with
name="screen-help", the guide ID as value and controls, and expanded={false}.
The disposable runtime binds it alongside the application-rail trigger; native
Help owns Escape without dismissing an underlying route modal.
Use MarkdownContent for the body, with source, a host-supplied GFM lexer
(marked.lexer is compatible), localized diagram/source/loading/error/table labels
and headingOffset={1} for the drawer's heading hierarchy. The component renders
headings, paragraphs, emphasis, lists, tasks, links, images, quotes, tables and code
on the server. Raw HTML is text, executable/protocol-relative URLs are rejected,
and Mermaid fences retain readable source without JavaScript. Tables and wide
SVG diagrams scroll within their own regions instead of widening the drawer.
Mermaid renders off-screen; once a diagram is shown the runtime fits its view box
to the drawing in place (8px inset), so a box measured off-screen never shifts or
clips it. A narrow drawer reads a top-down flow (flowchart TD) without scrolling.
Mermaid presentation belongs to the public DS runtime, including uses outside
help drawers. createMermaidTheme and readMermaidPalette are exported from
faifo-design/runtime; every app must use this configuration rather
than creating a local theme. It resolves the current DS tokens to hex colors,
including alpha and light/dark aliases, uses the interface font (--faifo-font-sans) at 13px, 1.25px flow/sequence strokes,
12px rectangular node corners and rounded connectors. Process nodes use the accent
surface; connectors stay muted. Explicit accent/positive/warning/danger classes
(faifo-accent, faifo-positive, faifo-warning, faifo-danger) work on rectangles,
polygons, circles and path-based shapes such as start/end stadiums. Notes use the warning surface. Flowchart, sequence, state, ER,
class, pie, Gantt and graph palettes share these roles; chart categories use soft
DS fills and readable foregrounds, never Mermaid's default rainbow.
Flowcharts use 24px sibling spacing, 32px rank spacing, 12px padding, an 180px
label wrapping width and an 80px minimum label width. These are diagram geometry,
not app spacing overrides. Labels stay 13px at narrow widths; scroll or the host's
expanded viewer preserves readability. Edge labels have rounded neutral pills.
The pinned Mermaid 12.1.0 renderer supports curve: 'rounded' for rounded bends.
Use Q("Question?"):::faifo-decision for compact decisions: an amber, dashed,
rounded box plus explicitly named branches. Use S(["Start"]) for start/end
stadiums, faifo-positive for a successful outcome, faifo-warning for attention or
waiting, and faifo-danger for a blocked/stopped outcome. Wording and dashed decision
borders carry meaning alongside colour. Existing diamond syntax remains supported;
the theme does not infer business meaning or rewrite diagram source.
flowchart TD
A(["Start"]) --> B["Check order"]
B --> C("Stock available?"):::faifo-decision
C -->|Yes| D["Reserve inventory"]
C -->|No| E["Contact customer"]:::faifo-warning
D --> F(["Complete"]):::faifo-positive
E --> G(["Stopped"]):::faifo-dangerKeep a reading diagram within its article column at normal scale where practical:
prefer top-to-bottom for long chains, keep recovery branches beside their decision,
and split approval from subsequent monitoring when one graph sprawls. Shorten node
labels only when adjacent prose preserves the detail. Do not remove conditions,
invent process edges for layout, or shrink the type to make a diagram fit.
See Mermaid flowchart syntax for shapes
and branches; use the DS classes rather than content-level CSS or classDef.
Help currently pins the older published DS 0.1.41. Its temporary compatibility module
is generated byte-for-byte from src/runtime/mermaid-theme.js by the host repository's
tools/sync-help-mermaid.mjs; --check detects divergence. Changes to this canonical
module must regenerate that adapter in the same change. Help has no separate theme
and still builds without a KetSuite checkout. Replace the adapter with public runtime
imports after Help upgrades to a DS release containing this contract; no npm publication
is implied by a local producer build.
Apps pin and bundle their renderer, then configure the loader before attaching
the shared runtime. The DS keeps its only dependency on ketjs-view; neither the
Markdown lexer nor Mermaid is a DS dependency. The catalogue pins marked 18.1.0
and Mermaid 12.1.0 and bundles diagram chunks locally, with no CDN requirement.
// File: apps/example/client.ts
import { configureMermaidLoader, attachDesignSystemInteractions } from 'faifo-design/runtime'
configureMermaidLoader(async () => (await import('mermaid')).default)
const dispose = attachDesignSystemInteractions(document)
// Call dispose before replacing this root's fragments.Both are also public exports of faifo-design; packages held to the
public entry, such as KetSuite (zero-dep-audit), import them from there.
After inserting a diagram, the runtime shows its canvas and fits the SVG view box to the visible drawing with an 8px inset before setting its natural width. Stale width/height attributes are removed so the fitted view box owns the aspect ratio and text stays at its native size. This prevents off-screen Mermaid measurements from clipping a screen-help diagram.
Rendering is lazy for closed drawers, serialized because Mermaid configuration is global, and guarded against disposal while a render is pending. Theme changes rerender the active SVGs. Strict Mermaid rendering disables HTML labels and click callbacks. Diagram frontmatter/config/style overrides are rejected so content cannot replace the ecosystem theme; use the semantic classes instead. Invalid syntax or unavailable renderers display a translated status and source fallback. No Markdown content is inserted as trusted HTML.
The connected preview is /demo2; /help-theme?theme=light and ?theme=dark
exercise five diagram families plus invalid-source fallback. Build only the
catalogue renderer with node tools/build-design-system-mermaid.mjs when iterating.
#RelationSelect field validation
RelationSelectConfig optionally accepts triggerId, invalid and describedBy. Compose these with a public Field: use its ID as triggerId, set invalid when the server returns a field error, and associate describedBy with the Field error ID. The visible trigger owns aria-invalid and keyboard error focus; the off-tab native select retains submission and required validation. Existing configurations may omit all three properties.
#Server field errors after a fetch submit
A form that posts with fetch learns about a field error only after the page has rendered,
so it cannot pass error to Field. Do not call setCustomValidity/reportValidity for
it: the browser bubble covers the help text, disappears on the next click and leaves nothing
for a screen reader to find again. Call showFieldError(control, message) from
faifo-design with the control the server named (for a checkbox or radio
group, any of its inputs). It adds the same field-error markup Field renders with
error, after the help, sets data-invalid on the Field and aria-invalid plus the error
ID in aria-describedby on the control (on the group and every choice for an option group),
and focuses the control; pass { focus: false } when another error already took focus.
A second call replaces the message. The next input or change inside that Field removes
it and restores the attributes it found; the returned function and
clearFieldError(control) remove it earlier, including an error the Field was rendered with.
A check that answers while the person is still typing (an email someone already uses) passes
{ focus: false, announce: true }: focus stays in the field, and the message is an alert that
is read out when it appears.
A control outside a Field is a no-op, so say that message elsewhere (a toast or a Notice).
#Record changes and client collections
The shared KetSuite record runtime emits cancelable faifo:records-changed. A mounted paged collection claims the event in capture phase and refreshes its read, preserving list query and focus. The backend shell remains the fallback for server-rendered collections. Closing a record through its own history entry does not navigate the collection. See the host's record runtime contract.
RecordForm.groups renders peer groups inside one native form and one save. Each group supplies a stable id, translated title, optional description and public FieldProps[]. fields remain the leading ungrouped fields (use an empty array for a fully grouped form). The form owns divided Stack/Section and FormGrid composition. The caller owns the working Surface, so groups add no nested frame or inset. Specimen: record-form-groups.
RecordForm.submitDisabled disables only its visible submit button. Fields remain editable and validation feedback remains available, so a domain prerequisite does not turn the draft into a disabled form. The server must still validate that prerequisite. Specimen: record-form-submit-blocked.
Record consumers preserve domain refusal messageKey alongside field/code. The Suite runtime translates the message key before the code, retaining a generic fallback when neither is known; field identity and focus remain unchanged. See the Suite record-modal documentation.
#Full-page native drafts
RecordForm.unsavedPrompt opts a full-page native form into the KetSuite host draft guard; initialDraft marks values retained after a refused submission. The host compares submitted controls (including relation/date hidden values) to the mounted baseline. Modified forms use the public centred in-app ConfirmDialog before links, other forms and history traversal; reload/close uses the browser unload prompt. Submitting the guarded form proceeds normally. A declined history traversal restores the draft URL as a history entry and keeps the mounted fields. Modal forms keep their existing modal owner. This requires the KetSuite backend runtime. The KetSuite compatibility ui.RecordForm adapter forwards the same unsavedPrompt and initialDraft hooks; it does not introduce a separate draft store.
#API
Generated from the package source. A property without a description has none in the source yet.
#createSearchFilterViewFunction
function createSearchFilterView(props: SearchFilterIslandProps, integration?: SearchFilterIntegration | undefined): IslandController| Parameter | Type |
|---|---|
propsrequired | SearchFilterIslandProps |
integration | SearchFilterIntegration |
| Returns | IslandController |
#searchFilterFunction
function searchFilter(props: IslandProps): IslandController| Parameter | Type |
|---|---|
propsrequired | IslandProps |
| Returns | IslandController |
#searchFilterRuleLabelFunction
Shared by SSR and interactive chips; values remain data and choices supply display labels.
function searchFilterRuleLabel(options: { fieldLabel: string; operator: SearchFilterOperator; value?: unknown; choices?: readonly { value: string; label: string; }[] | undefined; operatorLabels?: Partial<Record<SearchFilterOperator, string>> | undefined; }): string| Parameter | Type |
|---|---|
optionsrequired | { fieldLabel: string operator: SearchFilterOperator value?: unknown choices?: CustomFilterField['choices'] operatorLabels?: SearchFilterLabels['operatorLabels'] } |
| Returns | string |
#Types
#CustomFilterField
| Property | Description | Type | Default |
|---|---|---|---|
valuerequired | – | string | – |
labelrequired | – | string | – |
typerequired | – | SearchFilterFieldType | – |
choices | Screen-owned choices, including permission-checked reference lookups. | readonly { value: string; label: string }[] | – |
#SearchFacet
A removable chip in the search field. type only drives its colour token.
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
typerequired | – | 'field' | 'filter' | 'groupBy' | 'favorite' | – |
labelrequired | – | string | – |
#SearchFavorite
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
labelrequired | – | string | – |
isDefaultrequired | – | boolean | – |
activerequired | – | boolean | – |
#SearchFilterCustomRule
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
fieldrequired | – | string | – |
operatorrequired | – | SearchFilterOperator | – |
valuerequired | – | string | – |
labelrequired | – | string | – |
#SearchFilterConfig
| Property | Description | Type | Default |
|---|---|---|---|
namerequired | – | string | – |
presentation | Expanded keeps filters inline and grouping/saved searches independently reachable at every width. Omitted preserves the existing compact popup/mobile-sheet contract. | 'compact' | 'expanded' | – |
applyOnInput | Applies the typed text after a short pause (Enter applies at once) instead of waiting for a suggestion; the text stays in the field and never becomes a query chip. Filters and grouping always apply as they are chosen. | boolean | – |
capabilities | Disable unsupported editors while retaining the same search and preset-facet interaction. | { groupBy?: boolean; favorites?: boolean; customFilters?: boolean } | – |
size | Keeps the standard interaction while reducing the search bar's visual density. | SearchFilterSize | – |
query | – | string | – |
favoriteHref | Native link to a screen-owned favorite form, when one exists. | string | – |
facetsrequired | – | SearchFacet[] | – |
filtersrequired | – | SearchFilterOption[] | – |
groupByrequired | – | SearchGroupByOption[] | – |
maxGroupBy | Maximum simultaneous grouping levels supported by the consumer. | number | – |
favoritesrequired | – | SearchFavorite[] | – |
customFilterFieldsrequired | – | CustomFilterField[] | – |
customFilters | Rules already encoded in the server-rendered list state. | SearchFilterCustomRule[] | – |
labelsrequired | – | SearchFilterLabels | – |
manager | – | SearchFilterManager | – |
#SearchFilterApplyInput
An owning collection can apply through its own controlled data runtime.
| Property | Description | Type | Default |
|---|---|---|---|
queryrequired | – | string | – |
facetsrequired | – | SearchFacet[] | – |
filtersrequired | – | string[] | – |
groupByrequired | – | string[] | – |
favoriteIdrequired | – | string | null | – |
customFiltersrequired | – | Omit<SearchFilterCustomRule, 'label'>[] | – |
#SearchFilterIntegration
| Property | Description | Type | Default |
|---|---|---|---|
applyrequired | – | (input: SearchFilterApplyInput, signal: AbortSignal) => void | Promise<void> | – |
#SearchFilterNavigateDetail
A shell handles this event synchronously and supplies its navigation promise.
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
hrefrequired | – | string | – |
signalrequired | – | AbortSignal | – |
respondWithrequired | – | (result: Promise<void>) => void | – |
#SearchFilterFieldType
The same 7 field types and their operator vocabulary as packages/ketjs/src/data/list-search.ts's ListFieldType/defaultOperators — redeclared here because design-system cannot depend on @ketvietlab/ketjs.
type SearchFilterFieldType =
| 'text'
| 'number'
| 'boolean'
| 'selection'
| 'reference'
| 'date'
| 'datetime'#SearchFilterLabels
| Property | Description | Type | Default |
|---|---|---|---|
searchLabelrequired | – | string | – |
searchPlaceholderrequired | – | string | – |
toggleLabelrequired | Accessible name for the combined mobile Filters/Group By/Favorites sheet. | string | – |
filtersrequired | – | string | – |
allValues | Expanded quick-filter fallback when no option is applied. | string | – |
groupByrequired | – | string | – |
noGrouping | – | string | – |
groupByApplied | – | string | – |
groupByAdd | – | string | – |
groupByClear | – | string | – |
groupByMoveEarlier | – | string | – |
groupByMoveLater | – | string | – |
favoritesrequired | – | string | – |
searchGenericLabelrequired | The field-less suggestion: ${searchGenericLabel}: "query". | string | – |
searchFieldPrefixrequired | The per-field suggestion: ${searchFieldPrefix} <field> ${searchFieldPreposition}: "query". | string | – |
searchFieldPrepositionrequired | – | string | – |
customFilterFieldrequired | – | string | – |
customFilterOperatorrequired | – | string | – |
customFilterValuerequired | – | string | – |
customFilterAddrequired | – | string | – |
customFilterToggle | Optional short label for opening the expanded rule editor; add keeps its action label. | string | – |
customGroupByPlaceholderrequired | – | string | – |
saveSearchrequired | – | string | – |
favoriteNamerequired | – | string | – |
favoriteDefaultrequired | – | string | – |
favoriteSaveActionrequired | – | string | – |
favoriteCancel | – | string | – |
favoriteError | – | string | – |
favoriteRemoverequired | – | string | – |
favoriteSetDefaultrequired | – | string | – |
noFavoritesrequired | – | string | – |
clearrequired | – | string | – |
applyErrorrequired | – | string | – |
retryrequired | – | string | – |
clearFilters | – | string | – |
close | – | string | – |
valueFrom | – | string | – |
valueTo | – | string | – |
operatorLabels | – | Partial<Record<SearchFilterOperator, string>> | – |
#SearchFilterManager
| Property | Description | Type | Default |
|---|---|---|---|
applyFunctionrequired | – | string | – |
bodyIdrequired | – | string | – |
applyInput | Static, screen-owned input sent with every apply, delete and set-default request (for example the list key). | Record<string, unknown> | – |
saveFavoriteFunction | – | string | – |
deleteFavoriteFunction | – | string | – |
setDefaultFavoriteFunction | – | string | – |
#SearchFilterOperator
type SearchFilterOperator =
| 'contains'
| 'notContains'
| 'equals'
| 'notEquals'
| 'startsWith'
| 'gt'
| 'gte'
| 'lt'
| 'lte'
| 'between'
| 'anyOf'
| 'isTrue'
| 'isFalse'
| 'isSet'
| 'isNotSet'#SearchFilterSize
The density of the search bar; compact uses the small control-height token.
type SearchFilterSize = 'default' | 'compact'#SearchFilterOption
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
labelrequired | – | string | – |
activerequired | – | boolean | – |
group | Options sharing a group are OR'd together, set off from the next group by a divider. | string | – |
groupLabel | Visible label for this preset group in the expanded presentation. | string | – |
options | – | SearchFilterOption[] | – |
#SearchGroupByOption
| Property | Description | Type | Default |
|---|---|---|---|
idrequired | – | string | – |
labelrequired | – | string | – |
activerequired | – | boolean | – |
group | – | string | – |
options | – | SearchGroupByOption[] | – |
#Hooks
The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.
search-filtersearch-filter-barsearch-filter-toolssearch-filter-expandedsearch-filter-rule-togglesearch-filter-rule-editorsearch-filter-section-togglesearch-filter-sheetsearch-filter-clearsearch-filter-iconsearch-filter-fieldsearch-filter-inputsearch-filter-facetssearch-filter-facetsearch-filter-facet-removesearch-filter-suggestionssearch-filter-suggestionsearch-filter-togglesearch-filter-columnssearch-filter-columnsearch-filter-column-titlesearch-filter-emptysearch-filter-groupingsearch-filter-grouping-headsearch-filter-grouping-listsearch-filter-grouping-itemsearch-filter-grouping-ordersearch-filter-grouping-labelsearch-filter-grouping-actionssearch-filter-grouping-actionsearch-filter-grouping-clearsearch-filter-grouping-add-labelcustom-filtercustom-filter-rowcustom-filter-addcustom-group-byfavorite-listfavorite-itemfavorite-item-defaultfavorite-item-removefavorite-savefavorite-save-togglefavorite-save-row