Utilisation

React to a change outside the UI

Ce type est utilisé par TextField

tsx
import { TextField, signal, watch } from 'kuito';

export function Search(props: { search: (query: string) => void }) {
  const query = signal('');
  watch(query, (text) => {
    const timer = setTimeout(() => props.search(text), 250);
    return () => clearTimeout(timer);
  });
  return <TextField label="Search" value={query} />;
}

Déclaration du type

ts
export interface TextFieldProps extends CommonProps, TextFieldNativeProps {
  /**
   * The text the field shows for what the user typed: a card number's
   * groups, a date's slashes. The caret stays after the character it
   * followed. Runs on the UI thread, before the frame, when it can
   * (docs/keyboard.md#formatting).
   */
  format?: (text: string) => string;
  /** The text, as the user changes it. */
  onChange?: (text: string) => void;
  /** The selected range, as the user moves the caret or selects. */
  onSelectionChange?: (selection: TextSelection) => void;
  onSubmit?: (event: SubmitEvent) => void;
  onFocus?: (event: FocusEvent) => void;
  onBlur?: (event: FocusEvent) => void;
}

Membres 107

NomTypeRequisDescription
format(text: string) => stringNonThe text the field shows for what the user typed: a card number's groups, a date's slashes. The caret stays after the character it followed. Runs on the UI thread, before the frame, when it can (docs/keyboard.md#formatting).
onChange(text: string) => voidNonThe text, as the user changes it.
onSelectionChange(selection: TextSelection) => voidNonThe selected range, as the user moves the caret or selects.
onSubmit(event: SubmitEvent) => voidNon—
onFocus(event: FocusEvent) => voidNon—
onBlur(event: FocusEvent) => voidNon—
idstringNon—
refElementRef<ElementHandle>Non—
classProp<ClassNames>NonClass names from a .css import or styles(): a string, or a list with falsy entries skipped, following the signals it reads.
styleStyleDeclarationsNonStyles of this view alone, compiled at build time: CSS properties in camelCase. A value that changes must set a native prop (opacity).
onPress(event: PressEvent) => voidNon—
onPressCapture(event: PressEvent) => voidNon—
keystring | numberNon—
hiddenProp<boolean>NonTakes the view out of layout and off screen, as CSS display: none.
paddingProp<LengthPercentage>Non—
paddingTopProp<LengthPercentage>Non—
paddingRightProp<LengthPercentage>Non—
paddingBottomProp<LengthPercentage>Non—
paddingLeftProp<LengthPercentage>Non—
widthAnimatable<SizeValue>Non—
heightAnimatable<SizeValue>Non—
minWidthProp<SizeValue>Non—
maxWidthProp<SizeValue>Non—
minHeightProp<SizeValue>Non—
maxHeightProp<SizeValue>Non—
aspectRatioProp<number>NonWidth divided by height; sizes the missing side from the other.
positionProp<"relative" | "absolute">Non—
topProp<LengthPercentageAuto>Non—
rightProp<LengthPercentageAuto>Non—
bottomProp<LengthPercentageAuto>Non—
leftProp<LengthPercentageAuto>Non—
marginProp<LengthPercentageAuto>Non—
marginTopProp<LengthPercentageAuto>Non—
marginRightProp<LengthPercentageAuto>Non—
marginBottomProp<LengthPercentageAuto>Non—
marginLeftProp<LengthPercentageAuto>Non—
flexGrowProp<number>Non—
flexShrinkProp<number>Non—
flexBasisProp<SizeValue | "content">Non—
flexProp<number>NonA grow factor from a zero basis, as CSS flex: n; 0 is inflexible.
alignSelfProp<"auto" | SelfAlignment>Non—
directionProp<"ltr" | "rtl">NonThe way lines run; unset, the parent's, and the app's first language's at the root.
boxSizingProp<"border-box" | "content-box">Non—
paddingInlineStartProp<LengthPercentage>NonPadding on the side lines start from: the left in ltr, the right in rtl.
paddingInlineEndProp<LengthPercentage>NonPadding on the side lines end at: the right in ltr, the left in rtl.
marginInlineStartProp<LengthPercentageAuto>NonMargin on the side lines start from: the left in ltr, the right in rtl.
marginInlineEndProp<LengthPercentageAuto>NonMargin on the side lines end at: the right in ltr, the left in rtl.
insetInlineStartProp<LengthPercentageAuto>Nonleft in ltr, right in rtl.
insetInlineEndProp<LengthPercentageAuto>Nonright in ltr, left in rtl.
roleProp<Role>Non—
onAction(event: AccessibilityActionEvent) => voidNonThe screen reader action taken, by name.
accessibleProp<boolean>NonMakes the view one screen reader element, read as its label or its children's text.
labelProp<string>NonWhat a screen reader says for the view.
hintProp<string>NonWhat happens when the view is activated, read after the label.
aria-hiddenProp<boolean>NonScreen readers skip the view and its subtree.
actionsProp<readonly AccessibilityAction[]>NonActions a screen reader offers; onAction receives the one taken.
liveProp<"off" | "polite" | "assertive">NonARIA's aria-live: announces changes to the view's content, on iOS too.
aria-disabledProp<boolean>Non—
aria-selectedProp<boolean>Non—
aria-checkedProp<boolean | "mixed">Non—
aria-busyProp<boolean>Non—
aria-expandedProp<boolean>Non—
aria-valueminProp<number>Non—
aria-valuemaxProp<number>Non—
aria-valuenowProp<number>Non—
aria-valuetextProp<string>Non—
gesturesreadonly Composable[]NonThe view's gestures; several race unless composed with together or orElse.
opacityAnimatable<number>Non—
backgroundColorAnimatable<string>Non—
translateXAnimatable<number>Non—
translateYAnimatable<number>Non—
scaleAnimatable<number>Non—
scaleXAnimatable<number>Non—
scaleYAnimatable<number>Non—
rotateAnimatable<number>NonDegrees.
transitionPartial<Record<"opacity" | "backgroundColor" | "transform" | "borderRadius" | "borderColor" | "shadow" | "width" | "height" | "all", Animation<unknown> | AnimationSpec>>NonHow the animatable props move when they change, enter or leave, by group; a CSS transition compiles to it.
animatePartial<Record<AnimatableProps, string | number>>NonAnimatable props whose every change moves as transition says; the first value applies at once.
enterEffectNonWhere the view enters from: fade.and(slide.up(12)).
exitProp<Effect>NonWhere the view leaves to; it stays on screen until it is there. The renderer gets true, and keeps the view until exited.
layoutAnimation<number>NonHow the view moves to a new frame the layout gives it: layout={spring()}.
borderRadiusAnimatable<number>Non—
overflowProp<"visible" | "hidden" | "clip" | "scroll">Nonhidden and scroll clip; as in CSS, either lets a flex item shrink below its content.
borderWidthProp<number>Non—
borderColorAnimatable<string>Non—
shadowColorAnimatable<string>Non—
shadowRadiusAnimatable<number>Non—
shadowOffsetXAnimatable<number>Non—
shadowOffsetYAnimatable<number>Non—
backgroundGradient{ angle: number; colors: string[];}Non—
colorProp<string>Non—
sharedIdProp<string>NonA view the navigation stack flies to the view with the same sharedId on the screen it pushes or pops to (docs/navigation.md#shared-elements).
valueBound<string>NonThe field's text, as HTML's value.
disabledProp<boolean>NonTakes no presses or input, as HTML disabled.
placeholderProp<string>Non—
placeholderColorProp<string>NonThe placeholder's color.
selectionColorProp<string>NonThe cursor and selection color.
enterKeyHintProp<"enter" | "done" | "go" | "next" | "search" | "send">NonHTML's enterkeyhint: the enter key's label. next moves focus to the next input natively.
submitBehaviorProp<"submit" | "blurAndSubmit" | "newline">NonWhat the enter key does: newline (default with lines) adds a line; after onSubmit, blurAndSubmit (default without) hides the keyboard, or moves to the next input with enterKeyHint next, and submit keeps the focus.
autoFocusProp<boolean>NonFocuses the input once it is on screen.
typeProp<"number" | "search" | "text" | "password" | "email" | "tel" | "url">NonHTML's input type: the keyboard, and password hides the text.
inputModeProp<InputMode>NonHTML's inputmode: the keyboard to show instead of the type's; none shows none.
autoCompleteProp<"off" | "email" | "tel" | "username" | "current-password" | "new-password" | "one-time-code" | "name" | "given-name" | "family-name" | "street-address" | "postal-code" | "country-name" | "cc-number">NonHTML's autocomplete: what the field holds, for autofill and the password manager.
autoCapitalizeProp<"none" | "sentences" | "words" | "characters">NonHTML's autocapitalize. Unset, sentences for text and search fields and none for the others.
maxLengthProp<number>NonHTML's maxlength: the most UTF-16 code units the user can enter. Text the app sets is not cut.
spellCheckProp<boolean>NonHTML's spellcheck, which also turns autocorrection on or off. Unset, on for text and search fields.
linesProp<number | { min?: number; max?: number;}>NonWraps the text over lines: a count sets the height, { min, max } grows with the text (1 and no limit by default). Adding or removing it remounts the field.
selectionBound<TextSelection>NonThe selected range, { start, end } in UTF-16 offsets as HTML's selectionStart and selectionEnd; start === end is the caret. Two-way when given a signal; unset, the caret goes to the end.
format — signatures de méthode

Signatures

ts
(text: string): string

Paramètres

NomTypeRequisDescription
textstringOui—

Retourne

string

onChange — signatures de méthode

Signatures

ts
(text: string): void

Paramètres

NomTypeRequisDescription
textstringOui—

Retourne

void

onSelectionChange — signatures de méthode

Signatures

ts
(selection: TextSelection): void

Paramètres

NomTypeRequisDescription
selectionTextSelectionOui—

Retourne

void

onSubmit — signatures de méthode

Signatures

ts
(event: SubmitEvent): void

Paramètres

NomTypeRequisDescription
eventSubmitEventOui—

Retourne

void

onFocus — signatures de méthode

Signatures

ts
(event: FocusEvent): void

Paramètres

NomTypeRequisDescription
eventFocusEventOui—

Retourne

void

onBlur — signatures de méthode

Signatures

ts
(event: FocusEvent): void

Paramètres

NomTypeRequisDescription
eventFocusEventOui—

Retourne

void

onPress — signatures de méthode

Signatures

ts
(event: PressEvent): void

Paramètres

NomTypeRequisDescription
eventPressEventOui—

Retourne

void

onPressCapture — signatures de méthode

Signatures

ts
(event: PressEvent): void

Paramètres

NomTypeRequisDescription
eventPressEventOui—

Retourne

void

onAction — signatures de méthode

Signatures

ts
(event: AccessibilityActionEvent): void

Paramètres

NomTypeRequisDescription
eventAccessibilityActionEventOui—

Retourne

void

backgroundGradient — champs imbriqués

backgroundGradient champs

NomTypeRequisDescription
anglenumberOui—
colorsstring[]Oui—
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.