@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
46 lines (45 loc) • 1.79 kB
TypeScript
import type { ReactNode } from 'react';
import { type ChoiceCardsFieldProps as UiChoiceCardsFieldProps } from '@mitcsutt/kiln-ui';
import type { ControlledKeys } from '../internal/controlledKeys.js';
import { type CommonFieldProps } from '../../../hooks/useFieldBinding.js';
import { type FieldOption } from '../../../kit/contracts.js';
/** The base value of a choice-card option (§7.2 `multiChoiceCards`: no booleans). */
export type MultiChoiceCardValue = string | number;
type UiMultipleProps = Extract<UiChoiceCardsFieldProps, {
type: 'multiple';
}>;
export interface FormMultiChoiceCardsFieldProps extends Omit<UiMultipleProps, ControlledKeys | 'options' | 'type'>, CommonFieldProps<readonly MultiChoiceCardValue[]> {
options?: readonly FieldOption<MultiChoiceCardValue>[];
/** A figure or short fact at the foot of an option's card, keyed by its value. */
optionMeta?: (value: MultiChoiceCardValue) => ReactNode;
}
/**
* Any number of choices from a handful of cards.
*
* @remarks
* It renders kiln-ui's {@link ChoiceCardsField | ChoiceCardsField} with `type="multiple"`.
*
* @example In a schema
* ```json
* {
* "kind": "multiChoiceCards",
* "name": "extras",
* "label": "Add-ons",
* "options": [
* {
* "value": "bike",
* "label": "Bike space"
* }
* ]
* }
* ```
*
* @value an array of the options' value type
* @empty `[]`
*
* @privateRemarks
* Any number of choices from a handful of cards (§7.2 `multiChoiceCards`, ui `type="multiple"`).
* Option values keep their primitive type; empty is `[]`.
*/
export declare const FormMultiChoiceCardsField: import("../../../kit/contracts.js").FieldDef<import("../../../kit/contracts.js").OptionsContract<MultiChoiceCardValue>, FormMultiChoiceCardsFieldProps>;
export {};