Search the documentation

Type to search page titles, component names and descriptions.

    Data Entry

    FaifoGrid

    An editable grid for entering many lines.

    import { FaifoGridPlaceholder } from 'faifo-design'

    FaifoGrid is an editable grid drawn in the browser: arrow keys move, Enter, F2 or typing edits, Tab goes to the next editable cell, and a block can be pasted from a spreadsheet. The server renders only FaifoGridPlaceholder; the faifoGrid island draws the grid, and createFaifoGrid builds one in a container an application owns.

    #When to use

    • Use it for the lines of a document: an order, a bill, a count.
    • The grid posts its changes through one named field, so the form around it still saves once.
    • For read-only rows use DataTable or FaifoTable.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Faifo grid

    Editable grid drawn entirely in the browser: the server renders only its loading placeholder. Arrow keys move, Enter or F2 or typing edits, Tab moves to the next editable cell, Ctrl+C/V copies and pastes ranges with spreadsheets, Ctrl+D fills down, Ctrl+Z undoes, Alt+↑/↓ or the handle reorders. Cells the reader may edit are light green and an edited cell turns light yellow until the host saves; a row is filled whole only when every cell is (sections, notes, a new or moved row). The order lines show sections and notes, a delivered (read-only) line, a pinned subtotal and its total; the stock list draws 500 rows by drawing only those in view.

    Show codeHide code
    import { renderIsland, trustedMarkup } from '@ketvietlab/ketjs-view'
    import { FaifoGridPlaceholder, Stack, faifoGrid } from 'faifo-design'
    // faifoGridDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/faifo-grid/demo.ts
    // faifoGridStockDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/faifo-grid/demo.ts
    
    export const Example = () => (
      <Stack
        items={[
          trustedMarkup(
            renderIsland('design-system.faifo-grid', faifoGrid, {
              id: 'demo-faifo-grid',
              config: faifoGridDemoConfig,
            }),
          ),
          trustedMarkup(
            renderIsland('design-system.faifo-grid', faifoGrid, {
              id: 'demo-faifo-grid-stock',
              config: faifoGridStockDemoConfig,
            }),
          ),
          <FaifoGridPlaceholder label="Loading order lines" rows={3} />,
        ]}
      />
    )

    #Contract

    #Editable grids: FaifoGrid

    Serialized columns accept writeSets for constant dependent values after a successful write, including a computed inverse. For example, a product/unit selection can set automatic: true, while a price or margin edit sets it to false. Failed inverse writes do not change intent. Declare boolean draftFlags: ['automatic'] to preserve that user-owned intent after draft restoration replays column writers. Non-boolean, undeclared and row/tier/column lock flags are excluded. Server validation remains mandatory. The order-lines specimen demonstrates this contract.

    Reading a collection is FaifoTable's job. Editing many rows in place (order lines, stock counts, price lists, any table whose numbers change live) uses FaifoGrid, which runs entirely in the browser. Do not put form controls in DataTable or FaifoTable cells, and do not edit such figures through one dialog per row; a dialog stays for one record's own action (a reason, a confirmation, adding a found item). A dialog setting a quantity per variant holds such a grid too, one row per variant.

    • Two entries. createFaifoGrid(container, options) builds the grid from client code and returns its API (changes(), posted(), validate(), setRows(), applyTransaction(), setErrors(), markSaved(), undo(), destroy() and the rest of FaifoGridApi). faifoGrid is the same grid as a ketjs-view island: the server renders only FaifoGridPlaceholder, the island takes JSON config (columns, rows, newRow, kindField/fullWidthKey for section and note rows, lockedField, keptField for a row that stays editable but may not be removed, compute, search.listFunction) and dispatches faifo:grid-ready with detail.grid so page code can feed it and save.
    • In a server-rendered form. A KetSuite route puts the grid in a form field as its control through editGridControl(ctx, url, req, id, config) (ketsuite/backend, joint backend:edit.grid), with config.name set to the field name: the grid keeps a hidden field of that name holding its posted changes and blocks the submit while a changed cell is wrong. The route reads the rows of a grid that started empty with postedGridRows(form[name]) (added rows in order, without the ones removed again; null for anything else) and passes carry: form[name] back when it refuses the form, so the reader's rows survive. Do not ask for pasted JSON in a textarea instead. faifoGridLocale(lang) (ketsuite/ui) supplies the grid's Vietnamese or English labels. A grid in a two-column form takes the full row (span: 'full'). Size the columns to fit the field column at desktop width; on a phone the grid scrolls sideways inside its own frame, and its empty message stays centred on the visible part.
    • Row totals. A numeric island column may declare sumEquals: { fields, total, message }. It validates that the sum of the named row fields equals the total field (quantity tolerance 0.000001), displaying the localized message at the edited cell. Attach it to each participating editable column; the domain must validate the same rule on save.
    • Computed values and inverse input. A product compute can subtract another product through less, show (product - less) / product * 100 through as: 'percent', and solve into exactly one multiplicand using solve: {field, digits}. percentOff applies before subtraction. Inverse input uses decimal rational arithmetic and rounds once, half away from zero. Invalid or non-unique targets, zero divisors, missing costs and unsafe minor-unit results keep the row unchanged. Text target columns retain decimal strings; derived values are never persisted as their own fields. Existing simple products and differences keep their behavior.
    • Remote option facts. search.setsFrom maps result fields to row fields on selection. Facts are cached per listInputFields context and option ID, bounded to 1000 entries, and do not cross product/quantity contexts. Declare resets for dependent facts; a refused draft cannot recreate a trusted remote response. Server permissions own what the endpoint returns. Consumers must omit display facts from business writes and revalidate every persisted field server-side.
    • Kinds of new row. newRows: [{label, row}] (client: {label, create}) gives one add button per kind, such as a line, a section and a note; it replaces newRow. A section or note row shows, edits and checks only its fullWidthKey cell, so a section is never "missing" a product or quantity. fullWidthTag: {field, label} shows label after the text of a section or note whose field is set (an optional section reads "Kit · Optional"); the tag is generated content of the cell's value (data-tag on fg-cell-value), so editing the text leaves it in place, and the cell's aria-description so assistive technology reads it too.
    • Rules from row data. Island columns take JSON-safe rules, so the server's own data drives them: lockedBy: 'field' makes the column read-only on rows where that field is set (a product already delivered), requires: 'field' keeps it read-only until that field is set (a line's unit waits for its product, and closes again when the product is cleared), minField: 'field' refuses a value under that field (belowMin, "At least {min}"), maxField: 'field' one over it (aboveMax, "At most {max}", such as a quantity above what is still due), and sets: {optionValue: {field: value}} lets a choice fill other cells of its row (a product's description, unit, price and tax). A select column's optionsBy: {field, values: {fieldValue: [optionValue]}} offers each row only the options its field allows (a product's own unit and packagings); a row whose value values does not name gets every option, typed or pasted values outside the row's options are refused (invalidOption), and every value still shows its label. Client columns take optionsFor(row). They guide the reader; the server still checks the same rules.
    • Compact remote labels. search.labelField may name a short code while descriptionField retains the full name in the picker. labelFallbackField supplies the cell label when that code is missing; it does not change the option ID.
    • Dependent fields and remote options. resets: [fields] clears dependent cells only when the parent changes, before sets fills defaults; a dependent cell protected by its lockedBy field is retained. A row with an explicit optionsBy entry searches only those local options, even when the column also declares remote search. search.listInputFields: {input: rowField} reads required RPC inputs from the current row at search time; missing parents return no options and send no request. The request uses the grid’s abort signal. Server eligibility and permission checks remain authoritative.
    • Steps from row data. The island config's tiers: {key, by, lockedBy?, steps} writes fields in steps of another field, as a pricelist prices a product by quantity: steps[row[key]] is a list of {from, row}, and the step with the largest from at most row[by] writes its row. It applies after sets whenever the key or the by cell is edited, so a price typed by hand stays until the product or the quantity changes; a row whose lockedBy field is set (already delivered or invoiced) keeps its fields. With with: 'field' (the unit a line is sold in) the steps of steps["<key>|<with>"] come first, then those of the key alone, and editing that cell steps the row too, so choosing a packaging writes its own price. The server works the steps out from its own rules. stepsField names a row-owned array of {from, row} supplied by a remote picker; when present, even an empty array replaces static steps. Steps must have finite numeric thresholds and object values. lockedBy also accepts an array of fields: any held lock prevents repricing, separating manual intent from fulfilment history. Lock fields cannot be restored through draftFlags. Server writers recalculate authoritative prices and never trust posted step arrays. The Order lines specimen's glass-cup row demonstrates the row-owned threshold at quantity48.
    • Computed columns. An island column's compute is {multiply: [fields], percentOff?} (a line amount) or {difference: [a, b]}, a − b, empty while either is missing (a count against the quantity on hand). With less: [fields] the product of those fields comes off the amount (a line's margin: quantity × price less discount, less quantity × cost), and with as: 'percent' the result is that margin's share of the amount, empty when the amount is 0. Computed cells follow edits live and are read-only, unless solve: {field, digits?} names one of multiply: the column is then editable where its editable/lockedBy allow, and a value typed sets that field, rounded to digits places (default 6), to what makes the row compute to it (a margin typed sets the unit price that earns it). A value no row computes to (100 % on a cost, a row selling none, a price below zero, a cleared cell) leaves the row as it was. The edit is the solved field's: it is what the grid marks unsaved and posts. A client column gets the same with value and set together.
    • Keyboard and clipboard. Arrows move, Shift extends, Ctrl/⌘+arrow jumps to the edge, Home/End and PageUp/PageDown work as in spreadsheets. Enter, F2 or typing edits (an IME composes in the editor); Tab moves to the next editable cell. Ctrl/⌘+C, X and V exchange ranges with spreadsheets as tab-separated text, Ctrl/⌘+D fills down, Delete clears, Space toggles a checkbox, Alt+↑/↓ or the handle reorders, and Ctrl/⌘+Z and Shift+Ctrl/⌘+Z undo and redo by operation.
    • Values. Text, number, money, percent, date, select, combobox and checkbox columns read what people type in either decimal convention (1.250,5, 1,250.5; money also 25k, 1,2tr), show values in the grid's locale, and keep a rejected entry open with its message.
    • Cell fills. Fills go by cell. A cell the reader may edit is light green (--faifo-success-bg); a cell whose value is not saved yet is light yellow (--faifo-warning-bg); read-only, computed and locked cells keep the plain fill. A row is filled as a whole, its drag handle too, only when every cell is: green when all its cells are editable (a section or note row), yellow when the row is new or was moved. The yellow clears when the host saves (markSaved(), or setRows() with the saved rows) and when an edit or undo brings the value back. State tints (selection, invalid, conflict) and the active outline draw over the fill. Consumers do not restyle cells or rows.
    • Saving. The host saves. A grid with name (and form when outside it) keeps a hidden text input holding posted() as JSON ({added, updated, removed, order}, only changed fields of updated rows; order lists every row id, new rows by their grid id, when rows moved or a row was added before the end) for the record form, or page code posts changes() itself. The input's default value is the clean JSON, exported as FAIFO_GRID_NO_CHANGES, so record drafts and "unsaved changes" checks see grid edits like any field: a record draft seeding carry falls back to FAIFO_GRID_NO_CHANGES, never ''. A read-only grid with no form to post to omits name/form/carry; a named field in it would read as an open control. Pressing anywhere outside the grid commits an open editor, and so does submitting that form; if any cell is invalid the grid stops the submit, focuses the first such cell and announces fixBeforeSaving. Both listen on window in the capture phase, so they run before a host's own submit handlers read the form. noValidate on the form or formNoValidate on the submitter skips the check. After a successful save call markSaved() (or reload the rows); field errors from the server go to setErrors().
    • Paged rows. A grid shows one page of a larger set when the host pages it. Pass the previous value of its input as carry (island: the JSON string; client: FaifoGridPosted): updated entries for rows on this page come back as unsaved edits, the others ride along in posted() and the status reads otherPages ("{count} changed on other pages"), so one save covers every page. posted() includes optional optionLabels for learned remote labels while dirty; carry this display-only metadata through a refused form and discard it before the business write. Labels never authorize a value. Added/removed rows and row order are also restored when the corresponding capabilities allow them; added row IDs stay stable. Only editable cells are restored. Draft restoration replays column writers in declaration order: put parent columns before dependent cells. This recomputes sets/resets and hidden lock metadata before restoring the dependent value; posted hidden metadata cannot unlock a cell. The same rule applies to new rows. setReadOnly(true) freezes edits and undo while the host saves, without dropping the draft. setRows(), markSaved() and reverting drop the carried edits.
    • Live data. applyTransaction({add, update, remove}) merges rows changed elsewhere. Untouched cells take the new value and flash; a cell the reader changed keeps their value and offers "Keep mine" or "Use new value".
    • Scale. Rows have one height and only those in view are drawn, so a grid holds thousands of rows; columns may be pinned to either edge and footers sum a column.

    Specimen: catalogue data-operations#faifo-grid. Tests: test/design-system-faifo-grid.test.ts.

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #createFaifoGridFunction

    function createFaifoGrid<Row extends FaifoGridRow = FaifoGridRow>(container: HTMLElement, options: FaifoGridOptions<Row>): FaifoGridApi<Row>
    ParameterType
    containerrequiredHTMLElement
    optionsrequiredFaifoGridOptions<Row>
    ReturnsFaifoGridApi<Row>

    #FAIFO_GRID_NO_CHANGESConstant

    What the grid's named field holds before any edit; a record draft that seeds it starts here too.

    const FAIFO_GRID_NO_CHANGES = JSON.stringify({ added: [], updated: [], removed: [], order: null })

    #faifoGridFunction

    The grid as a ketjs-view island: the server renders the placeholder, the browser the grid.

    function faifoGrid(props: IslandProps): IslandController
    ParameterType
    propsrequiredIslandProps
    ReturnsIslandController

    #FaifoGridPlaceholderComponent

    The server's stand-in until the grid draws itself: a frame of loading lines.

    PropertyDescriptionTypeDefault
    label–string–
    rows–number4

    #Types

    #FaifoGridApi

    PropertyDescriptionTypeDefault
    elementrequired–HTMLElement–
    rowsrequiredThe current rows, drafts included, in their saved order.() => Row[]–
    changesrequired–() => FaifoGridChanges<Row>–
    postedrequired–() => FaifoGridPosted–
    summaryrequired–() => FaifoGridSummary–
    dirtyrequired–() => boolean–
    issuesrequired–() => FaifoGridIssue[]–
    validaterequiredShows every check on changed rows (before a save) and returns what must be fixed.() => FaifoGridIssue[]–
    setRowsrequiredReplaces the rows and drops drafts and history.(rows: readonly Row[]) => void–
    setReadOnlyrequiredFreeze edits while the host saves, preserving the draft.(value: boolean) => void–
    applyTransactionrequiredApplies rows changed elsewhere, highlighting changed cells and keeping the reader's drafts.(transaction: FaifoGridTransaction<Row>) => void–
    markSavedrequiredTakes the saved rows (or the current ones) as the new server copy.(rows?: readonly Row[] | undefined) => void–
    revertrequired–() => void–
    setErrorsrequiredErrors from the server, by row id and column key; editing a cell clears its error.(errors: Readonly<Record<string, Readonly<Record<string, string>>>>) => void–
    patchrequiredWrites fields of one row as an undoable draft, such as a price looked up after an edit.(id: string, values: Partial<Row>) => void–
    addRowrequired–(row?: Row | undefined, index?: number | undefined) => string | null–
    removeRowsrequired–(ids: readonly string[]) => string[]–
    focusCellrequired–(id: string, key: string) => void–
    setBusyrequired–(busy: boolean) => void–
    undorequired–() => void–
    redorequired–() => void–
    destroyrequired–() => void–

    #FaifoGridCell

    PropertyDescriptionTypeDefault
    idrequired–string–
    keyrequired–string–

    #FaifoGridChangeEvent

    PropertyDescriptionTypeDefault
    reasonrequired–string–
    cellsrequired–FaifoGridCell[]–
    changesrequired–FaifoGridChanges<Row>–

    #FaifoGridChanges

    PropertyDescriptionTypeDefault
    addedrequiredNew rows the reader filled in, with their position. Rows added and left empty are not changes.{ id: string; index: number; row: Row }[]–
    updatedrequiredExisting rows with the fields that differ from the server's copy.{ id: string; row: Row; fields: string[] }[]–
    removedrequired–string[]–
    orderrequiredEvery row id in order, when the reader reordered rows or added one before the end; else null.string[] | null–

    #FaifoGridColumn

    PropertyDescriptionTypeDefault
    keyrequiredThe column's identity, and the row field it reads unless field names another.string–
    labelrequired–string–
    type–FaifoGridColumnType–
    field–string–
    widthWidth in CSS pixels; each type has a default.number–
    growA share of the spare width, as a CSS fraction. A pinned column ignores it.number–
    minWidth–number–
    pinned–'start' | 'end'–
    align–'start' | 'center' | 'end'–
    editableColumns are read-only unless they say otherwise; a function decides per row.boolean | ((row: Row) => boolean)–
    required–boolean–
    min–number–
    max–number–
    fractionDigits–number–
    currencyMoney columns: ISO 4217, defaulting to the grid's currency.string–
    options–readonly FaifoGridOption[]–
    optionsForSelect columns: the options this row may take, among options (a product's units). options still names every value the column shows.(row: Row) => readonly FaifoGridOption[]–
    searchCombobox columns: options for what the reader typed, read while they type.FaifoGridSearch<Row>–
    placeholderMuted text in an empty editable cell, such as "Choose a product".string–
    hintA longer description of the column, shown as the header's tooltip.string–
    sortable–boolean–
    resizable–boolean–
    valueA computed value. The column is read-only, unless set writes what was typed back into the fields it is computed from (a margin typed sets the price that earns it).(row: Row) => FaifoGridValue–
    setWrites an edited value. Return a new row; it may change other fields too (a product sets its price).(row: Row, value: FaifoGridValue) => Row–
    format–(value: FaifoGridValue, row: Row) => string–
    parseReads typed or pasted text. Return undefined for text that is not a value of this column.(text: string, row: Row) => FaifoGridValue | undefined–
    validateA message for a value the reader must fix, or null.(value: FaifoGridValue, row: Row) => string | null–
    footerThe footer total: the sum of the column, or a value computed from the rows.'sum' | ((rows: readonly Row[]) => FaifoGridValue)–

    #FaifoGridColumnType

    type FaifoGridColumnType =
      | 'text'
      | 'number'
      | 'money'
      | 'percent'
      | 'date'
      | 'select'
      | 'combobox'
      | 'checkbox'

    #FaifoGridFullWidth

    A row shown as one cell: a section heading or a note, with a short tag after its text (Optional).

    PropertyDescriptionTypeDefault
    keyrequired–string–
    tonerequired–'section' | 'note'–
    tag–string | null–

    #FaifoGridIslandColumn

    A column as island props: data only, so it crosses from the server as JSON.

    PropertyDescriptionTypeDefault
    keyrequiredThe column's identity, and the row field it reads unless field names another.string–
    labelrequired–string–
    type–FaifoGridColumnType–
    field–string–
    widthWidth in CSS pixels; each type has a default.number–
    growA share of the spare width, as a CSS fraction. A pinned column ignores it.number–
    minWidth–number–
    pinned–'start' | 'end'–
    align–'start' | 'center' | 'end'–
    required–boolean–
    min–number–
    max–number–
    fractionDigits–number–
    currencyMoney columns: ISO 4217, defaulting to the grid's currency.string–
    options–readonly FaifoGridOption[]–
    optionsForSelect columns: the options this row may take, among options (a product's units). options still names every value the column shows.(row: Row) => readonly FaifoGridOption[]–
    placeholderMuted text in an empty editable cell, such as "Choose a product".string–
    hintA longer description of the column, shown as the header's tooltip.string–
    sortable–boolean–
    resizable–boolean–
    editable–boolean–
    computeA value worked out from the row (FaifoGridCompute): a line's subtotal, margin or margin %, or one field less another (a count's difference), empty while either is.FaifoGridCompute–
    footer–'sum' | { decimalSum: number }–
    lockedByA row field that, when set (true, a non-zero number, text), makes this column read-only on that row, such as a product already delivered.string–
    requiresA row field that must be set before this column opens on that row: a unit waits for its product.string–
    minFieldA row field holding the smallest value this column takes on that row, such as what was delivered.string–
    maxFieldA row field holding the largest value this column takes on that row, such as what is still due.string–
    sumEqualsCross-field quantity validation, shown at the edited cell while retaining its draft.{ fields: readonly string[]; total: string; message: string }–
    optionsBySelect columns: a row field whose value picks the options that row may take, such as a product's units by product. A value values does not name leaves every option.{ field: string; values: Readonly<Record<string, readonly string[]>> }–
    setsFields a choice also writes into its row, by option value: a product's description, unit and price.Readonly<Record<string, FaifoGridRow>>–
    writeSetsConstant dependent fields written after a successful edit, including a computed inverse.FaifoGridRow–
    resetsClear dependent fields when this cell changes (a SKU clears its unit and automatic price).readonly string[]–
    searchCombobox columns read options from a KetJS function (POST /_ket/fn/<name>) as the reader types.{ listFunction: string listInput?: Record<string, unknown> /** Required function inputs read from this row; no request until every parent is set. */ listInputFields?: Readonly<Record<string, string>> searchParam?: string limitParam?: string limit?: number idField?: string labelField?: string /** Fallback for records without the compact identifier used as their cell label. */ labelFallbackField?: string descriptionField?: string /** Trusted remote option fields copied into row fields on selection, scoped by listInputFields. */ setsFrom?: Readonly<Record<string, string>> }–

    #FaifoGridIslandConfig

    PropertyDescriptionTypeDefault
    labelrequired–string–
    columnsrequired–readonly FaifoGridIslandColumn[]–
    rowsrequired–readonly FaifoGridRow[]–
    idFieldThe row field holding its id. Defaults to id.string–
    labels–Partial<FaifoGridLabels>–
    locale–string–
    currency–string–
    density–'compact' | 'default' | 'comfortable'–
    visibleRows–number–
    height–string–
    readOnly–boolean–
    newRowA new row's starting values; lets the reader add rows.FaifoGridRow–
    newRowsSeveral kinds of new row, each with its own add button (a line, a section, a note); replaces newRow.readonly { label: string; row: FaifoGridRow }[]–
    removable–boolean–
    reorderable–boolean–
    kindFieldA row field whose value section or note shows the row as one full-width cell of fullWidthKey.string–
    fullWidthKey–string–
    fullWidthTagA row field that, when set on a section or note, shows label after its text, as an optional section.{ field: string; label: string }–
    lockedFieldA row field that, when true, makes the row read-only and keeps it from being removed.string–
    keptFieldA row field that, when set, keeps the row from being removed while it stays editable, such as a line something was already recorded against.string–
    tiersFields a row takes in steps of another field, as a product's price by quantity: the row's key field picks a list of steps, and the step with the largest from at most the row's by field writes its fields. Applied after sets whenever either field is edited; a row whose lockedBy field is set (a line already delivered) keeps its fields. With with (a product's unit), the steps of <key>|<with> come first, then those of the key alone; editing with steps the row too.{ key: string by: string with?: string lockedBy?: string | readonly string[] steps?: Readonly<Record<string, readonly { from: number; row: FaifoGridRow }[]>> /** A row-owned array of steps supplied by a remote picker, preferred over static steps. */ stepsField?: string }–
    errorsServer-owned messages keyed by stable grid row ID and column key, applied after restoring carry.Readonly<Record<string, Readonly<Record<string, string>>>>–
    totalsLive exact totals; compareTo is a server-supplied fact, never a posted authority.readonly { key: string label: string digits?: number compareTo?: string differenceLabel?: string }[]–
    name–string–
    form–string–
    carryAn earlier posted value of this grid, as the JSON text a record draft keeps; see carry.string | FaifoGridPosted | null–
    draftFlagsUser-owned boolean intent carried with drafts; never authorization or lock metadata.readonly string[]–

    #FaifoGridIssue

    PropertyDescriptionTypeDefault
    idrequired–string–
    keyrequired–string–
    tonerequired–'danger' | 'warning'–
    messagerequired–string–

    #FaifoGridLabels

    PropertyDescriptionTypeDefault
    loadingrequired–string–
    emptyrequired–string–
    addRowrequired–string–
    removeRowsrequired–string–
    undorequired–string–
    redorequired–string–
    totalrequired–string–
    dragHandlerequired–string–
    instructionsrequired–string–
    requiredrequired–string–
    invalidNumberrequired–string–
    invalidDaterequired–string–
    invalidOptionrequired–string–
    invalidValuerequired–string–
    belowMinrequired{min} is the formatted minimum.string–
    aboveMaxrequired{max} is the formatted maximum.string–
    conflictrequired{value} is the value set elsewhere.string–
    keepMinerequired–string–
    takeTheirsrequired–string–
    removedElsewhererequired–string–
    searchingrequired–string–
    noOptionsrequired–string–
    searchFailedrequired–string–
    addedRowsrequired{count} placeholders below.string–
    editedCellsrequired–string–
    removedRowsrequired–string–
    otherPagesrequiredRows changed in an earlier view of this grid (another page) that the next save still posts.string–
    errorsrequired–string–
    conflictsrequired–string–
    copiedrequired–string–
    pastedrequired–string–
    pasteSkippedrequired–string–
    rowAddedrequired–string–
    rowsRemovedrequired–string–
    fixBeforeSavingrequiredSaid when a form holding the grid is kept from submitting.string–
    rowMovedrequired–string–
    undonerequired–string–
    redonerequired–string–
    sortedAscendingrequired{column} is the column's label.string–
    sortedDescendingrequired–string–
    sortClearedrequired–string–
    readOnlyCellrequired–string–
    yesrequired–string–
    norequired–string–

    #FaifoGridOption

    PropertyDescriptionTypeDefault
    valuerequired–string–
    labelrequired–string–
    description–string | null–

    #FaifoGridOptions

    PropertyDescriptionTypeDefault
    labelrequiredThe grid's accessible name.string–
    columnsrequired–readonly FaifoGridColumn<Row>[]–
    rowsrequired–readonly Row[]–
    rowIdrequired–(row: Row) => string–
    labels–Partial<FaifoGridLabels>–
    localeBCP 47; defaults to the document's language.string–
    currencyISO 4217 for money columns; defaults to VND.string–
    density–'compact' | 'default' | 'comfortable'–
    visibleRowsRows in view before the grid scrolls, without a fixed height. Defaults to 12.number–
    heightA fixed CSS height for the scrolling area, such as 100% inside a sized region.string–
    readOnly–boolean–
    rowEditable–(row: Row) => boolean–
    createRowLets the reader add rows; returns a new row's starting values.(context: { index: number }) => Row–
    newRowsSeveral kinds of new row (a line, a section, a note), each with its own button; the first is what Ctrl+Enter adds. Takes the place of createRow.readonly { label: string; create: (context: { index: number }) => Row }[]–
    removableLets the reader remove rows; a function decides per row.boolean | ((row: Row) => boolean)–
    reorderableLets the reader reorder rows by dragging the handle and with Alt+↑/↓.boolean–
    fullWidthA row shown as one full-width cell, such as a section heading or a note, editing one column.(row: Row) => FaifoGridFullWidth | null–
    namePosts the changes as JSON (FaifoGridPosted) in a hidden field with this name. The field counts as the reader's input (a form tracking unsaved edits sees it), and while a changed cell holds a wrong value the form does not submit, unless it or its submitter is novalidate.string–
    formThe form that hidden field belongs to, when the grid sits outside it.string–
    carryWhat an earlier posted() of this grid held, such as a record draft kept while the reader changed page. Updates to rows shown here are drafts again; updates to other rows ride along in what the grid posts, so one save keeps every page's edits. Structural edits and learned option labels are retained when allowed by the grid capabilities.FaifoGridPosted | null–
    draftFlagsExplicit user-owned boolean modes, validated again by the domain writer.readonly string[]–
    errors–Readonly<Record<string, Readonly<Record<string, string>>>>–
    summary–(rows: readonly Row[]) => string–
    onChange–(event: FaifoGridChangeEvent<Row>) => void–
    onActiveCellChange–(cell: FaifoGridCell | null) => void–

    #FaifoGridPosted

    What a form posts for the grid: the changes, with only the changed fields of updated rows.

    PropertyDescriptionTypeDefault
    optionLabelsDisplay-only labels retained with a form draft. Never authoritative server input.Record<string, Record<string, string>>–
    addedrequired–{ id: string; index: number; values: FaifoGridRow }[]–
    updatedrequired–{ id: string; values: FaifoGridRow }[]–
    removedrequired–string[]–
    orderrequired–string[] | null–

    #FaifoGridRow

    type FaifoGridRow = Record<string, unknown>

    #FaifoGridSearch

    type FaifoGridSearch<Row> = (
      query: string,
      context: { row: Row; signal: AbortSignal },
    ) => Promise<readonly FaifoGridOption[]>

    #FaifoGridSummary

    PropertyDescriptionTypeDefault
    addedrequired–number–
    editedrequired–number–
    removedrequired–number–
    errorsrequired–number–
    conflictsrequired–number–

    #FaifoGridTransaction

    PropertyDescriptionTypeDefault
    add–readonly Row[]–
    update–readonly Row[]–
    remove–readonly string[]–

    #FaifoGridValue

    type FaifoGridValue = string | number | boolean | null

    #Hooks

    The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.

    • faifo-grid
    • faifo-grid-island
    • fg-placeholder
    • fg-viewport
    • fg-header
    • fg-header-cell
    • fg-header-label
    • fg-sort
    • fg-resize
    • fg-body
    • fg-spacer
    • fg-row
    • fg-cell
    • fg-cell-value
    • fg-check
    • fg-flag
    • fg-handle
    • fg-drop
    • fg-empty
    • fg-footer
    • fg-editor
    • fg-popup
    • fg-options
    • fg-options-status
    • fg-option
    • fg-option-label
    • fg-option-description
    • fg-message
    • fg-message-actions
    • fg-tools
    • fg-status
    • fg-value