Krizaka UI
Krizaka UI
Components

Kind config editor

The admin's editors of a kind's vocabulary (@krizaka/organize KindConfig, krizaka-ts#89): TagSetEditor — the tags offered, who manages them, whether people add their own, the most — and StatusSetEditor — the states in their order, the initial state, the moves from × to with their roles, confirmation and reasons. Value in, onChange out; the product posts the save.

Web · ✓Mobile · ✓Desktop · ✓BetaForms
import { TagSetEditor, StatusSetEditor } from "@krizaka/ui/kind-config-editor";

Web and mobile — the same component for React and React Native. Beta: its API may still change in a minor version.

Why it is here. Used by Yomizaka, Akinaza.

When to use

  • A product's settings where the admin sets the tags and the statuses of a kind (clients, invoices, applicant files): « the admin configures everything ».
  • To show the problems the server's own rules found (kindConfigProblems) in the place where they are fixed.

When not to use

Installation

Install

npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Import

import { TagSetEditor, StatusSetEditor } from "@krizaka/ui/kind-config-editor";

Examples

Tag set

The presets of a hair studio's clients (name, colour, order), who manages tags, « people can add their own », the most; the server's problems in place.

Status set

Applicant files: states in order with both labels, tone and final, the initial state, and the moves from × to with roles, confirmation and reasons.

Derived set

An invoice's statuses come from the ledger: shown, with nothing to move.

Props

StatusSetEditor

The admin's status set: the states in their order (FR and EN, tone, final), the initial state, and the moves from × to.

PropTypeDefaultDescription
onChangerequired(value: StatusSet) => void—Called with the whole set after every change.
rolesrequiredreadonly EditorRole[]—The roles of the product that can make a move.
valuerequiredStatusSet—The kind's status set (KindConfig.status).
classNamestring—Classes merged on the root.
disabledboolean—Not available.
labelsPartial<StatusSetEditorLabels>—The words, passed translated (English by default).
localekeyof LabelenThe language the states are named in elsewhere in the editor (the moves' names).
problemsreadonly string[]—What kindConfigProblems found (the server's own rules), shown above the list.

TagSetEditor

The admin's tag set: the presets of a variant (name, colour, order), who writes, whether people add their own, the most.

PropTypeDefaultDescription
onChangerequired(value: TagSetValue) => void—Called with the whole set after every change.
rolesrequiredreadonly EditorRole[]—The roles of the product that can write tags.
valuerequiredTagSetValue—The tags of the kind's configuration (KindConfig.tags).
variantrequiredstring—The variant whose presets are edited (a trade, or default).
classNamestring—Classes merged on the root.
disabledboolean—Not available.
labelsPartial<TagSetEditorLabels>—The words, passed translated (English by default).
problemsreadonly string[]—What kindConfigProblems found (the server's own rules), shown above the list.

Accessibility

  • Every control has its own accessible name: a field says its position and its language (« Label in French of state 2 »), a move says its two states and its roles.
  • Dragging is an extra: the move-up and move-down buttons do the same, and the handle is not drawn on a phone.
  • A final state's row of moves says « Final: no way out » instead of offering buttons; the initial state's « final » switch is off and says why.
  • Problems are an alert above the list; a field with an empty label or a duplicate name is aria-invalid and says so.

Keyboard

KeysAction
TabReaches each field, switch and button in reading order.
Alt + ↑ / Alt + ↓In a name or a label, moves the row up or down; the focus follows the field.
Arrow keysIn a colour group, move between the six swatches.
EnterIn the field that adds a tag, adds it.

Best practices

  • Keep the descriptor in state, pass it as value and post it yourself with the version you read: a CONFLICT (409) says someone else changed it, a STATE_IN_USE (409) names the states entities still hold.
  • Pass problems={kindConfigProblems(config)}: the same rules as the server, shown above the list.
  • A colour is a name of the closed palette (blue · green · amber · red · violet · gray), never a colour picker; a status never takes a tag's colour.
  • A reason is a list the admin writes in both languages, off by default; there is never a free-text reason.
  • The order of the states is the order of the status column: reorder with the handle, the buttons, or Alt + ↑ ↓ in a field.

Generated from the code of @krizaka/ui 3.63.1: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page