Krizaka UI
Krizaka UI
Composants

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 · ✓Bureau · ✓BêtaFormulaires
import { TagSetEditor, StatusSetEditor } from "@krizaka/ui/kind-config-editor";

Web et mobile — le même composant pour React et React Native. Bêta : son API peut encore changer à une version mineure.

Pourquoi il est là. Used by Yomizaka, Akinaza.

Quand l’utiliser

  • 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.

Quand ne pas l’utiliser

Installation

Installer

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

Styles

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

Importer

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

Exemples

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.

PropTypeDéfautDescription
onChangerequis(value: StatusSet) => void—Called with the whole set after every change.
rolesrequisreadonly EditorRole[]—The roles of the product that can make a move.
valuerequisStatusSet—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.

PropTypeDéfautDescription
onChangerequis(value: TagSetValue) => void—Called with the whole set after every change.
rolesrequisreadonly EditorRole[]—The roles of the product that can write tags.
valuerequisTagSetValue—The tags of the kind's configuration (KindConfig.tags).
variantrequisstring—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.

Accessibilité

  • 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.

Clavier

TouchesAction
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.

Bonnes pratiques

  • 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.

Générée depuis le code de @krizaka/ui 3.63.1 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page