UNPKG

@spark-ui/components

Version:

Spark (Leboncoin design system) components.

83 lines (76 loc) 3.56 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import { RefObject, Ref, PropsWithChildren } from 'react'; import { AriaButtonOptions } from '@react-aria/button'; import { NumberFieldStateOptions } from '@react-stately/numberfield'; import { AriaNumberFieldProps } from '@react-types/numberfield'; import { IconButtonProps } from '../icon-button/index.js'; import { I as InputGroupProps } from '../InputGroup-aoaZxCLk.js'; import { I as InputProps } from '../Input-g0LpWuv0.js'; import '../button/index.js'; import 'class-variance-authority/types'; import 'class-variance-authority'; /** * As we're using React Spectrum library to build this component, we also want * to build our typing uppon theirs. * Still, we have to adapt it to avoid exposing useless props. */ type StepperButtonProps = Omit<IconButtonProps, 'shape' | 'size' | 'disabled' | 'asChild' | 'isLoading' | 'loadingLabel'> & Omit<AriaButtonOptions<'button'>, 'elementType' | 'href' | 'target' | 'isDisabled' | 'excludeFromTabOrder' | 'aria-label' | 'preventFocusOnPress'> & { disabled?: boolean; ref?: Ref<HTMLButtonElement>; }; type SpectrumNumberFieldPropsFilter = 'isDisabled' | 'isReadOnly' | 'isRequired' | 'isInvalid' | 'validationState' | 'validationBehavior' | 'validate' | 'label' | 'description' | 'errorMessage' | 'isWheelDisabled' | 'id' | 'onCopy' | 'onCut' | 'onPaste' | 'onCompositionStart' | 'onCompositionEnd' | 'onCompositionUpdate' | 'onSelect' | 'onBeforeInput' | 'onInput'; interface UseStepperArgs extends Omit<Omit<NumberFieldStateOptions, 'locale'> & Omit<AriaNumberFieldProps, 'incrementAriaLabel' | 'decrementAriaLabel'>, SpectrumNumberFieldPropsFilter> { inputRef: RefObject<HTMLInputElement | null>; /** * Sets the component as interactive or not. */ disabled?: boolean; /** * Sets the component as editable or not. */ readOnly?: boolean; /** * Sets the component as mandatory for form validation. */ required?: boolean; /** * The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. * @default 'fr' */ locale?: string; } type StepperProps = Omit<Omit<UseStepperArgs, 'inputRef' | 'aria-label'> & Omit<InputGroupProps, 'onClear'>, 'onChange'> & { onValueChange?: (e: number) => void; ref?: Ref<HTMLDivElement>; }; type StepperInputProps = Omit<InputProps, 'asChild'> & { ref?: Ref<HTMLInputElement>; }; declare const Stepper$1: { ({ children, formatOptions, minValue, maxValue, ref: forwardedRef, ...stepperProps }: PropsWithChildren<StepperProps>): react_jsx_runtime.JSX.Element; displayName: string; }; declare const StepperIncrementButton: { ({ children, design, intent, className, ref: forwardedRef, ...rest }: PropsWithChildren<StepperButtonProps>): react_jsx_runtime.JSX.Element; displayName: string; } & { id: string; }; declare const StepperDecrementButton: { ({ children, design, intent, className, ref: forwardedRef, ...rest }: PropsWithChildren<StepperButtonProps>): react_jsx_runtime.JSX.Element; displayName: string; } & { id: string; }; declare const StepperInput: { ({ ref: forwardedRef, ...props }: StepperInputProps): react_jsx_runtime.JSX.Element; displayName: string; } & { id: string; }; declare const Stepper: typeof Stepper$1 & { IncrementButton: typeof StepperIncrementButton; DecrementButton: typeof StepperDecrementButton; Input: typeof StepperInput; }; export { Stepper, type StepperButtonProps, type StepperInputProps, type StepperProps };