src/NumberField.tsx

gestalt · packages/gestalt/src/NumberField.tsx · typescript · Apache-2.0
ui

Form input for numeric values with validation, accessibility, and internationalization support.

// Source: https://github.com/pinterest/gestalt | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { forwardRef, ReactElement, ReactNode } from 'react';
import InternalTextField from './TextField/InternalTextField';
import VRInternalTextField from './TextField/VRInternalTextField';
import useExperimentalTheme from './utils/useExperimentalTheme';

// <input> deals with strings, but we only want numbers for this component.
// So we parse what we get from InternalTextField and we stringify what we give it.

type Handler = any;

const parseHandlerValue =
  (handler?: Handler) =>
  ({
    event,
    value,
  }:
    | {
        event: React.ChangeEvent<HTMLInputElement>;
        val

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key